📄 triggersegmentmanager.cpp
字号:
QListViewItem *it = m_listView->firstChild(); do { TriggerManagerItem *item = dynamic_cast<TriggerManagerItem*>(it); if (!item) continue; DeleteTriggerSegmentCommand *c = new DeleteTriggerSegmentCommand(m_doc, item->getId()); command->addCommand(c); } while ((it = it->nextSibling())); addCommandToHistory(command);}voidTriggerSegmentManager::slotAdd(){ TimeDialog dialog(this, i18n("Trigger Segment Duration"), &m_doc->getComposition(), 0, 3840, false); if (dialog.exec() == QDialog::Accepted) { addCommandToHistory(new AddTriggerSegmentCommand (m_doc, dialog.getTime(), 64)); }}voidTriggerSegmentManager::slotDelete(){ RG_DEBUG << "TriggerSegmentManager::slotDelete" << endl; TriggerManagerItem *item = dynamic_cast<TriggerManagerItem*>(m_listView->currentItem()); if (!item) return ; if (item->getUsage() > 0) { if (KMessageBox::warningContinueCancel(this, i18n("This triggered segment is used 1 time in the current composition. Are you sure you want to remove it?", "This triggered segment is used %n times in the current composition. Are you sure you want to remove it?", item->getUsage())) != KMessageBox::Continue) return ; } DeleteTriggerSegmentCommand *command = new DeleteTriggerSegmentCommand(m_doc, item->getId()); addCommandToHistory(command);}voidTriggerSegmentManager::slotPasteAsNew(){ Clipboard *clipboard = m_doc->getClipboard(); if (clipboard->isEmpty()) { KMessageBox::information(this, i18n("Clipboard is empty")); return ; } addCommandToHistory(new PasteToTriggerSegmentCommand (&m_doc->getComposition(), clipboard, "", -1));}voidTriggerSegmentManager::slotClose(){ RG_DEBUG << "TriggerSegmentManager::slotClose" << endl; if (m_doc) m_doc->getCommandHistory()->detachView(actionCollection()); m_doc = 0; close();}voidTriggerSegmentManager::setupActions(){ KAction* close = KStdAction::close(this, SLOT(slotClose()), actionCollection()); m_closeButton->setText(close->text()); connect(m_closeButton, SIGNAL(released()), this, SLOT(slotClose())); QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/"); // some adjustments new KToolBarPopupAction(i18n("Und&o"), "undo", KStdAccel::key(KStdAccel::Undo), actionCollection(), KStdAction::stdName(KStdAction::Undo)); new KToolBarPopupAction(i18n("Re&do"), "redo", KStdAccel::key(KStdAccel::Redo), actionCollection(), KStdAction::stdName(KStdAction::Redo)); new KAction(i18n("Pa&ste as New Triggered Segment"), CTRL + SHIFT + Key_V, this, SLOT(slotPasteAsNew()), actionCollection(), "paste_to_trigger_segment"); kapp->config()->setGroup(TriggerManagerConfigGroup); int timeMode = kapp->config()->readNumEntry("timemode", 0); KRadioAction *action; QCanvasPixmap pixmap(pixmapDir + "/toolbar/time-musical.png"); QIconSet icon(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("triggermanager.rc");}voidTriggerSegmentManager::addCommandToHistory(KCommand *command){ getCommandHistory()->addCommand(command); setModified(false);}MultiViewCommandHistory*TriggerSegmentManager::getCommandHistory(){ return m_doc->getCommandHistory();}voidTriggerSegmentManager::setModified(bool modified){ RG_DEBUG << "TriggerSegmentManager::setModified(" << modified << ")" << endl; m_modified = modified;}voidTriggerSegmentManager::checkModified(){ RG_DEBUG << "TriggerSegmentManager::checkModified(" << m_modified << ")" << endl;}voidTriggerSegmentManager::slotEdit(QListViewItem *i){ RG_DEBUG << "TriggerSegmentManager::slotEdit" << endl; TriggerManagerItem *item = dynamic_cast<TriggerManagerItem*>(i); if (!item) return ; TriggerSegmentId id = item->getId(); RG_DEBUG << "id is " << id << endl; emit editTriggerSegment(id);}voidTriggerSegmentManager::closeEvent(QCloseEvent *e){ emit closing(); KMainWindow::closeEvent(e);}voidTriggerSegmentManager::setDocument(RosegardenGUIDoc *doc){ // reset our pointers m_doc = doc; m_modified = false; slotUpdate();}voidTriggerSegmentManager::slotItemClicked(QListViewItem *item){ RG_DEBUG << "TriggerSegmentManager::slotItemClicked" << endl;}QStringTriggerSegmentManager::makeDurationString(timeT time, timeT duration, int timeMode){ //!!! duplication with EventView::makeDurationString -- merge somewhere? switch (timeMode) { case 0: // musical time { int bar, beat, fraction, remainder; m_doc->getComposition().getMusicalTimeForDuration (time, duration, bar, beat, fraction, remainder); return QString("%1%2%3-%4%5-%6%7-%8%9 ") .arg(bar / 100) .arg((bar % 100) / 10) .arg(bar % 10) .arg(beat / 10) .arg(beat % 10) .arg(fraction / 10) .arg(fraction % 10) .arg(remainder / 10) .arg(remainder % 10); } case 1: // real time { RealTime rt = m_doc->getComposition().getRealTimeDifference (time, time + duration); // return QString("%1 ").arg(rt.toString().c_str()); return QString("%1 ").arg(rt.toText().c_str()); } default: return QString("%1 ").arg(duration); }}voidTriggerSegmentManager::slotMusicalTime(){ kapp->config()->setGroup(TriggerManagerConfigGroup); kapp->config()->writeEntry("timemode", 0); slotUpdate();}voidTriggerSegmentManager::slotRealTime(){ kapp->config()->setGroup(TriggerManagerConfigGroup); kapp->config()->writeEntry("timemode", 1); slotUpdate();}voidTriggerSegmentManager::slotRawTime(){ kapp->config()->setGroup(TriggerManagerConfigGroup); kapp->config()->writeEntry("timemode", 2); slotUpdate();}}#include "TriggerSegmentManager.moc"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -