annotate data/fileio/CSVFileReader.h @ 248:084ae1c213ee

* Add display of selection extents in status bar when dragging a selection * Some build fixes after that i18n update
author Chris Cannam
date Wed, 07 Mar 2007 18:00:49 +0000
parents 1a42221a1522
children 5858cc462d0a
rev   line source
Chris@148 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@148 2
Chris@148 3 /*
Chris@148 4 Sonic Visualiser
Chris@148 5 An audio file viewer and annotation editor.
Chris@148 6 Centre for Digital Music, Queen Mary, University of London.
Chris@148 7 This file copyright 2006 Chris Cannam.
Chris@148 8
Chris@148 9 This program is free software; you can redistribute it and/or
Chris@148 10 modify it under the terms of the GNU General Public License as
Chris@148 11 published by the Free Software Foundation; either version 2 of the
Chris@148 12 License, or (at your option) any later version. See the file
Chris@148 13 COPYING included with this distribution for more information.
Chris@148 14 */
Chris@148 15
Chris@148 16 #ifndef _CSV_FILE_READER_H_
Chris@148 17 #define _CSV_FILE_READER_H_
Chris@148 18
Chris@148 19 #include "DataFileReader.h"
Chris@148 20
Chris@148 21 #include <QList>
Chris@148 22 #include <QStringList>
Chris@148 23 #include <QDialog>
Chris@148 24
Chris@148 25 class QFile;
Chris@148 26 class QTableWidget;
Chris@148 27 class QComboBox;
Chris@148 28 class QLabel;
Chris@148 29
Chris@148 30
Chris@148 31 class CSVFileReader : public DataFileReader
Chris@148 32 {
Chris@148 33 public:
Chris@148 34 CSVFileReader(QString path, size_t mainModelSampleRate);
Chris@148 35 virtual ~CSVFileReader();
Chris@148 36
Chris@148 37 virtual bool isOK() const;
Chris@148 38 virtual QString getError() const;
Chris@148 39 virtual Model *load() const;
Chris@148 40
Chris@148 41 protected:
Chris@148 42 QFile *m_file;
Chris@148 43 QString m_error;
Chris@148 44 size_t m_mainModelSampleRate;
Chris@148 45 };
Chris@148 46
Chris@148 47
Chris@148 48 class CSVFormatDialog : public QDialog
Chris@148 49 {
Chris@148 50 Q_OBJECT
Chris@148 51
Chris@148 52 public:
Chris@148 53 CSVFormatDialog(QWidget *parent, QFile *file, size_t defaultSampleRate);
Chris@148 54
Chris@148 55 ~CSVFormatDialog();
Chris@148 56
Chris@148 57 enum ModelType {
Chris@148 58 OneDimensionalModel,
Chris@148 59 TwoDimensionalModel,
Chris@148 60 ThreeDimensionalModel
Chris@148 61 };
Chris@148 62
Chris@148 63 enum TimingType {
Chris@148 64 ExplicitTiming,
Chris@148 65 ImplicitTiming
Chris@148 66 };
Chris@148 67
Chris@148 68 enum TimeUnits {
Chris@148 69 TimeSeconds,
Chris@148 70 TimeAudioFrames,
Chris@148 71 TimeWindows
Chris@148 72 };
Chris@148 73
Chris@148 74 ModelType getModelType() const { return m_modelType; }
Chris@148 75 TimingType getTimingType() const { return m_timingType; }
Chris@148 76 TimeUnits getTimeUnits() const { return m_timeUnits; }
Chris@148 77 QString getSeparator() const { return m_separator; }
Chris@148 78 size_t getSampleRate() const { return m_sampleRate; }
Chris@148 79 size_t getWindowSize() const { return m_windowSize; }
Chris@148 80
Chris@148 81 protected slots:
Chris@148 82 void modelTypeChanged(int type);
Chris@148 83 void timingTypeChanged(int type);
Chris@148 84 void sampleRateChanged(QString);
Chris@148 85 void windowSizeChanged(QString);
Chris@148 86
Chris@148 87 protected:
Chris@148 88 ModelType m_modelType;
Chris@148 89 TimingType m_timingType;
Chris@148 90 TimeUnits m_timeUnits;
Chris@148 91 QString m_separator;
Chris@148 92 size_t m_sampleRate;
Chris@148 93 size_t m_windowSize;
Chris@148 94
Chris@148 95 QList<QStringList> m_example;
Chris@148 96 int m_maxExampleCols;
Chris@148 97 QTableWidget *m_exampleWidget;
Chris@148 98
Chris@148 99 QComboBox *m_modelTypeCombo;
Chris@148 100 QComboBox *m_timingTypeCombo;
Chris@148 101 QLabel *m_sampleRateLabel;
Chris@148 102 QComboBox *m_sampleRateCombo;
Chris@148 103 QLabel *m_windowSizeLabel;
Chris@148 104 QComboBox *m_windowSizeCombo;
Chris@148 105
Chris@148 106 bool guessFormat(QFile *file);
Chris@148 107 void populateExample();
Chris@148 108 };
Chris@148 109
Chris@148 110 #endif
Chris@148 111