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,
57 ClipPosition(
int track,
int clip)
63 bool operator<(
const ClipPosition &rhs)
const
65 if (trackIndex == rhs.trackIndex) {
66 return clipIndex < rhs.clipIndex;
68 return trackIndex < rhs.trackIndex;
76class AppendCommand :
public QUndoCommand
79 AppendCommand(MultitrackModel &model,
82 bool skipProxy =
false,
84 QUndoCommand *parent = 0);
89 MultitrackModel &m_model;
92 UndoHelper m_undoHelper;
95 QVector<QUuid> m_uuids;
98class InsertCommand :
public QUndoCommand
101 InsertCommand(MultitrackModel &model,
102 MarkersModel &markersModel,
107 QUndoCommand *parent = 0);
120 bool isValid()
const {
return !xml.isEmpty(); }
123 bool undoByRemovingInserted();
124 void restoreSplitDest();
125 void snapshotSplitDest();
127 MultitrackModel &m_model;
128 MarkersModel &m_markersModel;
132 QStringList m_oldTracks;
133 UndoHelper m_undoHelper;
135 bool m_rippleAllTracks;
136 bool m_rippleMarkers;
138 QVector<QUuid> m_uuids;
139 SplitDest m_splitDest;
142class OverwriteCommand :
public QUndoCommand
145 OverwriteCommand(MultitrackModel &model,
150 QUndoCommand *parent = 0);
155 MultitrackModel &m_model;
159 UndoHelper m_undoHelper;
161 QVector<QUuid> m_uuids;
164class LiftCommand :
public QUndoCommand
167 LiftCommand(MultitrackModel &model,
int trackIndex,
int clipIndex, QUndoCommand *parent = 0);
172 MultitrackModel &m_model;
175 UndoHelper m_undoHelper;
178class RemoveCommand :
public QUndoCommand
181 RemoveCommand(MultitrackModel &model,
182 MarkersModel &markersModel,
185 QUndoCommand *parent = 0);
190 MultitrackModel &m_model;
191 MarkersModel &m_markersModel;
194 UndoHelper m_undoHelper;
195 bool m_rippleAllTracks;
196 bool m_rippleMarkers;
197 int m_markerRemoveStart;
198 int m_markerRemoveEnd;
199 QList<Markers::Marker> m_markers;
202class GroupCommand :
public QUndoCommand
205 GroupCommand(MultitrackModel &model, QUndoCommand *parent = 0);
206 void addToGroup(
int trackIndex,
int clipIndex);
211 MultitrackModel &m_model;
212 QList<ClipPosition> m_clips;
213 QMap<ClipPosition, int> m_prevGroups;
216class UngroupCommand :
public QUndoCommand
219 UngroupCommand(MultitrackModel &model, QUndoCommand *parent = 0);
220 void removeFromGroup(
int trackIndex,
int clipIndex);
225 MultitrackModel &m_model;
226 QMap<ClipPosition, int> m_prevGroups;
229class NameTrackCommand :
public QUndoCommand
232 NameTrackCommand(MultitrackModel &model,
235 QUndoCommand *parent = 0);
240 MultitrackModel &m_model;
246class MergeCommand :
public QUndoCommand
249 MergeCommand(MultitrackModel &model,
int trackIndex,
int clipIndex, QUndoCommand *parent = 0);
254 MultitrackModel &m_model;
257 UndoHelper m_undoHelper;
260class MuteTrackCommand :
public QUndoCommand
263 MuteTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
268 MultitrackModel &m_model;
273class HideTrackCommand :
public QUndoCommand
276 HideTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
281 MultitrackModel &m_model;
286class CompositeTrackCommand :
public QUndoCommand
289 CompositeTrackCommand(MultitrackModel &model,
292 QUndoCommand *parent = 0);
297 MultitrackModel &m_model;
303class LockTrackCommand :
public QUndoCommand
306 LockTrackCommand(MultitrackModel &model,
int trackIndex,
bool value, QUndoCommand *parent = 0);
311 MultitrackModel &m_model;
317class MoveClipCommand :
public QUndoCommand
320 MoveClipCommand(TimelineDock &timeline,
324 QUndoCommand *parent = 0);
325 void addClip(
int trackIndex,
int clipIndex);
330 int id()
const {
return UndoIdMoveClip; }
331 bool mergeWith(
const QUndoCommand *other);
335 QSet<int> trackScope()
const;
336 bool undoExplicitMove();
337 bool undoTransitionGrow();
338 void snapshotOverwritten();
339 void captureGeneratedCuts();
340 bool restoreOverwritten();
342 TimelineDock &m_timeline;
343 MultitrackModel &m_model;
344 MarkersModel &m_markersModel;
368 enum SpecialMove { NoSpecialMove, GrowTransitionOut, GrowTransitionIn };
386 bool m_rippleAllTracks;
387 bool m_rippleMarkers;
388 UndoHelper m_undoHelper;
389 QMultiMap<int, Info> m_clips;
390 SpecialMove m_specialMove = NoSpecialMove;
391 QList<Overwritten> m_overwritten;
392 QSet<QUuid> m_generatedCuts;
395 QList<Markers::Marker> m_markers;
396 int m_markersModified;
399class TrimCommand :
public QUndoCommand
402 explicit TrimCommand(QUndoCommand *parent = 0)
403 : QUndoCommand(parent)
405 void setUndoHelper(UndoHelper *helper)
407 m_undoHelper.reset(helper);
409 m_undoHelper->setText(text());
413 QScopedPointer<UndoHelper> m_undoHelper;
416class TrimClipInCommand :
public TrimCommand
419 TrimClipInCommand(MultitrackModel &model,
420 MarkersModel &markersModel,
426 QUndoCommand *parent = 0);
431 int id()
const {
return UndoIdTrimClipIn; }
432 bool mergeWith(
const QUndoCommand *other);
435 MultitrackModel &m_model;
436 MarkersModel &m_markersModel;
441 bool m_rippleAllTracks;
442 bool m_rippleMarkers;
444 int m_markerRemoveStart;
445 int m_markerRemoveEnd;
446 QList<Markers::Marker> m_markers;
449class TrimClipOutCommand :
public TrimCommand
452 TrimClipOutCommand(MultitrackModel &model,
453 MarkersModel &markersModel,
459 QUndoCommand *parent = 0);
464 int id()
const {
return UndoIdTrimClipOut; }
465 bool mergeWith(
const QUndoCommand *other);
468 MultitrackModel &m_model;
469 MarkersModel &m_markersModel;
474 bool m_rippleAllTracks;
475 bool m_rippleMarkers;
477 int m_markerRemoveStart;
478 int m_markerRemoveEnd;
479 QList<Markers::Marker> m_markers;
482class SplitCommand :
public QUndoCommand
485 SplitCommand(MultitrackModel &model,
486 const std::vector<int> &trackIndex,
487 const std::vector<int> &clipIndex,
489 QUndoCommand *parent = 0);
494 MultitrackModel &m_model;
495 std::vector<int> m_trackIndex;
496 std::vector<int> m_clipIndex;
498 UndoHelper m_undoHelper;
501class FadeInCommand :
public QUndoCommand
504 FadeInCommand(MultitrackModel &model,
508 QUndoCommand *parent = 0);
513 int id()
const {
return UndoIdFadeIn; }
514 bool mergeWith(
const QUndoCommand *other);
517 MultitrackModel &m_model;
524class FadeOutCommand :
public QUndoCommand
527 FadeOutCommand(MultitrackModel &model,
531 QUndoCommand *parent = 0);
536 int id()
const {
return UndoIdFadeOut; }
537 bool mergeWith(
const QUndoCommand *other);
540 MultitrackModel &m_model;
547class AddTransitionCommand :
public QUndoCommand
550 AddTransitionCommand(TimelineDock &timeline,
555 QUndoCommand *parent = 0);
558 int getTransitionIndex()
const {
return m_transitionIndex; }
561 TimelineDock &m_timeline;
562 MultitrackModel &m_model;
563 MarkersModel &m_markersModel;
567 int m_transitionIndex;
569 UndoHelper m_undoHelper;
570 bool m_rippleAllTracks;
571 bool m_rippleMarkers;
572 int m_markerOldStart;
573 int m_markerNewStart;
574 QList<Markers::Marker> m_markers;
577class TrimTransitionInCommand :
public TrimCommand
580 TrimTransitionInCommand(MultitrackModel &model,
585 QUndoCommand *parent = 0);
590 int id()
const {
return UndoIdTrimTransitionIn; }
591 bool mergeWith(
const QUndoCommand *other);
594 MultitrackModel &m_model;
602class TrimTransitionOutCommand :
public TrimCommand
605 TrimTransitionOutCommand(MultitrackModel &model,
610 QUndoCommand *parent = 0);
615 int id()
const {
return UndoIdTrimTransitionOut; }
616 bool mergeWith(
const QUndoCommand *other);
619 MultitrackModel &m_model;
627class ResizeTransitionCommand :
public TrimCommand
630 ResizeTransitionCommand(MultitrackModel &model,
635 QUndoCommand *parent = 0);
640 int id()
const {
return UndoIdResizeTransition; }
641 bool mergeWith(
const QUndoCommand *other);
644 MultitrackModel &m_model;
646 int m_transitionIndex;
651class AddTransitionByTrimInCommand :
public TrimCommand
654 AddTransitionByTrimInCommand(TimelineDock &timeline,
660 QUndoCommand *parent = 0);
665 int id()
const {
return UndoIdAddTransitionByTrimIn; }
666 bool mergeWith(
const QUndoCommand *other);
669 TimelineDock &m_timeline;
678class RemoveTransitionByTrimInCommand :
public TrimCommand
681 RemoveTransitionByTrimInCommand(MultitrackModel &model,
687 QUndoCommand *parent = 0);
692 MultitrackModel &m_model;
700class RemoveTransitionByTrimOutCommand :
public TrimCommand
703 RemoveTransitionByTrimOutCommand(MultitrackModel &model,
709 QUndoCommand *parent = 0);
714 MultitrackModel &m_model;
722class AddTransitionByTrimOutCommand :
public TrimCommand
725 AddTransitionByTrimOutCommand(MultitrackModel &model,
731 QUndoCommand *parent = 0);
736 int id()
const {
return UndoIdAddTransitionByTrimOut; }
737 bool mergeWith(
const QUndoCommand *other);
740 MultitrackModel &m_model;
749class AddTrackCommand :
public QUndoCommand
752 AddTrackCommand(MultitrackModel &model,
bool isVideo, QUndoCommand *parent = 0);
757 MultitrackModel &m_model;
763class InsertTrackCommand :
public QUndoCommand
766 InsertTrackCommand(MultitrackModel &model,
768 TrackType trackType = PlaylistTrackType,
769 QUndoCommand *parent = 0);
774 MultitrackModel &m_model;
776 TrackType m_trackType;
780class RemoveTrackCommand :
public QUndoCommand
783 RemoveTrackCommand(MultitrackModel &model,
int trackIndex, QUndoCommand *parent = 0);
788 MultitrackModel &m_model;
790 TrackType m_trackType;
792 UndoHelper m_undoHelper;
793 QScopedPointer<Mlt::Producer> m_filtersProducer;
797class MoveTrackCommand :
public QUndoCommand
800 MoveTrackCommand(MultitrackModel &model,
803 QUndoCommand *parent = 0);
808 MultitrackModel &m_model;
809 int m_fromTrackIndex;
813class ChangeBlendModeCommand :
public QObject,
public QUndoCommand
817 ChangeBlendModeCommand(Mlt::Transition &transition,
818 const QString &propertyName,
820 QUndoCommand *parent = 0);
824 void modeChanged(QString &mode);
827 Mlt::Transition m_transition;
828 QString m_propertyName;
833class ChangeTransitionPropertyCommand :
public QObject,
public QUndoCommand
837 ChangeTransitionPropertyCommand(
int trackIndex,
838 const QString &propertyName,
841 QUndoCommand *parent = 0);
846 int id()
const {
return UndoIdChangeTransitionProperty; }
847 bool mergeWith(
const QUndoCommand *other);
850 void valueChanged(
double value);
854 QString m_propertyName;
859class UpdateCommand :
public QUndoCommand
862 UpdateCommand(TimelineDock &timeline,
866 QUndoCommand *parent = 0);
867 void setXmlAfter(
const QString &xml);
868 void setPosition(
int trackIndex,
int clipIndex,
int position);
869 void setRippleAllTracks(
bool);
870 int trackIndex()
const {
return m_trackIndex; }
871 int clipIndex()
const {
return m_clipIndex; }
872 int position()
const {
return m_position; }
877 TimelineDock &m_timeline;
883 UndoHelper m_undoHelper;
885 bool m_rippleAllTracks;
888class DetachAudioCommand :
public QUndoCommand
891 DetachAudioCommand(TimelineDock &timeline,
896 QUndoCommand *parent = 0);
901 TimelineDock &m_timeline;
905 int m_targetTrackIndex;
907 UndoHelper m_undoHelper;
912class ReplaceCommand :
public QUndoCommand
915 ReplaceCommand(MultitrackModel &model,
919 QUndoCommand *parent =
nullptr);
924 MultitrackModel &m_model;
929 UndoHelper m_undoHelper;
932class AlignClipsCommand :
public QUndoCommand
935 AlignClipsCommand(MultitrackModel &model, QUndoCommand *parent = 0);
936 void addAlignment(QUuid uuid,
int offset,
double speedCompensation);
941 MultitrackModel &m_model;
942 UndoHelper m_undoHelper;
950 QVector<Alignment> m_alignments;
953class ApplyFiltersCommand :
public QUndoCommand
956 ApplyFiltersCommand(MultitrackModel &model,
957 const QString &filterProducerXml,
958 QUndoCommand *parent = 0);
959 void addClip(
int trackIndex,
int clipIndex);
964 MultitrackModel &m_model;
966 QMap<ClipPosition, QString> m_prevFilters;
969class ChangeGainCommand :
public QUndoCommand
972 ChangeGainCommand(MultitrackModel &model,
976 QUndoCommand *parent = 0);
981 int id()
const {
return UndoIdChangeGain; }
982 bool mergeWith(
const QUndoCommand *other);
985 MultitrackModel &m_model;
992class ChangeTrackGainCommand :
public QUndoCommand
995 ChangeTrackGainCommand(MultitrackModel &model,
998 QUndoCommand *parent = 0);
1003 int id()
const {
return UndoIdChangeTrackGain; }
1004 bool mergeWith(
const QUndoCommand *other);
1007 MultitrackModel &m_model;