comparison framework/MainWindowBase.cpp @ 537:dd195633fc9f subdivide-instants

Implement "Subdivide Selected Instants". Also add the relabel command to the history, which I previously forgot to do!
author Chris Cannam
date Fri, 25 Nov 2016 09:38:53 +0000
parents 3ab6a5f7aca8
children 287fce13a1ae
comparison
equal deleted inserted replaced
536:36aa947ec962 537:dd195633fc9f
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);
628 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection); 629 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection);
629 emit canClearSelection(haveSelection); 630 emit canClearSelection(haveSelection);
630 emit canEditSelection(haveSelection && haveCurrentEditableLayer); 631 emit canEditSelection(haveSelection && haveCurrentEditableLayer);
631 emit canSave(m_sessionFile != "" && m_documentModified); 632 emit canSave(m_sessionFile != "" && m_documentModified);
632 emit canSaveAs(haveMainModel); 633 emit canSaveAs(haveMainModel);
1215 if (!m_labeller) return; 1216 if (!m_labeller) return;
1216 1217
1217 Labeller labeller(*m_labeller); 1218 Labeller labeller(*m_labeller);
1218 labeller.setSampleRate(sodm->getSampleRate()); 1219 labeller.setSampleRate(sodm->getSampleRate());
1219 1220
1220 // This uses a command 1221 Command *c = labeller.labelAll<SparseOneDimensionalModel::Point>(*sodm, &ms);
1221 1222 if (c) CommandHistory::getInstance()->addCommand(c, false);
1222 labeller.labelAll<SparseOneDimensionalModel::Point>(*sodm, &ms); 1223 }
1224
1225 void
1226 MainWindowBase::subdivideInstantsBy(int n)
1227 {
1228 Pane *pane = m_paneStack->getCurrentPane();
1229 if (!pane) return;
1230
1231 Layer *layer = dynamic_cast<TimeInstantLayer *>(pane->getSelectedLayer());
1232 if (!layer) return;
1233
1234 MultiSelection ms(m_viewManager->getSelection());
1235
1236 Model *model = layer->getModel();
1237 SparseOneDimensionalModel *sodm =
1238 dynamic_cast<SparseOneDimensionalModel *>(model);
1239 if (!sodm) return;
1240
1241 if (!m_labeller) return;
1242
1243 Labeller labeller(*m_labeller);
1244 labeller.setSampleRate(sodm->getSampleRate());
1245
1246 Command *c = labeller.subdivide<SparseOneDimensionalModel::Point>
1247 (*sodm, &ms, n);
1248 if (c) CommandHistory::getInstance()->addCommand(c, false);
1223 } 1249 }
1224 1250
1225 MainWindowBase::FileOpenStatus 1251 MainWindowBase::FileOpenStatus
1226 MainWindowBase::openPath(QString fileOrUrl, AudioFileOpenMode mode) 1252 MainWindowBase::openPath(QString fileOrUrl, AudioFileOpenMode mode)
1227 { 1253 {