comparison framework/MainWindowBase.cpp @ 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
comparison
equal deleted inserted replaced
146:f90dcec6dd9a 147:c02706551309
876 } 876 }
877 } 877 }
878 878
879 if (rdf) { 879 if (rdf) {
880 if (rdfSession) { 880 if (rdfSession) {
881 if (!canImportLayer || shouldCreateNewSessionForRDFAudio()) { 881 bool cancel = false;
882 if (!canImportLayer || shouldCreateNewSessionForRDFAudio(&cancel)) {
882 return openSession(source); 883 return openSession(source);
884 } else if (cancel) {
885 return FileOpenCancelled;
883 } else { 886 } else {
884 return openLayer(source); 887 return openLayer(source);
885 } 888 }
886 } else { 889 } else {
887 if ((status = openSession(source)) != FileOpenFailed) { 890 if ((status = openSession(source)) != FileOpenFailed) {
940 // std::cerr << "mode = " << mode << std::endl; 943 // std::cerr << "mode = " << mode << std::endl;
941 944
942 if (mode == AskUser) { 945 if (mode == AskUser) {
943 if (getMainModel()) { 946 if (getMainModel()) {
944 947
945 static bool prevSetAsMain = true; 948 QSettings settings;
949 settings.beginGroup("MainWindow");
950 bool prevSetAsMain = settings.value("newsessionforaudio", true).toBool();
951 settings.endGroup();
946 bool setAsMain = true; 952 bool setAsMain = true;
947 953
948 QStringList items; 954 QStringList items;
949 items << tr("Replace the existing main waveform") 955 items << tr("Replace the existing main waveform")
950 << tr("Load this file into a new waveform pane"); 956 << tr("Load this file into a new waveform pane");
951 957
952 bool ok = false; 958 bool ok = false;
953 QString item = ListInputDialog::getItem 959 QString item = ListInputDialog::getItem
954 (this, tr("Select target for import"), 960 (this, tr("Select target for import"),
955 tr("You already have an audio waveform loaded.\nWhat would you like to do with the new audio file?"), 961 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?"),
956 items, prevSetAsMain ? 0 : 1, &ok); 962 items, prevSetAsMain ? 0 : 1, &ok);
957 963
958 if (!ok || item.isEmpty()) { 964 if (!ok || item.isEmpty()) {
959 delete newModel; 965 delete newModel;
960 m_openingAudioFile = false; 966 m_openingAudioFile = false;
961 return FileOpenCancelled; 967 return FileOpenCancelled;
962 } 968 }
963 969
964 setAsMain = (item == items[0]); 970 setAsMain = (item == items[0]);
965 prevSetAsMain = setAsMain; 971 settings.beginGroup("MainWindow");
972 settings.setValue("newsessionforaudio", setAsMain);
973 settings.endGroup();
966 974
967 if (setAsMain) mode = ReplaceMainModel; 975 if (setAsMain) mode = ReplaceMainModel;
968 else mode = CreateAdditionalModel; 976 else mode = CreateAdditionalModel;
969 977
970 } else { 978 } else {
1489 1497
1490 RDFImporter importer 1498 RDFImporter importer
1491 (QUrl::fromLocalFile(source.getLocalFilename()).toString(), rate); 1499 (QUrl::fromLocalFile(source.getLocalFilename()).toString(), rate);
1492 1500
1493 if (!importer.isOK()) { 1501 if (!importer.isOK()) {
1502 if (importer.getErrorString() != "") {
1503 QMessageBox::critical
1504 (this, tr("Failed to import RDF"),
1505 tr("<b>Failed to import RDF</b><p>Importing data from RDF document at \"%1\" failed: %2</p>")
1506 .arg(source.getLocation()).arg(importer.getErrorString()));
1507 }
1494 return FileOpenFailed; 1508 return FileOpenFailed;
1495 } 1509 }
1496 1510
1497 std::vector<Model *> models = importer.getDataModels(&dialog); 1511 std::vector<Model *> models = importer.getDataModels(&dialog);
1498 1512