📄 tempoview.cpp
字号:
RG_DEBUG << "TempoView::slotEditDelete - deleting " << selection.count() << " items" << endl; QPtrListIterator<QListViewItem> it(selection); QListViewItem *listItem; TempoListItem *item; int itemIndex = -1; m_ignoreUpdates = true; bool haveSomething = false; // We want the Remove commands to be in reverse order, because // removing one item by index will affect the indices of // subsequent items. So we'll stack them onto here and then pull // them off again. std::vector<KCommand *> commands; while ((listItem = it.current()) != 0) { item = dynamic_cast<TempoListItem*>((*it)); if (itemIndex == -1) itemIndex = m_list->itemIndex(*it); if (item) { if (item->getType() == TempoListItem::TimeSignature) { commands.push_back(new RemoveTimeSignatureCommand (item->getComposition(), item->getIndex())); haveSomething = true; } else { commands.push_back(new RemoveTempoChangeCommand (item->getComposition(), item->getIndex())); haveSomething = true; } } ++it; } if (haveSomething) { KMacroCommand *command = new KMacroCommand (i18n("Delete Tempo or Time Signature")); for (std::vector<KCommand *>::iterator i = commands.end(); i != commands.begin();) { command->addCommand(*--i); } addCommandToHistory(command); } applyLayout(); m_ignoreUpdates = false;}voidTempoView::slotEditInsertTempo(){ timeT insertTime = 0; QPtrList<QListViewItem> selection = m_list->selectedItems(); if (selection.count() > 0) { TempoListItem *item = dynamic_cast<TempoListItem*>(selection.getFirst()); if (item) insertTime = item->getTime(); } TempoDialog dialog(this, getDocument(), true); dialog.setTempoPosition(insertTime); connect(&dialog, SIGNAL(changeTempo(timeT, tempoT, tempoT, TempoDialog::TempoDialogAction)), this, SIGNAL(changeTempo(timeT, tempoT, tempoT, TempoDialog::TempoDialogAction))); dialog.exec();}voidTempoView::slotEditInsertTimeSignature(){ timeT insertTime = 0; QPtrList<QListViewItem> selection = m_list->selectedItems(); if (selection.count() > 0) { TempoListItem *item = dynamic_cast<TempoListItem*>(selection.getFirst()); if (item) insertTime = item->getTime(); } Composition &composition(m_doc->getComposition()); Rosegarden::TimeSignature sig = composition.getTimeSignatureAt(insertTime); TimeSignatureDialog dialog(this, &composition, insertTime, sig, true); if (dialog.exec() == QDialog::Accepted) { insertTime = dialog.getTime(); if (dialog.shouldNormalizeRests()) { addCommandToHistory (new AddTimeSignatureAndNormalizeCommand (&composition, insertTime, dialog.getTimeSignature())); } else { addCommandToHistory (new AddTimeSignatureCommand (&composition, insertTime, dialog.getTimeSignature())); } }}voidTempoView::slotEdit(){ RG_DEBUG << "TempoView::slotEdit" << endl; QPtrList<QListViewItem> selection = m_list->selectedItems(); if (selection.count() > 0) { TempoListItem *item = dynamic_cast<TempoListItem*>(selection.getFirst()); if (item) slotPopupEditor(item); }}voidTempoView::slotSelectAll(){ m_listSelection.clear(); for (int i = 0; m_list->itemAtIndex(i); ++i) { m_listSelection.push_back(i); m_list->setSelected(m_list->itemAtIndex(i), true); }}voidTempoView::slotClearSelection(){ m_listSelection.clear(); for (int i = 0; m_list->itemAtIndex(i); ++i) { m_list->setSelected(m_list->itemAtIndex(i), false); }}voidTempoView::setupActions(){ EditViewBase::setupActions("tempoview.rc", false); QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/"); QIconSet icon(QPixmap(pixmapDir + "/toolbar/event-insert-tempo.png")); new KAction(AddTempoChangeCommand::getGlobalName(), icon, Key_I, this, SLOT(slotEditInsertTempo()), actionCollection(), "insert_tempo"); QCanvasPixmap pixmap(pixmapDir + "/toolbar/event-insert-timesig.png"); icon = QIconSet(pixmap); new KAction(AddTimeSignatureCommand::getGlobalName(), icon, Key_G, this, SLOT(slotEditInsertTimeSignature()), actionCollection(), "insert_timesig"); pixmap.load(pixmapDir + "/toolbar/event-delete.png"); icon = QIconSet(pixmap); new KAction(i18n("&Delete"), icon, Key_Delete, this, SLOT(slotEditDelete()), actionCollection(), "delete"); pixmap.load(pixmapDir + "/toolbar/event-edit.png"); icon = QIconSet(pixmap); new KAction(i18n("&Edit Item"), icon, Key_E, this, SLOT(slotEdit()), actionCollection(), "edit"); new KAction(i18n("Select &All"), 0, this, SLOT(slotSelectAll()), actionCollection(), "select_all"); new KAction(i18n("Clear Selection"), Key_Escape, this, SLOT(slotClearSelection()), actionCollection(), "clear_selection"); m_config->setGroup(TempoViewConfigGroup); int timeMode = m_config->readNumEntry("timemode", 0); KRadioAction *action; pixmap.load(pixmapDir + "/toolbar/time-musical.png"); icon = QIconSet(pixmap); action = new KRadioAction(i18n("&Musical Times"), icon, 0, this, SLOT(slotMusicalTime()), actionCollection(), "time_musical"); action->setExclusiveGroup("timeMode"); if (timeMode == 0) action->setChecked(true); pixmap.load(pixmapDir + "/toolbar/time-real.png"); icon = QIconSet(pixmap); action = new KRadioAction(i18n("&Real Times"), icon, 0, this, SLOT(slotRealTime()), actionCollection(), "time_real"); action->setExclusiveGroup("timeMode"); if (timeMode == 1) action->setChecked(true); pixmap.load(pixmapDir + "/toolbar/time-raw.png"); icon = QIconSet(pixmap); action = new KRadioAction(i18n("Ra&w Times"), icon, 0, this, SLOT(slotRawTime()), actionCollection(), "time_raw"); action->setExclusiveGroup("timeMode"); if (timeMode == 2) action->setChecked(true); createGUI(getRCFileName());}voidTempoView::initStatusBar(){ KStatusBar* sb = statusBar(); sb->insertItem(KTmpStatusMsg::getDefaultMsg(), KTmpStatusMsg::getDefaultId(), 1); sb->setItemAlignment(KTmpStatusMsg::getDefaultId(), AlignLeft | AlignVCenter);}QSizeTempoView::getViewSize(){ return m_list->size();}voidTempoView::setViewSize(QSize s){ m_list->setFixedSize(s);}voidTempoView::readOptions(){ m_config->setGroup(TempoViewConfigGroup); EditViewBase::readOptions(); m_filter = m_config->readNumEntry("filter", m_filter); m_list->restoreLayout(m_config, TempoViewLayoutConfigGroupName);}voidTempoView::slotSaveOptions(){ m_config->setGroup(TempoViewConfigGroup); m_config->writeEntry("filter", m_filter); m_list->saveLayout(m_config, TempoViewLayoutConfigGroupName);}voidTempoView::slotModifyFilter(int button){ QCheckBox *checkBox = dynamic_cast<QCheckBox*>(m_filterGroup->find(button)); if (checkBox == 0) return ; if (checkBox->isChecked()) { switch (button) { case 0: m_filter |= Tempo; break; case 1: m_filter |= TimeSignature; break; default: break; } } else { switch (button) { case 0: m_filter ^= Tempo; break; case 1: m_filter ^= TimeSignature; break; default: break; } } m_lastSetFilter = m_filter; applyLayout(0);}voidTempoView::setButtonsToFilter(){ if (m_filter & Tempo) m_tempoCheckBox->setChecked(true); else m_tempoCheckBox->setChecked(false); if (m_filter & TimeSignature) m_timeSigCheckBox->setChecked(true); else m_timeSigCheckBox->setChecked(false);}voidTempoView::slotMusicalTime(){ m_config->setGroup(TempoViewConfigGroup); m_config->writeEntry("timemode", 0); applyLayout();}voidTempoView::slotRealTime(){ m_config->setGroup(TempoViewConfigGroup); m_config->writeEntry("timemode", 1); applyLayout();}voidTempoView::slotRawTime(){ m_config->setGroup(TempoViewConfigGroup); m_config->writeEntry("timemode", 2); applyLayout();}voidTempoView::slotPopupEditor(QListViewItem *qitem){ TempoListItem *item = dynamic_cast<TempoListItem *>(qitem); if (!item) return ; timeT time = item->getTime(); switch (item->getType()) { case TempoListItem::Tempo: { TempoDialog dialog(this, getDocument(), true); dialog.setTempoPosition(time); connect(&dialog, SIGNAL(changeTempo(timeT, tempoT, tempoT, TempoDialog::TempoDialogAction)), this, SIGNAL(changeTempo(timeT, tempoT, tempoT, TempoDialog::TempoDialogAction))); dialog.exec(); break; } case TempoListItem::TimeSignature: { Composition &composition(getDocument()->getComposition()); Rosegarden::TimeSignature sig = composition.getTimeSignatureAt(time); TimeSignatureDialog dialog(this, &composition, time, sig, true); if (dialog.exec() == QDialog::Accepted) { time = dialog.getTime(); if (dialog.shouldNormalizeRests()) { addCommandToHistory (new AddTimeSignatureAndNormalizeCommand (&composition, time, dialog.getTimeSignature())); } else { addCommandToHistory (new AddTimeSignatureCommand (&composition, time, dialog.getTimeSignature())); } } } default: break; }}voidTempoView::updateViewCaption(){ setCaption(i18n("%1 - Tempo and Time Signature Editor") .arg(getDocument()->getTitle()));}}#include "TempoView.moc"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -