comparison main/MainWindow.cpp @ 903:6d3220e7ecef cxx11

Merge from default branch
author Chris Cannam
date Mon, 09 Feb 2015 10:31:07 +0000
parents 35ce47084c84
children c08df7de50f6
comparison
equal deleted inserted replaced
884:93a770ecfc98 903:6d3220e7ecef
22 #include "view/PaneStack.h" 22 #include "view/PaneStack.h"
23 #include "data/model/WaveFileModel.h" 23 #include "data/model/WaveFileModel.h"
24 #include "data/model/SparseOneDimensionalModel.h" 24 #include "data/model/SparseOneDimensionalModel.h"
25 #include "data/model/RangeSummarisableTimeValueModel.h" 25 #include "data/model/RangeSummarisableTimeValueModel.h"
26 #include "data/model/NoteModel.h" 26 #include "data/model/NoteModel.h"
27 #include "data/model/AggregateWaveModel.h"
27 #include "data/model/Labeller.h" 28 #include "data/model/Labeller.h"
28 #include "data/osc/OSCQueue.h" 29 #include "data/osc/OSCQueue.h"
29 #include "framework/Document.h" 30 #include "framework/Document.h"
30 #include "framework/TransformUserConfigurator.h" 31 #include "framework/TransformUserConfigurator.h"
31 #include "view/ViewManager.h" 32 #include "view/ViewManager.h"
53 #include "widgets/NotifyingPushButton.h" 54 #include "widgets/NotifyingPushButton.h"
54 #include "widgets/KeyReference.h" 55 #include "widgets/KeyReference.h"
55 #include "widgets/TransformFinder.h" 56 #include "widgets/TransformFinder.h"
56 #include "widgets/LabelCounterInputDialog.h" 57 #include "widgets/LabelCounterInputDialog.h"
57 #include "widgets/ActivityLog.h" 58 #include "widgets/ActivityLog.h"
59 #include "widgets/UnitConverter.h"
58 #include "audioio/AudioCallbackPlaySource.h" 60 #include "audioio/AudioCallbackPlaySource.h"
59 #include "audioio/AudioCallbackPlayTarget.h" 61 #include "audioio/AudioCallbackPlayTarget.h"
60 #include "audioio/AudioTargetFactory.h" 62 #include "audioio/AudioTargetFactory.h"
61 #include "audioio/PlaySpeedRangeMapper.h" 63 #include "audioio/PlaySpeedRangeMapper.h"
62 #include "data/fileio/DataFileReaderFactory.h" 64 #include "data/fileio/DataFileReaderFactory.h"
159 m_playControlsSpacer(0), 161 m_playControlsSpacer(0),
160 m_playControlsWidth(0), 162 m_playControlsWidth(0),
161 m_preferencesDialog(0), 163 m_preferencesDialog(0),
162 m_layerTreeDialog(0), 164 m_layerTreeDialog(0),
163 m_activityLog(new ActivityLog()), 165 m_activityLog(new ActivityLog()),
166 m_unitConverter(new UnitConverter()),
164 m_keyReference(new KeyReference()), 167 m_keyReference(new KeyReference()),
165 m_templateWatcher(0) 168 m_templateWatcher(0)
166 { 169 {
167 Profiler profiler("MainWindow::MainWindow"); 170 Profiler profiler("MainWindow::MainWindow");
168 171
294 connect(this, SIGNAL(activity(QString)), 297 connect(this, SIGNAL(activity(QString)),
295 m_activityLog, SLOT(activityHappened(QString))); 298 m_activityLog, SLOT(activityHappened(QString)));
296 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced())); 299 connect(this, SIGNAL(replacedDocument()), this, SLOT(documentReplaced()));
297 m_activityLog->hide(); 300 m_activityLog->hide();
298 301
302 m_unitConverter->hide();
303
299 newSession(); 304 newSession();
300 305
301 connect(m_midiInput, SIGNAL(eventsAvailable()), 306 connect(m_midiInput, SIGNAL(eventsAvailable()),
302 this, SLOT(midiEventsAvailable())); 307 this, SLOT(midiEventsAvailable()));
303 308
323 MainWindow::~MainWindow() 328 MainWindow::~MainWindow()
324 { 329 {
325 // SVDEBUG << "MainWindow::~MainWindow" << endl; 330 // SVDEBUG << "MainWindow::~MainWindow" << endl;
326 delete m_keyReference; 331 delete m_keyReference;
327 delete m_activityLog; 332 delete m_activityLog;
333 delete m_unitConverter;
328 delete m_preferencesDialog; 334 delete m_preferencesDialog;
329 delete m_layerTreeDialog; 335 delete m_layerTreeDialog;
330 delete m_versionTester; 336 delete m_versionTester;
331 delete m_surveyer; 337 delete m_surveyer;
332 Profiles::getInstance()->dump(); 338 Profiles::getInstance()->dump();
1021 menu->addAction(action); 1027 menu->addAction(action);
1022 1028
1023 action = new QAction(tr("Show Acti&vity Log"), this); 1029 action = new QAction(tr("Show Acti&vity Log"), this);
1024 action->setStatusTip(tr("Open a window listing interactions and other events")); 1030 action->setStatusTip(tr("Open a window listing interactions and other events"));
1025 connect(action, SIGNAL(triggered()), this, SLOT(showActivityLog())); 1031 connect(action, SIGNAL(triggered()), this, SLOT(showActivityLog()));
1032 menu->addAction(action);
1033
1034 action = new QAction(tr("Show &Unit Converter"), this);
1035 action->setStatusTip(tr("Open a window of pitch and timing conversion utilities"));
1036 connect(action, SIGNAL(triggered()), this, SLOT(showUnitConverter()));
1026 menu->addAction(action); 1037 menu->addAction(action);
1027 1038
1028 menu->addSeparator(); 1039 menu->addSeparator();
1029 1040
1030 action = new QAction(tr("Go Full-Screen"), this); 1041 action = new QAction(tr("Go Full-Screen"), this);
2940 2951
2941 delete m_layerTreeDialog.data(); 2952 delete m_layerTreeDialog.data();
2942 delete m_preferencesDialog.data(); 2953 delete m_preferencesDialog.data();
2943 2954
2944 m_activityLog->hide(); 2955 m_activityLog->hide();
2956 m_unitConverter->hide();
2945 m_keyReference->hide(); 2957 m_keyReference->hide();
2946 2958
2947 delete m_document; 2959 delete m_document;
2948 m_document = 0; 2960 m_document = 0;
2949 m_viewManager->clearSelections(); 2961 m_viewManager->clearSelections();
3386 3398
3387 if (!saveSessionFile(path)) { 3399 if (!saveSessionFile(path)) {
3388 QMessageBox::critical(this, tr("Failed to save file"), 3400 QMessageBox::critical(this, tr("Failed to save file"),
3389 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path)); 3401 tr("<b>Save failed</b><p>Session file \"%1\" could not be saved.").arg(path));
3390 } else { 3402 } else {
3391 setWindowTitle(tr("%1: %1") 3403 setWindowTitle(tr("%1: %2")
3392 .arg(QApplication::applicationName()) 3404 .arg(QApplication::applicationName())
3393 .arg(QFileInfo(path).fileName())); 3405 .arg(QFileInfo(path).fileName()));
3394 m_sessionFile = path; 3406 m_sessionFile = path;
3395 CommandHistory::getInstance()->documentSaved(); 3407 CommandHistory::getInstance()->documentSaved();
3396 documentRestored(); 3408 documentRestored();
3692 3704
3693 std::vector<Model *> candidateInputModels = 3705 std::vector<Model *> candidateInputModels =
3694 m_document->getTransformInputModels(); 3706 m_document->getTransformInputModels();
3695 3707
3696 Model *defaultInputModel = 0; 3708 Model *defaultInputModel = 0;
3709
3697 for (int j = 0; j < pane->getLayerCount(); ++j) { 3710 for (int j = 0; j < pane->getLayerCount(); ++j) {
3711
3698 Layer *layer = pane->getLayer(j); 3712 Layer *layer = pane->getLayer(j);
3699 if (!layer) continue; 3713 if (!layer) continue;
3714
3700 if (LayerFactory::getInstance()->getLayerType(layer) != 3715 if (LayerFactory::getInstance()->getLayerType(layer) !=
3701 LayerFactory::Waveform && 3716 LayerFactory::Waveform &&
3702 !layer->isLayerOpaque()) continue; 3717 !layer->isLayerOpaque()) continue;
3718
3703 Model *model = layer->getModel(); 3719 Model *model = layer->getModel();
3704 if (!model) continue; 3720 if (!model) continue;
3721
3705 for (size_t k = 0; k < candidateInputModels.size(); ++k) { 3722 for (size_t k = 0; k < candidateInputModels.size(); ++k) {
3706 if (candidateInputModels[k] == model) { 3723 if (candidateInputModels[k] == model) {
3707 defaultInputModel = model; 3724 defaultInputModel = model;
3708 break; 3725 break;
3709 } 3726 }
3710 } 3727 }
3728
3711 if (defaultInputModel) break; 3729 if (defaultInputModel) break;
3730 }
3731
3732 if (candidateInputModels.size() > 1) {
3733 // Add an aggregate model as another option
3734 AggregateWaveModel::ChannelSpecList sl;
3735 foreach (Model *m, candidateInputModels) {
3736 RangeSummarisableTimeValueModel *r =
3737 qobject_cast<RangeSummarisableTimeValueModel *>(m);
3738 if (r) {
3739 sl.push_back(AggregateWaveModel::ModelChannelSpec(r, -1));
3740 }
3741 }
3742 if (!sl.empty()) {
3743 AggregateWaveModel *aggregate = new AggregateWaveModel(sl);
3744 aggregate->setObjectName(tr("Multiplex all of the above"));
3745 candidateInputModels.push_back(aggregate);
3746 //!!! but it leaks
3747 }
3712 } 3748 }
3713 3749
3714 int startFrame = 0, duration = 0; 3750 int startFrame = 0, duration = 0;
3715 int endFrame = 0; 3751 int endFrame = 0;
3716 m_viewManager->getSelection().getExtents(startFrame, endFrame); 3752 m_viewManager->getSelection().getExtents(startFrame, endFrame);
4356 MainWindow::showActivityLog() 4392 MainWindow::showActivityLog()
4357 { 4393 {
4358 m_activityLog->show(); 4394 m_activityLog->show();
4359 m_activityLog->raise(); 4395 m_activityLog->raise();
4360 m_activityLog->scrollToEnd(); 4396 m_activityLog->scrollToEnd();
4397 }
4398
4399 void
4400 MainWindow::showUnitConverter()
4401 {
4402 m_unitConverter->show();
4403 m_unitConverter->raise();
4361 } 4404 }
4362 4405
4363 void 4406 void
4364 MainWindow::preferences() 4407 MainWindow::preferences()
4365 { 4408 {