comparison main/MainWindow.cpp @ 665:17fe7e0c23a1

Drop std:: from cerr, cout, endl; drop toStdString etc; build fix
author Chris Cannam
date Tue, 26 Nov 2013 14:17:48 +0000
parents 55efa5a18814
children 17fbb120222b bfd68cc71a25
comparison
equal deleted inserted replaced
664:b4a7c98e4c83 665:17fe7e0c23a1
120 120
121 #include <iostream> 121 #include <iostream>
122 #include <cstdio> 122 #include <cstdio>
123 #include <errno.h> 123 #include <errno.h>
124 124
125 using std::cerr;
126 using std::endl;
127
128 using std::vector; 125 using std::vector;
129 using std::map; 126 using std::map;
130 using std::set; 127 using std::set;
131 128
132 129
300 newSession(); 297 newSession();
301 298
302 connect(m_midiInput, SIGNAL(eventsAvailable()), 299 connect(m_midiInput, SIGNAL(eventsAvailable()),
303 this, SLOT(midiEventsAvailable())); 300 this, SLOT(midiEventsAvailable()));
304 301
305 NetworkPermissionTester tester(this); 302 NetworkPermissionTester tester;
306 bool networkPermission = tester.havePermission(); 303 bool networkPermission = tester.havePermission();
307 if (networkPermission) { 304 if (networkPermission) {
308 TransformFactory::getInstance()->startPopulationThread(); 305 TransformFactory::getInstance()->startPopulationThread();
309 m_surveyer = new Surveyer 306 m_surveyer = new Surveyer
310 ("sonicvisualiser.org", "survey23-present.txt", "survey23.php"); 307 ("sonicvisualiser.org", "survey23-present.txt", "survey23.php");
1566 for (unsigned int i = 0; i < transforms.size(); ++i) { 1563 for (unsigned int i = 0; i < transforms.size(); ++i) {
1567 1564
1568 QString name = transforms[i].name; 1565 QString name = transforms[i].name;
1569 if (name == "") name = transforms[i].identifier; 1566 if (name == "") name = transforms[i].identifier;
1570 1567
1571 // std::cerr << "Plugin Name: " << name << std::endl; 1568 // cerr << "Plugin Name: " << name << endl;
1572 1569
1573 TransformDescription::Type type = transforms[i].type; 1570 TransformDescription::Type type = transforms[i].type;
1574 QString typeStr = factory->getTransformTypeName(type); 1571 QString typeStr = factory->getTransformTypeName(type);
1575 1572
1576 QString category = transforms[i].category; 1573 QString category = transforms[i].category;
1600 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); 1597 connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
1601 1598
1602 action->setStatusTip(transforms[i].longDescription); 1599 action->setStatusTip(transforms[i].longDescription);
1603 1600
1604 if (categoryMenus[type].find(category) == categoryMenus[type].end()) { 1601 if (categoryMenus[type].find(category) == categoryMenus[type].end()) {
1605 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " 1602 cerr << "WARNING: MainWindow::setupMenus: Internal error: "
1606 << "No category menu for transform \"" 1603 << "No category menu for transform \""
1607 << name << "\" (category = \"" 1604 << name << "\" (category = \""
1608 << category << "\")" << std::endl; 1605 << category << "\")" << endl;
1609 } else { 1606 } else {
1610 categoryMenus[type][category]->addAction(action); 1607 categoryMenus[type][category]->addAction(action);
1611 } 1608 }
1612 1609
1613 if (makerMenus[type].find(maker) == makerMenus[type].end()) { 1610 if (makerMenus[type].find(maker) == makerMenus[type].end()) {
1614 std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " 1611 cerr << "WARNING: MainWindow::setupMenus: Internal error: "
1615 << "No maker menu for transform \"" 1612 << "No maker menu for transform \""
1616 << name << "\" (maker = \"" 1613 << name << "\" (maker = \""
1617 << maker << "\")" << std::endl; 1614 << maker << "\")" << endl;
1618 } else { 1615 } else {
1619 makerMenus[type][maker]->addAction(action); 1616 makerMenus[type][maker]->addAction(action);
1620 } 1617 }
1621 1618
1622 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this); 1619 action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this);
1785 vector<QString> transforms = m_recentTransforms.getRecent(); 1782 vector<QString> transforms = m_recentTransforms.getRecent();
1786 for (size_t i = 0; i < transforms.size(); ++i) { 1783 for (size_t i = 0; i < transforms.size(); ++i) {
1787 TransformActionReverseMap::iterator ti = 1784 TransformActionReverseMap::iterator ti =
1788 m_transformActionsReverse.find(transforms[i]); 1785 m_transformActionsReverse.find(transforms[i]);
1789 if (ti == m_transformActionsReverse.end()) { 1786 if (ti == m_transformActionsReverse.end()) {
1790 std::cerr << "WARNING: MainWindow::setupRecentTransformsMenu: " 1787 cerr << "WARNING: MainWindow::setupRecentTransformsMenu: "
1791 << "Unknown transform \"" << transforms[i].toStdString() 1788 << "Unknown transform \"" << transforms[i]
1792 << "\" in recent transforms list" << std::endl; 1789 << "\" in recent transforms list" << endl;
1793 continue; 1790 continue;
1794 } 1791 }
1795 if (i == 0) { 1792 if (i == 0) {
1796 ti->second->setShortcut(tr("Ctrl+T")); 1793 ti->second->setShortcut(tr("Ctrl+T"));
1797 m_keyReference->registerShortcut 1794 m_keyReference->registerShortcut
1834 for (int j = 0; j < pane->getLayerCount(); ++j) { 1831 for (int j = 0; j < pane->getLayerCount(); ++j) {
1835 1832
1836 Layer *layer = pane->getLayer(j); 1833 Layer *layer = pane->getLayer(j);
1837 if (!layer) continue; 1834 if (!layer) continue;
1838 if (observedLayers.find(layer) != observedLayers.end()) { 1835 if (observedLayers.find(layer) != observedLayers.end()) {
1839 // std::cerr << "found duplicate layer " << layer << std::endl; 1836 // cerr << "found duplicate layer " << layer << endl;
1840 continue; 1837 continue;
1841 } 1838 }
1842 1839
1843 // std::cerr << "found new layer " << layer << " (name = " 1840 // cerr << "found new layer " << layer << " (name = "
1844 // << layer->getLayerPresentationName() << ")" << std::endl; 1841 // << layer->getLayerPresentationName() << ")" << endl;
1845 1842
1846 orderedLayers.push_back(layer); 1843 orderedLayers.push_back(layer);
1847 observedLayers.insert(layer); 1844 observedLayers.insert(layer);
1848 1845
1849 if (factory->isLayerSliceable(layer)) { 1846 if (factory->isLayerSliceable(layer)) {
2414 (this, tr("Select audio file to export"), 2411 (this, tr("Select audio file to export"),
2415 tr("Which audio file do you want to export from?"), 2412 tr("Which audio file do you want to export from?"),
2416 items, c, false, &ok); 2413 items, c, false, &ok);
2417 if (!ok || item.isEmpty()) return; 2414 if (!ok || item.isEmpty()) return;
2418 if (m.find(item) == m.end()) { 2415 if (m.find(item) == m.end()) {
2419 cerr << "WARNING: Model " << item.toStdString() 2416 cerr << "WARNING: Model " << item
2420 << " not found in list!" << endl; 2417 << " not found in list!" << endl;
2421 } else { 2418 } else {
2422 model = m[item]; 2419 model = m[item];
2423 } 2420 }
2424 } 2421 }
2561 { 2558 {
2562 Pane *pane = m_paneStack->getCurrentPane(); 2559 Pane *pane = m_paneStack->getCurrentPane();
2563 2560
2564 if (!pane) { 2561 if (!pane) {
2565 // shouldn't happen, as the menu action should have been disabled 2562 // shouldn't happen, as the menu action should have been disabled
2566 std::cerr << "WARNING: MainWindow::importLayer: no current pane" << std::endl; 2563 cerr << "WARNING: MainWindow::importLayer: no current pane" << endl;
2567 return; 2564 return;
2568 } 2565 }
2569 2566
2570 if (!getMainModel()) { 2567 if (!getMainModel()) {
2571 // shouldn't happen, as the menu action should have been disabled 2568 // shouldn't happen, as the menu action should have been disabled
2572 std::cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << std::endl; 2569 cerr << "WARNING: MainWindow::importLayer: No main model -- hence no default sample rate available" << endl;
2573 return; 2570 return;
2574 } 2571 }
2575 2572
2576 QString path = getOpenFileName(FileFinder::LayerFile); 2573 QString path = getOpenFileName(FileFinder::LayerFile);
2577 2574
2948 { 2945 {
2949 QObject *obj = sender(); 2946 QObject *obj = sender();
2950 QAction *action = dynamic_cast<QAction *>(obj); 2947 QAction *action = dynamic_cast<QAction *>(obj);
2951 2948
2952 if (!action) { 2949 if (!action) {
2953 std::cerr << "WARNING: MainWindow::openRecentFile: sender is not an action" 2950 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action"
2954 << std::endl; 2951 << endl;
2955 return; 2952 return;
2956 } 2953 }
2957 2954
2958 QString path = action->text(); 2955 QString path = action->text();
2959 if (path == "") return; 2956 if (path == "") return;
2976 { 2973 {
2977 QObject *s = sender(); 2974 QObject *s = sender();
2978 QAction *action = qobject_cast<QAction *>(s); 2975 QAction *action = qobject_cast<QAction *>(s);
2979 2976
2980 if (!action) { 2977 if (!action) {
2981 std::cerr << "WARNING: MainWindow::applyTemplate: sender is not an action" 2978 cerr << "WARNING: MainWindow::applyTemplate: sender is not an action"
2982 << std::endl; 2979 << endl;
2983 return; 2980 return;
2984 } 2981 }
2985 2982
2986 QString n = action->objectName(); 2983 QString n = action->objectName();
2987 if (n == "") n = action->text(); 2984 if (n == "") n = action->text();
2988 2985
2989 if (n == "") { 2986 if (n == "") {
2990 std::cerr << "WARNING: MainWindow::applyTemplate: sender has no name" 2987 cerr << "WARNING: MainWindow::applyTemplate: sender has no name"
2991 << std::endl; 2988 << endl;
2992 return; 2989 return;
2993 } 2990 }
2994 2991
2995 QString mainModelLocation; 2992 QString mainModelLocation;
2996 WaveFileModel *mm = getMainModel(); 2993 WaveFileModel *mm = getMainModel();
3127 } 3124 }
3128 3125
3129 void 3126 void
3130 MainWindow::closeEvent(QCloseEvent *e) 3127 MainWindow::closeEvent(QCloseEvent *e)
3131 { 3128 {
3132 // std::cerr << "MainWindow::closeEvent" << std::endl; 3129 // cerr << "MainWindow::closeEvent" << endl;
3133 3130
3134 if (m_openingAudioFile) { 3131 if (m_openingAudioFile) {
3135 // std::cerr << "Busy - ignoring close event" << std::endl; 3132 // cerr << "Busy - ignoring close event" << endl;
3136 e->ignore(); 3133 e->ignore();
3137 return; 3134 return;
3138 } 3135 }
3139 3136
3140 if (!m_abandoning && !checkSaveModified()) { 3137 if (!m_abandoning && !checkSaveModified()) {
3141 // std::cerr << "Close refused by user - ignoring close event" << endl; 3138 // cerr << "Close refused by user - ignoring close event" << endl;
3142 e->ignore(); 3139 e->ignore();
3143 return; 3140 return;
3144 } 3141 }
3145 3142
3146 QSettings settings; 3143 QSettings settings;
3364 { 3361 {
3365 QObject *s = sender(); 3362 QObject *s = sender();
3366 QAction *action = dynamic_cast<QAction *>(s); 3363 QAction *action = dynamic_cast<QAction *>(s);
3367 3364
3368 if (!action) { 3365 if (!action) {
3369 std::cerr << "WARNING: MainWindow::addPane: sender is not an action" 3366 cerr << "WARNING: MainWindow::addPane: sender is not an action"
3370 << std::endl; 3367 << endl;
3371 return; 3368 return;
3372 } 3369 }
3373 3370
3374 PaneActionMap::iterator i = m_paneActions.find(action); 3371 PaneActionMap::iterator i = m_paneActions.find(action);
3375 3372
3376 if (i == m_paneActions.end()) { 3373 if (i == m_paneActions.end()) {
3377 std::cerr << "WARNING: MainWindow::addPane: unknown action " 3374 cerr << "WARNING: MainWindow::addPane: unknown action "
3378 << action->objectName() << std::endl; 3375 << action->objectName() << endl;
3379 return; 3376 return;
3380 } 3377 }
3381 3378
3382 addPane(i->second, action->text()); 3379 addPane(i->second, action->text());
3383 } 3380 }
3400 3397
3401 if (configuration.layer != LayerFactory::TimeRuler && 3398 if (configuration.layer != LayerFactory::TimeRuler &&
3402 configuration.layer != LayerFactory::Spectrum) { 3399 configuration.layer != LayerFactory::Spectrum) {
3403 3400
3404 if (!m_timeRulerLayer) { 3401 if (!m_timeRulerLayer) {
3405 // std::cerr << "no time ruler layer, creating one" << std::endl; 3402 // cerr << "no time ruler layer, creating one" << endl;
3406 m_timeRulerLayer = m_document->createMainModelLayer 3403 m_timeRulerLayer = m_document->createMainModelLayer
3407 (LayerFactory::TimeRuler); 3404 (LayerFactory::TimeRuler);
3408 } 3405 }
3409 3406
3410 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl; 3407 // SVDEBUG << "adding time ruler layer " << m_timeRulerLayer << endl;
3427 break; 3424 break;
3428 } 3425 }
3429 } 3426 }
3430 3427
3431 if (!model) { 3428 if (!model) {
3432 std::cerr << "WARNING: Model " << (void *)suggestedModel 3429 cerr << "WARNING: Model " << (void *)suggestedModel
3433 << " appears in pane action map, but is not reported " 3430 << " appears in pane action map, but is not reported "
3434 << "by document as a valid transform source" << std::endl; 3431 << "by document as a valid transform source" << endl;
3435 } 3432 }
3436 } 3433 }
3437 3434
3438 if (!model) { 3435 if (!model) {
3439 model = m_document->getMainModel(); 3436 model = m_document->getMainModel();
3461 { 3458 {
3462 QObject *s = sender(); 3459 QObject *s = sender();
3463 QAction *action = dynamic_cast<QAction *>(s); 3460 QAction *action = dynamic_cast<QAction *>(s);
3464 3461
3465 if (!action) { 3462 if (!action) {
3466 std::cerr << "WARNING: MainWindow::addLayer: sender is not an action" 3463 cerr << "WARNING: MainWindow::addLayer: sender is not an action"
3467 << std::endl; 3464 << endl;
3468 return; 3465 return;
3469 } 3466 }
3470 3467
3471 Pane *pane = m_paneStack->getCurrentPane(); 3468 Pane *pane = m_paneStack->getCurrentPane();
3472 3469
3473 if (!pane) { 3470 if (!pane) {
3474 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl; 3471 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
3475 return; 3472 return;
3476 } 3473 }
3477 3474
3478 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action); 3475 ExistingLayerActionMap::iterator ei = m_existingLayerActions.find(action);
3479 3476
3509 if (i == m_transformActions.end()) { 3506 if (i == m_transformActions.end()) {
3510 3507
3511 LayerActionMap::iterator i = m_layerActions.find(action); 3508 LayerActionMap::iterator i = m_layerActions.find(action);
3512 3509
3513 if (i == m_layerActions.end()) { 3510 if (i == m_layerActions.end()) {
3514 std::cerr << "WARNING: MainWindow::addLayer: unknown action " 3511 cerr << "WARNING: MainWindow::addLayer: unknown action "
3515 << action->objectName() << std::endl; 3512 << action->objectName() << endl;
3516 return; 3513 return;
3517 } 3514 }
3518 3515
3519 LayerFactory::LayerType type = i->second.layer; 3516 LayerFactory::LayerType type = i->second.layer;
3520 3517
3558 newLayer = m_document->createLayer(type); 3555 newLayer = m_document->createLayer(type);
3559 if (m_document->isKnownModel(model)) { 3556 if (m_document->isKnownModel(model)) {
3560 m_document->setChannel(newLayer, i->second.channel); 3557 m_document->setChannel(newLayer, i->second.channel);
3561 m_document->setModel(newLayer, model); 3558 m_document->setModel(newLayer, model);
3562 } else { 3559 } else {
3563 std::cerr << "WARNING: MainWindow::addLayer: unknown model " 3560 cerr << "WARNING: MainWindow::addLayer: unknown model "
3564 << model 3561 << model
3565 << " (\"" 3562 << " (\""
3566 << (model ? model->objectName().toStdString() : "") 3563 << (model ? model->objectName() : "")
3567 << "\") in layer action map" 3564 << "\") in layer action map"
3568 << std::endl; 3565 << endl;
3569 } 3566 }
3570 } 3567 }
3571 } 3568 }
3572 3569
3573 if (newLayer) { 3570 if (newLayer) {
3604 void 3601 void
3605 MainWindow::addLayer(QString transformId) 3602 MainWindow::addLayer(QString transformId)
3606 { 3603 {
3607 Pane *pane = m_paneStack->getCurrentPane(); 3604 Pane *pane = m_paneStack->getCurrentPane();
3608 if (!pane) { 3605 if (!pane) {
3609 std::cerr << "WARNING: MainWindow::addLayer: no current pane" << std::endl; 3606 cerr << "WARNING: MainWindow::addLayer: no current pane" << endl;
3610 return; 3607 return;
3611 } 3608 }
3612 3609
3613 Transform transform = TransformFactory::getInstance()-> 3610 Transform transform = TransformFactory::getInstance()->
3614 getDefaultTransformFor(transformId); 3611 getDefaultTransformFor(transformId);
3760 PlaySpeedRangeMapper mapper(0, 200); 3757 PlaySpeedRangeMapper mapper(0, 200);
3761 3758
3762 float percent = m_playSpeed->mappedValue(); 3759 float percent = m_playSpeed->mappedValue();
3763 float factor = mapper.getFactorForValue(percent); 3760 float factor = mapper.getFactorForValue(percent);
3764 3761
3765 // std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl; 3762 // cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
3766 3763
3767 bool something = (position != 100); 3764 bool something = (position != 100);
3768 3765
3769 int pc = lrintf(percent); 3766 int pc = lrintf(percent);
3770 3767