Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 295:14b1768e5406 tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 14:39:57 +0000 |
parents | bc78f88a66f5 933b5aed341a |
children | febd49356ef3 |
comparison
equal
deleted
inserted
replaced
292:bc78f88a66f5 | 295:14b1768e5406 |
---|---|
101 | 101 |
102 #include <iostream> | 102 #include <iostream> |
103 #include <cstdio> | 103 #include <cstdio> |
104 #include <errno.h> | 104 #include <errno.h> |
105 | 105 |
106 using std::cerr; | 106 |
107 using std::endl; | 107 |
108 | 108 |
109 using std::vector; | 109 using std::vector; |
110 using std::map; | 110 using std::map; |
111 using std::set; | 111 using std::set; |
112 | 112 |
120 static int handle_x11_error(Display *dpy, XErrorEvent *err) | 120 static int handle_x11_error(Display *dpy, XErrorEvent *err) |
121 { | 121 { |
122 char errstr[256]; | 122 char errstr[256]; |
123 XGetErrorText(dpy, err->error_code, errstr, 256); | 123 XGetErrorText(dpy, err->error_code, errstr, 256); |
124 if (err->error_code != BadWindow) { | 124 if (err->error_code != BadWindow) { |
125 std::cerr << "Sonic Visualiser: X Error: " | 125 cerr << "Sonic Visualiser: X Error: " |
126 << errstr << " " << int(err->error_code) | 126 << errstr << " " << int(err->error_code) |
127 << "\nin major opcode: " | 127 << "\nin major opcode: " |
128 << int(err->request_code) << std::endl; | 128 << int(err->request_code) << endl; |
129 } | 129 } |
130 return 0; | 130 return 0; |
131 } | 131 } |
132 #undef Window | 132 #undef Window |
133 #endif | 133 #endif |
290 if (m_oscQueue && m_oscQueue->isOK()) { | 290 if (m_oscQueue && m_oscQueue->isOK()) { |
291 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); | 291 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); |
292 QTimer *oscTimer = new QTimer(this); | 292 QTimer *oscTimer = new QTimer(this); |
293 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); | 293 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); |
294 oscTimer->start(1000); | 294 oscTimer->start(1000); |
295 std::cerr << "Finished setting up OSC interface" << std::endl; | 295 cerr << "Finished setting up OSC interface" << endl; |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 QString | 299 QString |
300 MainWindowBase::getOpenFileName(FileFinder::FileType type) | 300 MainWindowBase::getOpenFileName(FileFinder::FileType type) |
579 // frame before switching to whichever one we decide we want to | 579 // frame before switching to whichever one we decide we want to |
580 // switch to, regardless of our efforts. | 580 // switch to, regardless of our efforts. |
581 | 581 |
582 int frame = m_playSource->getCurrentBufferedFrame(); | 582 int frame = m_playSource->getCurrentBufferedFrame(); |
583 | 583 |
584 // std::cerr << "currentPaneChanged: current frame (in ref model) = " << frame << std::endl; | 584 // cerr << "currentPaneChanged: current frame (in ref model) = " << frame << endl; |
585 | 585 |
586 View::ModelSet soloModels = p->getModels(); | 586 View::ModelSet soloModels = p->getModels(); |
587 | 587 |
588 View::ModelSet sources; | 588 View::ModelSet sources; |
589 for (View::ModelSet::iterator mi = soloModels.begin(); | 589 for (View::ModelSet::iterator mi = soloModels.begin(); |
1093 bool rdfSession = false; | 1093 bool rdfSession = false; |
1094 if (rdf) { | 1094 if (rdf) { |
1095 RDFImporter::RDFDocumentType rdfType = | 1095 RDFImporter::RDFDocumentType rdfType = |
1096 RDFImporter::identifyDocumentType | 1096 RDFImporter::identifyDocumentType |
1097 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); | 1097 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); |
1098 // std::cerr << "RDF type: " << (int)rdfType << std::endl; | 1098 // cerr << "RDF type: " << (int)rdfType << endl; |
1099 if (rdfType == RDFImporter::AudioRefAndAnnotations || | 1099 if (rdfType == RDFImporter::AudioRefAndAnnotations || |
1100 rdfType == RDFImporter::AudioRef) { | 1100 rdfType == RDFImporter::AudioRef) { |
1101 rdfSession = true; | 1101 rdfSession = true; |
1102 } else if (rdfType == RDFImporter::NotRDF) { | 1102 } else if (rdfType == RDFImporter::NotRDF) { |
1103 rdf = false; | 1103 rdf = false; |
1152 | 1152 |
1153 if (templateName == "") { | 1153 if (templateName == "") { |
1154 templateName = getDefaultSessionTemplate(); | 1154 templateName = getDefaultSessionTemplate(); |
1155 } | 1155 } |
1156 | 1156 |
1157 std::cerr << "template is: \"" << templateName.toStdString() << "\"" << std::endl; | 1157 cerr << "template is: \"" << templateName << "\"" << endl; |
1158 | 1158 |
1159 if (!source.isAvailable()) return FileOpenFailed; | 1159 if (!source.isAvailable()) return FileOpenFailed; |
1160 source.waitForData(); | 1160 source.waitForData(); |
1161 | 1161 |
1162 m_openingAudioFile = true; | 1162 m_openingAudioFile = true; |
1173 delete newModel; | 1173 delete newModel; |
1174 m_openingAudioFile = false; | 1174 m_openingAudioFile = false; |
1175 return FileOpenFailed; | 1175 return FileOpenFailed; |
1176 } | 1176 } |
1177 | 1177 |
1178 // std::cerr << "mode = " << mode << std::endl; | 1178 // cerr << "mode = " << mode << endl; |
1179 | 1179 |
1180 if (mode == AskUser) { | 1180 if (mode == AskUser) { |
1181 if (getMainModel()) { | 1181 if (getMainModel()) { |
1182 | 1182 |
1183 QSettings settings; | 1183 QSettings settings; |
1250 | 1250 |
1251 if (mode == ReplaceSession) { | 1251 if (mode == ReplaceSession) { |
1252 | 1252 |
1253 if (!checkSaveModified()) return FileOpenCancelled; | 1253 if (!checkSaveModified()) return FileOpenCancelled; |
1254 | 1254 |
1255 std::cerr << "SV looking for template " << templateName << std::endl; | 1255 cerr << "SV looking for template " << templateName << endl; |
1256 if (templateName != "") { | 1256 if (templateName != "") { |
1257 FileOpenStatus tplStatus = openSessionTemplate(templateName); | 1257 FileOpenStatus tplStatus = openSessionTemplate(templateName); |
1258 if (tplStatus == FileOpenCancelled) { | 1258 if (tplStatus == FileOpenCancelled) { |
1259 std::cerr << "Template load cancelled" << std::endl; | 1259 cerr << "Template load cancelled" << endl; |
1260 return FileOpenCancelled; | 1260 return FileOpenCancelled; |
1261 } | 1261 } |
1262 if (tplStatus != FileOpenFailed) { | 1262 if (tplStatus != FileOpenFailed) { |
1263 std::cerr << "Template load succeeded" << std::endl; | 1263 cerr << "Template load succeeded" << endl; |
1264 loadedTemplate = true; | 1264 loadedTemplate = true; |
1265 } | 1265 } |
1266 } | 1266 } |
1267 | 1267 |
1268 if (!loadedTemplate) { | 1268 if (!loadedTemplate) { |
1434 | 1434 |
1435 Pane *pane = m_paneStack->getCurrentPane(); | 1435 Pane *pane = m_paneStack->getCurrentPane(); |
1436 | 1436 |
1437 if (!pane) { | 1437 if (!pane) { |
1438 // shouldn't happen, as the menu action should have been disabled | 1438 // shouldn't happen, as the menu action should have been disabled |
1439 std::cerr << "WARNING: MainWindowBase::openLayer: no current pane" << std::endl; | 1439 cerr << "WARNING: MainWindowBase::openLayer: no current pane" << endl; |
1440 return FileOpenWrongMode; | 1440 return FileOpenWrongMode; |
1441 } | 1441 } |
1442 | 1442 |
1443 if (!getMainModel()) { | 1443 if (!getMainModel()) { |
1444 // shouldn't happen, as the menu action should have been disabled | 1444 // shouldn't happen, as the menu action should have been disabled |
1445 std::cerr << "WARNING: MainWindowBase::openLayer: No main model -- hence no default sample rate available" << std::endl; | 1445 cerr << "WARNING: MainWindowBase::openLayer: No main model -- hence no default sample rate available" << endl; |
1446 return FileOpenWrongMode; | 1446 return FileOpenWrongMode; |
1447 } | 1447 } |
1448 | 1448 |
1449 if (!source.isAvailable()) return FileOpenFailed; | 1449 if (!source.isAvailable()) return FileOpenFailed; |
1450 source.waitForData(); | 1450 source.waitForData(); |
1452 QString path = source.getLocalFilename(); | 1452 QString path = source.getLocalFilename(); |
1453 | 1453 |
1454 RDFImporter::RDFDocumentType rdfType = | 1454 RDFImporter::RDFDocumentType rdfType = |
1455 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString()); | 1455 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString()); |
1456 | 1456 |
1457 // std::cerr << "RDF type: (in layer) " << (int) rdfType << std::endl; | 1457 // cerr << "RDF type: (in layer) " << (int) rdfType << endl; |
1458 | 1458 |
1459 if (rdfType != RDFImporter::NotRDF) { | 1459 if (rdfType != RDFImporter::NotRDF) { |
1460 | 1460 |
1461 return openLayersFromRDF(source); | 1461 return openLayersFromRDF(source); |
1462 | 1462 |
1467 | 1467 |
1468 PaneCallback callback(this); | 1468 PaneCallback callback(this); |
1469 QFile file(path); | 1469 QFile file(path); |
1470 | 1470 |
1471 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { | 1471 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
1472 std::cerr << "ERROR: MainWindowBase::openLayer(" | 1472 cerr << "ERROR: MainWindowBase::openLayer(" |
1473 << source.getLocation().toStdString() | 1473 << source.getLocation() |
1474 << "): Failed to open file for reading" << std::endl; | 1474 << "): Failed to open file for reading" << endl; |
1475 return FileOpenFailed; | 1475 return FileOpenFailed; |
1476 } | 1476 } |
1477 | 1477 |
1478 SVFileReader reader(m_document, callback, source.getLocation()); | 1478 SVFileReader reader(m_document, callback, source.getLocation()); |
1479 connect | 1479 connect |
1486 | 1486 |
1487 QXmlInputSource inputSource(&file); | 1487 QXmlInputSource inputSource(&file); |
1488 reader.parse(inputSource); | 1488 reader.parse(inputSource); |
1489 | 1489 |
1490 if (!reader.isOK()) { | 1490 if (!reader.isOK()) { |
1491 std::cerr << "ERROR: MainWindowBase::openLayer(" | 1491 cerr << "ERROR: MainWindowBase::openLayer(" |
1492 << source.getLocation().toStdString() | 1492 << source.getLocation() |
1493 << "): Failed to read XML file: " | 1493 << "): Failed to read XML file: " |
1494 << reader.getErrorString() << std::endl; | 1494 << reader.getErrorString() << endl; |
1495 return FileOpenFailed; | 1495 return FileOpenFailed; |
1496 } | 1496 } |
1497 | 1497 |
1498 emit activity(tr("Import layer XML file \"%1\"").arg(source.getLocation())); | 1498 emit activity(tr("Import layer XML file \"%1\"").arg(source.getLocation())); |
1499 | 1499 |
1566 | 1566 |
1567 Pane *pane = m_paneStack->getCurrentPane(); | 1567 Pane *pane = m_paneStack->getCurrentPane(); |
1568 | 1568 |
1569 if (!pane) { | 1569 if (!pane) { |
1570 // shouldn't happen, as the menu action should have been disabled | 1570 // shouldn't happen, as the menu action should have been disabled |
1571 std::cerr << "WARNING: MainWindowBase::openImage: no current pane" << std::endl; | 1571 cerr << "WARNING: MainWindowBase::openImage: no current pane" << endl; |
1572 return FileOpenWrongMode; | 1572 return FileOpenWrongMode; |
1573 } | 1573 } |
1574 | 1574 |
1575 if (!m_document->getMainModel()) { | 1575 if (!m_document->getMainModel()) { |
1576 return FileOpenWrongMode; | 1576 return FileOpenWrongMode; |
1592 newLayer = true; | 1592 newLayer = true; |
1593 } | 1593 } |
1594 | 1594 |
1595 // We don't put the image file in Recent Files | 1595 // We don't put the image file in Recent Files |
1596 | 1596 |
1597 std::cerr << "openImage: trying location \"" << source.getLocation() << "\" in image layer" << std::endl; | 1597 cerr << "openImage: trying location \"" << source.getLocation() << "\" in image layer" << endl; |
1598 | 1598 |
1599 if (!il->addImage(m_viewManager->getGlobalCentreFrame(), source.getLocation())) { | 1599 if (!il->addImage(m_viewManager->getGlobalCentreFrame(), source.getLocation())) { |
1600 if (newLayer) { | 1600 if (newLayer) { |
1601 m_document->deleteLayer(il); // also releases its model | 1601 m_document->deleteLayer(il); // also releases its model |
1602 } | 1602 } |
1631 | 1631 |
1632 RDFImporter::RDFDocumentType rdfType = | 1632 RDFImporter::RDFDocumentType rdfType = |
1633 RDFImporter::identifyDocumentType | 1633 RDFImporter::identifyDocumentType |
1634 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); | 1634 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); |
1635 | 1635 |
1636 // std::cerr << "RDF type: " << (int)rdfType << std::endl; | 1636 // cerr << "RDF type: " << (int)rdfType << endl; |
1637 | 1637 |
1638 if (rdfType == RDFImporter::AudioRefAndAnnotations || | 1638 if (rdfType == RDFImporter::AudioRefAndAnnotations || |
1639 rdfType == RDFImporter::AudioRef) { | 1639 rdfType == RDFImporter::AudioRef) { |
1640 return openSessionFromRDF(source); | 1640 return openSessionFromRDF(source); |
1641 } else if (rdfType != RDFImporter::NotRDF) { | 1641 } else if (rdfType != RDFImporter::NotRDF) { |
1643 } | 1643 } |
1644 | 1644 |
1645 if (source.getExtension().toLower() == "xml") { | 1645 if (source.getExtension().toLower() == "xml") { |
1646 if (SVFileReader::identifyXmlFile(source.getLocalFilename()) == | 1646 if (SVFileReader::identifyXmlFile(source.getLocalFilename()) == |
1647 SVFileReader::SVSessionFile) { | 1647 SVFileReader::SVSessionFile) { |
1648 std::cerr << "This XML file looks like a session file, attempting to open it as a session" << std::endl; | 1648 cerr << "This XML file looks like a session file, attempting to open it as a session" << endl; |
1649 } else { | 1649 } else { |
1650 return FileOpenFailed; | 1650 return FileOpenFailed; |
1651 } | 1651 } |
1652 } else { | 1652 } else { |
1653 return FileOpenFailed; | 1653 return FileOpenFailed; |
1746 // priority over a bundled one; we don't unbundle, but | 1746 // priority over a bundled one; we don't unbundle, but |
1747 // open directly from the bundled file (where applicable) | 1747 // open directly from the bundled file (where applicable) |
1748 ResourceFinder rf; | 1748 ResourceFinder rf; |
1749 QString tfile = rf.getResourcePath("templates", templateName + ".svt"); | 1749 QString tfile = rf.getResourcePath("templates", templateName + ".svt"); |
1750 if (tfile != "") { | 1750 if (tfile != "") { |
1751 std::cerr << "SV loading template file " << tfile.toStdString() << std::endl; | 1751 cerr << "SV loading template file " << tfile << endl; |
1752 return openSessionTemplate(FileSource("file:" + tfile)); | 1752 return openSessionTemplate(FileSource("file:" + tfile)); |
1753 } else { | 1753 } else { |
1754 return FileOpenFailed; | 1754 return FileOpenFailed; |
1755 } | 1755 } |
1756 } | 1756 } |
1757 | 1757 |
1758 MainWindowBase::FileOpenStatus | 1758 MainWindowBase::FileOpenStatus |
1759 MainWindowBase::openSessionTemplate(FileSource source) | 1759 MainWindowBase::openSessionTemplate(FileSource source) |
1760 { | 1760 { |
1761 std::cerr << "MainWindowBase::openSessionTemplate(" << source.getLocation().toStdString() << ")" << std::endl; | 1761 cerr << "MainWindowBase::openSessionTemplate(" << source.getLocation() << ")" << endl; |
1762 | 1762 |
1763 if (!source.isAvailable()) return FileOpenFailed; | 1763 if (!source.isAvailable()) return FileOpenFailed; |
1764 source.waitForData(); | 1764 source.waitForData(); |
1765 | 1765 |
1766 QXmlInputSource *inputSource = 0; | 1766 QXmlInputSource *inputSource = 0; |
2085 | 2085 |
2086 TempWriteFile temp(path); | 2086 TempWriteFile temp(path); |
2087 | 2087 |
2088 BZipFileDevice bzFile(temp.getTemporaryFilename()); | 2088 BZipFileDevice bzFile(temp.getTemporaryFilename()); |
2089 if (!bzFile.open(QIODevice::WriteOnly)) { | 2089 if (!bzFile.open(QIODevice::WriteOnly)) { |
2090 std::cerr << "Failed to open session file \"" | 2090 cerr << "Failed to open session file \"" |
2091 << temp.getTemporaryFilename().toStdString() | 2091 << temp.getTemporaryFilename() |
2092 << "\" for writing: " | 2092 << "\" for writing: " |
2093 << bzFile.errorString() << std::endl; | 2093 << bzFile.errorString() << endl; |
2094 return false; | 2094 return false; |
2095 } | 2095 } |
2096 | 2096 |
2097 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); | 2097 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
2098 | 2098 |
2130 | 2130 |
2131 TempWriteFile temp(path); | 2131 TempWriteFile temp(path); |
2132 | 2132 |
2133 QFile file(temp.getTemporaryFilename()); | 2133 QFile file(temp.getTemporaryFilename()); |
2134 if (!file.open(QIODevice::WriteOnly)) { | 2134 if (!file.open(QIODevice::WriteOnly)) { |
2135 std::cerr << "Failed to open session template file \"" | 2135 cerr << "Failed to open session template file \"" |
2136 << temp.getTemporaryFilename().toStdString() | 2136 << temp.getTemporaryFilename() |
2137 << "\" for writing: " | 2137 << "\" for writing: " |
2138 << file.errorString().toStdString() << std::endl; | 2138 << file.errorString() << endl; |
2139 return false; | 2139 return false; |
2140 } | 2140 } |
2141 | 2141 |
2142 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); | 2142 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
2143 | 2143 |
3046 // SVDEBUG << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << endl; | 3046 // SVDEBUG << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << endl; |
3047 | 3047 |
3048 removeLayerEditDialog(layer); | 3048 removeLayerEditDialog(layer); |
3049 | 3049 |
3050 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { | 3050 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { |
3051 // std::cerr << "(this is the time ruler layer)" << std::endl; | 3051 // cerr << "(this is the time ruler layer)" << endl; |
3052 m_timeRulerLayer = 0; | 3052 m_timeRulerLayer = 0; |
3053 } | 3053 } |
3054 } | 3054 } |
3055 | 3055 |
3056 void | 3056 void |