comparison data/fileio/CSVFileReader.h @ 148:1a42221a1522

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 11:49:58 +0000
parents
children 5858cc462d0a
comparison
equal deleted inserted replaced
147:3a13b0d4934e 148:1a42221a1522
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _CSV_FILE_READER_H_
17 #define _CSV_FILE_READER_H_
18
19 #include "DataFileReader.h"
20
21 #include <QList>
22 #include <QStringList>
23 #include <QDialog>
24
25 class QFile;
26 class QTableWidget;
27 class QComboBox;
28 class QLabel;
29
30
31 class CSVFileReader : public DataFileReader
32 {
33 public:
34 CSVFileReader(QString path, size_t mainModelSampleRate);
35 virtual ~CSVFileReader();
36
37 virtual bool isOK() const;
38 virtual QString getError() const;
39 virtual Model *load() const;
40
41 protected:
42 QFile *m_file;
43 QString m_error;
44 size_t m_mainModelSampleRate;
45 };
46
47
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 protected slots:
82 void modelTypeChanged(int type);
83 void timingTypeChanged(int type);
84 void sampleRateChanged(QString);
85 void windowSizeChanged(QString);
86
87 protected:
88 ModelType m_modelType;
89 TimingType m_timingType;
90 TimeUnits m_timeUnits;
91 QString m_separator;
92 size_t m_sampleRate;
93 size_t m_windowSize;
94
95 QList<QStringList> m_example;
96 int m_maxExampleCols;
97 QTableWidget *m_exampleWidget;
98
99 QComboBox *m_modelTypeCombo;
100 QComboBox *m_timingTypeCombo;
101 QLabel *m_sampleRateLabel;
102 QComboBox *m_sampleRateCombo;
103 QLabel *m_windowSizeLabel;
104 QComboBox *m_windowSizeCombo;
105
106 bool guessFormat(QFile *file);
107 void populateExample();
108 };
109
110 #endif
111