MCPcopy Create free account
hub / github.com/KDE/labplot / maxRowToExport

Method maxRowToExport

src/frontend/spreadsheet/SpreadsheetView.cpp:3980–4013  ·  view source on GitHub ↗

! * the spreadsheet can have empty rows at the end full with NaNs. * for the export we only need to export valid (non-empty) rows. * this functions determines the maximal row to export, or -1 * if the spreadsheet doesn't have any data yet. */

Source from the content-addressed store, hash-verified

3978 * if the spreadsheet doesn't have any data yet.
3979 */
3980int SpreadsheetView::maxRowToExport() const {
3981 int maxRow = -1;
3982 for (int j = 0; j < m_spreadsheet->columnCount(); ++j) {
3983 Column* col = m_spreadsheet->column(j);
3984 auto mode = col->columnMode();
3985 if (mode == AbstractColumn::ColumnMode::Double) {
3986 for (int i = 0; i < m_spreadsheet->rowCount(); ++i) {
3987 if (!std::isnan(col->valueAt(i)) && i > maxRow)
3988 maxRow = i;
3989 }
3990 }
3991 if (mode == AbstractColumn::ColumnMode::Integer || mode == AbstractColumn::ColumnMode::BigInt) {
3992 // TODO:
3993 // integer column found. Since empty integer cells are equal to 0
3994 // at the moment, we need to export the whole column.
3995 // this logic needs to be adjusted once we're able to descriminate
3996 // between empty and 0 values for integer columns
3997 maxRow = m_spreadsheet->rowCount() - 1;
3998 break;
3999 } else if (mode == AbstractColumn::ColumnMode::DateTime) {
4000 for (int i = 0; i < m_spreadsheet->rowCount(); ++i) {
4001 if (col->dateTimeAt(i).isValid() && i > maxRow)
4002 maxRow = i;
4003 }
4004 } else if (mode == AbstractColumn::ColumnMode::Text) {
4005 for (int i = 0; i < m_spreadsheet->rowCount(); ++i) {
4006 if (!col->textAt(i).isEmpty() && i > maxRow)
4007 maxRow = i;
4008 }
4009 }
4010 }
4011
4012 return maxRow;
4013}
4014
4015void SpreadsheetView::exportToFile(const QString& path, const bool exportHeader, const QString& separator, QLocale::Language language) const {
4016 QFile file(path);

Callers

nothing calls this directly

Calls 9

columnCountMethod · 0.45
columnMethod · 0.45
columnModeMethod · 0.45
rowCountMethod · 0.45
valueAtMethod · 0.45
isValidMethod · 0.45
dateTimeAtMethod · 0.45
isEmptyMethod · 0.45
textAtMethod · 0.45

Tested by

no test coverage detected