comparison main/MainWindow.cpp @ 677:bfd68cc71a25 imaf_enc

Merge from default branch, fix build
author Chris Cannam
date Thu, 05 Dec 2013 10:57:51 +0000
parents f45af8d8091e 17fe7e0c23a1
children 60d3575f8016
comparison
equal deleted inserted replaced
676:dabe6e994a9c 677:bfd68cc71a25
81 #include "layer/ColourDatabase.h" 81 #include "layer/ColourDatabase.h"
82 #include "widgets/ModelDataTableDialog.h" 82 #include "widgets/ModelDataTableDialog.h"
83 #include "rdf/PluginRDFIndexer.h" 83 #include "rdf/PluginRDFIndexer.h"
84 #include "rdf/RDFExporter.h" 84 #include "rdf/RDFExporter.h"
85 85
86 #include "Surveyer.h"
87 #include "NetworkPermissionTester.h"
86 #include "framework/VersionTester.h" 88 #include "framework/VersionTester.h"
87 89
88 // For version information 90 // For version information
89 #include <vamp/vamp.h> 91 #include <vamp/vamp.h>
90 #include <vamp-hostsdk/PluginBase.h> 92 #include <vamp-hostsdk/PluginBase.h>
118 #include <QFileSystemWatcher> 120 #include <QFileSystemWatcher>
119 121
120 #include <iostream> 122 #include <iostream>
121 #include <cstdio> 123 #include <cstdio>
122 #include <errno.h> 124 #include <errno.h>
123
124 using std::cerr;
125 using std::endl;
126 125
127 using std::vector; 126 using std::vector;
128 using std::map; 127 using std::map;
129 using std::set; 128 using std::set;
130 129
267 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); 266 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
268 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); 267 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
269 268
270 IconLoader il; 269 IconLoader il;
271 270
272 QSettings settings;
273 settings.beginGroup("MainWindow");
274 settings.endGroup();
275
276 m_playControlsSpacer = new QFrame; 271 m_playControlsSpacer = new QFrame;
277 272
278 layout->setSpacing(4); 273 layout->setSpacing(4);
279 layout->addWidget(m_mainScroll, 0, 0, 1, 5); 274 layout->addWidget(m_mainScroll, 0, 0, 1, 5);
280 layout->addWidget(m_overview, 1, 1); 275 layout->addWidget(m_overview, 1, 1);
321 newSession(); 316 newSession();
322 317
323 connect(m_midiInput, SIGNAL(eventsAvailable()), 318 connect(m_midiInput, SIGNAL(eventsAvailable()),
324 this, SLOT(midiEventsAvailable())); 319 this, SLOT(midiEventsAvailable()));
325 320
326 TransformFactory::getInstance()->startPopulationThread(); 321 NetworkPermissionTester tester;
327 322 bool networkPermission = tester.havePermission();
328 VersionTester *vt = new VersionTester 323 if (networkPermission) {
329 ("sonicvisualiser.org", "/latest-version.txt", SV_VERSION); 324 TransformFactory::getInstance()->startPopulationThread();
330 connect(vt, SIGNAL(newerVersionAvailable(QString)), 325 m_surveyer = 0;
331 this, SLOT(newerVersionAvailable(QString))); 326 m_versionTester = 0;
327 /*
328 m_surveyer = new Surveyer
329 ("sonicvisualiser.org", "survey23-present.txt", "survey23.php");
330 m_versionTester = new VersionTester
331 ("sonicvisualiser.org", "latest-version.txt", SV_VERSION);
332 connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
333 this, SLOT(newerVersionAvailable(QString)));
334 */
335 } else {
336 m_surveyer = 0;
337 m_versionTester = 0;
338 }
332 } 339 }
333 340
334 MainWindow::~MainWindow() 341 MainWindow::~MainWindow()
335 { 342 {
336 // SVDEBUG << "MainWindow::~MainWindow" << endl; 343 // SVDEBUG << "MainWindow::~MainWindow" << endl;
337 delete m_keyReference; 344 delete m_keyReference;
338 delete m_activityLog; 345 delete m_activityLog;
339 delete m_preferencesDialog; 346 delete m_preferencesDialog;
340 delete m_layerTreeDialog; 347 delete m_layerTreeDialog;
348 delete m_versionTester;
349 delete m_surveyer;
341 Profiles::getInstance()->dump(); 350 Profiles::getInstance()->dump();
342 // SVDEBUG << "MainWindow::~MainWindow finishing" << endl; 351 // SVDEBUG << "MainWindow::~MainWindow finishing" << endl;
343 } 352 }
344 353
345 void 354 void
541 action->setStatusTip(tr("Export selection as an audio file")); 550 action->setStatusTip(tr("Export selection as an audio file"));
542 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio())); 551 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
543 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); 552 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
544 menu->addAction(action); 553 menu->addAction(action);
545 554
546 action = new QAction(tr("&Export Audio Data..."), this); 555 action = new QAction(tr("Export Audio Data..."), this);
547 action->setStatusTip(tr("Export audio from selection into a data file")); 556 action->setStatusTip(tr("Export audio from selection into a data file"));
548 connect(action, SIGNAL(triggered()), this, SLOT(exportAudioData())); 557 connect(action, SIGNAL(triggered()), this, SLOT(exportAudioData()));
549 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); 558 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
550 menu->addAction(action); 559 menu->addAction(action);
551 560
552 QAction *actionCreateIMAF = new QAction(tr("&Export IMAF File..."), this); 561 QAction *actionCreateIMAF = new QAction(tr("Export IMAF File..."), this);
553 actionCreateIMAF->setStatusTip(tr("Export selection as an IMAF file")); 562 actionCreateIMAF->setStatusTip(tr("Export selection as an IMAF file"));
554 menu->addAction(actionCreateIMAF); 563 menu->addAction(actionCreateIMAF);
555 connect(actionCreateIMAF,SIGNAL(triggered()),this,SLOT(exportIMAF())); 564 connect(actionCreateIMAF,SIGNAL(triggered()),this,SLOT(exportIMAF()));
556 565
557 QAction *actionOpenIMAF = new QAction(tr("&Import IMAF File..."), this); 566 QAction *actionOpenIMAF = new QAction(tr("Import IMAF File..."), this);
558 actionOpenIMAF->setStatusTip(tr("Import IMAF file")); 567 actionOpenIMAF->setStatusTip(tr("Import IMAF file"));
559 menu->addAction(actionOpenIMAF); 568 menu->addAction(actionOpenIMAF);
560 connect(actionOpenIMAF,SIGNAL(triggered()),this,SLOT(importIMAF())); 569 connect(actionOpenIMAF,SIGNAL(triggered()),this,SLOT(importIMAF()));
561 570
562 menu->addSeparator(); 571 menu->addSeparator();
1586 for (unsigned int i = 0; i < transforms.size(); ++i) { 1595 for (unsigned int i = 0; i < transforms.size(); ++i) {
1587 1596
1588 QString name = transforms[i].name; 1597 QString name = transforms[i].name;
1589 if (name == "") name = transforms[i].identifier; 1598 if (name == "") name = transforms[i].identifier;
1590 1599
1591 // std::cerr << "Plugin Name: " << name << std::endl; 1600 // cerr << "Plugin Name: " << name << endl;
1592 1601
1593 TransformDescription::Type type = transforms[i].type; 1602 TransformDescription::Type type = transforms[i].type;
1594 QString typeStr = factory->getTransformTypeName(type); 1603 QString typeStr = factory->getTransformTypeName(type);
1595 1604
1596 QString category = transforms[i].category; 1605 QString category = transforms[i].category;
1620 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); 1629 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
1621 1630
1622 action->setStatusTip(transforms[i].longDescription); 1631 action->setStatusTip(transforms[i].longDescription);
1623 1632
1624 if (categoryMenus[type].find(category) == categoryMenus[type].end()) { 1633 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
1625 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " 1634 cerr << "WARNING: MainWindow::setupMenus: Internal error: "
1626 << "No category menu for transform \"" 1635 << "No category menu for transform \""
1627 << name << "\" (category = \"" 1636 << name << "\" (category = \""
1628 << category << "\")" << std::endl; 1637 << category << "\")" << endl;
1629 } else { 1638 } else {
1630 categoryMenus[type][category]->addAction(action); 1639 categoryMenus[type][category]->addAction(action);
1631 } 1640 }
1632 1641
1633 if (makerMenus[type].find(maker) == makerMenus[type].end()) { 1642 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
1634 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " 1643 cerr << "WARNING: MainWindow::setupMenus: Internal error: "
1635 << "No maker menu for transform \"" 1644 << "No maker menu for transform \""
1636 << name << "\" (maker = \"" 1645 << name << "\" (maker = \""
1637 << maker << "\")" << std::endl; 1646 << maker << "\")" << endl;
1638 } else { 1647 } else {
1639 makerMenus[type][maker]->addAction(action); 1648 makerMenus[type][maker]->addAction(action);
1640 } 1649 }
1641 1650
1642 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this); 1651 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
1805 vector<QString> transforms = m_recentTransforms.getRecent(); 1814 vector<QString> transforms = m_recentTransforms.getRecent();
1806 for (size_t i = 0; i < transforms.size(); ++i) { 1815 for (size_t i = 0; i < transforms.size(); ++i) {
1807 TransformActionReverseMap::iterator ti = 1816 TransformActionReverseMap::iterator ti =
1808 m_transformActionsReverse.find(transforms[i]); 1817 m_transformActionsReverse.find(transforms[i]);
1809 if (ti == m_transformActionsReverse.end()) { 1818 if (ti == m_transformActionsReverse.end()) {
1810 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: " 1819 cerr << "WARNING: MainWindow::setupRecentTransformsMenu: "
1811 << "Unknown transform \"" << transforms[i].toStdString() 1820 << "Unknown transform \"" << transforms[i]
1812 << "\" in recent transforms list" << std::endl; 1821 << "\" in recent transforms list" << endl;
1813 continue; 1822 continue;
1814 } 1823 }
1815 if (i == 0) { 1824 if (i == 0) {
1816 ti->second->setShortcut(tr("Ctrl+T")); 1825 ti->second->setShortcut(tr("Ctrl+T"));
1817 m_keyReference->registerShortcut 1826 m_keyReference->registerShortcut
1846 1855
1847 LayerFactory *factory = LayerFactory::getInstance(); 1856 LayerFactory *factory = LayerFactory::getInstance();
1848 1857
1849 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) { 1858 for (int i = 0; i < m_paneStack->getPaneCount(); ++i) {
1850 1859
1851 Pane *pane = m_paneStack->getPane(i); 1860 Pane *pane = m_paneStack->getPane(i);
1852 if (!pane) continue; 1861 if (!pane) continue;
1853 1862
1854 for (int j = 0; j < pane->getLayerCount(); ++j) { 1863 for (int j = 0; j < pane->getLayerCount(); ++j) {
1855 1864
1856 Layer *layer = pane->getLayer(j); 1865 Layer *layer = pane->getLayer(j);
1857 if (!layer) continue; 1866 if (!layer) continue;
1858 if (observedLayers.find(layer) != observedLayers.end()) { 1867 if (observedLayers.find(layer) != observedLayers.end()) {
1859 // std::cerr << "found duplicate layer " << layer << std::endl; 1868 // cerr << "found duplicate layer " << layer << endl;
1860 continue; 1869 continue;
1861 } 1870 }
1862 1871
1863 // std::cerr << "found new layer " << layer << " (name = " 1872 // cerr << "found new layer " << layer << " (name = "
1864 // << layer->getLayerPresentationName() << ")" << std::endl; 1873 // << layer->getLayerPresentationName() << ")" << endl;
1865 1874
1866 orderedLayers.push_back(layer); 1875 orderedLayers.push_back(layer);
1867 observedLayers.insert(layer); 1876 observedLayers.insert(layer);
1868 1877
1869 if (factory->isLayerSliceable(layer)) { 1878 if (factory->isLayerSliceable(layer)) {
1870 sliceableLayers.insert(layer); 1879 sliceableLayers.insert(layer);
1871 } 1880 }
1872 } 1881 }
1873 } 1882 }
1874 1883
1875 map<QString, int> observedNames; 1884 map<QString, int> observedNames;
1876 1885
1877 for (size_t i = 0; i < orderedLayers.size(); ++i) { 1886 for (size_t i = 0; i < orderedLayers.size(); ++i) {
2436 (this, tr("Select audio file to export"), 2445 (this, tr("Select audio file to export"),
2437 tr("Which audio file do you want to export from?"), 2446 tr("Which audio file do you want to export from?"),
2438 items, c, false, &ok); 2447 items, c, false, &ok);
2439 if (!ok || item.isEmpty()) return; 2448 if (!ok || item.isEmpty()) return;
2440 if (m.find(item) == m.end()) { 2449 if (m.find(item) == m.end()) {
2441 cerr << "WARNING: Model " << item.toStdString() 2450 cerr << "WARNING: Model " << item
2442 << " not found in list!" << endl; 2451 << " not found in list!" << endl;
2443 } else { 2452 } else {
2444 model = m[item]; 2453 model = m[item];
2445 } 2454 }
2446 } 2455 }
2584 MainWindow::importLayer() 2593 MainWindow::importLayer()
2585 { 2594 {
2586 Pane *pane = m_paneStack->getCurrentPane(); 2595 Pane *pane = m_paneStack->getCurrentPane();
2587 2596
2588 if (!pane) { 2597 if (!pane) {
2589 // shouldn't happen, as the menu action should have been disabled 2598 // shouldn't happen, as the menu action should have been disabled
2590 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl; 2599 cerr << "WARNING: MainWindow::importLayer: no current pane" << endl;
2591 return; 2600 return;
2592 } 2601 }
2593 2602
2594 if (!getMainModel()) { 2603 if (!getMainModel()) {
2595 // shouldn't happen, as the menu action should have been disabled 2604 // shouldn't happen, as the menu action should have been disabled
2596 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl; 2605 cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << endl;
2597 return; 2606 return;
2598 } 2607 }
2599 2608
2600 QString path = getOpenFileName(FileFinder::LayerFile); 2609 QString path = getOpenFileName(FileFinder::LayerFile);
2601 2610
2602 if (path != "") { 2611 if (path != "") {
2977 { 2986 {
2978 QObject *obj = sender(); 2987 QObject *obj = sender();
2979 QAction *action = dynamic_cast<QAction *>(obj); 2988 QAction *action = dynamic_cast<QAction *>(obj);
2980 2989
2981 if (!action) { 2990 if (!action) {
2982 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action" 2991 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
2983 << std::endl; 2992 << endl;
2984 return; 2993 return;
2985 } 2994 }
2986 2995
2987 QString path = action->text(); 2996 QString path = action->text();
2988 if (path == "") return; 2997 if (path == "") return;
2989 2998
3005 { 3014 {
3006 QObject *s = sender(); 3015 QObject *s = sender();
3007 QAction *action = qobject_cast<QAction *>(s); 3016 QAction *action = qobject_cast<QAction *>(s);
3008 3017
3009 if (!action) { 3018 if (!action) {
3010 std::cerr << "WARNING: MainWindow::applyTemplate: sender is not an action" 3019 cerr << "WARNING: MainWindow::applyTemplate: sender is not an action"
3011 << std::endl; 3020 << endl;
3012 return; 3021 return;
3013 } 3022 }
3014 3023
3015 QString n = action->objectName(); 3024 QString n = action->objectName();
3016 if (n == "") n = action->text(); 3025 if (n == "") n = action->text();
3017 3026
3018 if (n == "") { 3027 if (n == "") {
3019 std::cerr << "WARNING: MainWindow::applyTemplate: sender has no name" 3028 cerr << "WARNING: MainWindow::applyTemplate: sender has no name"
3020 << std::endl; 3029 << endl;
3021 return; 3030 return;
3022 } 3031 }
3023 3032
3024 QString mainModelLocation; 3033 QString mainModelLocation;
3025 WaveFileModel *mm = getMainModel(); 3034 WaveFileModel *mm = getMainModel();
3156 } 3165 }
3157 3166
3158 void 3167 void
3159 MainWindow::closeEvent(QCloseEvent *e) 3168 MainWindow::closeEvent(QCloseEvent *e)
3160 { 3169 {
3161 // std::cerr << "MainWindow::closeEvent" << std::endl; 3170 // cerr << "MainWindow::closeEvent" << endl;
3162 3171
3163 if (m_openingAudioFile) { 3172 if (m_openingAudioFile) {
3164 // std::cerr << "Busy - ignoring close event" << std::endl; 3173 // cerr << "Busy - ignoring close event" << endl;
3165 e->ignore(); 3174 e->ignore();
3166 return; 3175 return;
3167 } 3176 }
3168 3177
3169 if (!m_abandoning && !checkSaveModified()) { 3178 if (!m_abandoning && !checkSaveModified()) {
3170 // std::cerr << "Close refused by user - ignoring close event" << endl; 3179 // cerr << "Close refused by user - ignoring close event" << endl;
3171 e->ignore(); 3180 e->ignore();
3172 return; 3181 return;
3173 } 3182 }
3174 3183
3175 QSettings settings; 3184 QSettings settings;
3176 settings.beginGroup("MainWindow"); 3185 settings.beginGroup("MainWindow");
3177 settings.setValue("maximised", isMaximized()); 3186 settings.setValue("maximised", isMaximized());
3393 { 3402 {
3394 QObject *s = sender(); 3403 QObject *s = sender();
3395 QAction *action = dynamic_cast<QAction *>(s); 3404 QAction *action = dynamic_cast<QAction *>(s);
3396 3405
3397 if (!action) { 3406 if (!action) {
3398 std::cerr << "WARNING: MainWindow::addPane: sender is not an action" 3407 cerr << "WARNING: MainWindow::addPane: sender is not an action"
3399 << std::endl; 3408 << endl;
3400 return; 3409 return;
3401 } 3410 }
3402 3411
3403 PaneActionMap::iterator i = m_paneActions.find(action); 3412 PaneActionMap::iterator i = m_paneActions.find(action);
3404 3413
3405 if (i == m_paneActions.end()) { 3414 if (i == m_paneActions.end()) {
3406 std::cerr << "WARNING: MainWindow::addPane: unknown action " 3415 cerr << "WARNING: MainWindow::addPane: unknown action "
3407 << action->objectName() << std::endl; 3416 << action->objectName() << endl;
3408 return; 3417 return;
3409 } 3418 }
3410 3419
3411 addPane(i->second, action->text()); 3420 addPane(i->second, action->text());
3412 } 3421 }
3413 3422
3428 } 3437 }
3429 3438
3430 if (configuration.layer != LayerFactory::TimeRuler && 3439 if (configuration.layer != LayerFactory::TimeRuler &&
3431 configuration.layer != LayerFactory::Spectrum) { 3440 configuration.layer != LayerFactory::Spectrum) {
3432 3441
3433 if (!m_timeRulerLayer) { 3442 if (!m_timeRulerLayer) {
3434 // std::cerr << "no time ruler layer, creating one" << std::endl; 3443 // cerr << "no time ruler layer, creating one" << endl;
3435 m_timeRulerLayer = m_document->createMainModelLayer 3444 m_timeRulerLayer = m_document->createMainModelLayer
3436 (LayerFactory::TimeRuler); 3445 (LayerFactory::TimeRuler);
3437 } 3446 }
3438 3447
3439 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl; 3448 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl;
3440 3449
3441 m_document->addLayerToView(pane, m_timeRulerLayer); 3450 m_document->addLayerToView(pane, m_timeRulerLayer);
3442 } 3451 }
3443 3452
3444 Layer *newLayer = m_document->createLayer(configuration.layer); 3453 Layer *newLayer = m_document->createLayer(configuration.layer);
3445 3454
3446 Model *suggestedModel = configuration.sourceModel; 3455 Model *suggestedModel = configuration.sourceModel;
3456 break; 3465 break;
3457 } 3466 }
3458 } 3467 }
3459 3468
3460 if (!model) { 3469 if (!model) {
3461 std::cerr << "WARNING: Model " << (void *)suggestedModel 3470 cerr << "WARNING: Model " << (void *)suggestedModel
3462 << " appears in pane action map, but is not reported " 3471 << " appears in pane action map, but is not reported "
3463 << "by document as a valid transform source" << std::endl; 3472 << "by document as a valid transform source" << endl;
3464 } 3473 }
3465 } 3474 }
3466 3475
3467 if (!model) { 3476 if (!model) {
3468 model = m_document->getMainModel(); 3477 model = m_document->getMainModel();
3490 { 3499 {
3491 QObject *s = sender(); 3500 QObject *s = sender();
3492 QAction *action = dynamic_cast<QAction *>(s); 3501 QAction *action = dynamic_cast<QAction *>(s);
3493 3502
3494 if (!action) { 3503 if (!action) {
3495 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action" 3504 cerr << "WARNING: MainWindow::addLayer: sender is not an action"
3496 << std::endl; 3505 << endl;
3497 return; 3506 return;
3498 } 3507 }
3499 3508
3500 Pane *pane = m_paneStack->getCurrentPane(); 3509 Pane *pane = m_paneStack->getCurrentPane();
3501 3510
3502 if (!pane) { 3511 if (!pane) {
3503 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl; 3512 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
3504 return; 3513 return;
3505 } 3514 }
3506 3515
3507 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action); 3516 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
3508 3517
3509 if (ei != m_existingLayerActions.end()) { 3518 if (ei != m_existingLayerActions.end()) {
3536 3545
3537 TransformActionMap::iterator i = m_transformActions.find(action); 3546 TransformActionMap::iterator i = m_transformActions.find(action);
3538 3547
3539 if (i == m_transformActions.end()) { 3548 if (i == m_transformActions.end()) {
3540 3549
3541 LayerActionMap::iterator i = m_layerActions.find(action); 3550 LayerActionMap::iterator i = m_layerActions.find(action);
3542 3551
3543 if (i == m_layerActions.end()) { 3552 if (i == m_layerActions.end()) {
3544 std::cerr << "WARNING: MainWindow::addLayer: unknown action " 3553 cerr << "WARNING: MainWindow::addLayer: unknown action "
3545 << action->objectName() << std::endl; 3554 << action->objectName() << endl;
3546 return; 3555 return;
3547 } 3556 }
3548 3557
3549 LayerFactory::LayerType type = i->second.layer; 3558 LayerFactory::LayerType type = i->second.layer;
3550 3559
3551 LayerFactory::LayerTypeSet emptyTypes = 3560 LayerFactory::LayerTypeSet emptyTypes =
3552 LayerFactory::getInstance()->getValidEmptyLayerTypes(); 3561 LayerFactory::getInstance()->getValidEmptyLayerTypes();
3553 3562
3554 Layer *newLayer = 0; 3563 Layer *newLayer = 0;
3555 3564
3556 if (emptyTypes.find(type) != emptyTypes.end()) { 3565 if (emptyTypes.find(type) != emptyTypes.end()) {
3557 3566
3558 newLayer = m_document->createEmptyLayer(type); 3567 newLayer = m_document->createEmptyLayer(type);
3568
3559 if (newLayer) { 3569 if (newLayer) {
3560 m_toolActions[ViewManager::DrawMode]->trigger(); 3570 m_toolActions[ViewManager::DrawMode]->trigger();
3561 } 3571 }
3562 3572
3563 } else { 3573 } else {
3564 3574
3565 Model *model = i->second.sourceModel; 3575 Model *model = i->second.sourceModel;
3566 3576
3567 cerr << "model = "<< model << endl; 3577 cerr << "model = "<< model << endl;
3568 3578
3588 newLayer = m_document->createLayer(type); 3598 newLayer = m_document->createLayer(type);
3589 if (m_document->isKnownModel(model)) { 3599 if (m_document->isKnownModel(model)) {
3590 m_document->setChannel(newLayer, i->second.channel); 3600 m_document->setChannel(newLayer, i->second.channel);
3591 m_document->setModel(newLayer, model); 3601 m_document->setModel(newLayer, model);
3592 } else { 3602 } else {
3593 std::cerr << "WARNING: MainWindow::addLayer: unknown model " 3603 cerr << "WARNING: MainWindow::addLayer: unknown model "
3594 << model 3604 << model
3595 << " (\"" 3605 << " (\""
3596 << (model ? model->objectName().toStdString() : "") 3606 << (model ? model->objectName() : "")
3597 << "\") in layer action map" 3607 << "\") in layer action map"
3598 << std::endl; 3608 << endl;
3599 } 3609 }
3600 } 3610 }
3601 } 3611 }
3602 3612
3603 if (newLayer) { 3613 if (newLayer) {
3634 void 3644 void
3635 MainWindow:: addLayer(QString transformId) 3645 MainWindow:: addLayer(QString transformId)
3636 { 3646 {
3637 Pane *pane = m_paneStack->getCurrentPane(); 3647 Pane *pane = m_paneStack->getCurrentPane();
3638 if (!pane) { 3648 if (!pane) {
3639 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl; 3649 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
3640 return; 3650 return;
3641 } 3651 }
3642 3652
3643 Transform transform = TransformFactory::getInstance()-> 3653 Transform transform = TransformFactory::getInstance()->
3644 getDefaultTransformFor(transformId); 3654 getDefaultTransformFor(transformId);
3645 3655
3790 PlaySpeedRangeMapper mapper(0, 200); 3800 PlaySpeedRangeMapper mapper(0, 200);
3791 3801
3792 float percent = m_playSpeed->mappedValue(); 3802 float percent = m_playSpeed->mappedValue();
3793 float factor = mapper.getFactorForValue(percent); 3803 float factor = mapper.getFactorForValue(percent);
3794 3804
3795 // std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl; 3805 // cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
3796 3806
3797 bool something = (position != 100); 3807 bool something = (position != 100);
3798 3808
3799 int pc = lrintf(percent); 3809 int pc = lrintf(percent);
3800 3810
4472 QSettings settings; 4482 QSettings settings;
4473 settings.beginGroup("NewerVersionWarning"); 4483 settings.beginGroup("NewerVersionWarning");
4474 QString tag = QString("version-%1-available-show").arg(version); 4484 QString tag = QString("version-%1-available-show").arg(version);
4475 if (settings.value(tag, true).toBool()) { 4485 if (settings.value(tag, true).toBool()) {
4476 QString title(tr("Newer version available")); 4486 QString title(tr("Newer version available"));
4477 QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Sonic Visualiser, but version %3 is now available.</p><p>Please see the <a href=\"http://sonicvisualiser.org/\">Sonic Visualiser website</a> for more information.</p>").arg(SV_VERSION).arg(version)); 4487 QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Sonic Visualiser, but version %2 is now available.</p><p>Please see the <a href=\"http://sonicvisualiser.org/\">Sonic Visualiser website</a> for more information.</p>").arg(SV_VERSION).arg(version));
4478 QMessageBox::information(this, title, text); 4488 QMessageBox::information(this, title, text);
4479 settings.setValue(tag, false); 4489 settings.setValue(tag, false);
4480 } 4490 }
4481 settings.endGroup(); 4491 settings.endGroup();
4482 } 4492 }