annotate widgets/CSVExportDialog.h @ 1570:9095fbec4e52

Clarify comment
author Chris Cannam
date Wed, 15 Jan 2020 13:57:52 +0000
parents 3943553b95b0
children
rev   line source
Chris@1568 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1568 2
Chris@1568 3 /*
Chris@1568 4 Sonic Visualiser
Chris@1568 5 An audio file viewer and annotation editor.
Chris@1568 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1568 7
Chris@1568 8 This program is free software; you can redistribute it and/or
Chris@1568 9 modify it under the terms of the GNU General Public License as
Chris@1568 10 published by the Free Software Foundation; either version 2 of the
Chris@1568 11 License, or (at your option) any later version. See the file
Chris@1568 12 COPYING included with this distribution for more information.
Chris@1568 13 */
Chris@1568 14
Chris@1568 15 #ifndef SV_CSV_EXPORT_DIALOG_H
Chris@1568 16 #define SV_CSV_EXPORT_DIALOG_H
Chris@1568 17
Chris@1568 18 #include <QDialog>
Chris@1568 19 #include <QString>
Chris@1568 20
Chris@1568 21 class QComboBox;
Chris@1568 22 class QCheckBox;
Chris@1568 23 class QRadioButton;
Chris@1568 24
Chris@1568 25 class CSVExportDialog : public QDialog
Chris@1568 26 {
Chris@1568 27 Q_OBJECT
Chris@1568 28
Chris@1568 29 public:
Chris@1568 30 struct Configuration {
Chris@1568 31 Configuration() :
Chris@1568 32 layerName(""),
Chris@1568 33 fileExtension("csv"),
Chris@1568 34 isDense(false),
Chris@1568 35 haveView(false),
Chris@1568 36 haveSelection(false) { }
Chris@1568 37
Chris@1568 38 /**
Chris@1568 39 * Presentation name of the layer being exported.
Chris@1568 40 */
Chris@1568 41 QString layerName;
Chris@1568 42
Chris@1568 43 /**
Chris@1568 44 * Extension of file being exported into.
Chris@1568 45 */
Chris@1568 46 QString fileExtension;
Chris@1568 47
Chris@1568 48 /**
Chris@1568 49 * True if the model is a dense type for which timestamps are
Chris@1568 50 * not written by default.
Chris@1568 51 */
Chris@1568 52 bool isDense;
Chris@1568 53
Chris@1568 54 /**
Chris@1568 55 * True if we have a view that provides a vertical scale
Chris@1568 56 * range, so we may want to offer a choice between exporting
Chris@1568 57 * only the visible range or exporting full height. This
Chris@1568 58 * choice happens to be offered only if isDense is also true.
Chris@1568 59 */
Chris@1568 60 bool haveView;
Chris@1568 61
Chris@1568 62 /**
Chris@1568 63 * True if there is a selection current that the user may want
Chris@1568 64 * to constrain export to.
Chris@1568 65 */
Chris@1568 66 bool haveSelection;
Chris@1568 67 };
Chris@1568 68
Chris@1568 69 CSVExportDialog(Configuration config, QWidget *parent);
Chris@1568 70
Chris@1568 71 /**
Chris@1568 72 * Return the column delimiter to use in the exported file. Either
Chris@1568 73 * the default for the supplied file extension, or some other
Chris@1568 74 * option chosen by the user.
Chris@1568 75 */
Chris@1568 76 QString getDelimiter() const;
Chris@1568 77
Chris@1568 78 /**
Chris@1568 79 * Return true if we should include a header row at the top of the
Chris@1568 80 * exported file.
Chris@1568 81 */
Chris@1568 82 bool shouldIncludeHeader() const;
Chris@1568 83
Chris@1568 84 /**
Chris@1568 85 * Return true if we should write a timestamp column. This is
Chris@1568 86 * always true for non-dense models, but is a user option for
Chris@1568 87 * dense ones.
Chris@1568 88 */
Chris@1568 89 bool shouldIncludeTimestamps() const;
Chris@1568 90
Chris@1568 91 /**
Chris@1568 92 * Return true if we should use sample frames rather than seconds
Chris@1568 93 * for the timestamp column (and duration where present).
Chris@1568 94 */
Chris@1568 95 bool shouldWriteTimeInFrames() const;
Chris@1568 96
Chris@1568 97 /**
Chris@1568 98 * Return true if we should constrain the vertical range to the
Chris@1568 99 * visible area only. Otherwise we should export the full vertical
Chris@1568 100 * range of the model.
Chris@1568 101 */
Chris@1568 102 bool shouldConstrainToViewHeight() const;
Chris@1568 103
Chris@1568 104 /**
Chris@1568 105 * Return true if we should export the selected time range(s)
Chris@1568 106 * only. Otherwise we should export the full length of the model.
Chris@1568 107 */
Chris@1568 108 bool shouldConstrainToSelection() const;
Chris@1568 109
Chris@1568 110 private:
Chris@1568 111 Configuration m_config;
Chris@1568 112
Chris@1568 113 QComboBox *m_separatorCombo;
Chris@1568 114 QCheckBox *m_header;
Chris@1568 115 QCheckBox *m_timestamps;
Chris@1568 116 QRadioButton *m_seconds;
Chris@1568 117 QRadioButton *m_frames;
Chris@1568 118 QRadioButton *m_selectionOnly;
Chris@1568 119 QRadioButton *m_viewOnly;
Chris@1568 120
Chris@1568 121 private slots:
Chris@1568 122 void timestampsToggled(bool);
Chris@1568 123 };
Chris@1568 124
Chris@1568 125 #endif