changeset 347:b3609adae921 tony_integration

Merge from tonioni branch
author Chris Cannam
date Wed, 07 May 2014 15:12:35 +0100
parents 0e4332efcc7d (current diff) 63dec7dc11cc (diff)
children f8e1ca25dd80
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 4 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Document.cpp	Wed May 07 15:11:20 2014 +0100
+++ b/framework/Document.cpp	Wed May 07 15:12:35 2014 +0100
@@ -105,7 +105,6 @@
 
     emit mainModelChanged(0);
     delete m_mainModel;
-
 }
 
 Layer *
--- a/framework/MainWindowBase.cpp	Wed May 07 15:11:20 2014 +0100
+++ b/framework/MainWindowBase.cpp	Wed May 07 15:12:35 2014 +0100
@@ -45,6 +45,7 @@
 #include "widgets/MIDIFileImportDialog.h"
 #include "widgets/CSVFormatDialog.h"
 #include "widgets/ModelDataTableDialog.h"
+#include "widgets/InteractiveFileFinder.h"
 
 #include "audioio/AudioCallbackPlaySource.h"
 #include "audioio/AudioCallbackPlayTarget.h"
@@ -1393,6 +1394,8 @@
 
     currentPaneChanged(m_paneStack->getCurrentPane());
 
+    emit audioFileLoaded();
+
     return FileOpenSucceeded;
 }
 
@@ -1637,7 +1640,10 @@
     if (!source.isAvailable()) return FileOpenFailed;
     source.waitForData();
 
-    if (source.getExtension().toLower() != "sv") {
+    QString sessionExt = 
+        InteractiveFileFinder::getInstance()->getApplicationSessionExtension();
+
+    if (source.getExtension().toLower() != sessionExt) {
 
         RDFImporter::RDFDocumentType rdfType = 
             RDFImporter::identifyDocumentType
@@ -1668,7 +1674,7 @@
     BZipFileDevice *bzFile = 0;
     QFile *rawFile = 0;
 
-    if (source.getExtension().toLower() == "sv") {
+    if (source.getExtension().toLower() == sessionExt) {
         bzFile = new BZipFileDevice(source.getLocalFilename());
         if (!bzFile->open(QIODevice::ReadOnly)) {
             delete bzFile;
@@ -1742,6 +1748,8 @@
                                        source.getLocalFilename());
         }
 
+        emit sessionLoaded();
+
     } else {
 	setWindowTitle(QApplication::applicationName());
     }
@@ -1824,6 +1832,8 @@
 	CommandHistory::getInstance()->documentSaved();
 	m_documentModified = false;
 	updateMenuStates();
+
+        emit sessionLoaded();
     }
 
     return ok ? FileOpenSucceeded : FileOpenFailed;
@@ -1855,6 +1865,8 @@
     CommandHistory::getInstance()->documentSaved();
     m_documentModified = false;
 
+    emit sessionLoaded();
+
     return status;
 }
 
@@ -2209,6 +2221,7 @@
 Pane *
 MainWindowBase::addPaneToStack()
 {
+    cerr << "MainWindowBase::addPaneToStack()" << endl;
     AddPaneCommand *command = new AddPaneCommand(this);
     CommandHistory::getInstance()->addCommand(command);
     Pane *pane = command->getPane();
--- a/framework/MainWindowBase.h	Wed May 07 15:11:20 2014 +0100
+++ b/framework/MainWindowBase.h	Wed May 07 15:12:35 2014 +0100
@@ -153,6 +153,8 @@
     void canSelectNextLayer(bool);
     void canSave(bool);
     void hideSplash();
+    void sessionLoaded();
+    void audioFileLoaded();
     void replacedDocument();
     void activity(QString);
 
@@ -352,7 +354,7 @@
 	    m_mw->resizeConstrained(QSize(width, height));
 	}
 	virtual void addSelection(int start, int end) {
-	    m_mw->m_viewManager->addSelection(Selection(start, end));
+	    m_mw->m_viewManager->addSelectionQuietly(Selection(start, end));
 	}
     protected:
 	MainWindowBase *m_mw;
--- a/framework/SVFileReader.cpp	Wed May 07 15:11:20 2014 +0100
+++ b/framework/SVFileReader.cpp	Wed May 07 15:12:35 2014 +0100
@@ -31,6 +31,7 @@
 #include "data/model/SparseOneDimensionalModel.h"
 #include "data/model/SparseTimeValueModel.h"
 #include "data/model/NoteModel.h"
+#include "data/model/FlexiNoteModel.h"
 #include "data/model/RegionModel.h"
 #include "data/model/TextModel.h"
 #include "data/model/ImageModel.h"
@@ -624,6 +625,19 @@
                     model->setScaleUnits(units);
                     model->setObjectName(name);
                     m_models[id] = model;
+                } else if (attributes.value("subtype") == "flexinote") {
+                    FlexiNoteModel *model;
+                    if (haveMinMax) {
+                        model = new FlexiNoteModel
+                            (sampleRate, resolution, minimum, maximum, notifyOnAdd);
+                    } else {
+                        model = new FlexiNoteModel
+                            (sampleRate, resolution, notifyOnAdd);
+                    }
+                    model->setValueQuantization(valueQuantization);
+                    model->setScaleUnits(units);
+                    model->setObjectName(name);
+                    m_models[id] = model;
                 } else {
                     // note models written out by SV 1.3 and earlier
                     // have no subtype, so we can't test that
@@ -726,6 +740,8 @@
 
     m_currentPane = m_paneCallback.addPane();
 
+    cerr << "SVFileReader::addPane: pane is " << m_currentPane << endl;
+
     if (!m_currentPane) {
 	cerr << "WARNING: SV-XML: Internal error: Failed to add pane!"
 		  << endl;
@@ -932,6 +948,7 @@
 
     case 3:
 	if (dynamic_cast<NoteModel *>(model)) good = true;
+	else if (dynamic_cast<FlexiNoteModel *>(model)) good = true;
 	else if (dynamic_cast<RegionModel *>(model)) good = true;
 	else if (dynamic_cast<EditableDenseThreeDimensionalModel *>(model)) {
 	    m_datasetSeparator = attributes.value("separator");
@@ -973,7 +990,7 @@
 	(m_currentDataset);
 
     if (stvm) {
-//        cerr << "Current dataset is a sparse time-value model" << endl;
+        cerr << "Current dataset is a sparse time-value model" << endl;
 	float value = 0.0;
 	value = attributes.value("value").trimmed().toFloat(&ok);
 	QString label = attributes.value("label");
@@ -984,7 +1001,7 @@
     NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset);
 
     if (nm) {
-//        cerr << "Current dataset is a note model" << endl;
+        cerr << "Current dataset is a note model" << endl;
 	float value = 0.0;
 	value = attributes.value("value").trimmed().toFloat(&ok);
 	size_t duration = 0;
@@ -999,10 +1016,28 @@
 	return ok;
     }
 
+    FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(m_currentDataset);
+
+    if (fnm) {
+        cerr << "Current dataset is a flexinote model" << endl;
+	float value = 0.0;
+	value = attributes.value("value").trimmed().toFloat(&ok);
+	size_t duration = 0;
+	duration = attributes.value("duration").trimmed().toUInt(&ok);
+	QString label = attributes.value("label");
+        float level = attributes.value("level").trimmed().toFloat(&ok);
+        if (!ok) { // level is optional
+            level = 1.f;
+            ok = true;
+        }
+	fnm->addPoint(FlexiNoteModel::Point(frame, value, duration, level, label));
+	return ok;
+    }
+
     RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset);
 
     if (rm) {
-//        cerr << "Current dataset is a note model" << endl;
+        cerr << "Current dataset is a region model" << endl;
 	float value = 0.0;
 	value = attributes.value("value").trimmed().toFloat(&ok);
 	size_t duration = 0;