CSVFileReader.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _CSV_FILE_READER_H_
00017 #define _CSV_FILE_READER_H_
00018 
00019 #include "DataFileReader.h"
00020 
00021 #include <QList>
00022 #include <QStringList>
00023 #include <QDialog>
00024 
00025 class QFile;
00026 class QTableWidget;
00027 class QComboBox;
00028 class QLabel;
00029 
00030 
00031 class CSVFileReader : public DataFileReader
00032 {
00033 public:
00034     CSVFileReader(QString path, size_t mainModelSampleRate);
00035     virtual ~CSVFileReader();
00036 
00037     virtual bool isOK() const;
00038     virtual QString getError() const;
00039     virtual Model *load() const;
00040 
00041 protected:
00042     QFile *m_file;
00043     QString m_error;
00044     size_t m_mainModelSampleRate;
00045 };
00046 
00047 
00048 class CSVFormatDialog : public QDialog
00049 {
00050     Q_OBJECT
00051     
00052 public:
00053     CSVFormatDialog(QWidget *parent, QFile *file, size_t defaultSampleRate);
00054     
00055     ~CSVFormatDialog();
00056     
00057     enum ModelType {
00058         OneDimensionalModel,
00059         TwoDimensionalModel,
00060         ThreeDimensionalModel
00061     };
00062     
00063     enum TimingType {
00064         ExplicitTiming,
00065         ImplicitTiming
00066     };
00067     
00068     enum TimeUnits {
00069         TimeSeconds,
00070         TimeAudioFrames,
00071         TimeWindows
00072     };
00073 
00074     ModelType  getModelType()   const { return m_modelType;   }
00075     TimingType getTimingType()  const { return m_timingType;  }
00076     TimeUnits  getTimeUnits()   const { return m_timeUnits;   }
00077     QString    getSeparator()   const { return m_separator;   }
00078     size_t     getSampleRate()  const { return m_sampleRate;  }
00079     size_t     getWindowSize()  const { return m_windowSize;  }
00080 
00081 protected slots:
00082     void modelTypeChanged(int type);
00083     void timingTypeChanged(int type);
00084     void sampleRateChanged(QString);
00085     void windowSizeChanged(QString);
00086 
00087 protected:
00088     ModelType  m_modelType;
00089     TimingType m_timingType;
00090     TimeUnits  m_timeUnits;
00091     QString    m_separator;
00092     size_t     m_sampleRate;
00093     size_t     m_windowSize;
00094     
00095     QList<QStringList> m_example;
00096     int m_maxExampleCols;
00097     QTableWidget *m_exampleWidget;
00098     
00099     QComboBox *m_modelTypeCombo;
00100     QComboBox *m_timingTypeCombo;
00101     QLabel *m_sampleRateLabel;
00102     QComboBox *m_sampleRateCombo;
00103     QLabel *m_windowSizeLabel;
00104     QComboBox *m_windowSizeCombo;
00105 
00106     bool guessFormat(QFile *file);
00107     void populateExample();
00108 };
00109 
00110 #endif
00111 

Generated on Wed Feb 20 15:45:25 2008 for SonicVisualiser by  doxygen 1.5.1