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