comparison framework/MainWindowBase.cpp @ 577:58354f2934ec 3.0-integration

Ensure a time ruler layer created from a template is identified as such, so that it gets added to subsequent panes as well
author Chris Cannam
date Wed, 04 Jan 2017 18:54:50 +0000
parents 7b115a6505b8
children 702272b78bbe
comparison
equal deleted inserted replaced
576:150cadf9c5fe 577:58354f2934ec
1374 { 1374 {
1375 SVDEBUG << "MainWindowBase::openAudio(" << source.getLocation() << ") with mode " << mode << " and template " << templateName << endl; 1375 SVDEBUG << "MainWindowBase::openAudio(" << source.getLocation() << ") with mode " << mode << " and template " << templateName << endl;
1376 1376
1377 if (templateName == "") { 1377 if (templateName == "") {
1378 templateName = getDefaultSessionTemplate(); 1378 templateName = getDefaultSessionTemplate();
1379 SVDEBUG << "(Default template is: \"" << templateName << "\")" << endl;
1379 } 1380 }
1380 1381
1381 // cerr << "template is: \"" << templateName << "\"" << endl; 1382 // cerr << "template is: \"" << templateName << "\"" << endl;
1382 1383
1383 if (!source.isAvailable()) { 1384 if (!source.isAvailable()) {
1494 1495
1495 SVDEBUG << "SV looking for template " << templateName << endl; 1496 SVDEBUG << "SV looking for template " << templateName << endl;
1496 if (templateName != "") { 1497 if (templateName != "") {
1497 FileOpenStatus tplStatus = openSessionTemplate(templateName); 1498 FileOpenStatus tplStatus = openSessionTemplate(templateName);
1498 if (tplStatus == FileOpenCancelled) { 1499 if (tplStatus == FileOpenCancelled) {
1499 cerr << "Template load cancelled" << endl; 1500 SVDEBUG << "Template load cancelled" << endl;
1500 return FileOpenCancelled; 1501 return FileOpenCancelled;
1501 } 1502 }
1502 if (tplStatus != FileOpenFailed) { 1503 if (tplStatus != FileOpenFailed) {
1503 cerr << "Template load succeeded" << endl; 1504 SVDEBUG << "Template load succeeded" << endl;
1504 loadedTemplate = true; 1505 loadedTemplate = true;
1505 } 1506 }
1506 } 1507 }
1507 1508
1508 if (!loadedTemplate) { 1509 if (!loadedTemplate) {
1553 1554
1554 if (!source.isRemote()) m_audioFile = source.getLocalFilename(); 1555 if (!source.isRemote()) m_audioFile = source.getLocalFilename();
1555 1556
1556 } else if (mode == CreateAdditionalModel) { 1557 } else if (mode == CreateAdditionalModel) {
1557 1558
1559 SVCERR << "Mode is CreateAdditionalModel" << endl;
1560
1558 CommandHistory::getInstance()->startCompoundOperation 1561 CommandHistory::getInstance()->startCompoundOperation
1559 (tr("Import \"%1\"").arg(source.getBasename()), true); 1562 (tr("Import \"%1\"").arg(source.getBasename()), true);
1560 1563
1561 m_document->addImportedModel(newModel); 1564 m_document->addImportedModel(newModel);
1562 1565
1564 CommandHistory::getInstance()->addCommand(command); 1567 CommandHistory::getInstance()->addCommand(command);
1565 1568
1566 Pane *pane = command->getPane(); 1569 Pane *pane = command->getPane();
1567 1570
1568 if (m_timeRulerLayer) { 1571 if (m_timeRulerLayer) {
1572 SVCERR << "Have time ruler, adding it" << endl;
1569 m_document->addLayerToView(pane, m_timeRulerLayer); 1573 m_document->addLayerToView(pane, m_timeRulerLayer);
1574 } else {
1575 SVCERR << "Do not have time ruler" << endl;
1570 } 1576 }
1571 1577
1572 Layer *newLayer = m_document->createImportedLayer(newModel); 1578 Layer *newLayer = m_document->createImportedLayer(newModel);
1573 1579
1574 if (newLayer) { 1580 if (newLayer) {
2008 .arg(source.getLocation())); 2014 .arg(source.getLocation()));
2009 2015
2010 if (!source.isRemote()) m_sessionFile = source.getLocalFilename(); 2016 if (!source.isRemote()) m_sessionFile = source.getLocalFilename();
2011 2017
2012 setupMenus(); 2018 setupMenus();
2019 findTimeRulerLayer();
2013 2020
2014 CommandHistory::getInstance()->clear(); 2021 CommandHistory::getInstance()->clear();
2015 CommandHistory::getInstance()->documentSaved(); 2022 CommandHistory::getInstance()->documentSaved();
2016 m_documentModified = false; 2023 m_documentModified = false;
2017 updateMenuStates(); 2024 updateMenuStates();
2100 if (ok) { 2107 if (ok) {
2101 2108
2102 emit activity(tr("Open session template \"%1\"").arg(source.getLocation())); 2109 emit activity(tr("Open session template \"%1\"").arg(source.getLocation()));
2103 2110
2104 setupMenus(); 2111 setupMenus();
2112 findTimeRulerLayer();
2105 2113
2106 CommandHistory::getInstance()->clear(); 2114 CommandHistory::getInstance()->clear();
2107 CommandHistory::getInstance()->documentSaved(); 2115 CommandHistory::getInstance()->documentSaved();
2108 m_documentModified = false; 2116 m_documentModified = false;
2109 updateMenuStates(); 2117 updateMenuStates();
2130 createDocument(); 2138 createDocument();
2131 2139
2132 FileOpenStatus status = openLayersFromRDF(source); 2140 FileOpenStatus status = openLayersFromRDF(source);
2133 2141
2134 setupMenus(); 2142 setupMenus();
2143 findTimeRulerLayer();
2135 2144
2136 setWindowTitle(tr("%1: %2") 2145 setWindowTitle(tr("%1: %2")
2137 .arg(QApplication::applicationName()) 2146 .arg(QApplication::applicationName())
2138 .arg(source.getLocation())); 2147 .arg(source.getLocation()));
2139 CommandHistory::getInstance()->clear(); 2148 CommandHistory::getInstance()->clear();
2689 2698
2690 void 2699 void
2691 MainWindowBase::showAllOverlays() 2700 MainWindowBase::showAllOverlays()
2692 { 2701 {
2693 m_viewManager->setOverlayMode(ViewManager::AllOverlays); 2702 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
2703 }
2704
2705 void
2706 MainWindowBase::findTimeRulerLayer()
2707 {
2708 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
2709 Pane *pane = m_paneStack->getPane(i);
2710 if (!pane) continue;
2711 for (int j = 0; j < pane->getLayerCount(); ++j) {
2712 Layer *layer = pane->getLayer(j);
2713 if (!dynamic_cast<TimeRulerLayer *>(layer)) continue;
2714 m_timeRulerLayer = layer;
2715 return;
2716 }
2717 }
2718 if (m_timeRulerLayer) {
2719 SVCERR << "WARNING: Time ruler layer was not reset to 0 before session template loaded?" << endl;
2720 delete m_timeRulerLayer;
2721 m_timeRulerLayer = 0;
2722 }
2694 } 2723 }
2695 2724
2696 void 2725 void
2697 MainWindowBase::toggleTimeRulers() 2726 MainWindowBase::toggleTimeRulers()
2698 { 2727 {
2931 PlayParameterRepository::getInstance()->removePlayable(prevMain); 2960 PlayParameterRepository::getInstance()->removePlayable(prevMain);
2932 } 2961 }
2933 2962
2934 m_document->setMainModel(model); 2963 m_document->setMainModel(model);
2935 setupMenus(); 2964 setupMenus();
2965 findTimeRulerLayer();
2936 2966
2937 if (loadedTemplate || (m_sessionFile == "")) { 2967 if (loadedTemplate || (m_sessionFile == "")) {
2938 //!!! shouldn't be dealing directly with title from here -- call a method 2968 //!!! shouldn't be dealing directly with title from here -- call a method
2939 setWindowTitle(tr("%1: %2") 2969 setWindowTitle(tr("%1: %2")
2940 .arg(QApplication::applicationName()) 2970 .arg(QApplication::applicationName())