MuseScore/libmscore/undo.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

1516 lines
37 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
2017-05-19 09:06:41 +02:00
// Copyright (C) 2002-2017 Werner Schweer
2012-05-26 14:26:10 +02:00
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __UNDO_H__
#define __UNDO_H__
/**
\file
Definition of undo-releated classes and structs.
*/
#include "spatium.h"
#include "mscore.h"
#include "sig.h"
#include "tempo.h"
#include "input.h"
#include "style.h"
#include "key.h"
#include "select.h"
#include "instrument.h"
#include "pitchvalue.h"
#include "timesig.h"
2012-11-19 10:08:15 +01:00
#include "noteevent.h"
#include "synthesizerstate.h"
#include "dynamic.h"
2015-08-04 19:53:54 +02:00
#include "staff.h"
2014-04-30 10:08:38 +02:00
#include "stafftype.h"
2014-05-08 17:59:24 +02:00
#include "cleflist.h"
#include "note.h"
#include "chord.h"
#include "drumset.h"
#include "rest.h"
#include "fret.h"
2012-05-26 14:26:10 +02:00
#include "audio/midi/midipatch.h"
Q_DECLARE_LOGGING_CATEGORY(undoRedo);
2016-03-18 09:29:16 +01:00
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class ElementList;
class Element;
class Instrument;
class System;
class Measure;
class Segment;
class Staff;
class Part;
class Volta;
class Score;
class Note;
class Chord;
class ChordRest;
class Harmony;
class SlurTie;
2016-12-12 12:02:18 +01:00
class MStaff;
2012-05-26 14:26:10 +02:00
class MeasureBase;
class Dynamic;
class Selection;
class Text;
fix #275313: rework mixer ui 2 Moving PartEditBase into separate file. Creating new files for building mixer. Creating art assets/UI design for new components. Styling the track control. Adding track area. Separating out score from update. Creating instances of mixer UI. Creating part per voice now. Can click on tracks to select them now. Can now switch bwtewwn tracks. Setting patch channel now. Setting enabled off when no track selected. Improving slider ui. Turning Channel into a class and adding listener to it. Somewhat stabalized sharing track objects between interfaces. Can now apply volume changes to both expanded and collapsed tracks. Pan knob is now working. Encapsulating the rest of the fields in Channel. Mute and solo now working. Reverb and chorus now working. Drumkit checkbox now working. Port and channel somewhat working. Adding support for colors per track. Part name change now working. Separating out MixerTrackItem Finishing moving MixerTrackItem to new file. Cleaning up code. Moving PartEditBase into separate file. Creating new files for building mixer. Creating art assets/UI design for new components. Styling the track control. Adding track area. Separating out score from update. Creating instances of mixer UI. Creating part per voice now. Can click on tracks to select them now. Can now switch bwtewwn tracks. Setting patch channel now. Setting enabled off when no track selected. Improving slider ui. Turning Channel into a class and adding listener to it. Somewhat stabalized sharing track objects between interfaces. Can now apply volume changes to both expanded and collapsed tracks. Pan knob is now working. Encapsulating the rest of the fields in Channel. Mute and solo now working. Reverb and chorus now working. Drumkit checkbox now working. Port and channel somewhat working. Adding support for colors per track. Part name change now working. Separating out MixerTrackItem Finishing moving MixerTrackItem to new file. Cleaning up code. Setting color in collapsed mode now affects all channels. Using shared_ptr to track MixerTrackItem. Part changes now affect all instruments. Creating new track UI object to handle parts. Using shard_ptr to track MixerTrackItem objects. setting port and channel data now. Changing to horizontal layout. Fixing knob display. Chaning track control appearance. Setting init slider window size. Switchong back to vertical orientation. Fixing a few UI bugs in the slider. Tracks now left aligned. Moving details panel above mixer. Now changing track selection when user clicks on sliders. Pan and volume controls now reflect track color. Showing volume and pan values in tooltips. Creating a new slider control for mixer. Switching Channel's volume, pan, reverb and chorus and chaning them to doubles with a decimal range. No longer writing out vol, pan, chor, reverb when at default values. Nolonger writing vol, pan, chorus, reverb as controler values in output file. Now testing against default values on write. More export fixes. Manually editing test files to reflect new channel parameters. Manually editing more test files to reflect new channel parameters. Manually editing more test files to reflect new channel parameters. More test changes to make Travis happy. More test changes to make Travis happy. Importing MusicXML now matches new volume, pan ranges. Changing range of pan. Fixing a few bugs with calculating MIDI. Altering test files for Travis. fix #275313: rework-mixer-ui-2 Moving PartEditBase into separate file. Creating new files for building mixer. Creating art assets/UI design for new components. Styling the track control. Adding track area. Separating out score from update. Creating instances of mixer UI. Creating part per voice now. Can click on tracks to select them now. Can now switch bwtewwn tracks. Setting patch channel now. Setting enabled off when no track selected. Improving slider ui. Turning Channel into a class and adding listener to it. Somewhat stabalized sharing track objects between interfaces. Can now apply volume changes to both expanded and collapsed tracks. Pan knob is now working. Encapsulating the rest of the fields in Channel. Mute and solo now working. Reverb and chorus now working. Drumkit checkbox now working. Port and channel somewhat working. Adding support for colors per track. Part name change now working. Separating out MixerTrackItem Finishing moving MixerTrackItem to new file. Cleaning up code. Moving PartEditBase into separate file. Creating new files for building mixer. Creating art assets/UI design for new components. Styling the track control. Adding track area. Separating out score from update. Creating instances of mixer UI. Creating part per voice now. Can click on tracks to select them now. Can now switch bwtewwn tracks. Setting patch channel now. Setting enabled off when no track selected. Improving slider ui. Turning Channel into a class and adding listener to it. Somewhat stabalized sharing track objects between interfaces. Can now apply volume changes to both expanded and collapsed tracks. Pan knob is now working. Encapsulating the rest of the fields in Channel. Mute and solo now working. Reverb and chorus now working. Drumkit checkbox now working. Port and channel somewhat working. Adding support for colors per track. Part name change now working. Separating out MixerTrackItem Finishing moving MixerTrackItem to new file. Cleaning up code. Setting color in collapsed mode now affects all channels. Using shared_ptr to track MixerTrackItem. Part changes now affect all instruments. Creating new track UI object to handle parts. Using shard_ptr to track MixerTrackItem objects. setting port and channel data now. Changing to horizontal layout. Fixing knob display. Chaning track control appearance. Setting init slider window size. Switchong back to vertical orientation. Fixing a few UI bugs in the slider. Tracks now left aligned. Moving details panel above mixer. Now changing track selection when user clicks on sliders. Pan and volume controls now reflect track color. Showing volume and pan values in tooltips. Creating a new slider control for mixer. Switching Channel's volume, pan, reverb and chorus and chaning them to doubles with a decimal range. No longer writing out vol, pan, chor, reverb when at default values. Nolonger writing vol, pan, chorus, reverb as controler values in output file. Now testing against default values on write. More export fixes. Manually editing test files to reflect new channel parameters. Manually editing more test files to reflect new channel parameters. Manually editing more test files to reflect new channel parameters. More test changes to make Travis happy. More test changes to make Travis happy. Importing MusicXML now matches new volume, pan ranges. Changing range of pan. Fixing a few bugs with calculating MIDI. Altering test files for Travis. Restoring the volume, pan, chorus, reverb to original char data type & range. UI now shows different 'user friendly' ranges. Overwriting tests with versions from master. mtest/libmscore/compat114/clef_missing_first-ref.mscx mtest/libmscore/compat114/hor_frame_and_mmrest-ref.mscx mtest/musicxml/io/testInstrumentChangeMIDIportExport_ref.xml mtest/musicxml/io/testUninitializedDivisions_ref.xml Restoring test files to original state. Restoring test files to original state. Restoring old values for importing files. Restoring part methods. mtest/importmidi/simplify_8th_dotted_no_staccato.mscx mtest/libmscore/compat114/clef_missing_first-ref.mscx mtest/libmscore/compat114/hor_frame_and_mmrest-ref.mscx mtest/musicxml/io/testInstrumentChangeMIDIportExport_ref.xml mtest/musicxml/io/testUninitializedDivisions_ref.xml Rearranging UI components for better feel. Improving UI. Fixed crash when changing part name. Adding support for two lighting modes. Showing part name over channel expansion. Adding master gain control to mixer. Changing color of gain slider. Adapting to latest source in main. Changing master gain slider to use decibel calculation. CSS now set on tracks whenever a Paint event received. Restoring mixer slider values to refect MIDI ranges. Fixing crash when drumkit checked. Fixing crash when closing score. Fixing alignment in mixer details. Tweaking UI for better appearance.
2018-11-13 18:43:19 +01:00
class Channel;
2012-05-26 14:26:10 +02:00
class Tuplet;
class KeySig;
class TimeSig;
class Clef;
class Image;
class Bend;
class TremoloBar;
class NoteEvent;
class SlurSegment;
class InstrumentChange;
class Box;
class Spanner;
class BarLine;
2013-09-05 16:37:49 +02:00
enum class ClefType : signed char;
enum class PlayEventType : char;
2016-12-12 12:15:53 +01:00
class Excerpt;
class EditData;
2012-05-26 14:26:10 +02:00
2016-03-18 09:29:16 +01:00
#define UNDO_NAME(a) virtual const char* name() const override { return a; }
2012-05-26 14:26:10 +02:00
2014-11-17 13:06:34 +01:00
enum class LayoutMode : char;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// UndoCommand
//---------------------------------------------------------
class UndoCommand
{
QList<UndoCommand*> childList;
2020-05-26 15:54:26 +02:00
2012-11-19 10:08:15 +01:00
protected:
2017-05-19 09:06:41 +02:00
virtual void flip(EditData*) {}
void appendChildren(UndoCommand*);
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
public:
enum class Filter {
TextEdit,
AddElement,
AddElementLinked,
Link,
RemoveElement,
RemoveElementLinked,
ChangePropertyLinked,
};
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
virtual ~UndoCommand();
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*);
virtual void redo(EditData*);
2012-05-26 14:26:10 +02:00
void appendChild(UndoCommand* cmd) { childList.append(cmd); }
UndoCommand* removeChild() { return childList.takeLast(); }
int childCount() const { return childList.size(); }
void unwind();
const QList<UndoCommand*>& commands() const { return childList; }
2014-11-06 11:34:42 +01:00
virtual void cleanup(bool undo);
2016-03-24 12:39:18 +01:00
// #ifndef QT_NO_DEBUG
2016-03-18 09:29:16 +01:00
virtual const char* name() const { return "UndoCommand"; }
2016-03-24 12:39:18 +01:00
// #endif
virtual bool isFiltered(Filter, const Element* /* target */) const { return false; }
bool hasFilteredChildren(Filter, const Element* target) const;
bool hasUnfilteredChildren(const std::vector<Filter>& filters, const Element* target) const;
void filterChildren(UndoCommand::Filter f, Element* target);
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// UndoMacro
// A root element for undo macro which is stored
// directly in UndoStack
//---------------------------------------------------------
class UndoMacro : public UndoCommand
{
struct SelectionInfo {
std::vector<Element*> elements;
Fraction tickStart;
Fraction tickEnd;
int staffStart = -1;
int staffEnd = -1;
bool isValid() const { return !elements.empty() || staffStart != -1; }
};
InputState undoInputState;
InputState redoInputState;
SelectionInfo undoSelectionInfo;
SelectionInfo redoSelectionInfo;
Score* score;
static void fillSelectionInfo(SelectionInfo&, const Selection&);
static void applySelectionInfo(const SelectionInfo&, Selection&);
public:
UndoMacro(Score* s);
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
bool empty() const { return childCount() == 0; }
void append(UndoMacro&& other);
UNDO_NAME("UndoMacro");
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// UndoStack
//---------------------------------------------------------
class UndoStack
{
UndoMacro* curCmd;
QList<UndoMacro*> list;
2018-07-23 19:50:53 +02:00
std::vector<int> stateList;
int nextState;
int cleanState;
2012-05-26 14:26:10 +02:00
int curIdx;
2020-05-26 15:54:26 +02:00
void remove(int idx);
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
public:
UndoStack();
~UndoStack();
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
bool active() const { return curCmd != 0; }
void beginMacro(Score*);
2012-05-26 14:26:10 +02:00
void endMacro(bool rollback);
2017-05-19 09:06:41 +02:00
void push(UndoCommand*, EditData*); // push & execute
2013-02-26 15:50:36 +01:00
void push1(UndoCommand*);
2012-05-26 14:26:10 +02:00
void pop();
void setClean();
bool canUndo() const { return curIdx > 0; }
bool canRedo() const { return curIdx < list.size(); }
2018-07-23 19:50:53 +02:00
int state() const { return stateList[curIdx]; }
bool isClean() const { return cleanState == state(); }
2018-05-25 09:26:38 +02:00
int getCurIdx() const { return curIdx; }
2017-03-31 13:03:15 +02:00
bool empty() const { return !canUndo() && !canRedo(); }
UndoMacro* current() const { return curCmd; }
UndoMacro* last() const { return curIdx > 0 ? list[curIdx - 1] : 0; }
UndoMacro* prev() const { return curIdx > 1 ? list[curIdx - 2] : 0; }
2017-05-19 09:06:41 +02:00
void undo(EditData*);
void redo(EditData*);
void rollback();
void reopen();
2020-05-26 15:54:26 +02:00
void mergeCommands(int startIdx);
void cleanRedoStack() { remove(curIdx); }
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// InsertPart
//---------------------------------------------------------
class InsertPart : public UndoCommand
{
Part* part;
int idx;
public:
InsertPart(Part* p, int i);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("InsertPart")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// RemovePart
//---------------------------------------------------------
class RemovePart : public UndoCommand
{
Part* part;
int idx;
public:
RemovePart(Part*, int idx);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("RemovePart")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// InsertStaff
//---------------------------------------------------------
class InsertStaff : public UndoCommand
{
Staff* staff;
2014-08-11 15:25:55 +02:00
int ridx;
2012-05-26 14:26:10 +02:00
public:
InsertStaff(Staff*, int idx);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("InsertStaff")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// RemoveStaff
//---------------------------------------------------------
class RemoveStaff : public UndoCommand
{
Staff* staff;
2014-08-11 15:25:55 +02:00
int ridx;
2012-05-26 14:26:10 +02:00
public:
2014-08-11 15:25:55 +02:00
RemoveStaff(Staff*);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("RemoveStaff")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// InsertMStaff
//---------------------------------------------------------
class InsertMStaff : public UndoCommand
{
Measure* measure;
MStaff* mstaff;
int idx;
public:
InsertMStaff(Measure*, MStaff*, int);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("InsertMStaff")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// RemoveMStaff
//---------------------------------------------------------
class RemoveMStaff : public UndoCommand
{
Measure* measure;
MStaff* mstaff;
int idx;
public:
RemoveMStaff(Measure*, MStaff*, int);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("RemoveMStaff")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// InsertStaves
//---------------------------------------------------------
class InsertStaves : public UndoCommand
{
Measure* measure;
int a;
int b;
public:
InsertStaves(Measure*, int, int);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("InsertStaves")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// RemoveStaves
//---------------------------------------------------------
class RemoveStaves : public UndoCommand
{
Measure* measure;
int a;
int b;
public:
RemoveStaves(Measure*, int, int);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("RemoveStaves")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// SortStaves
//---------------------------------------------------------
class SortStaves : public UndoCommand
{
Score* score;
QList<int> list;
QList<int> rlist;
public:
SortStaves(Score*, QList<int>);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("SortStaves")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangePitch
//---------------------------------------------------------
class ChangePitch : public UndoCommand
{
Note* note;
int pitch;
int tpc1;
int tpc2;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangePitch(Note* note, int pitch, int tpc1, int tpc2);
UNDO_NAME("ChangePitch")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeFretting
//---------------------------------------------------------
class ChangeFretting : public UndoCommand
{
Note* note;
int pitch;
int string;
int fret;
int tpc1;
int tpc2;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
public:
ChangeFretting(Note* note, int pitch, int string, int fret, int tpc1, int tpc2);
UNDO_NAME("ChangeFretting")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeKeySig
//---------------------------------------------------------
class ChangeKeySig : public UndoCommand
{
KeySig* keysig;
KeySigEvent ks;
bool showCourtesy;
bool evtInStaff;
2012-05-26 14:26:10 +02:00
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeKeySig(KeySig* k, KeySigEvent newKeySig, bool sc, bool addEvtToStaff = true);
UNDO_NAME("ChangeKeySig")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeMeasureLen
//---------------------------------------------------------
class ChangeMeasureLen : public UndoCommand
{
Measure* measure;
Fraction len;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeMeasureLen(Measure*, Fraction);
UNDO_NAME("ChangeMeasureLen")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeElement
//---------------------------------------------------------
class ChangeElement : public UndoCommand
{
Element* oldElement;
Element* newElement;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeElement(Element* oldElement, Element* newElement);
UNDO_NAME("ChangeElement")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// TransposeHarmony
//---------------------------------------------------------
class TransposeHarmony : public UndoCommand
{
Harmony* harmony;
int rootTpc, baseTpc;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
TransposeHarmony(Harmony*, int rootTpc, int baseTpc);
UNDO_NAME("TransposeHarmony")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ExchangeVoice
//---------------------------------------------------------
class ExchangeVoice : public UndoCommand
{
Measure* measure;
int val1, val2;
2014-08-29 10:35:17 +02:00
int staff;
2012-05-26 14:26:10 +02:00
public:
2016-07-31 15:23:11 +02:00
ExchangeVoice(Measure*,int val1, int val2, int staff);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("ExchangeVoice")
2012-05-26 14:26:10 +02:00
};
2016-07-31 15:23:11 +02:00
//---------------------------------------------------------
// CloneVoice
//---------------------------------------------------------
class CloneVoice : public UndoCommand
{
Segment* sf;
Fraction lTick;
2016-07-31 15:23:11 +02:00
Segment* d; //Destination
int strack, dtrack;
int otrack;
bool linked;
2016-07-25 23:22:35 +02:00
bool first = true; //first redo
2016-07-31 15:23:11 +02:00
public:
CloneVoice(Segment* sf, const Fraction& lTick, Segment* d, int strack, int dtrack, int otrack, bool linked = true);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
2016-07-31 15:23:11 +02:00
UNDO_NAME("CloneVoice")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeInstrumentShort
//---------------------------------------------------------
class ChangeInstrumentShort : public UndoCommand
{
Part* part;
Fraction tick;
2014-02-11 14:27:44 +01:00
QList<StaffName> text;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeInstrumentShort(const Fraction&, Part*, QList<StaffName>);
UNDO_NAME("ChangeInstrumentShort")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeInstrumentLong
//---------------------------------------------------------
class ChangeInstrumentLong : public UndoCommand
{
Part* part;
Fraction tick;
2014-02-11 14:27:44 +01:00
QList<StaffName> text;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2014-02-11 14:27:44 +01:00
const QList<StaffName>& longNames() const;
ChangeInstrumentLong(const Fraction&, Part*, QList<StaffName>);
UNDO_NAME("ChangeInstrumentLong")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeBracketType
//---------------------------------------------------------
class ChangeBracketType : public UndoCommand
{
Bracket* bracket;
BracketType type;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
public:
ChangeBracketType(Bracket*, BracketType type);
UNDO_NAME("ChangeBracketType")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// AddElement
//---------------------------------------------------------
class AddElement : public UndoCommand
{
Element* element;
2014-04-15 17:01:41 +02:00
void endUndoRedo(bool) const;
2017-05-19 09:06:41 +02:00
void undo(EditData*) override;
void redo(EditData*) override;
2014-04-15 14:18:56 +02:00
2012-05-26 14:26:10 +02:00
public:
AddElement(Element*);
Element* getElement() const { return element; }
2014-11-06 11:34:42 +01:00
virtual void cleanup(bool);
2016-03-18 09:29:16 +01:00
virtual const char* name() const override;
bool isFiltered(UndoCommand::Filter f, const Element* target) const override;
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// RemoveElement
//---------------------------------------------------------
class RemoveElement : public UndoCommand
{
Element* element;
public:
RemoveElement(Element*);
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
2014-11-06 11:34:42 +01:00
virtual void cleanup(bool);
2016-03-18 09:29:16 +01:00
virtual const char* name() const override;
bool isFiltered(UndoCommand::Filter f, const Element* target) const override;
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// EditText
//---------------------------------------------------------
class EditText : public UndoCommand
{
Text* text;
QString oldText;
//int undoLevel;
2012-05-26 14:26:10 +02:00
void undoRedo();
public:
2020-05-29 18:47:27 +02:00
EditText(Text* t, const QString& ot, int /*l*/)
: text(t), oldText(ot) /*, undoLevel(l)*/ {}
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("EditText")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangePatch
//---------------------------------------------------------
class ChangePatch : public UndoCommand
{
Score* score;
2012-05-26 14:26:10 +02:00
Channel* channel;
MidiPatch patch;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangePatch(Score* s, Channel* c, const MidiPatch* pt)
: score(s), channel(c), patch(*pt) {}
2015-06-04 20:43:37 +02:00
UNDO_NAME("ChangePatch")
2012-05-26 14:26:10 +02:00
};
2018-12-22 11:43:23 +01:00
//---------------------------------------------------------
// SetUserBankController
//---------------------------------------------------------
class SetUserBankController : public UndoCommand
{
Channel* channel;
bool val;
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
SetUserBankController(Channel* c, bool v)
: channel(c), val(v) {}
2018-12-22 11:43:23 +01:00
UNDO_NAME("SetUserBankController")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeStaff
//---------------------------------------------------------
class ChangeStaff : public UndoCommand
{
2015-08-04 19:53:54 +02:00
Staff* staff;
bool invisible;
ClefTypeList clefType;
2015-08-04 19:53:54 +02:00
qreal userDist;
Staff::HideMode hideMode;
bool showIfEmpty;
bool cutaway;
bool hideSystemBarLine;
2015-01-05 17:55:06 +01:00
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeStaff(Staff*, bool invisible, ClefTypeList _clefType, qreal userDist, Staff::HideMode _hideMode,
2015-08-04 19:53:54 +02:00
bool _showIfEmpty, bool _cutaway, bool hide);
UNDO_NAME("ChangeStaff")
2012-05-26 14:26:10 +02:00
};
2014-04-30 10:08:38 +02:00
//---------------------------------------------------------
// ChangeStaffType
//---------------------------------------------------------
class ChangeStaffType : public UndoCommand
{
Staff* staff;
StaffType staffType;
2014-04-30 10:08:38 +02:00
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2014-04-30 10:08:38 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeStaffType(Staff* s, const StaffType& t)
: staff(s), staffType(t) {}
2014-04-30 10:08:38 +02:00
UNDO_NAME("ChangeStaffType")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangePart
//---------------------------------------------------------
class ChangePart : public UndoCommand
{
Part* part;
Instrument* instrument;
2012-05-26 14:26:10 +02:00
QString partName;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangePart(Part*, Instrument*, const QString& name);
UNDO_NAME("ChangePart")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeStyle
//---------------------------------------------------------
class ChangeStyle : public UndoCommand
{
Score* score;
MStyle style;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeStyle(Score*, const MStyle&);
UNDO_NAME("ChangeStyle")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeStyleVal
//---------------------------------------------------------
class ChangeStyleVal : public UndoCommand
{
Score* score;
2018-03-27 15:36:00 +02:00
Sid idx;
QVariant value;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangeStyleVal(Score* s, Sid i, const QVariant& v)
: score(s), idx(i), value(v) {}
UNDO_NAME("ChangeStyleVal")
};
//---------------------------------------------------------
// ChangePageNumberOffset
//---------------------------------------------------------
class ChangePageNumberOffset : public UndoCommand
{
Score* score;
int pageOffset;
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangePageNumberOffset(Score* s, int po)
: score(s), pageOffset(po) {}
UNDO_NAME("ChangePageNumberOffset")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeChordStaffMove
//---------------------------------------------------------
class ChangeChordStaffMove : public UndoCommand
{
ChordRest* chordRest;
2012-05-26 14:26:10 +02:00
int staffMove;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeChordStaffMove(ChordRest* cr, int);
UNDO_NAME("ChangeChordStaffMove")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeVelocity
//---------------------------------------------------------
class ChangeVelocity : public UndoCommand
{
Note* note;
Note::ValueType veloType;
2012-05-26 14:26:10 +02:00
int veloOffset;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeVelocity(Note*, Note::ValueType, int);
UNDO_NAME("ChangeVelocity")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeMStaffProperties
//---------------------------------------------------------
class ChangeMStaffProperties : public UndoCommand
{
2016-12-12 14:55:35 +01:00
Measure* measure;
int staffIdx;
2012-05-26 14:26:10 +02:00
bool visible;
bool stemless;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeMStaffProperties(Measure*, int staffIdx, bool visible, bool stemless);
UNDO_NAME("ChangeMStaffProperties")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// InsertRemoveMeasures
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class InsertRemoveMeasures : public UndoCommand
{
MeasureBase* fm;
MeasureBase* lm;
2012-05-26 14:26:10 +02:00
static std::vector<Clef*> getCourtesyClefs(Measure* m);
protected:
void removeMeasures();
void insertMeasures();
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
InsertRemoveMeasures(MeasureBase* _fm, MeasureBase* _lm)
: fm(_fm), lm(_lm) {}
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override = 0;
virtual void redo(EditData*) override = 0;
};
//---------------------------------------------------------
// RemoveMeasures
//---------------------------------------------------------
class RemoveMeasures : public InsertRemoveMeasures
{
public:
2020-05-29 18:47:27 +02:00
RemoveMeasures(MeasureBase* m1, MeasureBase* m2)
: InsertRemoveMeasures(m1, m2) {}
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override { insertMeasures(); }
virtual void redo(EditData*) override { removeMeasures(); }
UNDO_NAME("RemoveMeasures")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// InsertMeasures
//---------------------------------------------------------
class InsertMeasures : public InsertRemoveMeasures
{
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
InsertMeasures(MeasureBase* m1, MeasureBase* m2)
: InsertRemoveMeasures(m1, m2) {}
2017-05-19 09:06:41 +02:00
virtual void redo(EditData*) override { insertMeasures(); }
virtual void undo(EditData*) override { removeMeasures(); }
UNDO_NAME("InsertMeasures")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// AddExcerpt
//---------------------------------------------------------
class AddExcerpt : public UndoCommand
{
2016-10-10 18:37:28 +02:00
Excerpt* excerpt;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
AddExcerpt(Excerpt* ex)
: excerpt(ex) {}
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("AddExcerpt")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// RemoveExcerpt
//---------------------------------------------------------
class RemoveExcerpt : public UndoCommand
{
2016-10-10 18:37:28 +02:00
Excerpt* excerpt;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
RemoveExcerpt(Excerpt* ex)
: excerpt(ex) {}
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
UNDO_NAME("RemoveExcerpt")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// SwapExcerpt
//---------------------------------------------------------
class SwapExcerpt : public UndoCommand
{
MasterScore* score;
int pos1;
int pos2;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2016-10-10 18:37:28 +02:00
public:
2020-05-29 18:47:27 +02:00
SwapExcerpt(MasterScore* s, int p1, int p2)
: score(s), pos1(p1), pos2(p2) {}
UNDO_NAME("SwapExcerpt")
};
2016-10-10 18:37:28 +02:00
//---------------------------------------------------------
// ChangeExcerptTitle
//---------------------------------------------------------
class ChangeExcerptTitle : public UndoCommand
{
Excerpt* excerpt;
QString title;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2016-10-10 18:37:28 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeExcerptTitle(Excerpt* x, const QString& t)
: excerpt(x), title(t) {}
2016-10-10 18:37:28 +02:00
UNDO_NAME("ChangeExcerptTitle")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeBend
//---------------------------------------------------------
class ChangeBend : public UndoCommand
{
Bend* bend;
QList<PitchValue> points;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeBend(Bend* b, QList<PitchValue> p)
: bend(b), points(p) {}
UNDO_NAME("ChangeBend")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeTremoloBar
//---------------------------------------------------------
class ChangeTremoloBar : public UndoCommand
{
TremoloBar* bend;
QList<PitchValue> points;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeTremoloBar(TremoloBar* b, QList<PitchValue> p)
: bend(b), points(p) {}
UNDO_NAME("ChangeTremoloBar")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeNoteEvents
//---------------------------------------------------------
class ChangeNoteEvents : public UndoCommand
{
//Chord* chord;
2012-05-26 14:26:10 +02:00
QList<NoteEvent*> events;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeNoteEvents(Chord* /*n*/, const QList<NoteEvent*>& l)
: /*chord(n),*/ events(l) {}
UNDO_NAME("ChangeNoteEvents")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeNoteEventList
//---------------------------------------------------------
class ChangeNoteEventList : public UndoCommand
{
Ms::Note* note;
NoteEventList newEvents;
PlayEventType newPetype;
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangeNoteEventList(Ms::Note* n, NoteEventList& ne)
: note(n), newEvents(ne), newPetype(PlayEventType::User) {}
UNDO_NAME("ChangeNoteEventList")
};
//---------------------------------------------------------
// ChangeChordPlayEventType
//---------------------------------------------------------
class ChangeChordPlayEventType : public UndoCommand
{
Ms::Chord* chord;
Ms::PlayEventType petype;
QList<NoteEventList> events;
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangeChordPlayEventType(Chord* c, Ms::PlayEventType pet)
: chord(c), petype(pet)
{
events = c->getNoteEventLists();
}
2020-05-29 18:47:27 +02:00
UNDO_NAME("ChangeChordPlayEventType")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeInstrument
// change instrument in an InstrumentChange element
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class ChangeInstrument : public UndoCommand
{
InstrumentChange* is;
Instrument* instrument;
2012-05-26 14:26:10 +02:00
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeInstrument(InstrumentChange* _is, Instrument* i)
: is(_is), instrument(i) {}
UNDO_NAME("ChangeInstrument")
2012-05-26 14:26:10 +02:00
};
2012-09-20 11:35:34 +02:00
extern void updateNoteLines(Segment*, int track);
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// SwapCR
//---------------------------------------------------------
class SwapCR : public UndoCommand
{
ChordRest* cr1;
ChordRest* cr2;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
SwapCR(ChordRest* a, ChordRest* b)
: cr1(a), cr2(b) {}
UNDO_NAME("SwapCR")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeClefType
//---------------------------------------------------------
class ChangeClefType : public UndoCommand
{
Clef* clef;
ClefType concertClef;
ClefType transposingClef;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
ChangeClefType(Clef*, ClefType cl, ClefType tc);
UNDO_NAME("ChangeClef")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// MoveStaff
//---------------------------------------------------------
2019-10-23 23:40:03 +02:00
#if 0 // commented out in mscore/instrwidget.cpp, not used anywhere else
2012-05-26 14:26:10 +02:00
class MoveStaff : public UndoCommand
{
Staff* staff;
Part* part;
int rstaff;
2020-05-26 15:54:26 +02:00
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
MoveStaff(Staff* s, Part* p, int idx)
: staff(s), part(p), rstaff(idx) {}
UNDO_NAME("MoveStaff")
2012-05-26 14:26:10 +02:00
};
2019-10-23 23:40:03 +02:00
#endif
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeProperty
//---------------------------------------------------------
class ChangeProperty : public UndoCommand
{
protected:
ScoreElement* element;
2018-03-27 15:36:00 +02:00
Pid id;
2012-05-26 14:26:10 +02:00
QVariant property;
PropertyFlags flags;
2012-05-26 14:26:10 +02:00
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeProperty(ScoreElement* e, Pid i, const QVariant& v, PropertyFlags ps = PropertyFlags::NOSTYLE)
: element(e), id(i), property(v), flags(ps) {}
2018-03-27 15:36:00 +02:00
Pid getId() const { return id; }
ScoreElement* getElement() const { return element; }
QVariant data() const { return property; }
UNDO_NAME("ChangeProperty")
bool isFiltered(UndoCommand::Filter f, const Element* target) const override
{
return f == UndoCommand::Filter::ChangePropertyLinked && target->linkList().contains(element);
}
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeBracketProperty
//---------------------------------------------------------
class ChangeBracketProperty : public ChangeProperty
{
Staff* staff;
int level;
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangeBracketProperty(Staff* s, int l, Pid i, const QVariant& v, PropertyFlags ps = PropertyFlags::NOSTYLE)
: ChangeProperty(nullptr, i, v, ps), staff(s), level(l) {}
UNDO_NAME("ChangeBracketProperty")
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// ChangeMetaText
//---------------------------------------------------------
class ChangeMetaText : public UndoCommand
{
Score* score;
QString id;
QString text;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeMetaText(Score* s, const QString& i, const QString& t)
: score(s), id(i), text(t) {}
UNDO_NAME("ChangeMetaText")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// ChangeSynthesizerState
//---------------------------------------------------------
class ChangeSynthesizerState : public UndoCommand
{
Score* score;
SynthesizerState state;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangeSynthesizerState(Score* s, const SynthesizerState& st)
: score(s), state(st) {}
UNDO_NAME("ChangeSynthesizerState")
};
2013-06-28 17:46:24 +02:00
//---------------------------------------------------------
// RemoveBracket
//---------------------------------------------------------
class RemoveBracket : public UndoCommand
{
Staff* staff;
int level;
BracketType type;
int span;
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
2013-06-28 17:46:24 +02:00
public:
2020-05-29 18:47:27 +02:00
RemoveBracket(Staff* s, int l, BracketType t, int sp)
: staff(s), level(l), type(t), span(sp) {}
UNDO_NAME("RemoveBracket")
2013-06-28 17:46:24 +02:00
};
//---------------------------------------------------------
// AddBracket
//---------------------------------------------------------
class AddBracket : public UndoCommand
{
Staff* staff;
int level;
BracketType type;
int span;
2017-05-19 09:06:41 +02:00
virtual void undo(EditData*) override;
virtual void redo(EditData*) override;
2013-06-28 17:46:24 +02:00
public:
2020-05-29 18:47:27 +02:00
AddBracket(Staff* s, int l, BracketType t, int sp)
: staff(s), level(l), type(t), span(sp) {}
UNDO_NAME("AddBracket")
2013-06-28 17:46:24 +02:00
};
2013-08-22 12:18:14 +02:00
//---------------------------------------------------------
// ChangeSpannerElements
//---------------------------------------------------------
2013-06-28 17:46:24 +02:00
2013-08-22 12:18:14 +02:00
class ChangeSpannerElements : public UndoCommand
{
Spanner* spanner;
Element* startElement;
Element* endElement;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2013-08-22 12:18:14 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeSpannerElements(Spanner* s, Element* se, Element* ee)
: spanner(s), startElement(se), endElement(ee) {}
UNDO_NAME("ChangeSpannerElements")
2013-08-22 12:18:14 +02:00
};
2013-05-13 18:49:17 +02:00
2013-10-22 12:05:31 +02:00
//---------------------------------------------------------
// ChangeParent
//---------------------------------------------------------
class ChangeParent : public UndoCommand
{
Element* element;
Element* parent;
int staffIdx;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2013-10-22 12:05:31 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeParent(Element* e, Element* p, int si)
: element(e), parent(p), staffIdx(si) {}
UNDO_NAME("ChangeParent")
2013-10-22 12:05:31 +02:00
};
2013-10-30 14:21:08 +01:00
//---------------------------------------------------------
// ChangeMMRest
//---------------------------------------------------------
class ChangeMMRest : public UndoCommand
{
Measure* m;
Measure* mmrest;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2013-10-30 14:21:08 +01:00
public:
2020-05-29 18:47:27 +02:00
ChangeMMRest(Measure* _m, Measure* _mmr)
: m(_m), mmrest(_mmr) {}
UNDO_NAME("ChangeMMRest")
2013-10-30 14:21:08 +01:00
};
//---------------------------------------------------------
// InsertTime
//---------------------------------------------------------
class InsertTime : public UndoCommand
{
Score* score;
Fraction tick;
Fraction len;
2017-05-19 09:06:41 +02:00
void redo(EditData*) override;
void undo(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
InsertTime(Score* _score, const Fraction& _tick, const Fraction& _len)
: score(_score), tick(_tick), len(_len) {}
UNDO_NAME("InsertTime")
};
//---------------------------------------------------------
// InsertTimeUnmanagedSpanner
//---------------------------------------------------------
class InsertTimeUnmanagedSpanner : public UndoCommand
{
Score* score;
Fraction tick;
Fraction len;
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
InsertTimeUnmanagedSpanner(Score* s, const Fraction& _tick, const Fraction& _len)
: score(s), tick(_tick), len(_len) {}
UNDO_NAME("InsertTimeUnmanagedSpanner")
};
//---------------------------------------------------------
// ChangeNoteEvent
//---------------------------------------------------------
class ChangeNoteEvent : public UndoCommand
{
Note* note;
NoteEvent* oldEvent;
NoteEvent newEvent;
PlayEventType newPetype;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangeNoteEvent(Note* n, NoteEvent* oe, const NoteEvent& ne)
: note(n), oldEvent(oe), newEvent(ne), newPetype(PlayEventType::User) {}
2014-08-01 16:21:39 +02:00
UNDO_NAME("ChangeNoteEvent")
};
2016-03-18 09:29:16 +01:00
//---------------------------------------------------------
// LinkUnlink
//---------------------------------------------------------
class LinkUnlink : public UndoCommand
{
2018-04-27 13:29:20 +02:00
bool mustDelete { false };
2016-03-18 09:29:16 +01:00
protected:
2018-04-27 13:29:20 +02:00
LinkedElements* le;
ScoreElement* e;
void link();
void unlink();
2016-03-18 09:29:16 +01:00
public:
2018-04-27 13:29:20 +02:00
LinkUnlink() {}
~LinkUnlink();
2016-03-18 09:29:16 +01:00
};
2016-04-13 12:25:06 +02:00
//---------------------------------------------------------
// Unlink
//---------------------------------------------------------
2016-04-13 12:25:06 +02:00
class Unlink : public LinkUnlink
{
public:
2018-04-27 13:29:20 +02:00
Unlink(ScoreElement*);
virtual void undo(EditData*) override { link(); }
virtual void redo(EditData*) override { unlink(); }
2014-08-01 16:21:39 +02:00
UNDO_NAME("Unlink")
};
2016-04-13 12:25:06 +02:00
2014-08-01 16:21:39 +02:00
//---------------------------------------------------------
// Link
//---------------------------------------------------------
2016-04-13 12:25:06 +02:00
class Link : public LinkUnlink
{
2014-08-01 16:21:39 +02:00
public:
2018-04-27 13:29:20 +02:00
Link(ScoreElement*, ScoreElement*);
virtual void undo(EditData*) override { unlink(); }
virtual void redo(EditData*) override { link(); }
2014-08-01 16:21:39 +02:00
UNDO_NAME("Link")
bool isFiltered(UndoCommand::Filter f, const Element* target) const override;
2014-08-01 16:21:39 +02:00
};
2014-07-10 14:32:04 +02:00
//---------------------------------------------------------
// ChangeStartEndSpanner
//---------------------------------------------------------
class ChangeStartEndSpanner : public UndoCommand
{
Spanner* spanner;
Element* start;
Element* end;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2014-07-10 14:32:04 +02:00
public:
2020-05-29 18:47:27 +02:00
ChangeStartEndSpanner(Spanner* sp, Element* s, Element* e)
: spanner(sp), start(s), end(e) {}
2014-08-01 16:21:39 +02:00
UNDO_NAME("ChangeStartEndSpanner")
2014-07-10 14:32:04 +02:00
};
2014-11-23 15:42:06 +01:00
//---------------------------------------------------------
// ChangeMetaTags
//---------------------------------------------------------
class ChangeMetaTags : public UndoCommand
{
Score* score;
QMap<QString,QString> metaTags;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
2014-11-23 15:42:06 +01:00
public:
2020-05-29 18:47:27 +02:00
ChangeMetaTags(Score* s, const QMap<QString,QString>& m)
: score(s), metaTags(m) {}
2014-11-23 15:42:06 +01:00
UNDO_NAME("ChangeMetaTags")
};
//---------------------------------------------------------
// ChangeDrumset
//---------------------------------------------------------
class ChangeDrumset : public UndoCommand
{
Instrument* instrument;
Drumset drumset;
2017-05-19 09:06:41 +02:00
void flip(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
ChangeDrumset(Instrument* i, const Drumset* d)
: instrument(i), drumset(*d) {}
UNDO_NAME("ChangeDrumset")
};
//---------------------------------------------------------
// FretDot
//---------------------------------------------------------
class FretDot : public UndoCommand
{
FretDiagram* diagram;
int string;
int fret;
bool add;
FretDotType dtype;
FretUndoData undoData;
void redo(EditData*) override;
void undo(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
FretDot(FretDiagram* d, int _string, int _fret, bool _add = false, FretDotType _dtype = FretDotType::NORMAL)
: diagram(d), string(_string), fret(_fret), add(_add), dtype(_dtype) {}
UNDO_NAME("FretDot")
};
//---------------------------------------------------------
// FretMarker
//---------------------------------------------------------
class FretMarker : public UndoCommand
{
FretDiagram* diagram;
int string;
FretMarkerType mtype;
FretUndoData undoData;
void redo(EditData*) override;
void undo(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
FretMarker(FretDiagram* d, int _string, FretMarkerType _mtype)
: diagram(d), string(_string), mtype(_mtype) {}
UNDO_NAME("FretMarker")
};
//---------------------------------------------------------
// FretBarre
//---------------------------------------------------------
class FretBarre : public UndoCommand
{
FretDiagram* diagram;
int string;
int fret;
bool add;
FretUndoData undoData;
void redo(EditData*) override;
void undo(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
FretBarre(FretDiagram* d, int _string, int _fret, bool _add = false)
: diagram(d), string(_string), fret(_fret),
add(_add) {}
UNDO_NAME("FretBarre")
};
//---------------------------------------------------------
// FretClear
//---------------------------------------------------------
class FretClear : public UndoCommand
{
FretDiagram* diagram;
FretUndoData undoData;
void redo(EditData*) override;
void undo(EditData*) override;
public:
2020-05-29 18:47:27 +02:00
FretClear(FretDiagram* d)
: diagram(d) {}
UNDO_NAME("FretClear")
};
//---------------------------------------------------------
// MoveTremolo
//---------------------------------------------------------
class MoveTremolo : public UndoCommand
{
Score* score { nullptr };
Fraction chord1Tick;
Fraction chord2Tick;
Tremolo* trem { nullptr };
int track { 0 };
Chord* oldC1 { nullptr };
Chord* oldC2 { nullptr };
void undo(EditData*) override;
void redo(EditData*) override;
2020-05-26 15:54:26 +02:00
public:
2020-05-29 18:47:27 +02:00
MoveTremolo(Score* s, Fraction c1, Fraction c2, Tremolo* tr, int t)
: score(s), chord1Tick(c1), chord2Tick(c2),
trem(tr), track(t) {}
UNDO_NAME("MoveTremolo")
2020-05-26 15:54:26 +02:00
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif