From 46833b89bdccbf8a88680143c2152708dc0c20e0 Mon Sep 17 00:00:00 2001 From: RomanPudashkin Date: Thu, 25 Feb 2021 16:15:29 +0200 Subject: [PATCH] implemented resequence-rehearsal-marks action --- src/appshell/view/appmenumodel.cpp | 2 +- src/notation/inotationinteraction.h | 1 + src/notation/internal/notationactioncontroller.cpp | 11 +++++++++++ src/notation/internal/notationactioncontroller.h | 1 + src/notation/internal/notationactions.cpp | 5 +++++ src/notation/internal/notationinteraction.cpp | 9 +++++++++ src/notation/internal/notationinteraction.h | 1 + 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/appshell/view/appmenumodel.cpp b/src/appshell/view/appmenumodel.cpp index 95789c1c81..be8f817b37 100644 --- a/src/appshell/view/appmenumodel.cpp +++ b/src/appshell/view/appmenumodel.cpp @@ -332,7 +332,7 @@ MenuItem AppMenuModel::toolsItem() makeSeparator(), makeAction("pitch-spell"), makeAction("reset-groupings"), - makeAction("resequence-rehearsal-marks"), // need implement + makeAction("resequence-rehearsal-marks"), makeAction("unroll-repeats"), // need implement makeSeparator(), makeAction("copy-lyrics-to-clipboard"), // need implement diff --git a/src/notation/inotationinteraction.h b/src/notation/inotationinteraction.h index 23768447ae..e6b76c206e 100644 --- a/src/notation/inotationinteraction.h +++ b/src/notation/inotationinteraction.h @@ -131,6 +131,7 @@ public: virtual void spellPitches() = 0; virtual void regroupNotesAndRests() = 0; + virtual void resequenceRehearsalMarks() = 0; virtual void resetToDefault(ResettableValueType type) = 0; diff --git a/src/notation/internal/notationactioncontroller.cpp b/src/notation/internal/notationactioncontroller.cpp index 81a558f652..5da94769c4 100644 --- a/src/notation/internal/notationactioncontroller.cpp +++ b/src/notation/internal/notationactioncontroller.cpp @@ -216,6 +216,7 @@ void NotationActionController::init() dispatcher()->reg(this, "slash-rhythm", this, &NotationActionController::replaceSelectedNotesWithSlashes); dispatcher()->reg(this, "pitch-spell", this, &NotationActionController::spellPitches); dispatcher()->reg(this, "reset-groupings", this, &NotationActionController::regroupNotesAndRests); + dispatcher()->reg(this, "resequence-rehearsal-marks", this, &NotationActionController::resequenceRehearsalMarks); for (int i = MIN_NOTES_INTERVAL; i <= MAX_NOTES_INTERVAL; ++i) { if (isNotesIntervalValid(i)) { @@ -994,6 +995,16 @@ void NotationActionController::regroupNotesAndRests() interaction->regroupNotesAndRests(); } +void NotationActionController::resequenceRehearsalMarks() +{ + auto interaction = currentNotationInteraction(); + if (!interaction) { + return; + } + + interaction->resequenceRehearsalMarks(); +} + void NotationActionController::addStretch(qreal value) { auto interaction = currentNotationInteraction(); diff --git a/src/notation/internal/notationactioncontroller.h b/src/notation/internal/notationactioncontroller.h index 3753d080d4..039c3f0ea1 100644 --- a/src/notation/internal/notationactioncontroller.h +++ b/src/notation/internal/notationactioncontroller.h @@ -110,6 +110,7 @@ private: void replaceSelectedNotesWithSlashes(); void spellPitches(); void regroupNotesAndRests(); + void resequenceRehearsalMarks(); void resetState(); void resetStretch(); diff --git a/src/notation/internal/notationactions.cpp b/src/notation/internal/notationactions.cpp index e2ca5a7ee4..f81be06277 100644 --- a/src/notation/internal/notationactions.cpp +++ b/src/notation/internal/notationactions.cpp @@ -219,6 +219,11 @@ const ActionList NotationActions::m_actions = { QT_TRANSLATE_NOOP("action", "Regroup Rhythms"), QT_TRANSLATE_NOOP("action", "Combine rests and tied notes from selection and resplit at rhythmical") ), + ActionItem("resequence-rehearsal-marks", + ShortcutContext::NotationActive, + QT_TRANSLATE_NOOP("action", "Resequence Rehearsal Marks"), + QT_TRANSLATE_NOOP("action", "Resequence rehearsal marks") + ), ActionItem("parts", ShortcutContext::NotationActive, QT_TRANSLATE_NOOP("action", "Parts"), diff --git a/src/notation/internal/notationinteraction.cpp b/src/notation/internal/notationinteraction.cpp index 9469f23b95..92c3ea906e 100644 --- a/src/notation/internal/notationinteraction.cpp +++ b/src/notation/internal/notationinteraction.cpp @@ -2458,6 +2458,15 @@ void NotationInteraction::regroupNotesAndRests() notifyAboutNotationChanged(); } +void NotationInteraction::resequenceRehearsalMarks() +{ + startEdit(); + score()->cmdResequenceRehearsalMarks(); + apply(); + + notifyAboutNotationChanged(); +} + void NotationInteraction::resetToDefault(ResettableValueType type) { switch (type) { diff --git a/src/notation/internal/notationinteraction.h b/src/notation/internal/notationinteraction.h index 724934467b..088df6f0c2 100644 --- a/src/notation/internal/notationinteraction.h +++ b/src/notation/internal/notationinteraction.h @@ -148,6 +148,7 @@ public: void spellPitches() override; void regroupNotesAndRests() override; + void resequenceRehearsalMarks() override; void resetToDefault(ResettableValueType type) override;