annotate document/SVFileReader.h @ 117:8089a394829a

* 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 8944f3005a15
children fbd09fcda469
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 Sonic Visualiser
Chris@0 5 An audio file viewer and annotation editor.
Chris@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@77 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@0 8
Chris@0 9 This program is free software; you can redistribute it and/or
Chris@0 10 modify it under the terms of the GNU General Public License as
Chris@0 11 published by the Free Software Foundation; either version 2 of the
Chris@0 12 License, or (at your option) any later version. See the file
Chris@0 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _SV_FILE_READER_H_
Chris@0 17 #define _SV_FILE_READER_H_
Chris@0 18
Chris@0 19 #include "layer/LayerFactory.h"
Chris@0 20 #include "transform/Transform.h"
Chris@30 21 #include "transform/PluginTransform.h"
Chris@0 22
Chris@0 23 #include <QXmlDefaultHandler>
Chris@0 24
Chris@0 25 #include <map>
Chris@0 26
Chris@0 27 class Pane;
Chris@0 28 class Model;
Chris@0 29 class Document;
Chris@0 30 class PlayParameters;
Chris@0 31
Chris@0 32 class SVFileReaderPaneCallback
Chris@0 33 {
Chris@0 34 public:
Chris@0 35 virtual Pane *addPane() = 0;
Chris@0 36 virtual void setWindowSize(int width, int height) = 0;
Chris@0 37 virtual void addSelection(int start, int end) = 0;
Chris@0 38 };
Chris@0 39
Chris@0 40 class SVFileReader : public QXmlDefaultHandler
Chris@0 41 {
Chris@0 42 public:
Chris@0 43 SVFileReader(Document *document,
Chris@87 44 SVFileReaderPaneCallback &callback,
Chris@87 45 QString location = ""); // for audio file locate mechanism
Chris@0 46 virtual ~SVFileReader();
Chris@0 47
Chris@0 48 void parse(const QString &xmlData);
Chris@0 49 void parse(QXmlInputSource &source);
Chris@0 50
Chris@0 51 bool isOK();
Chris@0 52 QString getErrorString() const { return m_errorString; }
Chris@0 53
Chris@0 54 // For loading a single layer onto an existing pane
Chris@0 55 void setCurrentPane(Pane *pane) { m_currentPane = pane; }
Chris@0 56
Chris@0 57 virtual bool startElement(const QString &namespaceURI,
Chris@0 58 const QString &localName,
Chris@0 59 const QString &qName,
Chris@0 60 const QXmlAttributes& atts);
Chris@0 61
Chris@0 62 virtual bool characters(const QString &);
Chris@0 63
Chris@0 64 virtual bool endElement(const QString &namespaceURI,
Chris@0 65 const QString &localName,
Chris@0 66 const QString &qName);
Chris@0 67
Chris@0 68 bool error(const QXmlParseException &exception);
Chris@0 69 bool fatalError(const QXmlParseException &exception);
Chris@0 70
Chris@0 71 protected:
Chris@0 72 bool readWindow(const QXmlAttributes &);
Chris@0 73 bool readModel(const QXmlAttributes &);
Chris@0 74 bool readView(const QXmlAttributes &);
Chris@0 75 bool readLayer(const QXmlAttributes &);
Chris@0 76 bool readDatasetStart(const QXmlAttributes &);
Chris@0 77 bool addBinToDataset(const QXmlAttributes &);
Chris@0 78 bool addPointToDataset(const QXmlAttributes &);
Chris@0 79 bool addRowToDataset(const QXmlAttributes &);
Chris@0 80 bool readRowData(const QString &);
Chris@0 81 bool readDerivation(const QXmlAttributes &);
Chris@0 82 bool readPlayParameters(const QXmlAttributes &);
Chris@0 83 bool readPlugin(const QXmlAttributes &);
Chris@0 84 bool readSelection(const QXmlAttributes &);
Chris@0 85 void addUnaddedModels();
Chris@0 86
Chris@0 87 Document *m_document;
Chris@0 88 SVFileReaderPaneCallback &m_paneCallback;
Chris@87 89 QString m_location;
Chris@0 90 Pane *m_currentPane;
Chris@0 91 std::map<int, Layer *> m_layers;
Chris@0 92 std::map<int, Model *> m_models;
Chris@0 93 std::set<Model *> m_addedModels;
Chris@0 94 std::map<int, int> m_awaitingDatasets; // map dataset id -> model id
Chris@0 95 Model *m_currentDataset;
Chris@0 96 Model *m_currentDerivedModel;
Chris@55 97 int m_currentDerivedModelId;
Chris@0 98 PlayParameters *m_currentPlayParameters;
Chris@0 99 QString m_currentTransform;
Chris@55 100 Model *m_currentTransformSource;
Chris@30 101 PluginTransform::ExecutionContext m_currentTransformContext;
Chris@0 102 QString m_currentTransformConfiguration;
Chris@0 103 QString m_datasetSeparator;
Chris@0 104 bool m_inRow;
Chris@0 105 bool m_inView;
Chris@0 106 bool m_inData;
Chris@0 107 bool m_inSelections;
Chris@0 108 int m_rowNumber;
Chris@0 109 QString m_errorString;
Chris@0 110 bool m_ok;
Chris@0 111 };
Chris@0 112
Chris@0 113 #endif