comparison main/MainWindow.cpp @ 437:9de86c1b980e

Merge from debug-output branch
author Chris Cannam
date Tue, 14 Jun 2011 14:50:08 +0100
parents 5f22e0bbe4ba ae68fc09bf16
children 868f73825b37
comparison
equal deleted inserted replaced
428:5f22e0bbe4ba 437:9de86c1b980e
308 this, SLOT(newerVersionAvailable(QString))); 308 this, SLOT(newerVersionAvailable(QString)));
309 } 309 }
310 310
311 MainWindow::~MainWindow() 311 MainWindow::~MainWindow()
312 { 312 {
313 // std::cerr << "MainWindow::~MainWindow" << std::endl; 313 // DEBUG << "MainWindow::~MainWindow" << endl;
314 delete m_keyReference; 314 delete m_keyReference;
315 delete m_preferencesDialog; 315 delete m_preferencesDialog;
316 delete m_layerTreeDialog; 316 delete m_layerTreeDialog;
317 Profiles::getInstance()->dump(); 317 Profiles::getInstance()->dump();
318 // std::cerr << "MainWindow::~MainWindow finishing" << std::endl; 318 // DEBUG << "MainWindow::~MainWindow finishing" << endl;
319 } 319 }
320 320
321 void 321 void
322 MainWindow::setupMenus() 322 MainWindow::setupMenus()
323 { 323 {
1457 for (unsigned int i = 0; i < transforms.size(); ++i) { 1457 for (unsigned int i = 0; i < transforms.size(); ++i) {
1458 1458
1459 QString name = transforms[i].name; 1459 QString name = transforms[i].name;
1460 if (name == "") name = transforms[i].identifier; 1460 if (name == "") name = transforms[i].identifier;
1461 1461
1462 // std::cerr << "Plugin Name: " << name.toStdString() << std::endl; 1462 // std::cerr << "Plugin Name: " << name << std::endl;
1463 1463
1464 TransformDescription::Type type = transforms[i].type; 1464 TransformDescription::Type type = transforms[i].type;
1465 QString typeStr = factory->getTransformTypeName(type); 1465 QString typeStr = factory->getTransformTypeName(type);
1466 1466
1467 QString category = transforms[i].category; 1467 QString category = transforms[i].category;
1493 action->setStatusTip(transforms[i].longDescription); 1493 action->setStatusTip(transforms[i].longDescription);
1494 1494
1495 if (categoryMenus[type].find(category) == categoryMenus[type].end()) { 1495 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
1496 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " 1496 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
1497 << "No category menu for transform \"" 1497 << "No category menu for transform \""
1498 << name.toStdString() << "\" (category = \"" 1498 << name << "\" (category = \""
1499 << category.toStdString() << "\")" << std::endl; 1499 << category << "\")" << std::endl;
1500 } else { 1500 } else {
1501 categoryMenus[type][category]->addAction(action); 1501 categoryMenus[type][category]->addAction(action);
1502 } 1502 }
1503 1503
1504 if (makerMenus[type].find(maker) == makerMenus[type].end()) { 1504 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
1505 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " 1505 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: "
1506 << "No maker menu for transform \"" 1506 << "No maker menu for transform \""
1507 << name.toStdString() << "\" (maker = \"" 1507 << name << "\" (maker = \""
1508 << maker.toStdString() << "\")" << std::endl; 1508 << maker << "\")" << std::endl;
1509 } else { 1509 } else {
1510 makerMenus[type][maker]->addAction(action); 1510 makerMenus[type][maker]->addAction(action);
1511 } 1511 }
1512 1512
1513 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this); 1513 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
1514 connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); 1514 connect(action, SIGNAL(triggered()), this, SLOT(addLayer()));
1515 m_transformActions[action] = transforms[i].identifier; 1515 m_transformActions[action] = transforms[i].identifier;
1516 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); 1516 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
1517 action->setStatusTip(transforms[i].longDescription); 1517 action->setStatusTip(transforms[i].longDescription);
1518 1518
1519 // cerr << "Transform: \"" << name.toStdString() << "\": plugin name \"" << pluginName.toStdString() << "\"" << endl; 1519 // cerr << "Transform: \"" << name << "\": plugin name \"" << pluginName << "\"" << endl;
1520 1520
1521 if (pluginNameMenus[type].find(pluginName) == 1521 if (pluginNameMenus[type].find(pluginName) ==
1522 pluginNameMenus[type].end()) { 1522 pluginNameMenus[type].end()) {
1523 1523
1524 SubdividingMenu *parentMenu = byPluginNameMenus[type]; 1524 SubdividingMenu *parentMenu = byPluginNameMenus[type];
1646 void 1646 void
1647 MainWindow::setupExistingLayersMenus() 1647 MainWindow::setupExistingLayersMenus()
1648 { 1648 {
1649 if (!m_existingLayersMenu) return; // should have been created by setupMenus 1649 if (!m_existingLayersMenu) return; // should have been created by setupMenus
1650 1650
1651 // std::cerr << "MainWindow::setupExistingLayersMenu" << std::endl; 1651 // DEBUG << "MainWindow::setupExistingLayersMenu" << endl;
1652 1652
1653 m_existingLayersMenu->clear(); 1653 m_existingLayersMenu->clear();
1654 m_existingLayerActions.clear(); 1654 m_existingLayerActions.clear();
1655 1655
1656 m_sliceMenu->clear(); 1656 m_sliceMenu->clear();
1677 // std::cerr << "found duplicate layer " << layer << std::endl; 1677 // std::cerr << "found duplicate layer " << layer << std::endl;
1678 continue; 1678 continue;
1679 } 1679 }
1680 1680
1681 // std::cerr << "found new layer " << layer << " (name = " 1681 // std::cerr << "found new layer " << layer << " (name = "
1682 // << layer->getLayerPresentationName().toStdString() << ")" << std::endl; 1682 // << layer->getLayerPresentationName() << ")" << std::endl;
1683 1683
1684 orderedLayers.push_back(layer); 1684 orderedLayers.push_back(layer);
1685 observedLayers.insert(layer); 1685 observedLayers.insert(layer);
1686 1686
1687 if (factory->isLayerSliceable(layer)) { 1687 if (factory->isLayerSliceable(layer)) {
2184 Pane *pane = m_paneStack->getPane(i); 2184 Pane *pane = m_paneStack->getPane(i);
2185 if (!pane) continue; 2185 if (!pane) continue;
2186 for (int j = 0; j < pane->getLayerCount(); ++j) { 2186 for (int j = 0; j < pane->getLayerCount(); ++j) {
2187 Layer *layer = pane->getLayer(j); 2187 Layer *layer = pane->getLayer(j);
2188 if (!layer) continue; 2188 if (!layer) continue;
2189 cerr << "layer = " << layer->objectName().toStdString() << endl; 2189 cerr << "layer = " << layer->objectName() << endl;
2190 Model *m = layer->getModel(); 2190 Model *m = layer->getModel();
2191 RangeSummarisableTimeValueModel *wm = 2191 RangeSummarisableTimeValueModel *wm =
2192 dynamic_cast<RangeSummarisableTimeValueModel *>(m); 2192 dynamic_cast<RangeSummarisableTimeValueModel *>(m);
2193 if (wm) { 2193 if (wm) {
2194 cerr << "found: " << wm->objectName().toStdString() << endl; 2194 cerr << "found: " << wm->objectName() << endl;
2195 otherModels.insert(wm); 2195 otherModels.insert(wm);
2196 if (pane == m_paneStack->getCurrentPane()) { 2196 if (pane == m_paneStack->getCurrentPane()) {
2197 current = wm; 2197 current = wm;
2198 } 2198 }
2199 } 2199 }
2815 } 2815 }
2816 2816
2817 void 2817 void
2818 MainWindow::closeEvent(QCloseEvent *e) 2818 MainWindow::closeEvent(QCloseEvent *e)
2819 { 2819 {
2820 // std::cerr << "MainWindow::closeEvent" << std::endl; 2820 // DEBUG << "MainWindow::closeEvent" << endl;
2821 2821
2822 if (m_openingAudioFile) { 2822 if (m_openingAudioFile) {
2823 // std::cerr << "Busy - ignoring close event" << std::endl; 2823 // std::cerr << "Busy - ignoring close event" << std::endl;
2824 e->ignore(); 2824 e->ignore();
2825 return; 2825 return;
2826 } 2826 }
2827 2827
2828 if (!m_abandoning && !checkSaveModified()) { 2828 if (!m_abandoning && !checkSaveModified()) {
2829 // std::cerr << "Ignoring close event" << std::endl; 2829 // DEBUG << "Ignoring close event" << endl;
2830 e->ignore(); 2830 e->ignore();
2831 return; 2831 return;
2832 } 2832 }
2833 2833
2834 QSettings settings; 2834 QSettings settings;
3032 } 3032 }
3033 3033
3034 void 3034 void
3035 MainWindow::propertyStacksResized(int width) 3035 MainWindow::propertyStacksResized(int width)
3036 { 3036 {
3037 // std::cerr << "MainWindow::propertyStacksResized(" << width << ")" << std::endl; 3037 // DEBUG << "MainWindow::propertyStacksResized(" << width << ")" << endl;
3038 3038
3039 if (!m_playControlsSpacer) return; 3039 if (!m_playControlsSpacer) return;
3040 3040
3041 int spacerWidth = width - m_playControlsWidth - 4; 3041 int spacerWidth = width - m_playControlsWidth - 4;
3042 3042
3043 // std::cerr << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << std::endl; 3043 // DEBUG << "resizing spacer from " << m_playControlsSpacer->width() << " to " << spacerWidth << endl;
3044 3044
3045 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2)); 3045 m_playControlsSpacer->setFixedSize(QSize(spacerWidth, 2));
3046 } 3046 }
3047 3047
3048 void 3048 void
3059 3059
3060 PaneActionMap::iterator i = m_paneActions.find(action); 3060 PaneActionMap::iterator i = m_paneActions.find(action);
3061 3061
3062 if (i == m_paneActions.end()) { 3062 if (i == m_paneActions.end()) {
3063 std::cerr << "WARNING: MainWindow::addPane: unknown action " 3063 std::cerr << "WARNING: MainWindow::addPane: unknown action "
3064 << action->objectName().toStdString() << std::endl; 3064 << action->objectName() << std::endl;
3065 return; 3065 return;
3066 } 3066 }
3067 3067
3068 addPane(i->second, action->text()); 3068 addPane(i->second, action->text());
3069 } 3069 }
3091 // std::cerr << "no time ruler layer, creating one" << std::endl; 3091 // std::cerr << "no time ruler layer, creating one" << std::endl;
3092 m_timeRulerLayer = m_document->createMainModelLayer 3092 m_timeRulerLayer = m_document->createMainModelLayer
3093 (LayerFactory::TimeRuler); 3093 (LayerFactory::TimeRuler);
3094 } 3094 }
3095 3095
3096 // std::cerr << "adding time ruler layer " << m_timeRulerLayer << std::endl; 3096 // DEBUG << "adding time ruler layer " << m_timeRulerLayer << endl;
3097 3097
3098 m_document->addLayerToView(pane, m_timeRulerLayer); 3098 m_document->addLayerToView(pane, m_timeRulerLayer);
3099 } 3099 }
3100 3100
3101 Layer *newLayer = m_document->createLayer(configuration.layer); 3101 Layer *newLayer = m_document->createLayer(configuration.layer);
3131 m_document->addLayerToView(pane, newLayer); 3131 m_document->addLayerToView(pane, newLayer);
3132 3132
3133 m_paneStack->setCurrentPane(pane); 3133 m_paneStack->setCurrentPane(pane);
3134 m_paneStack->setCurrentLayer(pane, newLayer); 3134 m_paneStack->setCurrentLayer(pane, newLayer);
3135 3135
3136 // std::cerr << "MainWindow::addPane: global centre frame is " 3136 // DEBUG << "MainWindow::addPane: global centre frame is "
3137 // << m_viewManager->getGlobalCentreFrame() << std::endl; 3137 // << m_viewManager->getGlobalCentreFrame() << endl;
3138 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame()); 3138 // pane->setCentreFrame(m_viewManager->getGlobalCentreFrame());
3139 3139
3140 CommandHistory::getInstance()->endCompoundOperation(); 3140 CommandHistory::getInstance()->endCompoundOperation();
3141 3141
3142 updateMenuStates(); 3142 updateMenuStates();
3196 3196
3197 LayerActionMap::iterator i = m_layerActions.find(action); 3197 LayerActionMap::iterator i = m_layerActions.find(action);
3198 3198
3199 if (i == m_layerActions.end()) { 3199 if (i == m_layerActions.end()) {
3200 std::cerr << "WARNING: MainWindow::addLayer: unknown action " 3200 std::cerr << "WARNING: MainWindow::addLayer: unknown action "
3201 << action->objectName().toStdString() << std::endl; 3201 << action->objectName() << std::endl;
3202 return; 3202 return;
3203 } 3203 }
3204 3204
3205 LayerFactory::LayerType type = i->second.layer; 3205 LayerFactory::LayerType type = i->second.layer;
3206 3206
3338 duration, 3338 duration,
3339 &configurator); 3339 &configurator);
3340 3340
3341 if (!input.getModel()) return; 3341 if (!input.getModel()) return;
3342 3342
3343 // std::cerr << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName().toStdString() << "\"" << std::endl << "transform:" << std::endl << transform.toXmlString().toStdString() << std::endl; 3343 // DEBUG << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName() << "\"" << endl << "transform:" << endl << transform.toXmlString() << endl;
3344 3344
3345 Layer *newLayer = m_document->createDerivedLayer(transform, input); 3345 Layer *newLayer = m_document->createDerivedLayer(transform, input);
3346 3346
3347 if (newLayer) { 3347 if (newLayer) {
3348 m_document->addLayerToView(pane, newLayer); 3348 m_document->addLayerToView(pane, newLayer);
3882 } 3882 }
3883 3883
3884 void 3884 void
3885 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position) 3885 MainWindow::rightButtonMenuRequested(Pane *pane, QPoint position)
3886 { 3886 {
3887 // std::cerr << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << std::endl; 3887 // DEBUG << "MainWindow::rightButtonMenuRequested(" << pane << ", " << position.x() << ", " << position.y() << ")" << endl;
3888 m_paneStack->setCurrentPane(pane); 3888 m_paneStack->setCurrentPane(pane);
3889 m_rightButtonMenu->popup(position); 3889 m_rightButtonMenu->popup(position);
3890 } 3890 }
3891 3891
3892 void 3892 void