CuteLogger
Fast and simple logging solution for Qt based applications
timelinecommands.h
1/*
2 * Copyright (c) 2013-2026 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef COMMANDS_H
19#define COMMANDS_H
20
21#include "docks/timelinedock.h"
22#include "models/markersmodel.h"
23#include "models/multitrackmodel.h"
24#include "undohelper.h"
25
26#include <MltProducer.h>
27#include <MltTransition.h>
28#include <QObject>
29#include <QSet>
30#include <QString>
31#include <QUndoCommand>
32#include <QUuid>
33
34#include <vector>
35
36namespace Timeline {
37
38enum {
39 UndoIdTrimClipIn = 100,
40 UndoIdTrimClipOut,
41 UndoIdFadeIn,
42 UndoIdFadeOut,
43 UndoIdTrimTransitionIn,
44 UndoIdTrimTransitionOut,
45 UndoIdResizeTransition,
46 UndoIdAddTransitionByTrimIn,
47 UndoIdAddTransitionByTrimOut,
48 UndoIdUpdate,
49 UndoIdMoveClip,
50 UndoIdChangeGain,
51 UndoIdChangeTransitionProperty,
52 UndoIdChangeTrackGain,
53};
54
55struct ClipPosition
56{
57 ClipPosition(int track, int clip)
58 {
59 trackIndex = track;
60 clipIndex = clip;
61 }
62
63 bool operator<(const ClipPosition &rhs) const
64 {
65 if (trackIndex == rhs.trackIndex) {
66 return clipIndex < rhs.clipIndex;
67 } else {
68 return trackIndex < rhs.trackIndex;
69 }
70 }
71
72 int trackIndex;
73 int clipIndex;
74};
75
76class AppendCommand : public QUndoCommand
77{
78public:
79 AppendCommand(MultitrackModel &model,
80 int trackIndex,
81 const QString &xml,
82 bool skipProxy = false,
83 bool seek = true,
84 QUndoCommand *parent = 0);
85 void redo();
86 void undo();
87
88private:
89 MultitrackModel &m_model;
90 int m_trackIndex;
91 QString m_xml;
92 UndoHelper m_undoHelper;
93 bool m_skipProxy;
94 bool m_seek;
95 QVector<QUuid> m_uuids;
96};
97
98class InsertCommand : public QUndoCommand
99{
100public:
101 InsertCommand(MultitrackModel &model,
102 MarkersModel &markersModel,
103 int trackIndex,
104 int position,
105 const QString &xml,
106 bool seek = true,
107 QUndoCommand *parent = 0);
108 void redo();
109 void undo();
110
111private:
112 struct SplitDest
113 {
114 QString xml;
115 QUuid uuid;
116 int start = -1;
117 int frame_in = -1;
118 int frame_out = -1;
119 int group = -1;
120 bool isValid() const { return !xml.isEmpty(); }
121 };
122
123 bool undoByRemovingInserted();
124 void restoreSplitDest();
125 void snapshotSplitDest();
126
127 MultitrackModel &m_model;
128 MarkersModel &m_markersModel;
129 int m_trackIndex;
130 int m_position;
131 QString m_xml;
132 QStringList m_oldTracks;
133 UndoHelper m_undoHelper;
134 bool m_seek;
135 bool m_rippleAllTracks;
136 bool m_rippleMarkers;
137 int m_markersShift;
138 QVector<QUuid> m_uuids;
139 SplitDest m_splitDest;
140};
141
142class OverwriteCommand : public QUndoCommand
143{
144public:
145 OverwriteCommand(MultitrackModel &model,
146 int trackIndex,
147 int position,
148 const QString &xml,
149 bool seek = true,
150 QUndoCommand *parent = 0);
151 void redo();
152 void undo();
153
154private:
155 MultitrackModel &m_model;
156 int m_trackIndex;
157 int m_position;
158 QString m_xml;
159 UndoHelper m_undoHelper;
160 bool m_seek;
161 QVector<QUuid> m_uuids;
162};
163
164class LiftCommand : public QUndoCommand
165{
166public:
167 LiftCommand(MultitrackModel &model, int trackIndex, int clipIndex, QUndoCommand *parent = 0);
168 void redo();
169 void undo();
170
171private:
172 MultitrackModel &m_model;
173 int m_trackIndex;
174 int m_clipIndex;
175 UndoHelper m_undoHelper;
176};
177
178class RemoveCommand : public QUndoCommand
179{
180public:
181 RemoveCommand(MultitrackModel &model,
182 MarkersModel &markersModel,
183 int trackIndex,
184 int clipIndex,
185 QUndoCommand *parent = 0);
186 void redo();
187 void undo();
188
189private:
190 MultitrackModel &m_model;
191 MarkersModel &m_markersModel;
192 int m_trackIndex;
193 int m_clipIndex;
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;
200};
201
202class GroupCommand : public QUndoCommand
203{
204public:
205 GroupCommand(MultitrackModel &model, QUndoCommand *parent = 0);
206 void addToGroup(int trackIndex, int clipIndex);
207 void redo();
208 void undo();
209
210private:
211 MultitrackModel &m_model;
212 QList<ClipPosition> m_clips;
213 QMap<ClipPosition, int> m_prevGroups;
214};
215
216class UngroupCommand : public QUndoCommand
217{
218public:
219 UngroupCommand(MultitrackModel &model, QUndoCommand *parent = 0);
220 void removeFromGroup(int trackIndex, int clipIndex);
221 void redo();
222 void undo();
223
224private:
225 MultitrackModel &m_model;
226 QMap<ClipPosition, int> m_prevGroups;
227};
228
229class NameTrackCommand : public QUndoCommand
230{
231public:
232 NameTrackCommand(MultitrackModel &model,
233 int trackIndex,
234 const QString &name,
235 QUndoCommand *parent = 0);
236 void redo();
237 void undo();
238
239private:
240 MultitrackModel &m_model;
241 int m_trackIndex;
242 QString m_name;
243 QString m_oldName;
244};
245
246class MergeCommand : public QUndoCommand
247{
248public:
249 MergeCommand(MultitrackModel &model, int trackIndex, int clipIndex, QUndoCommand *parent = 0);
250 void redo();
251 void undo();
252
253private:
254 MultitrackModel &m_model;
255 int m_trackIndex;
256 int m_clipIndex;
257 UndoHelper m_undoHelper;
258};
259
260class MuteTrackCommand : public QUndoCommand
261{
262public:
263 MuteTrackCommand(MultitrackModel &model, int trackIndex, QUndoCommand *parent = 0);
264 void redo();
265 void undo();
266
267private:
268 MultitrackModel &m_model;
269 int m_trackIndex;
270 bool m_oldValue;
271};
272
273class HideTrackCommand : public QUndoCommand
274{
275public:
276 HideTrackCommand(MultitrackModel &model, int trackIndex, QUndoCommand *parent = 0);
277 void redo();
278 void undo();
279
280private:
281 MultitrackModel &m_model;
282 int m_trackIndex;
283 bool m_oldValue;
284};
285
286class CompositeTrackCommand : public QUndoCommand
287{
288public:
289 CompositeTrackCommand(MultitrackModel &model,
290 int trackIndex,
291 bool value,
292 QUndoCommand *parent = 0);
293 void redo();
294 void undo();
295
296private:
297 MultitrackModel &m_model;
298 int m_trackIndex;
299 bool m_value;
300 bool m_oldValue;
301};
302
303class LockTrackCommand : public QUndoCommand
304{
305public:
306 LockTrackCommand(MultitrackModel &model, int trackIndex, bool value, QUndoCommand *parent = 0);
307 void redo();
308 void undo();
309
310private:
311 MultitrackModel &m_model;
312 int m_trackIndex;
313 bool m_value;
314 bool m_oldValue;
315};
316
317class MoveClipCommand : public QUndoCommand
318{
319public:
320 MoveClipCommand(TimelineDock &timeline,
321 int trackDelta,
322 int positionDelta,
323 bool ripple,
324 QUndoCommand *parent = 0);
325 void addClip(int trackIndex, int clipIndex);
326 void redo();
327 void undo();
328
329protected:
330 int id() const { return UndoIdMoveClip; }
331 bool mergeWith(const QUndoCommand *other);
332
333private:
334 void redoMarkers();
335 QSet<int> trackScope() const;
336 bool undoExplicitMove();
337 bool undoTransitionGrow();
338 void snapshotOverwritten();
339 void captureGeneratedCuts();
340 bool restoreOverwritten();
341
342 TimelineDock &m_timeline;
343 MultitrackModel &m_model;
344 MarkersModel &m_markersModel;
345
346 struct Info
347 {
348 int trackIndex;
349 int clipIndex;
350 int frame_in;
351 int frame_out;
352 int start;
353 int group;
354 QUuid uuid;
355
356 Info()
357 : trackIndex(-1)
358 , clipIndex(-1)
359 , frame_in(-1)
360 , frame_out(-1)
361 , start(0)
362 , group(-1)
363 {}
364 };
365
366 // A clip-drag onto a neighboring mix grows it in place; undo is the opposite trim, never an
367 // XML restore (that dangles mix_in/mix_out and crashes the consumer).
368 enum SpecialMove { NoSpecialMove, GrowTransitionOut, GrowTransitionIn };
369
370 // A non-ripple drop deletes/splits the dest clips it lands on; snapshot them so undo can put
371 // them back without rebuilding the whole track.
372 struct Overwritten
373 {
374 int trackIndex = -1;
375 int start = 0;
376 int frame_in = -1;
377 int frame_out = -1;
378 int group = -1;
379 QUuid uuid;
380 QString xml;
381 };
382
383 int m_trackDelta;
384 int m_positionDelta;
385 bool m_ripple;
386 bool m_rippleAllTracks;
387 bool m_rippleMarkers;
388 UndoHelper m_undoHelper; // captures the before-snapshot for the whole-track undo fallback
389 QMultiMap<int, Info> m_clips; // ordered by position
390 SpecialMove m_specialMove = NoSpecialMove;
391 QList<Overwritten> m_overwritten;
392 QSet<QUuid> m_generatedCuts;
393 bool m_redo;
394 int m_earliestStart;
395 QList<Markers::Marker> m_markers;
396 int m_markersModified;
397};
398
399class TrimCommand : public QUndoCommand
400{
401public:
402 explicit TrimCommand(QUndoCommand *parent = 0)
403 : QUndoCommand(parent)
404 {}
405 void setUndoHelper(UndoHelper *helper)
406 {
407 m_undoHelper.reset(helper);
408 if (m_undoHelper)
409 m_undoHelper->setText(text());
410 }
411
412protected:
413 QScopedPointer<UndoHelper> m_undoHelper;
414};
415
416class TrimClipInCommand : public TrimCommand
417{
418public:
419 TrimClipInCommand(MultitrackModel &model,
420 MarkersModel &markersModel,
421 int trackIndex,
422 int clipIndex,
423 int delta,
424 bool ripple,
425 bool redo = true,
426 QUndoCommand *parent = 0);
427 void redo();
428 void undo();
429
430protected:
431 int id() const { return UndoIdTrimClipIn; }
432 bool mergeWith(const QUndoCommand *other);
433
434private:
435 MultitrackModel &m_model;
436 MarkersModel &m_markersModel;
437 int m_trackIndex;
438 int m_clipIndex;
439 int m_delta;
440 bool m_ripple;
441 bool m_rippleAllTracks;
442 bool m_rippleMarkers;
443 bool m_redo;
444 int m_markerRemoveStart;
445 int m_markerRemoveEnd;
446 QList<Markers::Marker> m_markers;
447};
448
449class TrimClipOutCommand : public TrimCommand
450{
451public:
452 TrimClipOutCommand(MultitrackModel &model,
453 MarkersModel &markersModel,
454 int trackIndex,
455 int clipIndex,
456 int delta,
457 bool ripple,
458 bool redo = true,
459 QUndoCommand *parent = 0);
460 void redo();
461 void undo();
462
463protected:
464 int id() const { return UndoIdTrimClipOut; }
465 bool mergeWith(const QUndoCommand *other);
466
467private:
468 MultitrackModel &m_model;
469 MarkersModel &m_markersModel;
470 int m_trackIndex;
471 int m_clipIndex;
472 int m_delta;
473 bool m_ripple;
474 bool m_rippleAllTracks;
475 bool m_rippleMarkers;
476 bool m_redo;
477 int m_markerRemoveStart;
478 int m_markerRemoveEnd;
479 QList<Markers::Marker> m_markers;
480};
481
482class SplitCommand : public QUndoCommand
483{
484public:
485 SplitCommand(MultitrackModel &model,
486 const std::vector<int> &trackIndex,
487 const std::vector<int> &clipIndex,
488 int position,
489 QUndoCommand *parent = 0);
490 void redo();
491 void undo();
492
493private:
494 MultitrackModel &m_model;
495 std::vector<int> m_trackIndex;
496 std::vector<int> m_clipIndex;
497 int m_position;
498 UndoHelper m_undoHelper;
499};
500
501class FadeInCommand : public QUndoCommand
502{
503public:
504 FadeInCommand(MultitrackModel &model,
505 int trackIndex,
506 int clipIndex,
507 int duration,
508 QUndoCommand *parent = 0);
509 void redo();
510 void undo();
511
512protected:
513 int id() const { return UndoIdFadeIn; }
514 bool mergeWith(const QUndoCommand *other);
515
516private:
517 MultitrackModel &m_model;
518 int m_trackIndex;
519 int m_clipIndex;
520 int m_duration;
521 int m_previous;
522};
523
524class FadeOutCommand : public QUndoCommand
525{
526public:
527 FadeOutCommand(MultitrackModel &model,
528 int trackIndex,
529 int clipIndex,
530 int duration,
531 QUndoCommand *parent = 0);
532 void redo();
533 void undo();
534
535protected:
536 int id() const { return UndoIdFadeOut; }
537 bool mergeWith(const QUndoCommand *other);
538
539private:
540 MultitrackModel &m_model;
541 int m_trackIndex;
542 int m_clipIndex;
543 int m_duration;
544 int m_previous;
545};
546
547class AddTransitionCommand : public QUndoCommand
548{
549public:
550 AddTransitionCommand(TimelineDock &timeline,
551 int trackIndex,
552 int clipIndex,
553 int position,
554 bool ripple,
555 QUndoCommand *parent = 0);
556 void redo();
557 void undo();
558 int getTransitionIndex() const { return m_transitionIndex; }
559
560private:
561 TimelineDock &m_timeline;
562 MultitrackModel &m_model;
563 MarkersModel &m_markersModel;
564 int m_trackIndex;
565 int m_clipIndex;
566 int m_position;
567 int m_transitionIndex;
568 bool m_ripple;
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;
575};
576
577class TrimTransitionInCommand : public TrimCommand
578{
579public:
580 TrimTransitionInCommand(MultitrackModel &model,
581 int trackIndex,
582 int clipIndex,
583 int delta,
584 bool redo = true,
585 QUndoCommand *parent = 0);
586 void redo();
587 void undo();
588
589protected:
590 int id() const { return UndoIdTrimTransitionIn; }
591 bool mergeWith(const QUndoCommand *other);
592
593private:
594 MultitrackModel &m_model;
595 int m_trackIndex;
596 int m_clipIndex;
597 int m_delta;
598 bool m_notify;
599 bool m_redo;
600};
601
602class TrimTransitionOutCommand : public TrimCommand
603{
604public:
605 TrimTransitionOutCommand(MultitrackModel &model,
606 int trackIndex,
607 int clipIndex,
608 int delta,
609 bool redo = true,
610 QUndoCommand *parent = 0);
611 void redo();
612 void undo();
613
614protected:
615 int id() const { return UndoIdTrimTransitionOut; }
616 bool mergeWith(const QUndoCommand *other);
617
618private:
619 MultitrackModel &m_model;
620 int m_trackIndex;
621 int m_clipIndex;
622 int m_delta;
623 bool m_notify;
624 bool m_redo;
625};
626
627class ResizeTransitionCommand : public TrimCommand
628{
629public:
630 ResizeTransitionCommand(MultitrackModel &model,
631 int trackIndex,
632 int transitionIndex,
633 int delta,
634 bool redo = true,
635 QUndoCommand *parent = 0);
636 void redo();
637 void undo();
638
639protected:
640 int id() const { return UndoIdResizeTransition; }
641 bool mergeWith(const QUndoCommand *other);
642
643private:
644 MultitrackModel &m_model;
645 int m_trackIndex;
646 int m_transitionIndex;
647 int m_delta;
648 bool m_redo;
649};
650
651class AddTransitionByTrimInCommand : public TrimCommand
652{
653public:
654 AddTransitionByTrimInCommand(TimelineDock &timeline,
655 int trackIndex,
656 int clipIndex,
657 int duration,
658 int trimDelta,
659 bool redo = true,
660 QUndoCommand *parent = 0);
661 void redo();
662 void undo();
663
664protected:
665 int id() const { return UndoIdAddTransitionByTrimIn; }
666 bool mergeWith(const QUndoCommand *other);
667
668private:
669 TimelineDock &m_timeline;
670 int m_trackIndex;
671 int m_clipIndex;
672 int m_duration;
673 int m_trimDelta;
674 bool m_notify;
675 bool m_redo;
676};
677
678class RemoveTransitionByTrimInCommand : public TrimCommand
679{
680public:
681 RemoveTransitionByTrimInCommand(MultitrackModel &model,
682 int trackIndex,
683 int clipIndex,
684 int delta,
685 QString xml,
686 bool redo = true,
687 QUndoCommand *parent = 0);
688 void redo();
689 void undo();
690
691private:
692 MultitrackModel &m_model;
693 int m_trackIndex;
694 int m_clipIndex;
695 int m_delta;
696 QString m_xml;
697 bool m_redo;
698};
699
700class RemoveTransitionByTrimOutCommand : public TrimCommand
701{
702public:
703 RemoveTransitionByTrimOutCommand(MultitrackModel &model,
704 int trackIndex,
705 int clipIndex,
706 int delta,
707 QString xml,
708 bool redo = true,
709 QUndoCommand *parent = 0);
710 void redo();
711 void undo();
712
713private:
714 MultitrackModel &m_model;
715 int m_trackIndex;
716 int m_clipIndex;
717 int m_delta;
718 QString m_xml;
719 bool m_redo;
720};
721
722class AddTransitionByTrimOutCommand : public TrimCommand
723{
724public:
725 AddTransitionByTrimOutCommand(MultitrackModel &model,
726 int trackIndex,
727 int clipIndex,
728 int duration,
729 int trimDelta,
730 bool redo = true,
731 QUndoCommand *parent = 0);
732 void redo();
733 void undo();
734
735protected:
736 int id() const { return UndoIdAddTransitionByTrimOut; }
737 bool mergeWith(const QUndoCommand *other);
738
739private:
740 MultitrackModel &m_model;
741 int m_trackIndex;
742 int m_clipIndex;
743 int m_duration;
744 int m_trimDelta;
745 bool m_notify;
746 bool m_redo;
747};
748
749class AddTrackCommand : public QUndoCommand
750{
751public:
752 AddTrackCommand(MultitrackModel &model, bool isVideo, QUndoCommand *parent = 0);
753 void redo();
754 void undo();
755
756private:
757 MultitrackModel &m_model;
758 int m_trackIndex;
759 bool m_isVideo;
760 QUuid m_uuid;
761};
762
763class InsertTrackCommand : public QUndoCommand
764{
765public:
766 InsertTrackCommand(MultitrackModel &model,
767 int trackIndex,
768 TrackType trackType = PlaylistTrackType,
769 QUndoCommand *parent = 0);
770 void redo();
771 void undo();
772
773private:
774 MultitrackModel &m_model;
775 int m_trackIndex;
776 TrackType m_trackType;
777 QUuid m_uuid;
778};
779
780class RemoveTrackCommand : public QUndoCommand
781{
782public:
783 RemoveTrackCommand(MultitrackModel &model, int trackIndex, QUndoCommand *parent = 0);
784 void redo();
785 void undo();
786
787private:
788 MultitrackModel &m_model;
789 int m_trackIndex;
790 TrackType m_trackType;
791 QString m_trackName;
792 UndoHelper m_undoHelper;
793 QScopedPointer<Mlt::Producer> m_filtersProducer;
794 QUuid m_uuid;
795};
796
797class MoveTrackCommand : public QUndoCommand
798{
799public:
800 MoveTrackCommand(MultitrackModel &model,
801 int fromTrackIndex,
802 int toTrackIndex,
803 QUndoCommand *parent = 0);
804 void redo();
805 void undo();
806
807private:
808 MultitrackModel &m_model;
809 int m_fromTrackIndex;
810 int m_toTrackIndex;
811};
812
813class ChangeBlendModeCommand : public QObject, public QUndoCommand
814{
815 Q_OBJECT
816public:
817 ChangeBlendModeCommand(Mlt::Transition &transition,
818 const QString &propertyName,
819 const QString &mode,
820 QUndoCommand *parent = 0);
821 void redo();
822 void undo();
823signals:
824 void modeChanged(QString &mode);
825
826private:
827 Mlt::Transition m_transition;
828 QString m_propertyName;
829 QString m_newMode;
830 QString m_oldMode;
831};
832
833class ChangeTransitionPropertyCommand : public QObject, public QUndoCommand
834{
835 Q_OBJECT
836public:
837 ChangeTransitionPropertyCommand(int trackIndex,
838 const QString &propertyName,
839 double value,
840 const QString &text,
841 QUndoCommand *parent = 0);
842 void redo();
843 void undo();
844
845protected:
846 int id() const { return UndoIdChangeTransitionProperty; }
847 bool mergeWith(const QUndoCommand *other);
848
849signals:
850 void valueChanged(double value);
851
852private:
853 int m_trackIndex;
854 QString m_propertyName;
855 double m_newValue;
856 double m_oldValue;
857};
858
859class UpdateCommand : public QUndoCommand
860{
861public:
862 UpdateCommand(TimelineDock &timeline,
863 int trackIndex,
864 int clipIndex,
865 int position,
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; }
873 void redo();
874 void undo();
875
876private:
877 TimelineDock &m_timeline;
878 int m_trackIndex;
879 int m_clipIndex;
880 int m_position;
881 QString m_xmlAfter;
882 bool m_isFirstRedo;
883 UndoHelper m_undoHelper;
884 bool m_ripple;
885 bool m_rippleAllTracks;
886};
887
888class DetachAudioCommand : public QUndoCommand
889{
890public:
891 DetachAudioCommand(TimelineDock &timeline,
892 int trackIndex,
893 int clipIndex,
894 int position,
895 const QString &xml,
896 QUndoCommand *parent = 0);
897 void redo();
898 void undo();
899
900private:
901 TimelineDock &m_timeline;
902 int m_trackIndex;
903 int m_clipIndex;
904 int m_position;
905 int m_targetTrackIndex;
906 QString m_xml;
907 UndoHelper m_undoHelper;
908 bool m_trackAdded;
909 QUuid m_uuid;
910};
911
912class ReplaceCommand : public QUndoCommand
913{
914public:
915 ReplaceCommand(MultitrackModel &model,
916 int trackIndex,
917 int clipIndex,
918 const QString &xml,
919 QUndoCommand *parent = nullptr);
920 void redo();
921 void undo();
922
923private:
924 MultitrackModel &m_model;
925 int m_trackIndex;
926 int m_clipIndex;
927 QString m_xml;
928 bool m_isFirstRedo;
929 UndoHelper m_undoHelper;
930};
931
932class AlignClipsCommand : public QUndoCommand
933{
934public:
935 AlignClipsCommand(MultitrackModel &model, QUndoCommand *parent = 0);
936 void addAlignment(QUuid uuid, int offset, double speedCompensation);
937 void redo();
938 void undo();
939
940private:
941 MultitrackModel &m_model;
942 UndoHelper m_undoHelper;
943 bool m_redo;
944 struct Alignment
945 {
946 QUuid uuid;
947 int offset;
948 double speed;
949 };
950 QVector<Alignment> m_alignments;
951};
952
953class ApplyFiltersCommand : public QUndoCommand
954{
955public:
956 ApplyFiltersCommand(MultitrackModel &model,
957 const QString &filterProducerXml,
958 QUndoCommand *parent = 0);
959 void addClip(int trackIndex, int clipIndex);
960 void redo();
961 void undo();
962
963private:
964 MultitrackModel &m_model;
965 QString m_xml;
966 QMap<ClipPosition, QString> m_prevFilters;
967};
968
969class ChangeGainCommand : public QUndoCommand
970{
971public:
972 ChangeGainCommand(MultitrackModel &model,
973 int trackIndex,
974 int clipIndex,
975 double gain,
976 QUndoCommand *parent = 0);
977 void redo();
978 void undo();
979
980protected:
981 int id() const { return UndoIdChangeGain; }
982 bool mergeWith(const QUndoCommand *other);
983
984private:
985 MultitrackModel &m_model;
986 int m_trackIndex;
987 int m_clipIndex;
988 double m_gain;
989 double m_previous;
990};
991
992class ChangeTrackGainCommand : public QUndoCommand
993{
994public:
995 ChangeTrackGainCommand(MultitrackModel &model,
996 int trackIndex,
997 double gain,
998 QUndoCommand *parent = 0);
999 void redo();
1000 void undo();
1001
1002protected:
1003 int id() const { return UndoIdChangeTrackGain; }
1004 bool mergeWith(const QUndoCommand *other);
1005
1006private:
1007 MultitrackModel &m_model;
1008 int m_trackIndex;
1009 double m_gain;
1010 double m_previous;
1011};
1012
1013} // namespace Timeline
1014
1015#endif