📄 markereditor.cpp
字号:
QListViewItem *item = m_listView->firstChild(); do { MarkerEditorViewItem *ei = dynamic_cast<MarkerEditorViewItem *>(item); if (!ei || ei->isFake()) continue; RemoveMarkerCommand *rc = new RemoveMarkerCommand(&m_doc->getComposition(), ei->getRawTime(), qstrtostr(item->text(1)), qstrtostr(item->text(2))); command->addCommand(rc); } while ((item = item->nextSibling())); addCommandToHistory(command);}voidMarkerEditor::slotAdd(){ RG_DEBUG << "MarkerEditor::slotAdd" << endl; AddMarkerCommand *command = new AddMarkerCommand(&m_doc->getComposition(), m_doc->getComposition().getPosition(), std::string("new marker"), std::string("no description")); addCommandToHistory(command);}voidMarkerEditor::slotDelete(){ RG_DEBUG << "MarkerEditor::slotDelete" << endl; QListViewItem *item = m_listView->currentItem(); MarkerEditorViewItem *ei = dynamic_cast<MarkerEditorViewItem *>(item); if (!ei || ei->isFake()) return ; RemoveMarkerCommand *command = new RemoveMarkerCommand(&m_doc->getComposition(), ei->getRawTime(), qstrtostr(item->text(1)), qstrtostr(item->text(2))); addCommandToHistory(command);}voidMarkerEditor::slotClose(){ RG_DEBUG << "MarkerEditor::slotClose" << endl; if (m_doc) m_doc->getCommandHistory()->detachView(actionCollection()); m_doc = 0; close();}voidMarkerEditor::setupActions(){ KAction* close = KStdAction::close(this, SLOT(slotClose()), actionCollection()); m_closeButton->setText(close->text()); connect(m_closeButton, SIGNAL(released()), this, SLOT(slotClose())); // 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)); QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/"); kapp->config()->setGroup(MarkerEditorConfigGroup); 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("markereditor.rc");}voidMarkerEditor::addCommandToHistory(KCommand *command){ getCommandHistory()->addCommand(command); setModified(false);}MultiViewCommandHistory*MarkerEditor::getCommandHistory(){ return m_doc->getCommandHistory();}voidMarkerEditor::setModified(bool modified){ RG_DEBUG << "MarkerEditor::setModified(" << modified << ")" << endl; if (modified) {} else {} m_modified = modified;}voidMarkerEditor::checkModified(){ RG_DEBUG << "MarkerEditor::checkModified(" << m_modified << ")" << endl;}voidMarkerEditor::slotEdit(QListViewItem *i){ RG_DEBUG << "MarkerEditor::slotEdit" << endl; if (m_listView->selectionMode() == QListView::NoSelection) { // The marker list is empty, so we shouldn't allow editing the // <none> placeholder return ; } // Need to get the raw time from the ListViewItem // MarkerEditorViewItem *item = dynamic_cast<MarkerEditorViewItem*>(i); if (!item || item->isFake()) return ; MarkerModifyDialog dialog(this, &m_doc->getComposition(), item->getRawTime(), item->text(1), item->text(2)); if (dialog.exec() == QDialog::Accepted) { ModifyMarkerCommand *command = new ModifyMarkerCommand(&m_doc->getComposition(), dialog.getOriginalTime(), dialog.getTime(), qstrtostr(dialog.getName()), qstrtostr(dialog.getDescription())); addCommandToHistory(command); }}voidMarkerEditor::closeEvent(QCloseEvent *e){ emit closing(); KMainWindow::closeEvent(e);}voidMarkerEditor::setDocument(RosegardenGUIDoc *doc){ // reset our pointers m_doc = doc; m_modified = false; slotUpdate();}voidMarkerEditor::slotItemClicked(QListViewItem *item){ RG_DEBUG << "MarkerEditor::slotItemClicked" << endl; MarkerEditorViewItem *ei = dynamic_cast<MarkerEditorViewItem *>(item); if (ei && !ei->isFake()) { RG_DEBUG << "MarkerEditor::slotItemClicked - " << "jump to marker at " << ei->getRawTime() << endl; emit jumpToMarker(timeT(ei->getRawTime())); }}QStringMarkerEditor::makeTimeString(timeT time, int timeMode){ switch (timeMode) { case 0: // musical time { int bar, beat, fraction, remainder; m_doc->getComposition().getMusicalTimeForAbsoluteTime (time, bar, beat, fraction, remainder); ++bar; 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().getElapsedRealTime(time); // return QString("%1 ").arg(rt.toString().c_str()); return QString("%1 ").arg(rt.toText().c_str()); } default: return QString("%1 ").arg(time); }}voidMarkerEditor::slotMusicalTime(){ kapp->config()->setGroup(MarkerEditorConfigGroup); kapp->config()->writeEntry("timemode", 0); slotUpdate();}voidMarkerEditor::slotRealTime(){ kapp->config()->setGroup(MarkerEditorConfigGroup); kapp->config()->writeEntry("timemode", 1); slotUpdate();}voidMarkerEditor::slotRawTime(){ kapp->config()->setGroup(MarkerEditorConfigGroup); kapp->config()->writeEntry("timemode", 2); slotUpdate();}}#include "MarkerEditor.moc"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -