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 _SV_FILE_READER_H_
|
Chris@148
|
17 #define _SV_FILE_READER_H_
|
Chris@148
|
18
|
Chris@148
|
19 #include "layer/LayerFactory.h"
|
Chris@148
|
20 #include "transform/Transform.h"
|
Chris@148
|
21
|
Chris@148
|
22 #include <QXmlDefaultHandler>
|
Chris@148
|
23
|
Chris@148
|
24 #include <map>
|
Chris@148
|
25
|
Chris@148
|
26 class Pane;
|
Chris@148
|
27 class Model;
|
Chris@148
|
28 class Document;
|
Chris@148
|
29 class PlayParameters;
|
Chris@148
|
30
|
Chris@148
|
31 class SVFileReaderPaneCallback
|
Chris@148
|
32 {
|
Chris@148
|
33 public:
|
Chris@148
|
34 virtual Pane *addPane() = 0;
|
Chris@148
|
35 virtual void setWindowSize(int width, int height) = 0;
|
Chris@148
|
36 virtual void addSelection(int start, int end) = 0;
|
Chris@148
|
37 };
|
Chris@148
|
38
|
Chris@148
|
39 class SVFileReader : public QXmlDefaultHandler
|
Chris@148
|
40 {
|
Chris@148
|
41 public:
|
Chris@148
|
42 SVFileReader(Document *document,
|
Chris@148
|
43 SVFileReaderPaneCallback &callback);
|
Chris@148
|
44 virtual ~SVFileReader();
|
Chris@148
|
45
|
Chris@148
|
46 void parse(const QString &xmlData);
|
Chris@148
|
47 void parse(QXmlInputSource &source);
|
Chris@148
|
48
|
Chris@148
|
49 bool isOK();
|
Chris@148
|
50 QString getErrorString() const { return m_errorString; }
|
Chris@148
|
51
|
Chris@148
|
52 // For loading a single layer onto an existing pane
|
Chris@148
|
53 void setCurrentPane(Pane *pane) { m_currentPane = pane; }
|
Chris@148
|
54
|
Chris@148
|
55 virtual bool startElement(const QString &namespaceURI,
|
Chris@148
|
56 const QString &localName,
|
Chris@148
|
57 const QString &qName,
|
Chris@148
|
58 const QXmlAttributes& atts);
|
Chris@148
|
59
|
Chris@148
|
60 virtual bool characters(const QString &);
|
Chris@148
|
61
|
Chris@148
|
62 virtual bool endElement(const QString &namespaceURI,
|
Chris@148
|
63 const QString &localName,
|
Chris@148
|
64 const QString &qName);
|
Chris@148
|
65
|
Chris@148
|
66 bool error(const QXmlParseException &exception);
|
Chris@148
|
67 bool fatalError(const QXmlParseException &exception);
|
Chris@148
|
68
|
Chris@148
|
69 protected:
|
Chris@148
|
70 bool readWindow(const QXmlAttributes &);
|
Chris@148
|
71 bool readModel(const QXmlAttributes &);
|
Chris@148
|
72 bool readView(const QXmlAttributes &);
|
Chris@148
|
73 bool readLayer(const QXmlAttributes &);
|
Chris@148
|
74 bool readDatasetStart(const QXmlAttributes &);
|
Chris@148
|
75 bool addBinToDataset(const QXmlAttributes &);
|
Chris@148
|
76 bool addPointToDataset(const QXmlAttributes &);
|
Chris@148
|
77 bool addRowToDataset(const QXmlAttributes &);
|
Chris@148
|
78 bool readRowData(const QString &);
|
Chris@148
|
79 bool readDerivation(const QXmlAttributes &);
|
Chris@148
|
80 bool readPlayParameters(const QXmlAttributes &);
|
Chris@148
|
81 bool readPlugin(const QXmlAttributes &);
|
Chris@148
|
82 bool readSelection(const QXmlAttributes &);
|
Chris@148
|
83 void addUnaddedModels();
|
Chris@148
|
84
|
Chris@148
|
85 Document *m_document;
|
Chris@148
|
86 SVFileReaderPaneCallback &m_paneCallback;
|
Chris@148
|
87 Pane *m_currentPane;
|
Chris@148
|
88 std::map<int, Layer *> m_layers;
|
Chris@148
|
89 std::map<int, Model *> m_models;
|
Chris@148
|
90 std::set<Model *> m_addedModels;
|
Chris@148
|
91 std::map<int, int> m_awaitingDatasets; // map dataset id -> model id
|
Chris@148
|
92 Model *m_currentDataset;
|
Chris@148
|
93 Model *m_currentDerivedModel;
|
Chris@148
|
94 PlayParameters *m_currentPlayParameters;
|
Chris@148
|
95 QString m_currentTransform;
|
Chris@148
|
96 int m_currentTransformChannel;
|
Chris@148
|
97 QString m_currentTransformConfiguration;
|
Chris@148
|
98 QString m_datasetSeparator;
|
Chris@148
|
99 bool m_inRow;
|
Chris@148
|
100 bool m_inView;
|
Chris@148
|
101 bool m_inData;
|
Chris@148
|
102 bool m_inSelections;
|
Chris@148
|
103 int m_rowNumber;
|
Chris@148
|
104 QString m_errorString;
|
Chris@148
|
105 bool m_ok;
|
Chris@148
|
106 };
|
Chris@148
|
107
|
Chris@148
|
108 #endif
|