comparison data/fileio/CSVFileReader.h @ 392:183ee2a55fc7

* More work to abstract out interactive components used in the data library, so that it does not need to depend on QtGui.
author Chris Cannam
date Fri, 14 Mar 2008 17:14:21 +0000
parents 5858cc462d0a
children 3a5ee4b6c9ad
comparison
equal deleted inserted replaced
391:5858cc462d0a 392:183ee2a55fc7
16 #ifndef _CSV_FILE_READER_H_ 16 #ifndef _CSV_FILE_READER_H_
17 #define _CSV_FILE_READER_H_ 17 #define _CSV_FILE_READER_H_
18 18
19 #include "DataFileReader.h" 19 #include "DataFileReader.h"
20 20
21 #include "CSVFormat.h"
22
21 #include <QList> 23 #include <QList>
22 #include <QStringList> 24 #include <QStringList>
23 #include <QDialog>
24 25
25 class QFile; 26 class QFile;
26 class QTableWidget;
27 class QComboBox;
28 class QLabel;
29
30 27
31 class CSVFileReader : public DataFileReader 28 class CSVFileReader : public DataFileReader
32 { 29 {
33 public: 30 public:
34 CSVFileReader(QString path, size_t mainModelSampleRate); 31 CSVFileReader(QString path, CSVFormat format, size_t mainModelSampleRate);
35 virtual ~CSVFileReader(); 32 virtual ~CSVFileReader();
36 33
37 virtual bool isOK() const; 34 virtual bool isOK() const;
38 virtual QString getError() const; 35 virtual QString getError() const;
39 virtual Model *load() const; 36 virtual Model *load() const;
40 37
41 protected: 38 protected:
39 CSVFormat m_format;
42 QFile *m_file; 40 QFile *m_file;
43 QString m_error; 41 QString m_error;
44 size_t m_mainModelSampleRate; 42 size_t m_mainModelSampleRate;
45 }; 43 };
46 44
47 45
48 class CSVFormatDialog : public QDialog
49 {
50 Q_OBJECT
51
52 public:
53 CSVFormatDialog(QWidget *parent, QFile *file, size_t defaultSampleRate);
54
55 ~CSVFormatDialog();
56
57 enum ModelType {
58 OneDimensionalModel,
59 TwoDimensionalModel,
60 ThreeDimensionalModel
61 };
62
63 enum TimingType {
64 ExplicitTiming,
65 ImplicitTiming
66 };
67
68 enum TimeUnits {
69 TimeSeconds,
70 TimeAudioFrames,
71 TimeWindows
72 };
73
74 ModelType getModelType() const { return m_modelType; }
75 TimingType getTimingType() const { return m_timingType; }
76 TimeUnits getTimeUnits() const { return m_timeUnits; }
77 QString getSeparator() const { return m_separator; }
78 size_t getSampleRate() const { return m_sampleRate; }
79 size_t getWindowSize() const { return m_windowSize; }
80
81 QString::SplitBehavior getSplitBehaviour() const { return m_behaviour; }
82
83 protected slots:
84 void modelTypeChanged(int type);
85 void timingTypeChanged(int type);
86 void sampleRateChanged(QString);
87 void windowSizeChanged(QString);
88
89 protected:
90 ModelType m_modelType;
91 TimingType m_timingType;
92 TimeUnits m_timeUnits;
93 QString m_separator;
94 size_t m_sampleRate;
95 size_t m_windowSize;
96
97 QString::SplitBehavior m_behaviour;
98
99 QList<QStringList> m_example;
100 int m_maxExampleCols;
101 QTableWidget *m_exampleWidget;
102
103 QComboBox *m_modelTypeCombo;
104 QComboBox *m_timingTypeCombo;
105 QLabel *m_sampleRateLabel;
106 QComboBox *m_sampleRateCombo;
107 QLabel *m_windowSizeLabel;
108 QComboBox *m_windowSizeCombo;
109
110 bool guessFormat(QFile *file);
111 void populateExample();
112 };
113
114 #endif 46 #endif
115 47