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