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 MergeCommand :
public QUndoCommand
251 MergeCommand(MultitrackModel &model,
int trackIndex,
int clipIndex, QUndoCommand *parent = 0);
256 MultitrackModel &m_model;
259 UndoHelper m_undoHelper;
262class MuteTrackCommand :
public QUndoCommand
265 MuteTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
270 MultitrackModel &m_model;
275class HideTrackCommand :
public QUndoCommand
278 HideTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
283 MultitrackModel &m_model;
288class CompositeTrackCommand :
public QUndoCommand
291 CompositeTrackCommand(MultitrackModel &model,
294 QUndoCommand *parent = 0);
299 MultitrackModel &m_model;
305class LockTrackCommand :
public QUndoCommand
308 LockTrackCommand(MultitrackModel &model,
int trackIndex,
bool value, QUndoCommand *parent = 0);
313 MultitrackModel &m_model;
319class MoveClipCommand :
public QUndoCommand
322 MoveClipCommand(TimelineDock &timeline,
326 QUndoCommand *parent = 0);
327 void addClip(
int trackIndex,
int clipIndex);
332 int id()
const {
return UndoIdMoveClip; }
333 bool mergeWith(
const QUndoCommand *other);
337 QSet<int> trackScope()
const;
338 bool undoExplicitMove();
339 bool undoTransitionGrow();
340 void snapshotOverwritten();
341 void captureGeneratedCuts();
342 bool restoreOverwritten();
344 TimelineDock &m_timeline;
345 MultitrackModel &m_model;
346 MarkersModel &m_markersModel;
370 enum SpecialMove { NoSpecialMove, GrowTransitionOut, GrowTransitionIn };
388 bool m_rippleAllTracks;
389 bool m_rippleMarkers;
390 UndoHelper m_undoHelper;
391 QMultiMap<int, Info> m_clips;
392 SpecialMove m_specialMove = NoSpecialMove;
393 QList<Overwritten> m_overwritten;
394 QSet<QUuid> m_generatedCuts;
397 QList<Markers::Marker> m_markers;
398 int m_markersModified;
401class TrimCommand :
public QUndoCommand
404 explicit TrimCommand(QUndoCommand *parent = 0)
405 : QUndoCommand(parent)
407 void setUndoHelper(UndoHelper *helper)
409 m_undoHelper.reset(helper);
411 m_undoHelper->setText(text());
415 QScopedPointer<UndoHelper> m_undoHelper;
418class TrimClipInCommand :
public TrimCommand
421 TrimClipInCommand(MultitrackModel &model,
422 MarkersModel &markersModel,
428 QUndoCommand *parent = 0);
433 int id()
const {
return UndoIdTrimClipIn; }
434 bool mergeWith(
const QUndoCommand *other);
437 MultitrackModel &m_model;
438 MarkersModel &m_markersModel;
443 bool m_rippleAllTracks;
444 bool m_rippleMarkers;
446 int m_markerRemoveStart;
447 int m_markerRemoveEnd;
448 QList<Markers::Marker> m_markers;
451class TrimClipOutCommand :
public TrimCommand
454 TrimClipOutCommand(MultitrackModel &model,
455 MarkersModel &markersModel,
461 QUndoCommand *parent = 0);
466 int id()
const {
return UndoIdTrimClipOut; }
467 bool mergeWith(
const QUndoCommand *other);
470 MultitrackModel &m_model;
471 MarkersModel &m_markersModel;
476 bool m_rippleAllTracks;
477 bool m_rippleMarkers;
479 int m_markerRemoveStart;
480 int m_markerRemoveEnd;
481 QList<Markers::Marker> m_markers;
484class SplitCommand :
public QUndoCommand
487 SplitCommand(MultitrackModel &model,
488 const std::vector<int> &trackIndex,
489 const std::vector<int> &clipIndex,
491 QUndoCommand *parent = 0);
496 MultitrackModel &m_model;
497 std::vector<int> m_trackIndex;
498 std::vector<int> m_clipIndex;
500 UndoHelper m_undoHelper;
503class FadeInCommand :
public QUndoCommand
506 FadeInCommand(MultitrackModel &model,
510 QUndoCommand *parent = 0);
515 int id()
const {
return UndoIdFadeIn; }
516 bool mergeWith(
const QUndoCommand *other);
519 MultitrackModel &m_model;
526class FadeOutCommand :
public QUndoCommand
529 FadeOutCommand(MultitrackModel &model,
533 QUndoCommand *parent = 0);
538 int id()
const {
return UndoIdFadeOut; }
539 bool mergeWith(
const QUndoCommand *other);
542 MultitrackModel &m_model;
549class AddTransitionCommand :
public QUndoCommand
552 AddTransitionCommand(TimelineDock &timeline,
557 QUndoCommand *parent = 0);
560 int getTransitionIndex()
const {
return m_transitionIndex; }
563 TimelineDock &m_timeline;
564 MultitrackModel &m_model;
565 MarkersModel &m_markersModel;
569 int m_transitionIndex;
571 UndoHelper m_undoHelper;
572 bool m_rippleAllTracks;
573 bool m_rippleMarkers;
574 int m_markerOldStart;
575 int m_markerNewStart;
576 QList<Markers::Marker> m_markers;
579class TrimTransitionInCommand :
public TrimCommand
582 TrimTransitionInCommand(MultitrackModel &model,
587 QUndoCommand *parent = 0);
592 int id()
const {
return UndoIdTrimTransitionIn; }
593 bool mergeWith(
const QUndoCommand *other);
596 MultitrackModel &m_model;
604class TrimTransitionOutCommand :
public TrimCommand
607 TrimTransitionOutCommand(MultitrackModel &model,
612 QUndoCommand *parent = 0);
617 int id()
const {
return UndoIdTrimTransitionOut; }
618 bool mergeWith(
const QUndoCommand *other);
621 MultitrackModel &m_model;
629class ResizeTransitionCommand :
public TrimCommand
632 ResizeTransitionCommand(MultitrackModel &model,
637 QUndoCommand *parent = 0);
642 int id()
const {
return UndoIdResizeTransition; }
643 bool mergeWith(
const QUndoCommand *other);
646 MultitrackModel &m_model;
648 int m_transitionIndex;
653class AddTransitionByTrimInCommand :
public TrimCommand
656 AddTransitionByTrimInCommand(TimelineDock &timeline,
662 QUndoCommand *parent = 0);
667 int id()
const {
return UndoIdAddTransitionByTrimIn; }
668 bool mergeWith(
const QUndoCommand *other);
671 TimelineDock &m_timeline;
680class RemoveTransitionByTrimInCommand :
public TrimCommand
683 RemoveTransitionByTrimInCommand(MultitrackModel &model,
689 QUndoCommand *parent = 0);
694 MultitrackModel &m_model;
702class RemoveTransitionByTrimOutCommand :
public TrimCommand
705 RemoveTransitionByTrimOutCommand(MultitrackModel &model,
711 QUndoCommand *parent = 0);
716 MultitrackModel &m_model;
724class AddTransitionByTrimOutCommand :
public TrimCommand
727 AddTransitionByTrimOutCommand(MultitrackModel &model,
733 QUndoCommand *parent = 0);
738 int id()
const {
return UndoIdAddTransitionByTrimOut; }
739 bool mergeWith(
const QUndoCommand *other);
742 MultitrackModel &m_model;
751class AddTrackCommand :
public QUndoCommand
754 AddTrackCommand(MultitrackModel &model,
bool isVideo, QUndoCommand *parent = 0);
759 MultitrackModel &m_model;
765class InsertTrackCommand :
public QUndoCommand
768 InsertTrackCommand(MultitrackModel &model,
770 TrackType trackType = PlaylistTrackType,
771 QUndoCommand *parent = 0);
776 MultitrackModel &m_model;
778 TrackType m_trackType;
782class RemoveTrackCommand :
public QUndoCommand
785 RemoveTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
790 MultitrackModel &m_model;
792 TrackType m_trackType;
794 UndoHelper m_undoHelper;
795 QScopedPointer<Mlt::Producer> m_filtersProducer;
799class MoveTrackCommand :
public QUndoCommand
802 MoveTrackCommand(MultitrackModel &model,
805 QUndoCommand *parent = 0);
810 MultitrackModel &m_model;
811 int m_fromTrackIndex;
815class ChangeBlendModeCommand :
public QObject,
public QUndoCommand
819 ChangeBlendModeCommand(Mlt::Transition &transition,
820 const QString &propertyName,
822 QUndoCommand *parent = 0);
826 void modeChanged(QString &mode);
829 Mlt::Transition m_transition;
830 QString m_propertyName;
835class ChangeTransitionPropertyCommand :
public QObject,
public QUndoCommand
839 ChangeTransitionPropertyCommand(
int trackIndex,
840 const QString &propertyName,
843 bool mergeable =
true,
844 QUndoCommand *parent = 0);
849 int id()
const {
return UndoIdChangeTransitionProperty; }
850 bool mergeWith(
const QUndoCommand *other);
853 void valueChanged(
double value);
857 QString m_propertyName;
865class ChangeDuckThresholdCommand :
public QObject,
public QUndoCommand
869 ChangeDuckThresholdCommand(
int trackIndex,
872 const QString &text = QString(),
873 bool isToggle =
false,
874 QUndoCommand *parent = 0);
879 int id()
const {
return m_isToggle ? UndoIdChangeDuckEnabled : UndoIdChangeDuckThreshold; }
880 bool mergeWith(
const QUndoCommand *other);
883 void valueChanged(
double value);
891 double m_oldRealValue;
894class UpdateCommand :
public QUndoCommand
897 UpdateCommand(TimelineDock &timeline,
901 QUndoCommand *parent = 0);
902 void setXmlAfter(
const QString &xml);
903 void setPosition(
int trackIndex,
int clipIndex,
int position);
904 void setRippleAllTracks(
bool);
905 int trackIndex()
const {
return m_trackIndex; }
906 int clipIndex()
const {
return m_clipIndex; }
907 int position()
const {
return m_position; }
912 TimelineDock &m_timeline;
918 UndoHelper m_undoHelper;
920 bool m_rippleAllTracks;
923class DetachAudioCommand :
public QUndoCommand
926 DetachAudioCommand(TimelineDock &timeline,
931 QUndoCommand *parent = 0);
936 TimelineDock &m_timeline;
940 int m_targetTrackIndex;
942 UndoHelper m_undoHelper;
947class ReplaceCommand :
public QUndoCommand
950 ReplaceCommand(MultitrackModel &model,
954 QUndoCommand *parent =
nullptr);
959 MultitrackModel &m_model;
964 UndoHelper m_undoHelper;
967class AlignClipsCommand :
public QUndoCommand
970 AlignClipsCommand(MultitrackModel &model, QUndoCommand *parent = 0);
971 void addAlignment(QUuid uuid,
int offset,
double speedCompensation);
976 MultitrackModel &m_model;
977 UndoHelper m_undoHelper;
985 QVector<Alignment> m_alignments;
988class ApplyFiltersCommand :
public QUndoCommand
991 ApplyFiltersCommand(MultitrackModel &model,
992 const QString &filterProducerXml,
993 QUndoCommand *parent = 0);
994 void addClip(
int trackIndex,
int clipIndex);
999 MultitrackModel &m_model;
1001 QMap<ClipPosition, QString> m_prevFilters;
1004class ChangeGainCommand :
public QUndoCommand
1007 ChangeGainCommand(MultitrackModel &model,
1011 QUndoCommand *parent = 0);
1016 int id()
const {
return UndoIdChangeGain; }
1017 bool mergeWith(
const QUndoCommand *other);
1020 MultitrackModel &m_model;
1027class ChangeTrackGainCommand :
public QUndoCommand
1030 ChangeTrackGainCommand(MultitrackModel &model,
1033 QUndoCommand *parent = 0);
1038 int id()
const {
return UndoIdChangeTrackGain; }
1039 bool mergeWith(
const QUndoCommand *other);
1042 MultitrackModel &m_model;