Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "undoablecommand.h"
24 :
25 : #include "dom/chord.h"
26 : #include "dom/fret.h"
27 : #include "dom/harmony.h"
28 : #include "dom/note.h"
29 :
30 : using namespace mu::engraving;
31 :
32 19029 : std::vector<EngravingObject*> mu::engraving::compoundObjects(EngravingObject* object)
33 : {
34 19029 : std::vector<EngravingObject*> objects;
35 :
36 19029 : if (object->isChord()) {
37 3700 : const Chord* chord = toChord(object);
38 9579 : for (const Note* note : chord->notes()) {
39 17639 : for (Note* compoundNote : note->compoundNotes()) {
40 11760 : objects.push_back(compoundNote);
41 5879 : }
42 : }
43 15329 : } else if (object->isNote()) {
44 1557 : const Note* note = toNote(object);
45 4671 : for (Note* compoundNote : note->compoundNotes()) {
46 3114 : objects.push_back(compoundNote);
47 1557 : }
48 13772 : } else if (object->isFretDiagram()) {
49 31 : const FretDiagram* fret = toFretDiagram(object);
50 31 : if (Harmony* harmony = fret->harmony()) {
51 28 : objects.push_back(harmony);
52 : }
53 : }
54 :
55 19029 : objects.push_back(object);
56 :
57 19029 : return objects;
58 0 : }
59 :
60 1049 : void UndoableCommand::undo()
61 : {
62 1049 : flip();
63 1049 : }
64 :
65 6637 : void UndoableCommand::redo()
66 : {
67 6637 : flip();
68 6637 : }
|