📄 editview.cpp
字号:
getInstrument()); if (!instrument) return 0; return instrument->getDevice();}timeTEditView::getInsertionTime(Clef &clef, Rosegarden::Key &key){ timeT t = getInsertionTime(); Segment *segment = getCurrentSegment(); if (segment) { clef = segment->getClefAtTime(t); key = segment->getKeyAtTime(t); } else { clef = Clef(); key = ::Rosegarden::Key(); } return t;}void EditView::slotActiveItemPressed(QMouseEvent* e, QCanvasItem* item){ if (!item) return ; // Check if it's a groupable item, if so get its group // QCanvasGroupableItem *gitem = dynamic_cast<QCanvasGroupableItem*>(item); if (gitem) item = gitem->group(); // Check if it's an active item // ActiveItem *activeItem = dynamic_cast<ActiveItem*>(item); if (activeItem) { setActiveItem(activeItem); activeItem->handleMousePress(e); updateView(); }}voidEditView::slotStepBackward(){ Staff *staff = getCurrentStaff(); if (!staff) return ; ViewElementList *vel = staff->getViewElementList(); timeT time = getInsertionTime(); ViewElementList::iterator i = vel->findTime(time); while (i != vel->begin() && (i == vel->end() || (*i)->getViewAbsoluteTime() >= time)) --i; if (i != vel->end()) slotSetInsertCursorPosition((*i)->getViewAbsoluteTime());}voidEditView::slotStepForward(){ Staff *staff = getCurrentStaff(); if (!staff) return ; ViewElementList *vel = staff->getViewElementList(); timeT time = getInsertionTime(); ViewElementList::iterator i = vel->findTime(time); while (i != vel->end() && (*i)->getViewAbsoluteTime() <= time) ++i; if (i == vel->end()) { slotSetInsertCursorPosition(staff->getSegment().getEndMarkerTime()); } else { slotSetInsertCursorPosition((*i)->getViewAbsoluteTime()); }}voidEditView::slotJumpBackward(){ Segment *segment = getCurrentSegment(); if (!segment) return ; timeT time = getInsertionTime(); time = segment->getBarStartForTime(time - 1); slotSetInsertCursorPosition(time);}voidEditView::slotJumpForward(){ Segment *segment = getCurrentSegment(); if (!segment) return ; timeT time = getInsertionTime(); time = segment->getBarEndForTime(time); slotSetInsertCursorPosition(time);}voidEditView::slotJumpToStart(){ Segment *segment = getCurrentSegment(); if (!segment) return ; timeT time = segment->getStartTime(); slotSetInsertCursorPosition(time);}voidEditView::slotJumpToEnd(){ Segment *segment = getCurrentSegment(); if (!segment) return ; timeT time = segment->getEndMarkerTime(); slotSetInsertCursorPosition(time);}void EditView::slotExtendSelectionBackward(){ slotExtendSelectionBackward(false);}void EditView::slotExtendSelectionBackwardBar(){ slotExtendSelectionBackward(true);}void EditView::slotExtendSelectionBackward(bool bar){ // If there is no current selection, or the selection is entirely // to the right of the cursor, move the cursor left and add to the // selection timeT oldTime = getInsertionTime(); if (bar) slotJumpBackward(); else slotStepBackward(); timeT newTime = getInsertionTime(); Staff *staff = getCurrentStaff(); if (!staff) return ; Segment *segment = &staff->getSegment(); ViewElementList *vel = staff->getViewElementList(); EventSelection *es = new EventSelection(*segment); if (m_currentEventSelection && &m_currentEventSelection->getSegment() == segment) es->addFromSelection(m_currentEventSelection); if (!m_currentEventSelection || &m_currentEventSelection->getSegment() != segment || m_currentEventSelection->getSegmentEvents().size() == 0 || m_currentEventSelection->getStartTime() >= oldTime) { ViewElementList::iterator extendFrom = vel->findTime(oldTime); while (extendFrom != vel->begin() && (*--extendFrom)->getViewAbsoluteTime() >= newTime) { if ((*extendFrom)->event()->isa(Note::EventType)) { es->addEvent((*extendFrom)->event()); } } } else { // remove an event EventSelection::eventcontainer::iterator i = es->getSegmentEvents().end(); std::vector<Event *> toErase; while (i != es->getSegmentEvents().begin() && (*--i)->getAbsoluteTime() >= newTime) { toErase.push_back(*i); } for (unsigned int j = 0; j < toErase.size(); ++j) { es->removeEvent(toErase[j]); } } setCurrentSelection(es);}void EditView::slotExtendSelectionForward(){ slotExtendSelectionForward(false);}void EditView::slotExtendSelectionForwardBar(){ slotExtendSelectionForward(true);}void EditView::slotExtendSelectionForward(bool bar){ // If there is no current selection, or the selection is entirely // to the left of the cursor, move the cursor right and add to the // selection timeT oldTime = getInsertionTime(); if (bar) slotJumpForward(); else slotStepForward(); timeT newTime = getInsertionTime(); Staff *staff = getCurrentStaff(); if (!staff) return ; Segment *segment = &staff->getSegment(); ViewElementList *vel = staff->getViewElementList(); EventSelection *es = new EventSelection(*segment); if (m_currentEventSelection && &m_currentEventSelection->getSegment() == segment) es->addFromSelection(m_currentEventSelection); if (!m_currentEventSelection || &m_currentEventSelection->getSegment() != segment || m_currentEventSelection->getSegmentEvents().size() == 0 || m_currentEventSelection->getEndTime() <= oldTime) { ViewElementList::iterator extendFrom = vel->findTime(oldTime); while (extendFrom != vel->end() && (*extendFrom)->getViewAbsoluteTime() < newTime) { if ((*extendFrom)->event()->isa(Note::EventType)) { es->addEvent((*extendFrom)->event()); } ++extendFrom; } } else { // remove an event EventSelection::eventcontainer::iterator i = es->getSegmentEvents().begin(); std::vector<Event *> toErase; while (i != es->getSegmentEvents().end() && (*i)->getAbsoluteTime() < newTime) { toErase.push_back(*i); ++i; } for (unsigned int j = 0; j < toErase.size(); ++j) { es->removeEvent(toErase[j]); } } setCurrentSelection(es);}voidEditView::setupActions(){ createInsertPitchActionMenu(); new KAction(AddTempoChangeCommand::getGlobalName(), 0, this, SLOT(slotAddTempo()), actionCollection(), "add_tempo"); new KAction(AddTimeSignatureCommand::getGlobalName(), 0, this, SLOT(slotAddTimeSignature()), actionCollection(), "add_time_signature"); // // Transforms // new KAction(i18n("&Halve Speed"), Key_Less + CTRL, this, SLOT(slotHalfSpeed()), actionCollection(), "half_speed"); new KAction(i18n("&Double Speed"), Key_Greater + CTRL, this, SLOT(slotDoubleSpeed()), actionCollection(), "double_speed"); new KAction(RescaleCommand::getGlobalName(), 0, this, SLOT(slotRescale()), actionCollection(), "rescale"); new KAction(TransposeCommand::getGlobalName(1), 0, Key_Up, this, SLOT(slotTransposeUp()), actionCollection(), "transpose_up"); new KAction(TransposeCommand::getGlobalName(12), 0, Key_Up + CTRL, this, SLOT(slotTransposeUpOctave()), actionCollection(), "transpose_up_octave"); new KAction(TransposeCommand::getGlobalName( -1), 0, Key_Down, this, SLOT(slotTransposeDown()), actionCollection(), "transpose_down"); new KAction(TransposeCommand::getGlobalName( -12), 0, Key_Down + CTRL, this, SLOT(slotTransposeDownOctave()), actionCollection(), "transpose_down_octave"); new KAction(TransposeCommand::getGlobalName(0), 0, this, SLOT(slotTranspose()), actionCollection(), "general_transpose"); new KAction(TransposeCommand::getDiatonicGlobalName(0,0), 0, this, SLOT(slotDiatonicTranspose()), actionCollection(), "general_diatonic_transpose"); new KAction(InvertCommand::getGlobalName(0), 0, this, SLOT(slotInvert()), actionCollection(), "invert"); new KAction(RetrogradeCommand::getGlobalName(0), 0, this, SLOT(slotRetrograde()), actionCollection(), "retrograde"); new KAction(RetrogradeInvertCommand::getGlobalName(0), 0, this, SLOT(slotRetrogradeInvert()), actionCollection(), "retrograde_invert"); new KAction(i18n("Jog &Left"), Key_Left + ALT, this, SLOT(slotJogLeft()), actionCollection(), "jog_left"); new KAction(i18n("Jog &Right"), Key_Right + ALT, this, SLOT(slotJogRight()), actionCollection(), "jog_right"); // Control rulers // new KAction(i18n("Show Velocity Property Ruler"), 0, this, SLOT(slotShowVelocityControlRuler()), actionCollection(), "show_velocity_control_ruler"); /* new KAction(i18n("Show Controllers Events Ruler"), 0, this, SLOT(slotShowControllerEventsRuler()), actionCollection(), "show_controller_events_ruler"); */ // Disabled for now // // new KAction(i18n("Add Control Ruler..."), 0, this, // SLOT(slotShowPropertyControlRuler()), actionCollection(), // "add_control_ruler"); // // Control Ruler context menu // new KAction(i18n("Insert item"), 0, this, SLOT(slotInsertControlRulerItem()), actionCollection(), "insert_control_ruler_item"); // This was on Key_Delete, but that conflicts with existing Delete commands // on individual edit views new KAction(i18n("Erase selected items"), 0, this, SLOT(slotEraseControlRulerItem()), actionCollection(), "erase_control_ruler_item"); new KAction(i18n("Clear ruler"), 0, this, SLOT(slotClearControlRulerItem()), actionCollection(), "clear_control_ruler_item"); new KAction(i18n("Insert line of controllers"), 0, this, SLOT(slotStartControlLineItem()), actionCollection(), "start_control_line_item"); new KAction(i18n("Flip forward"), Key_BracketRight, this, SLOT(slotFlipForwards()), actionCollection(), "flip_control_events_forward"); new KAction(i18n("Flip backwards"), Key_BracketLeft, this, SLOT(slotFlipBackwards()), actionCollection(), "flip_control_events_back"); new KAction(i18n("Draw property line"), 0, this, SLOT(slotDrawPropertyLine()), actionCollection(), "draw_property_line"); new KAction(i18n("Select all property values"), 0, this, SLOT(slotSelectAllProperties()), actionCollection(), "select_all_properties");}voidEditView::setupAddControlRulerMenu(){ RG_DEBUG << "EditView::setupAddControlRulerMenu" << endl; QPopupMenu* addControlRulerMenu = dynamic_cast<QPopupMenu*> (factory()->container("add_control_ruler", this)); if (addControlRulerMenu) { addControlRulerMenu->clear(); //!!! problem here with notation view -- current segment can // change after construction, but this function isn't used again Controllable *c = dynamic_cast<MidiDevice *>(getCurrentDevice()); if (!c) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -