Mercurial > hg > svcore
comparison data/model/EditableDenseThreeDimensionalModel.cpp @ 1833:21c792334c2e sensible-delimited-data-strings
Rewrite all the DelimitedDataString stuff so as to return vectors of individual cell strings rather than having the classes add the delimiters themselves. Rename accordingly to names based on StringExport. Take advantage of this in the CSV writer code so as to properly quote cells that contain delimiter characters.
author | Chris Cannam |
---|---|
date | Fri, 03 Apr 2020 17:11:05 +0100 |
parents | c546429d4c2f |
children |
comparison
equal
deleted
inserted
replaced
1832:7c92c644db20 | 1833:21c792334c2e |
---|---|
349 EditableDenseThreeDimensionalModel::getCompletion() const | 349 EditableDenseThreeDimensionalModel::getCompletion() const |
350 { | 350 { |
351 return m_completion; | 351 return m_completion; |
352 } | 352 } |
353 | 353 |
354 QString | 354 QVector<QString> |
355 EditableDenseThreeDimensionalModel::getDelimitedDataHeaderLine(QString delimiter, | 355 EditableDenseThreeDimensionalModel::getStringExportHeaders(DataExportOptions) |
356 DataExportOptions) const | 356 const |
357 { | 357 { |
358 QStringList list; | 358 QVector<QString> sv; |
359 for (int i = 0; i < m_yBinCount; ++i) { | 359 for (int i = 0; i < m_yBinCount; ++i) { |
360 list << QString("Bin%1").arg(i+1); | 360 sv.push_back(QString("Bin%1").arg(i+1)); |
361 } | 361 } |
362 return list.join(delimiter); | 362 return sv; |
363 } | 363 } |
364 | 364 |
365 QString | 365 QVector<QVector<QString>> |
366 EditableDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter, | 366 EditableDenseThreeDimensionalModel::toStringExportRows(DataExportOptions, |
367 DataExportOptions, | 367 sv_frame_t startFrame, |
368 sv_frame_t startFrame, | 368 sv_frame_t duration) |
369 sv_frame_t duration) const | 369 const |
370 { | 370 { |
371 QMutexLocker locker(&m_mutex); | 371 QMutexLocker locker(&m_mutex); |
372 QString s; | 372 |
373 QVector<QVector<QString>> rows; | |
374 | |
373 for (int i = 0; in_range_for(m_data, i); ++i) { | 375 for (int i = 0; in_range_for(m_data, i); ++i) { |
374 sv_frame_t fr = m_startFrame + i * m_resolution; | 376 sv_frame_t fr = m_startFrame + i * m_resolution; |
375 if (fr >= startFrame && fr < startFrame + duration) { | 377 if (fr >= startFrame && fr < startFrame + duration) { |
376 QStringList list; | 378 QVector<QString> row; |
377 for (int j = 0; in_range_for(m_data.at(i), j); ++j) { | 379 for (int j = 0; in_range_for(m_data.at(i), j); ++j) { |
378 list << QString("%1").arg(m_data.at(i).at(j)); | 380 row.push_back(QString("%1").arg(m_data.at(i).at(j))); |
379 } | 381 } |
380 s += list.join(delimiter) + "\n"; | 382 rows.push_back(row); |
381 } | 383 } |
382 } | 384 } |
383 return s; | 385 return rows; |
384 } | 386 } |
385 | 387 |
386 void | 388 void |
387 EditableDenseThreeDimensionalModel::toXml(QTextStream &out, | 389 EditableDenseThreeDimensionalModel::toXml(QTextStream &out, |
388 QString indent, | 390 QString indent, |