21#include "docks/timelinedock.h"
22#include "models/markersmodel.h"
23#include "models/multitrackmodel.h"
24#include "undohelper.h"
26#include <MltProducer.h>
27#include <MltTransition.h>
31#include <QUndoCommand>
39 UndoIdTrimClipIn = 100,
43 UndoIdTrimTransitionIn,
44 UndoIdTrimTransitionOut,
45 UndoIdResizeTransition,
46 UndoIdAddTransitionByTrimIn,
47 UndoIdAddTransitionByTrimOut,
51 UndoIdChangeTransitionProperty,
52 UndoIdChangeTrackGain,
53 UndoIdChangeDuckThreshold,
54 UndoIdChangeDuckEnabled,
59 ClipPosition(
int track,
int clip)
65 bool operator<(
const ClipPosition &rhs)
const
67 if (trackIndex == rhs.trackIndex) {
68 return clipIndex < rhs.clipIndex;
70 return trackIndex < rhs.trackIndex;
78class AppendCommand :
public QUndoCommand
81 AppendCommand(MultitrackModel &model,
84 bool skipProxy =
false,
86 QUndoCommand *parent = 0);
91 MultitrackModel &m_model;
94 UndoHelper m_undoHelper;
97 QVector<QUuid> m_uuids;
100class InsertCommand :
public QUndoCommand
103 InsertCommand(MultitrackModel &model,
104 MarkersModel &markersModel,
109 QUndoCommand *parent = 0);
122 bool isValid()
const {
return !xml.isEmpty(); }
125 bool undoByRemovingInserted();
126 void restoreSplitDest();
127 void snapshotSplitDest();
129 MultitrackModel &m_model;
130 MarkersModel &m_markersModel;
134 QStringList m_oldTracks;
135 UndoHelper m_undoHelper;
137 bool m_rippleAllTracks;
138 bool m_rippleMarkers;
140 QVector<QUuid> m_uuids;
141 SplitDest m_splitDest;
144class OverwriteCommand :
public QUndoCommand
147 OverwriteCommand(MultitrackModel &model,
152 QUndoCommand *parent = 0);
157 MultitrackModel &m_model;
161 UndoHelper m_undoHelper;
163 QVector<QUuid> m_uuids;
166class LiftCommand :
public QUndoCommand
169 LiftCommand(MultitrackModel &model,
int trackIndex,
int clipIndex, QUndoCommand *parent = 0);
174 MultitrackModel &m_model;
177 UndoHelper m_undoHelper;
180class RemoveCommand :
public QUndoCommand
183 RemoveCommand(MultitrackModel &model,
184 MarkersModel &markersModel,
187 QUndoCommand *parent = 0);
192 MultitrackModel &m_model;
193 MarkersModel &m_markersModel;
196 UndoHelper m_undoHelper;
197 bool m_rippleAllTracks;
198 bool m_rippleMarkers;
199 int m_markerRemoveStart;
200 int m_markerRemoveEnd;
201 QList<Markers::Marker> m_markers;
204class GroupCommand :
public QUndoCommand
207 GroupCommand(MultitrackModel &model, QUndoCommand *parent = 0);
208 void addToGroup(
int trackIndex,
int clipIndex);
213 MultitrackModel &m_model;
214 QList<ClipPosition> m_clips;
215 QMap<ClipPosition, int> m_prevGroups;
218class UngroupCommand :
public QUndoCommand
221 UngroupCommand(MultitrackModel &model, QUndoCommand *parent = 0);
222 void removeFromGroup(
int trackIndex,
int clipIndex);
227 MultitrackModel &m_model;
228 QMap<ClipPosition, int> m_prevGroups;
231class NameTrackCommand :
public QUndoCommand
234 NameTrackCommand(MultitrackModel &model,
237 QUndoCommand *parent = 0);
242 MultitrackModel &m_model;
248class ChangeTrackRoleCommand :
public QUndoCommand
251 ChangeTrackRoleCommand(MultitrackModel &model,
254 QUndoCommand *parent = 0);
259 MultitrackModel &m_model;
261 AudioTrackRole m_role;
262 AudioTrackRole m_oldRole;
265class MergeCommand :
public QUndoCommand
268 MergeCommand(MultitrackModel &model,
int trackIndex,
int clipIndex, QUndoCommand *parent = 0);
273 MultitrackModel &m_model;
276 UndoHelper m_undoHelper;
279class MuteTrackCommand :
public QUndoCommand
282 MuteTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
287 MultitrackModel &m_model;
292class HideTrackCommand :
public QUndoCommand
295 HideTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
300 MultitrackModel &m_model;
305class CompositeTrackCommand :
public QUndoCommand
308 CompositeTrackCommand(MultitrackModel &model,
311 QUndoCommand *parent = 0);
316 MultitrackModel &m_model;
322class LockTrackCommand :
public QUndoCommand
325 LockTrackCommand(MultitrackModel &model,
int trackIndex,
bool value, QUndoCommand *parent = 0);
330 MultitrackModel &m_model;
336class MoveClipCommand :
public QUndoCommand
339 MoveClipCommand(TimelineDock &timeline,
343 QUndoCommand *parent = 0);
344 void addClip(
int trackIndex,
int clipIndex);
349 int id()
const {
return UndoIdMoveClip; }
350 bool mergeWith(
const QUndoCommand *other);
354 QSet<int> trackScope()
const;
355 bool undoExplicitMove();
356 bool undoTransitionGrow();
357 void snapshotOverwritten();
358 void captureGeneratedCuts();
359 bool restoreOverwritten();
361 TimelineDock &m_timeline;
362 MultitrackModel &m_model;
363 MarkersModel &m_markersModel;
387 enum SpecialMove { NoSpecialMove, GrowTransitionOut, GrowTransitionIn };
405 bool m_rippleAllTracks;
406 bool m_rippleMarkers;
407 UndoHelper m_undoHelper;
408 QMultiMap<int, Info> m_clips;
409 SpecialMove m_specialMove = NoSpecialMove;
410 QList<Overwritten> m_overwritten;
411 QSet<QUuid> m_generatedCuts;
414 QList<Markers::Marker> m_markers;
415 int m_markersModified;
418class TrimCommand :
public QUndoCommand
421 explicit TrimCommand(QUndoCommand *parent = 0)
422 : QUndoCommand(parent)
424 void setUndoHelper(UndoHelper *helper)
426 m_undoHelper.reset(helper);
428 m_undoHelper->setText(text());
432 QScopedPointer<UndoHelper> m_undoHelper;
435class TrimClipInCommand :
public TrimCommand
438 TrimClipInCommand(MultitrackModel &model,
439 MarkersModel &markersModel,
445 QUndoCommand *parent = 0);
450 int id()
const {
return UndoIdTrimClipIn; }
451 bool mergeWith(
const QUndoCommand *other);
454 MultitrackModel &m_model;
455 MarkersModel &m_markersModel;
460 bool m_rippleAllTracks;
461 bool m_rippleMarkers;
463 int m_markerRemoveStart;
464 int m_markerRemoveEnd;
465 QList<Markers::Marker> m_markers;
468class TrimClipOutCommand :
public TrimCommand
471 TrimClipOutCommand(MultitrackModel &model,
472 MarkersModel &markersModel,
478 QUndoCommand *parent = 0);
483 int id()
const {
return UndoIdTrimClipOut; }
484 bool mergeWith(
const QUndoCommand *other);
487 MultitrackModel &m_model;
488 MarkersModel &m_markersModel;
493 bool m_rippleAllTracks;
494 bool m_rippleMarkers;
496 int m_markerRemoveStart;
497 int m_markerRemoveEnd;
498 QList<Markers::Marker> m_markers;
501class SplitCommand :
public QUndoCommand
504 SplitCommand(MultitrackModel &model,
505 const std::vector<int> &trackIndex,
506 const std::vector<int> &clipIndex,
508 QUndoCommand *parent = 0);
513 MultitrackModel &m_model;
514 std::vector<int> m_trackIndex;
515 std::vector<int> m_clipIndex;
517 UndoHelper m_undoHelper;
520class FadeInCommand :
public QUndoCommand
523 FadeInCommand(MultitrackModel &model,
527 QUndoCommand *parent = 0);
532 int id()
const {
return UndoIdFadeIn; }
533 bool mergeWith(
const QUndoCommand *other);
536 MultitrackModel &m_model;
543class FadeOutCommand :
public QUndoCommand
546 FadeOutCommand(MultitrackModel &model,
550 QUndoCommand *parent = 0);
555 int id()
const {
return UndoIdFadeOut; }
556 bool mergeWith(
const QUndoCommand *other);
559 MultitrackModel &m_model;
566class AddTransitionCommand :
public QUndoCommand
569 AddTransitionCommand(TimelineDock &timeline,
574 QUndoCommand *parent = 0);
577 int getTransitionIndex()
const {
return m_transitionIndex; }
580 TimelineDock &m_timeline;
581 MultitrackModel &m_model;
582 MarkersModel &m_markersModel;
586 int m_transitionIndex;
588 UndoHelper m_undoHelper;
589 bool m_rippleAllTracks;
590 bool m_rippleMarkers;
591 int m_markerOldStart;
592 int m_markerNewStart;
593 QList<Markers::Marker> m_markers;
596class TrimTransitionInCommand :
public TrimCommand
599 TrimTransitionInCommand(MultitrackModel &model,
604 QUndoCommand *parent = 0);
609 int id()
const {
return UndoIdTrimTransitionIn; }
610 bool mergeWith(
const QUndoCommand *other);
613 MultitrackModel &m_model;
621class TrimTransitionOutCommand :
public TrimCommand
624 TrimTransitionOutCommand(MultitrackModel &model,
629 QUndoCommand *parent = 0);
634 int id()
const {
return UndoIdTrimTransitionOut; }
635 bool mergeWith(
const QUndoCommand *other);
638 MultitrackModel &m_model;
646class ResizeTransitionCommand :
public TrimCommand
649 ResizeTransitionCommand(MultitrackModel &model,
654 QUndoCommand *parent = 0);
659 int id()
const {
return UndoIdResizeTransition; }
660 bool mergeWith(
const QUndoCommand *other);
663 MultitrackModel &m_model;
665 int m_transitionIndex;
670class AddTransitionByTrimInCommand :
public TrimCommand
673 AddTransitionByTrimInCommand(TimelineDock &timeline,
679 QUndoCommand *parent = 0);
684 int id()
const {
return UndoIdAddTransitionByTrimIn; }
685 bool mergeWith(
const QUndoCommand *other);
688 TimelineDock &m_timeline;
697class RemoveTransitionByTrimInCommand :
public TrimCommand
700 RemoveTransitionByTrimInCommand(MultitrackModel &model,
706 QUndoCommand *parent = 0);
711 MultitrackModel &m_model;
719class RemoveTransitionByTrimOutCommand :
public TrimCommand
722 RemoveTransitionByTrimOutCommand(MultitrackModel &model,
728 QUndoCommand *parent = 0);
733 MultitrackModel &m_model;
741class AddTransitionByTrimOutCommand :
public TrimCommand
744 AddTransitionByTrimOutCommand(MultitrackModel &model,
750 QUndoCommand *parent = 0);
755 int id()
const {
return UndoIdAddTransitionByTrimOut; }
756 bool mergeWith(
const QUndoCommand *other);
759 MultitrackModel &m_model;
768class AddTrackCommand :
public QUndoCommand
771 AddTrackCommand(MultitrackModel &model,
bool isVideo, QUndoCommand *parent = 0);
776 MultitrackModel &m_model;
782class InsertTrackCommand :
public QUndoCommand
785 InsertTrackCommand(MultitrackModel &model,
787 TrackType trackType = PlaylistTrackType,
788 QUndoCommand *parent = 0);
793 MultitrackModel &m_model;
795 TrackType m_trackType;
799class RemoveTrackCommand :
public QUndoCommand
802 RemoveTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
807 MultitrackModel &m_model;
809 TrackType m_trackType;
811 UndoHelper m_undoHelper;
812 QScopedPointer<Mlt::Producer> m_filtersProducer;
816class MoveTrackCommand :
public QUndoCommand
819 MoveTrackCommand(MultitrackModel &model,
822 QUndoCommand *parent = 0);
827 MultitrackModel &m_model;
828 int m_fromTrackIndex;
832class ChangeBlendModeCommand :
public QObject,
public QUndoCommand
836 ChangeBlendModeCommand(Mlt::Transition &transition,
837 const QString &propertyName,
839 QUndoCommand *parent = 0);
843 void modeChanged(QString &mode);
846 Mlt::Transition m_transition;
847 QString m_propertyName;
852class ChangeTransitionPropertyCommand :
public QObject,
public QUndoCommand
856 ChangeTransitionPropertyCommand(
int trackIndex,
857 const QString &propertyName,
860 bool mergeable =
true,
861 QUndoCommand *parent = 0);
866 int id()
const {
return UndoIdChangeTransitionProperty; }
867 bool mergeWith(
const QUndoCommand *other);
870 void valueChanged(
double value);
874 QString m_propertyName;
882class ChangeDuckThresholdCommand :
public QObject,
public QUndoCommand
886 ChangeDuckThresholdCommand(
int trackIndex,
889 const QString &text = QString(),
890 bool isToggle =
false,
891 QUndoCommand *parent = 0);
896 int id()
const {
return m_isToggle ? UndoIdChangeDuckEnabled : UndoIdChangeDuckThreshold; }
897 bool mergeWith(
const QUndoCommand *other);
900 void valueChanged(
double value);
908 double m_oldRealValue;
911class UpdateCommand :
public QUndoCommand
914 UpdateCommand(TimelineDock &timeline,
918 QUndoCommand *parent = 0);
919 void setXmlAfter(
const QString &xml);
920 void setPosition(
int trackIndex,
int clipIndex,
int position);
921 void setRippleAllTracks(
bool);
922 int trackIndex()
const {
return m_trackIndex; }
923 int clipIndex()
const {
return m_clipIndex; }
924 int position()
const {
return m_position; }
929 TimelineDock &m_timeline;
935 UndoHelper m_undoHelper;
937 bool m_rippleAllTracks;
940class DetachAudioCommand :
public QUndoCommand
943 DetachAudioCommand(TimelineDock &timeline,
948 QUndoCommand *parent = 0);
953 TimelineDock &m_timeline;
957 int m_targetTrackIndex;
959 UndoHelper m_undoHelper;
964class ReplaceCommand :
public QUndoCommand
967 ReplaceCommand(MultitrackModel &model,
971 QUndoCommand *parent =
nullptr);
976 MultitrackModel &m_model;
981 UndoHelper m_undoHelper;
984class AlignClipsCommand :
public QUndoCommand
987 AlignClipsCommand(MultitrackModel &model, QUndoCommand *parent = 0);
988 void addAlignment(QUuid uuid,
int offset,
double speedCompensation);
993 MultitrackModel &m_model;
994 UndoHelper m_undoHelper;
1002 QVector<Alignment> m_alignments;
1005class ApplyFiltersCommand :
public QUndoCommand
1008 ApplyFiltersCommand(MultitrackModel &model,
1009 const QString &filterProducerXml,
1010 QUndoCommand *parent = 0);
1011 void addClip(
int trackIndex,
int clipIndex);
1016 MultitrackModel &m_model;
1018 QMap<ClipPosition, QString> m_prevFilters;
1021class ChangeGainCommand :
public QUndoCommand
1024 ChangeGainCommand(MultitrackModel &model,
1028 QUndoCommand *parent = 0);
1033 int id()
const {
return UndoIdChangeGain; }
1034 bool mergeWith(
const QUndoCommand *other);
1037 MultitrackModel &m_model;
1044class ChangeTrackGainCommand :
public QUndoCommand
1047 ChangeTrackGainCommand(MultitrackModel &model,
1050 QUndoCommand *parent = 0);
1055 int id()
const {
return UndoIdChangeTrackGain; }
1056 bool mergeWith(
const QUndoCommand *other);
1059 MultitrackModel &m_model;