Mercurial > hg > svcore
changeset 1816:fd5a87f3c5b4 csv-export-dialog
Overhaul and tidy the export options, and add support for header row
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2020 15:39:12 +0000 |
parents | c546429d4c2f |
children | 23d5cb3f9f38 |
files | base/DataExportOptions.h base/Event.h data/fileio/CSVFileWriter.cpp |
diffstat | 3 files changed, 35 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/base/DataExportOptions.h Fri Jan 10 14:29:54 2020 +0000 +++ b/base/DataExportOptions.h Tue Jan 14 15:39:12 2020 +0000 @@ -18,9 +18,36 @@ enum DataExportOption { DataExportDefaults = 0x0, + + /** + * Export sparse event-based models as if they were dense models, + * writing an event at every interval of the model's + * resolution. Where no event is present in the actual model, a + * constant "fill event" is interpolated instead. + */ DataExportFillGaps = 0x1, - DataExportOmitLevels = 0x2, - DataExportWriteTimeInFrames = 0x4 // otherwise in seconds + + /** + * Omit the level attribute from exported events. + */ + DataExportOmitLevel = 0x2, + + /** + * Always include a timestamp in the first column. Otherwise + * timestamps will only be included in sparse models. + */ + DataExportAlwaysIncludeTimestamp = 0x4, + + /** + * Use sample frames rather than seconds for time and duration + * values. + */ + DataExportWriteTimeInFrames = 0x8, + + /** + * Write a header row before any data rows. + */ + DataExportIncludeHeader = 0x10 }; typedef int DataExportOptions;
--- a/base/Event.h Fri Jan 10 14:29:54 2020 +0000 +++ b/base/Event.h Tue Jan 14 15:39:12 2020 +0000 @@ -390,7 +390,7 @@ } if (m_haveLevel) { - if (!(opts & DataExportOmitLevels)) { + if (!(opts & DataExportOmitLevel)) { list << nameOpts.levelAttributeName; } } @@ -430,7 +430,7 @@ } if (m_haveLevel) { - if (!(opts & DataExportOmitLevels)) { + if (!(opts & DataExportOmitLevel)) { list << QString("%1").arg(m_level); } }
--- a/data/fileio/CSVFileWriter.cpp Fri Jan 10 14:29:54 2020 +0000 +++ b/data/fileio/CSVFileWriter.cpp Tue Jan 14 15:39:12 2020 +0000 @@ -85,8 +85,10 @@ QTextStream out(&file); -// out << m_model->getDelimitedDataHeaderLine(m_delimiter, m_options) -// << endl; + if (m_options & DataExportIncludeHeader) { + out << m_model->getDelimitedDataHeaderLine(m_delimiter, m_options) + << endl; + } sv_frame_t blockSize = 65536;