void TextBase::endEdit(EditData& ed) { TextEditData* ted = static_cast<TextEditData*>(ed.getData(this)); score()->undoStack()->remove(ted->startUndoIdx); // remove all undo/redo records // replace all undo/redo records collected during text editing with // one property change QString actualText = xmlText(); if (ted->oldXmlText.isEmpty()) { UndoStack* us = score()->undoStack(); UndoCommand* ucmd = us->last(); if (ucmd) { const QList<UndoCommand*>& cl = ucmd->commands(); const UndoCommand* cmd = cl.back(); if (strncmp(cmd->name(), "Add:", 4) == 0) { const AddElement* ae = static_cast<const AddElement*>(cmd); if (ae->getElement() == this) { if (actualText.isEmpty()) { // we just created this empty text, rollback that operation us->rollback(); score()->update(); ed.element = 0; } else { setXmlText(ted->oldXmlText); // reset text to value before editing us->reopen(); // combine undo records of text creation with text editing undoChangeProperty(Pid::TEXT, actualText); layout1(); score()->endCmd(); } return; } } } } if (actualText.isEmpty()) { qDebug("actual text is empty"); score()->startCmd(); score()->undoRemoveElement(this); ed.element = 0; score()->endCmd(); return; } setXmlText(ted->oldXmlText); // reset text to value before editing score()->startCmd(); undoChangeProperty(Pid::TEXT, actualText); // change property to set text to actual value again // this also changes text of linked elements layout1(); triggerLayout(); // force relayout even if text did not change score()->endCmd(); static const qreal w = 2.0; score()->addRefresh(canvasBoundingRect().adjusted(-w, -w, w, w)); }
void Hairpin::reset() { if (lineWidthStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::LINE_WIDTH, propertyDefault(P_ID::LINE_WIDTH), PropertyStyle::STYLED); if (hairpinHeightStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::HAIRPIN_HEIGHT, propertyDefault(P_ID::HAIRPIN_HEIGHT), PropertyStyle::STYLED); if (hairpinContHeightStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::HAIRPIN_CONT_HEIGHT, propertyDefault(P_ID::HAIRPIN_CONT_HEIGHT), PropertyStyle::STYLED); TextLine::reset(); }
void Articulation::reset() { #if 0 if (_direction != Direction_AUTO) undoChangeProperty(P_ID::DIRECTION, Direction_AUTO); ArticulationAnchor a = score()->style()->articulationAnchor(int(articulationType())); if (_anchor != a) undoChangeProperty(P_ID::ARTICULATION_ANCHOR, int(a)); #endif Element::reset(); }
void Ottava::reset() { if (lineWidthStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::LINE_WIDTH, propertyDefault(P_ID::LINE_WIDTH), PropertyStyle::STYLED); if (lineStyleStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::LINE_STYLE, propertyDefault(P_ID::LINE_STYLE), PropertyStyle::STYLED); if (numbersOnlyStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::NUMBERS_ONLY, propertyDefault(P_ID::NUMBERS_ONLY), PropertyStyle::STYLED); if (beginTextStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::BEGIN_TEXT, propertyDefault(P_ID::BEGIN_TEXT), PropertyStyle::STYLED); if (continueTextStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::CONTINUE_TEXT, propertyDefault(P_ID::CONTINUE_TEXT), PropertyStyle::STYLED); setOttavaType(_ottavaType); TextLine::reset(); }
void Marker::undoSetMarkerType(Type t) { undoChangeProperty(P_ID::MARKER_TYPE, int(t)); }
void Hairpin::undoSetVeloChange(int val) { undoChangeProperty(P_ID::VELO_CHANGE, val); }
void LayoutBreak::undoSetLayoutBreakType(Type t) { undoChangeProperty(P_ID::LAYOUT_BREAK, int(t)); }
void Glissando::undoSetShowText(bool f) { undoChangeProperty(P_ID::GLISS_SHOW_TEXT, f); }
void Glissando::undoSetGlissandoType(Type t) { undoChangeProperty(P_ID::GLISS_TYPE, int(t)); }
void Jump::undoSetJumpTo(const QString& s) { undoChangeProperty(P_ID::JUMP_TO, s); }
void ChordRest::undoSetSmall(bool val) { undoChangeProperty(P_ID::SMALL, val); }
void ChordRest::undoSetBeamMode(Beam::Mode mode) { undoChangeProperty(P_ID::BEAM_MODE, int(mode)); }
void Accidental::undoSetSmall(bool val) { undoChangeProperty(P_ID::SMALL, val); }
void Accidental::undoSetHasBracket(bool val) { undoChangeProperty(P_ID::ACCIDENTAL_BRACKET, val); }
void TremoloBar::reset() { if (lineWidthStyle == PropertyFlags::UNSTYLED) undoChangeProperty(Pid::LINE_WIDTH, propertyDefault(Pid::LINE_WIDTH), PropertyFlags::STYLED); Element::reset(); }
void Clef::undoSetShowCourtesy(bool v) { undoChangeProperty(P_ID::SHOW_COURTESY, v); }
void Stem::reset() { undoChangeProperty(P_ID::USER_LEN, 0.0); Element::reset(); }
void Jump::undoSetPlayUntil(const QString& s) { undoChangeProperty(P_ID::PLAY_UNTIL, s); }
void Glissando::undoSetText(const QString& s) { undoChangeProperty(P_ID::GLISS_TEXT, s); }
void Jump::undoSetContinueAt(const QString& s) { undoChangeProperty(P_ID::CONTINUE_AT, s); }
void SpannerSegment::reset() { undoChangeProperty(P_ID::USER_OFF2, QPointF()); Element::reset(); spanner()->reset(); }
void Trill::undoSetTrillType(Type val) { undoChangeProperty(Pid::TRILL_TYPE, int(val)); }
void Hairpin::undoSetHairpinType(Type val) { undoChangeProperty(P_ID::HAIRPIN_TYPE, int(val)); }
void LayoutBreak::undoSetLayoutBreakType(LayoutBreakType t) { undoChangeProperty(P_LAYOUT_BREAK, t); }
void Hairpin::undoSetDynRange(Dynamic::Range val) { undoChangeProperty(P_ID::DYNAMIC_RANGE, int(val)); }
void Volta::reset() { if (lineWidthStyle == PropertyStyle::UNSTYLED) undoChangeProperty(P_ID::LINE_WIDTH, propertyDefault(P_ID::LINE_WIDTH), PropertyStyle::STYLED); TextLineBase::reset(); }
void Marker::undoSetLabel(const QString& s) { undoChangeProperty(P_ID::LABEL, s); }
void TempoText::undoSetTempo(qreal v) { undoChangeProperty(P_ID::TEMPO, v); }
void Volta::undoSetVoltaType(Type val) { undoChangeProperty(P_ID::VOLTA_TYPE, int(val)); }
void TempoText::undoSetFollowText(bool v) { undoChangeProperty(P_ID::TEMPO_FOLLOW_TEXT, v); }