Mercurial > hg > svapp
diff 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 |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Wed Dec 21 14:02:29 2016 +0000 +++ b/framework/MainWindowBase.cpp Wed Jan 04 18:54:50 2017 +0000 @@ -1376,6 +1376,7 @@ if (templateName == "") { templateName = getDefaultSessionTemplate(); + SVDEBUG << "(Default template is: \"" << templateName << "\")" << endl; } // cerr << "template is: \"" << templateName << "\"" << endl; @@ -1496,11 +1497,11 @@ if (templateName != "") { FileOpenStatus tplStatus = openSessionTemplate(templateName); if (tplStatus == FileOpenCancelled) { - cerr << "Template load cancelled" << endl; + SVDEBUG << "Template load cancelled" << endl; return FileOpenCancelled; } if (tplStatus != FileOpenFailed) { - cerr << "Template load succeeded" << endl; + SVDEBUG << "Template load succeeded" << endl; loadedTemplate = true; } } @@ -1555,6 +1556,8 @@ } else if (mode == CreateAdditionalModel) { + SVCERR << "Mode is CreateAdditionalModel" << endl; + CommandHistory::getInstance()->startCompoundOperation (tr("Import \"%1\"").arg(source.getBasename()), true); @@ -1566,7 +1569,10 @@ Pane *pane = command->getPane(); if (m_timeRulerLayer) { + SVCERR << "Have time ruler, adding it" << endl; m_document->addLayerToView(pane, m_timeRulerLayer); + } else { + SVCERR << "Do not have time ruler" << endl; } Layer *newLayer = m_document->createImportedLayer(newModel); @@ -2010,6 +2016,7 @@ if (!source.isRemote()) m_sessionFile = source.getLocalFilename(); setupMenus(); + findTimeRulerLayer(); CommandHistory::getInstance()->clear(); CommandHistory::getInstance()->documentSaved(); @@ -2102,6 +2109,7 @@ emit activity(tr("Open session template \"%1\"").arg(source.getLocation())); setupMenus(); + findTimeRulerLayer(); CommandHistory::getInstance()->clear(); CommandHistory::getInstance()->documentSaved(); @@ -2132,6 +2140,7 @@ FileOpenStatus status = openLayersFromRDF(source); setupMenus(); + findTimeRulerLayer(); setWindowTitle(tr("%1: %2") .arg(QApplication::applicationName()) @@ -2694,6 +2703,26 @@ } void +MainWindowBase::findTimeRulerLayer() +{ + for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { + Pane *pane = m_paneStack->getPane(i); + if (!pane) continue; + for (int j = 0; j < pane->getLayerCount(); ++j) { + Layer *layer = pane->getLayer(j); + if (!dynamic_cast<TimeRulerLayer *>(layer)) continue; + m_timeRulerLayer = layer; + return; + } + } + if (m_timeRulerLayer) { + SVCERR << "WARNING: Time ruler layer was not reset to 0 before session template loaded?" << endl; + delete m_timeRulerLayer; + m_timeRulerLayer = 0; + } +} + +void MainWindowBase::toggleTimeRulers() { bool haveRulers = false; @@ -2933,6 +2962,7 @@ m_document->setMainModel(model); setupMenus(); + findTimeRulerLayer(); if (loadedTemplate || (m_sessionFile == "")) { //!!! shouldn't be dealing directly with title from here -- call a method