Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 293:068235cf5bf7
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 14:12:50 +0000 |
parents | 3fc0df289533 |
children | 933b5aed341a |
comparison
equal
deleted
inserted
replaced
291:3fc0df289533 | 293:068235cf5bf7 |
---|---|
99 | 99 |
100 #include <iostream> | 100 #include <iostream> |
101 #include <cstdio> | 101 #include <cstdio> |
102 #include <errno.h> | 102 #include <errno.h> |
103 | 103 |
104 using std::cerr; | 104 |
105 using std::endl; | 105 |
106 | 106 |
107 using std::vector; | 107 using std::vector; |
108 using std::map; | 108 using std::map; |
109 using std::set; | 109 using std::set; |
110 | 110 |
118 static int handle_x11_error(Display *dpy, XErrorEvent *err) | 118 static int handle_x11_error(Display *dpy, XErrorEvent *err) |
119 { | 119 { |
120 char errstr[256]; | 120 char errstr[256]; |
121 XGetErrorText(dpy, err->error_code, errstr, 256); | 121 XGetErrorText(dpy, err->error_code, errstr, 256); |
122 if (err->error_code != BadWindow) { | 122 if (err->error_code != BadWindow) { |
123 std::cerr << "Sonic Visualiser: X Error: " | 123 cerr << "Sonic Visualiser: X Error: " |
124 << errstr << " " << int(err->error_code) | 124 << errstr << " " << int(err->error_code) |
125 << "\nin major opcode: " | 125 << "\nin major opcode: " |
126 << int(err->request_code) << std::endl; | 126 << int(err->request_code) << endl; |
127 } | 127 } |
128 return 0; | 128 return 0; |
129 } | 129 } |
130 #undef Window | 130 #undef Window |
131 #endif | 131 #endif |
288 if (m_oscQueue && m_oscQueue->isOK()) { | 288 if (m_oscQueue && m_oscQueue->isOK()) { |
289 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); | 289 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); |
290 QTimer *oscTimer = new QTimer(this); | 290 QTimer *oscTimer = new QTimer(this); |
291 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); | 291 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); |
292 oscTimer->start(1000); | 292 oscTimer->start(1000); |
293 std::cerr << "Finished setting up OSC interface" << std::endl; | 293 cerr << "Finished setting up OSC interface" << endl; |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 QString | 297 QString |
298 MainWindowBase::getOpenFileName(FileFinder::FileType type) | 298 MainWindowBase::getOpenFileName(FileFinder::FileType type) |
576 // frame before switching to whichever one we decide we want to | 576 // frame before switching to whichever one we decide we want to |
577 // switch to, regardless of our efforts. | 577 // switch to, regardless of our efforts. |
578 | 578 |
579 int frame = m_playSource->getCurrentBufferedFrame(); | 579 int frame = m_playSource->getCurrentBufferedFrame(); |
580 | 580 |
581 // std::cerr << "currentPaneChanged: current frame (in ref model) = " << frame << std::endl; | 581 // cerr << "currentPaneChanged: current frame (in ref model) = " << frame << endl; |
582 | 582 |
583 View::ModelSet soloModels = p->getModels(); | 583 View::ModelSet soloModels = p->getModels(); |
584 | 584 |
585 View::ModelSet sources; | 585 View::ModelSet sources; |
586 for (View::ModelSet::iterator mi = soloModels.begin(); | 586 for (View::ModelSet::iterator mi = soloModels.begin(); |
1071 bool rdfSession = false; | 1071 bool rdfSession = false; |
1072 if (rdf) { | 1072 if (rdf) { |
1073 RDFImporter::RDFDocumentType rdfType = | 1073 RDFImporter::RDFDocumentType rdfType = |
1074 RDFImporter::identifyDocumentType | 1074 RDFImporter::identifyDocumentType |
1075 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); | 1075 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); |
1076 // std::cerr << "RDF type: " << (int)rdfType << std::endl; | 1076 // cerr << "RDF type: " << (int)rdfType << endl; |
1077 if (rdfType == RDFImporter::AudioRefAndAnnotations || | 1077 if (rdfType == RDFImporter::AudioRefAndAnnotations || |
1078 rdfType == RDFImporter::AudioRef) { | 1078 rdfType == RDFImporter::AudioRef) { |
1079 rdfSession = true; | 1079 rdfSession = true; |
1080 } else if (rdfType == RDFImporter::NotRDF) { | 1080 } else if (rdfType == RDFImporter::NotRDF) { |
1081 rdf = false; | 1081 rdf = false; |
1130 | 1130 |
1131 if (templateName == "") { | 1131 if (templateName == "") { |
1132 templateName = getDefaultSessionTemplate(); | 1132 templateName = getDefaultSessionTemplate(); |
1133 } | 1133 } |
1134 | 1134 |
1135 std::cerr << "template is: \"" << templateName.toStdString() << "\"" << std::endl; | 1135 cerr << "template is: \"" << templateName.toStdString() << "\"" << endl; |
1136 | 1136 |
1137 if (!source.isAvailable()) return FileOpenFailed; | 1137 if (!source.isAvailable()) return FileOpenFailed; |
1138 source.waitForData(); | 1138 source.waitForData(); |
1139 | 1139 |
1140 m_openingAudioFile = true; | 1140 m_openingAudioFile = true; |
1151 delete newModel; | 1151 delete newModel; |
1152 m_openingAudioFile = false; | 1152 m_openingAudioFile = false; |
1153 return FileOpenFailed; | 1153 return FileOpenFailed; |
1154 } | 1154 } |
1155 | 1155 |
1156 // std::cerr << "mode = " << mode << std::endl; | 1156 // cerr << "mode = " << mode << endl; |
1157 | 1157 |
1158 if (mode == AskUser) { | 1158 if (mode == AskUser) { |
1159 if (getMainModel()) { | 1159 if (getMainModel()) { |
1160 | 1160 |
1161 QSettings settings; | 1161 QSettings settings; |
1228 | 1228 |
1229 if (mode == ReplaceSession) { | 1229 if (mode == ReplaceSession) { |
1230 | 1230 |
1231 if (!checkSaveModified()) return FileOpenCancelled; | 1231 if (!checkSaveModified()) return FileOpenCancelled; |
1232 | 1232 |
1233 std::cerr << "SV looking for template " << templateName << std::endl; | 1233 cerr << "SV looking for template " << templateName << endl; |
1234 if (templateName != "") { | 1234 if (templateName != "") { |
1235 FileOpenStatus tplStatus = openSessionTemplate(templateName); | 1235 FileOpenStatus tplStatus = openSessionTemplate(templateName); |
1236 if (tplStatus == FileOpenCancelled) { | 1236 if (tplStatus == FileOpenCancelled) { |
1237 std::cerr << "Template load cancelled" << std::endl; | 1237 cerr << "Template load cancelled" << endl; |
1238 return FileOpenCancelled; | 1238 return FileOpenCancelled; |
1239 } | 1239 } |
1240 if (tplStatus != FileOpenFailed) { | 1240 if (tplStatus != FileOpenFailed) { |
1241 std::cerr << "Template load succeeded" << std::endl; | 1241 cerr << "Template load succeeded" << endl; |
1242 loadedTemplate = true; | 1242 loadedTemplate = true; |
1243 } | 1243 } |
1244 } | 1244 } |
1245 | 1245 |
1246 if (!loadedTemplate) { | 1246 if (!loadedTemplate) { |
1412 | 1412 |
1413 Pane *pane = m_paneStack->getCurrentPane(); | 1413 Pane *pane = m_paneStack->getCurrentPane(); |
1414 | 1414 |
1415 if (!pane) { | 1415 if (!pane) { |
1416 // shouldn't happen, as the menu action should have been disabled | 1416 // shouldn't happen, as the menu action should have been disabled |
1417 std::cerr << "WARNING: MainWindowBase::openLayer: no current pane" << std::endl; | 1417 cerr << "WARNING: MainWindowBase::openLayer: no current pane" << endl; |
1418 return FileOpenWrongMode; | 1418 return FileOpenWrongMode; |
1419 } | 1419 } |
1420 | 1420 |
1421 if (!getMainModel()) { | 1421 if (!getMainModel()) { |
1422 // shouldn't happen, as the menu action should have been disabled | 1422 // shouldn't happen, as the menu action should have been disabled |
1423 std::cerr << "WARNING: MainWindowBase::openLayer: No main model -- hence no default sample rate available" << std::endl; | 1423 cerr << "WARNING: MainWindowBase::openLayer: No main model -- hence no default sample rate available" << endl; |
1424 return FileOpenWrongMode; | 1424 return FileOpenWrongMode; |
1425 } | 1425 } |
1426 | 1426 |
1427 if (!source.isAvailable()) return FileOpenFailed; | 1427 if (!source.isAvailable()) return FileOpenFailed; |
1428 source.waitForData(); | 1428 source.waitForData(); |
1430 QString path = source.getLocalFilename(); | 1430 QString path = source.getLocalFilename(); |
1431 | 1431 |
1432 RDFImporter::RDFDocumentType rdfType = | 1432 RDFImporter::RDFDocumentType rdfType = |
1433 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString()); | 1433 RDFImporter::identifyDocumentType(QUrl::fromLocalFile(path).toString()); |
1434 | 1434 |
1435 // std::cerr << "RDF type: (in layer) " << (int) rdfType << std::endl; | 1435 // cerr << "RDF type: (in layer) " << (int) rdfType << endl; |
1436 | 1436 |
1437 if (rdfType != RDFImporter::NotRDF) { | 1437 if (rdfType != RDFImporter::NotRDF) { |
1438 | 1438 |
1439 return openLayersFromRDF(source); | 1439 return openLayersFromRDF(source); |
1440 | 1440 |
1445 | 1445 |
1446 PaneCallback callback(this); | 1446 PaneCallback callback(this); |
1447 QFile file(path); | 1447 QFile file(path); |
1448 | 1448 |
1449 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { | 1449 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
1450 std::cerr << "ERROR: MainWindowBase::openLayer(" | 1450 cerr << "ERROR: MainWindowBase::openLayer(" |
1451 << source.getLocation().toStdString() | 1451 << source.getLocation().toStdString() |
1452 << "): Failed to open file for reading" << std::endl; | 1452 << "): Failed to open file for reading" << endl; |
1453 return FileOpenFailed; | 1453 return FileOpenFailed; |
1454 } | 1454 } |
1455 | 1455 |
1456 SVFileReader reader(m_document, callback, source.getLocation()); | 1456 SVFileReader reader(m_document, callback, source.getLocation()); |
1457 connect | 1457 connect |
1464 | 1464 |
1465 QXmlInputSource inputSource(&file); | 1465 QXmlInputSource inputSource(&file); |
1466 reader.parse(inputSource); | 1466 reader.parse(inputSource); |
1467 | 1467 |
1468 if (!reader.isOK()) { | 1468 if (!reader.isOK()) { |
1469 std::cerr << "ERROR: MainWindowBase::openLayer(" | 1469 cerr << "ERROR: MainWindowBase::openLayer(" |
1470 << source.getLocation().toStdString() | 1470 << source.getLocation().toStdString() |
1471 << "): Failed to read XML file: " | 1471 << "): Failed to read XML file: " |
1472 << reader.getErrorString() << std::endl; | 1472 << reader.getErrorString() << endl; |
1473 return FileOpenFailed; | 1473 return FileOpenFailed; |
1474 } | 1474 } |
1475 | 1475 |
1476 emit activity(tr("Import layer XML file \"%1\"").arg(source.getLocation())); | 1476 emit activity(tr("Import layer XML file \"%1\"").arg(source.getLocation())); |
1477 | 1477 |
1544 | 1544 |
1545 Pane *pane = m_paneStack->getCurrentPane(); | 1545 Pane *pane = m_paneStack->getCurrentPane(); |
1546 | 1546 |
1547 if (!pane) { | 1547 if (!pane) { |
1548 // shouldn't happen, as the menu action should have been disabled | 1548 // shouldn't happen, as the menu action should have been disabled |
1549 std::cerr << "WARNING: MainWindowBase::openImage: no current pane" << std::endl; | 1549 cerr << "WARNING: MainWindowBase::openImage: no current pane" << endl; |
1550 return FileOpenWrongMode; | 1550 return FileOpenWrongMode; |
1551 } | 1551 } |
1552 | 1552 |
1553 if (!m_document->getMainModel()) { | 1553 if (!m_document->getMainModel()) { |
1554 return FileOpenWrongMode; | 1554 return FileOpenWrongMode; |
1570 newLayer = true; | 1570 newLayer = true; |
1571 } | 1571 } |
1572 | 1572 |
1573 // We don't put the image file in Recent Files | 1573 // We don't put the image file in Recent Files |
1574 | 1574 |
1575 std::cerr << "openImage: trying location \"" << source.getLocation() << "\" in image layer" << std::endl; | 1575 cerr << "openImage: trying location \"" << source.getLocation() << "\" in image layer" << endl; |
1576 | 1576 |
1577 if (!il->addImage(m_viewManager->getGlobalCentreFrame(), source.getLocation())) { | 1577 if (!il->addImage(m_viewManager->getGlobalCentreFrame(), source.getLocation())) { |
1578 if (newLayer) { | 1578 if (newLayer) { |
1579 m_document->deleteLayer(il); // also releases its model | 1579 m_document->deleteLayer(il); // also releases its model |
1580 } | 1580 } |
1609 | 1609 |
1610 RDFImporter::RDFDocumentType rdfType = | 1610 RDFImporter::RDFDocumentType rdfType = |
1611 RDFImporter::identifyDocumentType | 1611 RDFImporter::identifyDocumentType |
1612 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); | 1612 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); |
1613 | 1613 |
1614 // std::cerr << "RDF type: " << (int)rdfType << std::endl; | 1614 // cerr << "RDF type: " << (int)rdfType << endl; |
1615 | 1615 |
1616 if (rdfType == RDFImporter::AudioRefAndAnnotations || | 1616 if (rdfType == RDFImporter::AudioRefAndAnnotations || |
1617 rdfType == RDFImporter::AudioRef) { | 1617 rdfType == RDFImporter::AudioRef) { |
1618 return openSessionFromRDF(source); | 1618 return openSessionFromRDF(source); |
1619 } else if (rdfType != RDFImporter::NotRDF) { | 1619 } else if (rdfType != RDFImporter::NotRDF) { |
1621 } | 1621 } |
1622 | 1622 |
1623 if (source.getExtension().toLower() == "xml") { | 1623 if (source.getExtension().toLower() == "xml") { |
1624 if (SVFileReader::identifyXmlFile(source.getLocalFilename()) == | 1624 if (SVFileReader::identifyXmlFile(source.getLocalFilename()) == |
1625 SVFileReader::SVSessionFile) { | 1625 SVFileReader::SVSessionFile) { |
1626 std::cerr << "This XML file looks like a session file, attempting to open it as a session" << std::endl; | 1626 cerr << "This XML file looks like a session file, attempting to open it as a session" << endl; |
1627 } else { | 1627 } else { |
1628 return FileOpenFailed; | 1628 return FileOpenFailed; |
1629 } | 1629 } |
1630 } else { | 1630 } else { |
1631 return FileOpenFailed; | 1631 return FileOpenFailed; |
1724 // priority over a bundled one; we don't unbundle, but | 1724 // priority over a bundled one; we don't unbundle, but |
1725 // open directly from the bundled file (where applicable) | 1725 // open directly from the bundled file (where applicable) |
1726 ResourceFinder rf; | 1726 ResourceFinder rf; |
1727 QString tfile = rf.getResourcePath("templates", templateName + ".svt"); | 1727 QString tfile = rf.getResourcePath("templates", templateName + ".svt"); |
1728 if (tfile != "") { | 1728 if (tfile != "") { |
1729 std::cerr << "SV loading template file " << tfile.toStdString() << std::endl; | 1729 cerr << "SV loading template file " << tfile.toStdString() << endl; |
1730 return openSessionTemplate(FileSource("file:" + tfile)); | 1730 return openSessionTemplate(FileSource("file:" + tfile)); |
1731 } else { | 1731 } else { |
1732 return FileOpenFailed; | 1732 return FileOpenFailed; |
1733 } | 1733 } |
1734 } | 1734 } |
1735 | 1735 |
1736 MainWindowBase::FileOpenStatus | 1736 MainWindowBase::FileOpenStatus |
1737 MainWindowBase::openSessionTemplate(FileSource source) | 1737 MainWindowBase::openSessionTemplate(FileSource source) |
1738 { | 1738 { |
1739 std::cerr << "MainWindowBase::openSessionTemplate(" << source.getLocation().toStdString() << ")" << std::endl; | 1739 cerr << "MainWindowBase::openSessionTemplate(" << source.getLocation().toStdString() << ")" << endl; |
1740 | 1740 |
1741 if (!source.isAvailable()) return FileOpenFailed; | 1741 if (!source.isAvailable()) return FileOpenFailed; |
1742 source.waitForData(); | 1742 source.waitForData(); |
1743 | 1743 |
1744 QXmlInputSource *inputSource = 0; | 1744 QXmlInputSource *inputSource = 0; |
2063 | 2063 |
2064 TempWriteFile temp(path); | 2064 TempWriteFile temp(path); |
2065 | 2065 |
2066 BZipFileDevice bzFile(temp.getTemporaryFilename()); | 2066 BZipFileDevice bzFile(temp.getTemporaryFilename()); |
2067 if (!bzFile.open(QIODevice::WriteOnly)) { | 2067 if (!bzFile.open(QIODevice::WriteOnly)) { |
2068 std::cerr << "Failed to open session file \"" | 2068 cerr << "Failed to open session file \"" |
2069 << temp.getTemporaryFilename().toStdString() | 2069 << temp.getTemporaryFilename().toStdString() |
2070 << "\" for writing: " | 2070 << "\" for writing: " |
2071 << bzFile.errorString() << std::endl; | 2071 << bzFile.errorString() << endl; |
2072 return false; | 2072 return false; |
2073 } | 2073 } |
2074 | 2074 |
2075 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); | 2075 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
2076 | 2076 |
2108 | 2108 |
2109 TempWriteFile temp(path); | 2109 TempWriteFile temp(path); |
2110 | 2110 |
2111 QFile file(temp.getTemporaryFilename()); | 2111 QFile file(temp.getTemporaryFilename()); |
2112 if (!file.open(QIODevice::WriteOnly)) { | 2112 if (!file.open(QIODevice::WriteOnly)) { |
2113 std::cerr << "Failed to open session template file \"" | 2113 cerr << "Failed to open session template file \"" |
2114 << temp.getTemporaryFilename().toStdString() | 2114 << temp.getTemporaryFilename().toStdString() |
2115 << "\" for writing: " | 2115 << "\" for writing: " |
2116 << file.errorString().toStdString() << std::endl; | 2116 << file.errorString().toStdString() << endl; |
2117 return false; | 2117 return false; |
2118 } | 2118 } |
2119 | 2119 |
2120 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); | 2120 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
2121 | 2121 |
3024 // SVDEBUG << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << endl; | 3024 // SVDEBUG << "MainWindowBase::layerAboutToBeDeleted(" << layer << ")" << endl; |
3025 | 3025 |
3026 removeLayerEditDialog(layer); | 3026 removeLayerEditDialog(layer); |
3027 | 3027 |
3028 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { | 3028 if (m_timeRulerLayer && (layer == m_timeRulerLayer)) { |
3029 // std::cerr << "(this is the time ruler layer)" << std::endl; | 3029 // cerr << "(this is the time ruler layer)" << endl; |
3030 m_timeRulerLayer = 0; | 3030 m_timeRulerLayer = 0; |
3031 } | 3031 } |
3032 } | 3032 } |
3033 | 3033 |
3034 void | 3034 void |