| 1167 | } |
| 1168 | |
| 1169 | void MatrixView::exportToFile(const QString& path, const QString& separator, QLocale::Language language) const { |
| 1170 | QFile file(path); |
| 1171 | if (!file.open(QFile::WriteOnly | QFile::Truncate)) |
| 1172 | return; |
| 1173 | |
| 1174 | QTextStream out(&file); |
| 1175 | |
| 1176 | QString sep = separator; |
| 1177 | sep = sep.replace(QLatin1String("TAB"), QLatin1String("\t"), Qt::CaseInsensitive); |
| 1178 | sep = sep.replace(QLatin1String("SPACE"), QLatin1String(" "), Qt::CaseInsensitive); |
| 1179 | |
| 1180 | // export values |
| 1181 | const int cols = m_matrix->columnCount(); |
| 1182 | const int rows = m_matrix->rowCount(); |
| 1183 | const auto* data = static_cast<QVector<QVector<double>>*>(m_matrix->data()); |
| 1184 | // TODO: use general setting for number locale? |
| 1185 | QLocale locale(language); |
| 1186 | for (int row = 0; row < rows; ++row) { |
| 1187 | for (int col = 0; col < cols; ++col) { |
| 1188 | out << locale.toString(data->at(col)[row], m_matrix->numericFormat(), m_matrix->precision()); |
| 1189 | |
| 1190 | out << data->at(col)[row]; |
| 1191 | if (col != cols - 1) |
| 1192 | out << sep; |
| 1193 | } |
| 1194 | out << QLatin1Char('\n'); |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | void MatrixView::exportToLaTeX(const QString& path, |
| 1199 | const bool verticalHeaders, |
no test coverage detected