comparison framework/MainWindowBase.cpp @ 539:630c4a9885ca 3.0-integration

Merge from branch subdivide-instants
author Chris Cannam
date Fri, 25 Nov 2016 10:08:52 +0000
parents 287fce13a1ae
children 0d5c3abc9658
comparison
equal deleted inserted replaced
536:36aa947ec962 539:630c4a9885ca
623 emit canPaste(haveClipboardContents); 623 emit canPaste(haveClipboardContents);
624 emit canInsertInstant(haveCurrentPane); 624 emit canInsertInstant(haveCurrentPane);
625 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection); 625 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection);
626 emit canInsertItemAtSelection(haveCurrentPane && haveSelection && haveCurrentDurationLayer); 626 emit canInsertItemAtSelection(haveCurrentPane && haveSelection && haveCurrentDurationLayer);
627 emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection); 627 emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection);
628 emit canSubdivideInstants(haveCurrentTimeInstantsLayer && haveSelection);
629 emit canWinnowInstants(haveCurrentTimeInstantsLayer && haveSelection);
628 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection); 630 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection);
629 emit canClearSelection(haveSelection); 631 emit canClearSelection(haveSelection);
630 emit canEditSelection(haveSelection && haveCurrentEditableLayer); 632 emit canEditSelection(haveSelection && haveCurrentEditableLayer);
631 emit canSave(m_sessionFile != "" && m_documentModified); 633 emit canSave(m_sessionFile != "" && m_documentModified);
632 emit canSaveAs(haveMainModel); 634 emit canSaveAs(haveMainModel);
1215 if (!m_labeller) return; 1217 if (!m_labeller) return;
1216 1218
1217 Labeller labeller(*m_labeller); 1219 Labeller labeller(*m_labeller);
1218 labeller.setSampleRate(sodm->getSampleRate()); 1220 labeller.setSampleRate(sodm->getSampleRate());
1219 1221
1220 // This uses a command 1222 Command *c = labeller.labelAll<SparseOneDimensionalModel::Point>(*sodm, &ms);
1221 1223 if (c) CommandHistory::getInstance()->addCommand(c, false);
1222 labeller.labelAll<SparseOneDimensionalModel::Point>(*sodm, &ms); 1224 }
1225
1226 void
1227 MainWindowBase::subdivideInstantsBy(int n)
1228 {
1229 Pane *pane = m_paneStack->getCurrentPane();
1230 if (!pane) return;
1231
1232 Layer *layer = dynamic_cast<TimeInstantLayer *>(pane->getSelectedLayer());
1233 if (!layer) return;
1234
1235 MultiSelection ms(m_viewManager->getSelection());
1236
1237 Model *model = layer->getModel();
1238 SparseOneDimensionalModel *sodm =
1239 dynamic_cast<SparseOneDimensionalModel *>(model);
1240 if (!sodm) return;
1241
1242 if (!m_labeller) return;
1243
1244 Labeller labeller(*m_labeller);
1245 labeller.setSampleRate(sodm->getSampleRate());
1246
1247 Command *c = labeller.subdivide<SparseOneDimensionalModel::Point>
1248 (*sodm, &ms, n);
1249 if (c) CommandHistory::getInstance()->addCommand(c, false);
1250 }
1251
1252 void
1253 MainWindowBase::winnowInstantsBy(int n)
1254 {
1255 Pane *pane = m_paneStack->getCurrentPane();
1256 if (!pane) return;
1257
1258 Layer *layer = dynamic_cast<TimeInstantLayer *>(pane->getSelectedLayer());
1259 if (!layer) return;
1260
1261 MultiSelection ms(m_viewManager->getSelection());
1262
1263 Model *model = layer->getModel();
1264 SparseOneDimensionalModel *sodm =
1265 dynamic_cast<SparseOneDimensionalModel *>(model);
1266 if (!sodm) return;
1267
1268 if (!m_labeller) return;
1269
1270 Labeller labeller(*m_labeller);
1271 labeller.setSampleRate(sodm->getSampleRate());
1272
1273 Command *c = labeller.winnow<SparseOneDimensionalModel::Point>
1274 (*sodm, &ms, n);
1275 if (c) CommandHistory::getInstance()->addCommand(c, false);
1223 } 1276 }
1224 1277
1225 MainWindowBase::FileOpenStatus 1278 MainWindowBase::FileOpenStatus
1226 MainWindowBase::openPath(QString fileOrUrl, AudioFileOpenMode mode) 1279 MainWindowBase::openPath(QString fileOrUrl, AudioFileOpenMode mode)
1227 { 1280 {