changeset 147:c02706551309

* Improvements to importer feedback dialogs and suchlike
author Chris Cannam
date Fri, 05 Dec 2008 18:45:49 +0000
parents f90dcec6dd9a
children 7dca51571320
files framework/MainWindowBase.cpp framework/MainWindowBase.h
diffstat 2 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Tue Dec 02 17:17:25 2008 +0000
+++ b/framework/MainWindowBase.cpp	Fri Dec 05 18:45:49 2008 +0000
@@ -878,8 +878,11 @@
 
     if (rdf) {
         if (rdfSession) {
-            if (!canImportLayer || shouldCreateNewSessionForRDFAudio()) {
+            bool cancel = false;
+            if (!canImportLayer || shouldCreateNewSessionForRDFAudio(&cancel)) {
                 return openSession(source);
+            } else if (cancel) {
+                return FileOpenCancelled;
             } else {
                 return openLayer(source);
             }
@@ -942,7 +945,10 @@
     if (mode == AskUser) {
         if (getMainModel()) {
 
-            static bool prevSetAsMain = true;
+            QSettings settings;
+            settings.beginGroup("MainWindow");
+            bool prevSetAsMain = settings.value("newsessionforaudio", true).toBool();
+            settings.endGroup();
             bool setAsMain = true;
             
             QStringList items;
@@ -952,7 +958,7 @@
             bool ok = false;
             QString item = ListInputDialog::getItem
                 (this, tr("Select target for import"),
-                 tr("You already have an audio waveform loaded.\nWhat would you like to do with the new audio file?"),
+                 tr("<b>Select a target for import</b><p>You already have an audio waveform loaded.\nWhat would you like to do with the new audio file?"),
                  items, prevSetAsMain ? 0 : 1, &ok);
             
             if (!ok || item.isEmpty()) {
@@ -962,7 +968,9 @@
             }
             
             setAsMain = (item == items[0]);
-            prevSetAsMain = setAsMain;
+            settings.beginGroup("MainWindow");
+            settings.setValue("newsessionforaudio", setAsMain);
+            settings.endGroup();
 
             if (setAsMain) mode = ReplaceMainModel;
             else mode = CreateAdditionalModel;
@@ -1491,6 +1499,12 @@
         (QUrl::fromLocalFile(source.getLocalFilename()).toString(), rate);
 
     if (!importer.isOK()) {
+        if (importer.getErrorString() != "") {
+            QMessageBox::critical
+                (this, tr("Failed to import RDF"),
+                 tr("<b>Failed to import RDF</b><p>Importing data from RDF document at \"%1\" failed: %2</p>")
+                 .arg(source.getLocation()).arg(importer.getErrorString()));
+        }
         return FileOpenFailed;
     }
 
--- a/framework/MainWindowBase.h	Tue Dec 02 17:17:25 2008 +0000
+++ b/framework/MainWindowBase.h	Fri Dec 05 18:45:49 2008 +0000
@@ -377,7 +377,7 @@
     virtual void setupMenus() = 0;
     virtual void updateVisibleRangeDisplay(Pane *p) const = 0;
 
-    virtual bool shouldCreateNewSessionForRDFAudio() { return true; }
+    virtual bool shouldCreateNewSessionForRDFAudio(bool *) { return true; }
 
     virtual void connectLayerEditDialog(ModelDataTableDialog *dialog);