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 ChangeTrackRoleCommand : public QUndoCommand
249{
250public:
251 ChangeTrackRoleCommand(MultitrackModel &model,
252 int trackIndex,
253 AudioTrackRole role,
254 QUndoCommand *parent = 0);
255 void redo();
256 void undo();
257
258private:
259 MultitrackModel &m_model;
260 int m_trackIndex;
261 AudioTrackRole m_role;
262 AudioTrackRole m_oldRole;
263};
264
265class MergeCommand : public QUndoCommand
266{
267public:
268 MergeCommand(MultitrackModel &model, int trackIndex, int clipIndex, QUndoCommand *parent = 0);
269 void redo();
270 void undo();
271
272private:
273 MultitrackModel &m_model;
274 int m_trackIndex;
275 int m_clipIndex;
276 UndoHelper m_undoHelper;
277};
278
279class MuteTrackCommand : public QUndoCommand
280{
281public:
282 MuteTrackCommand(MultitrackModel &model, int trackIndex, QUndoCommand *parent = 0);
283 void redo();
284 void undo();
285
286private:
287 MultitrackModel &m_model;
288 int m_trackIndex;
289 bool m_oldValue;
290};
291
292class HideTrackCommand : public QUndoCommand
293{
294public:
295 HideTrackCommand(MultitrackModel &model, int trackIndex, QUndoCommand *parent = 0);
296 void redo();
297 void undo();
298
299private:
300 MultitrackModel &m_model;
301 int m_trackIndex;
302 bool m_oldValue;
303};
304
305class CompositeTrackCommand : public QUndoCommand
306{
307public:
308 CompositeTrackCommand(MultitrackModel &model,
309 int trackIndex,
310 bool value,
311 QUndoCommand *parent = 0);
312 void redo();
313 void undo();
314
315private:
316 MultitrackModel &m_model;
317 int m_trackIndex;
318 bool m_value;
319 bool m_oldValue;
320};
321
322class LockTrackCommand : public QUndoCommand
323{
324public:
325 LockTrackCommand(MultitrackModel &model, int trackIndex, bool value, QUndoCommand *parent = 0);
326 void redo();
327 void undo();
328
329private:
330 MultitrackModel &m_model;
331 int m_trackIndex;
332 bool m_value;
333 bool m_oldValue;
334};
335
336class MoveClipCommand : public QUndoCommand
337{
338public:
339 MoveClipCommand(TimelineDock &timeline,
340 int trackDelta,
341 int positionDelta,
342 bool ripple,
343 QUndoCommand *parent = 0);
344 void addClip(int trackIndex, int clipIndex);
345 void redo();
346 void undo();
347
348protected:
349 int id() const { return UndoIdMoveClip; }
350 bool mergeWith(const QUndoCommand *other);
351
352private:
353 void redoMarkers();
354 QSet<int> trackScope() const;
355 bool undoExplicitMove();
356 bool undoTransitionGrow();
357 void snapshotOverwritten();
358 void captureGeneratedCuts();
359 bool restoreOverwritten();
360
361 TimelineDock &m_timeline;
362 MultitrackModel &m_model;
363 MarkersModel &m_markersModel;
364
365 struct Info
366 {
367 int trackIndex;
368 int clipIndex;
369 int frame_in;
370 int frame_out;
371 int start;
372 int group;
373 QUuid uuid;
374
375 Info()
376 : trackIndex(-1)
377 , clipIndex(-1)
378 , frame_in(-1)
379 , frame_out(-1)
380 , start(0)
381 , group(-1)
382 {}
383 };
384
385 // A clip-drag onto a neighboring mix grows it in place; undo is the opposite trim, never an
386 // XML restore (that dangles mix_in/mix_out and crashes the consumer).
387 enum SpecialMove { NoSpecialMove, GrowTransitionOut, GrowTransitionIn };
388
389 // A non-ripple drop deletes/splits the dest clips it lands on; snapshot them so undo can put
390 // them back without rebuilding the whole track.
391 struct Overwritten
392 {
393 int trackIndex = -1;
394 int start = 0;
395 int frame_in = -1;
396 int frame_out = -1;
397 int group = -1;
398 QUuid uuid;
399 QString xml;
400 };
401
402 int m_trackDelta;
403 int m_positionDelta;
404 bool m_ripple;
405 bool m_rippleAllTracks;
406 bool m_rippleMarkers;
407 UndoHelper m_undoHelper; // captures the before-snapshot for the whole-track undo fallback
408 QMultiMap<int, Info> m_clips; // ordered by position
409 SpecialMove m_specialMove = NoSpecialMove;
410 QList<Overwritten> m_overwritten;
411 QSet<QUuid> m_generatedCuts;
412 bool m_redo;
413 int m_earliestStart;
414 QList<Markers::Marker> m_markers;
415 int m_markersModified;
416};
417
418class TrimCommand : public QUndoCommand
419{
420public:
421 explicit TrimCommand(QUndoCommand *parent = 0)
422 : QUndoCommand(parent)
423 {}
424 void setUndoHelper(UndoHelper *helper)
425 {
426 m_undoHelper.reset(helper);
427 if (m_undoHelper)
428 m_undoHelper->setText(text());
429 }
430
431protected:
432 QScopedPointer<UndoHelper> m_undoHelper;
433};
434
435class TrimClipInCommand : public TrimCommand
436{
437public:
438 TrimClipInCommand(MultitrackModel &model,
439 MarkersModel &markersModel,
440 int trackIndex,
441 int clipIndex,
442 int delta,
443 bool ripple,
444 bool redo = true,
445 QUndoCommand *parent = 0);
446 void redo();
447 void undo();
448
449protected:
450 int id() const { return UndoIdTrimClipIn; }
451 bool mergeWith(const QUndoCommand *other);
452
453private:
454 MultitrackModel &m_model;
455 MarkersModel &m_markersModel;
456 int m_trackIndex;
457 int m_clipIndex;
458 int m_delta;
459 bool m_ripple;
460 bool m_rippleAllTracks;
461 bool m_rippleMarkers;
462 bool m_redo;
463 int m_markerRemoveStart;
464 int m_markerRemoveEnd;
465 QList<Markers::Marker> m_markers;
466};
467
468class TrimClipOutCommand : public TrimCommand
469{
470public:
471 TrimClipOutCommand(MultitrackModel &model,
472 MarkersModel &markersModel,
473 int trackIndex,
474 int clipIndex,
475 int delta,
476 bool ripple,
477 bool redo = true,
478 QUndoCommand *parent = 0);
479 void redo();
480 void undo();
481
482protected:
483 int id() const { return UndoIdTrimClipOut; }
484 bool mergeWith(const QUndoCommand *other);
485
486private:
487 MultitrackModel &m_model;
488 MarkersModel &m_markersModel;
489 int m_trackIndex;
490 int m_clipIndex;
491 int m_delta;
492 bool m_ripple;
493 bool m_rippleAllTracks;
494 bool m_rippleMarkers;
495 bool m_redo;
496 int m_markerRemoveStart;
497 int m_markerRemoveEnd;
498 QList<Markers::Marker> m_markers;
499};
500
501class SplitCommand : public QUndoCommand
502{
503public:
504 SplitCommand(MultitrackModel &model,
505 const std::vector<int> &trackIndex,
506 const std::vector<int> &clipIndex,
507 int position,
508 QUndoCommand *parent = 0);
509 void redo();
510 void undo();
511
512private:
513 MultitrackModel &m_model;
514 std::vector<int> m_trackIndex;
515 std::vector<int> m_clipIndex;
516 int m_position;
517 UndoHelper m_undoHelper;
518};
519
520class FadeInCommand : public QUndoCommand
521{
522public:
523 FadeInCommand(MultitrackModel &model,
524 int trackIndex,
525 int clipIndex,
526 int duration,
527 QUndoCommand *parent = 0);
528 void redo();
529 void undo();
530
531protected:
532 int id() const { return UndoIdFadeIn; }
533 bool mergeWith(const QUndoCommand *other);
534
535private:
536 MultitrackModel &m_model;
537 int m_trackIndex;
538 int m_clipIndex;
539 int m_duration;
540 int m_previous;
541};
542
543class FadeOutCommand : public QUndoCommand
544{
545public:
546 FadeOutCommand(MultitrackModel &model,
547 int trackIndex,
548 int clipIndex,
549 int duration,
550 QUndoCommand *parent = 0);
551 void redo();
552 void undo();
553
554protected:
555 int id() const { return UndoIdFadeOut; }
556 bool mergeWith(const QUndoCommand *other);
557
558private:
559 MultitrackModel &m_model;
560 int m_trackIndex;
561 int m_clipIndex;
562 int m_duration;
563 int m_previous;
564};
565
566class AddTransitionCommand : public QUndoCommand
567{
568public:
569 AddTransitionCommand(TimelineDock &timeline,
570 int trackIndex,
571 int clipIndex,
572 int position,
573 bool ripple,
574 QUndoCommand *parent = 0);
575 void redo();
576 void undo();
577 int getTransitionIndex() const { return m_transitionIndex; }
578
579private:
580 TimelineDock &m_timeline;
581 MultitrackModel &m_model;
582 MarkersModel &m_markersModel;
583 int m_trackIndex;
584 int m_clipIndex;
585 int m_position;
586 int m_transitionIndex;
587 bool m_ripple;
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;
594};
595
596class TrimTransitionInCommand : public TrimCommand
597{
598public:
599 TrimTransitionInCommand(MultitrackModel &model,
600 int trackIndex,
601 int clipIndex,
602 int delta,
603 bool redo = true,
604 QUndoCommand *parent = 0);
605 void redo();
606 void undo();
607
608protected:
609 int id() const { return UndoIdTrimTransitionIn; }
610 bool mergeWith(const QUndoCommand *other);
611
612private:
613 MultitrackModel &m_model;
614 int m_trackIndex;
615 int m_clipIndex;
616 int m_delta;
617 bool m_notify;
618 bool m_redo;
619};
620
621class TrimTransitionOutCommand : public TrimCommand
622{
623public:
624 TrimTransitionOutCommand(MultitrackModel &model,
625 int trackIndex,
626 int clipIndex,
627 int delta,
628 bool redo = true,
629 QUndoCommand *parent = 0);
630 void redo();
631 void undo();
632
633protected:
634 int id() const { return UndoIdTrimTransitionOut; }
635 bool mergeWith(const QUndoCommand *other);
636
637private:
638 MultitrackModel &m_model;
639 int m_trackIndex;
640 int m_clipIndex;
641 int m_delta;
642 bool m_notify;
643 bool m_redo;
644};
645
646class ResizeTransitionCommand : public TrimCommand
647{
648public:
649 ResizeTransitionCommand(MultitrackModel &model,
650 int trackIndex,
651 int transitionIndex,
652 int delta,
653 bool redo = true,
654 QUndoCommand *parent = 0);
655 void redo();
656 void undo();
657
658protected:
659 int id() const { return UndoIdResizeTransition; }
660 bool mergeWith(const QUndoCommand *other);
661
662private:
663 MultitrackModel &m_model;
664 int m_trackIndex;
665 int m_transitionIndex;
666 int m_delta;
667 bool m_redo;
668};
669
670class AddTransitionByTrimInCommand : public TrimCommand
671{
672public:
673 AddTransitionByTrimInCommand(TimelineDock &timeline,
674 int trackIndex,
675 int clipIndex,
676 int duration,
677 int trimDelta,
678 bool redo = true,
679 QUndoCommand *parent = 0);
680 void redo();
681 void undo();
682
683protected:
684 int id() const { return UndoIdAddTransitionByTrimIn; }
685 bool mergeWith(const QUndoCommand *other);
686
687private:
688 TimelineDock &m_timeline;
689 int m_trackIndex;
690 int m_clipIndex;
691 int m_duration;
692 int m_trimDelta;
693 bool m_notify;
694 bool m_redo;
695};
696
697class RemoveTransitionByTrimInCommand : public TrimCommand
698{
699public:
700 RemoveTransitionByTrimInCommand(MultitrackModel &model,
701 int trackIndex,
702 int clipIndex,
703 int delta,
704 QString xml,
705 bool redo = true,
706 QUndoCommand *parent = 0);
707 void redo();
708 void undo();
709
710private:
711 MultitrackModel &m_model;
712 int m_trackIndex;
713 int m_clipIndex;
714 int m_delta;
715 QString m_xml;
716 bool m_redo;
717};
718
719class RemoveTransitionByTrimOutCommand : public TrimCommand
720{
721public:
722 RemoveTransitionByTrimOutCommand(MultitrackModel &model,
723 int trackIndex,
724 int clipIndex,
725 int delta,
726 QString xml,
727 bool redo = true,
728 QUndoCommand *parent = 0);
729 void redo();
730 void undo();
731
732private:
733 MultitrackModel &m_model;
734 int m_trackIndex;
735 int m_clipIndex;
736 int m_delta;
737 QString m_xml;
738 bool m_redo;
739};
740
741class AddTransitionByTrimOutCommand : public TrimCommand
742{
743public:
744 AddTransitionByTrimOutCommand(MultitrackModel &model,
745 int trackIndex,
746 int clipIndex,
747 int duration,
748 int trimDelta,
749 bool redo = true,
750 QUndoCommand *parent = 0);
751 void redo();
752 void undo();
753
754protected:
755 int id() const { return UndoIdAddTransitionByTrimOut; }
756 bool mergeWith(const QUndoCommand *other);
757
758private:
759 MultitrackModel &m_model;
760 int m_trackIndex;
761 int m_clipIndex;
762 int m_duration;
763 int m_trimDelta;
764 bool m_notify;
765 bool m_redo;
766};
767
768class AddTrackCommand : public QUndoCommand
769{
770public:
771 AddTrackCommand(MultitrackModel &model, bool isVideo, QUndoCommand *parent = 0);
772 void redo();
773 void undo();
774
775private:
776 MultitrackModel &m_model;
777 int m_trackIndex;
778 bool m_isVideo;
779 QUuid m_uuid;
780};
781
782class InsertTrackCommand : public QUndoCommand
783{
784public:
785 InsertTrackCommand(MultitrackModel &model,
786 int trackIndex,
787 TrackType trackType = PlaylistTrackType,
788 QUndoCommand *parent = 0);
789 void redo();
790 void undo();
791
792private:
793 MultitrackModel &m_model;
794 int m_trackIndex;
795 TrackType m_trackType;
796 QUuid m_uuid;
797};
798
799class RemoveTrackCommand : public QUndoCommand
800{
801public:
802 RemoveTrackCommand(MultitrackModel &model, int trackIndex, QUndoCommand *parent = 0);
803 void redo();
804 void undo();
805
806private:
807 MultitrackModel &m_model;
808 int m_trackIndex;
809 TrackType m_trackType;
810 QString m_trackName;
811 UndoHelper m_undoHelper;
812 QScopedPointer<Mlt::Producer> m_filtersProducer;
813 QUuid m_uuid;
814};
815
816class MoveTrackCommand : public QUndoCommand
817{
818public:
819 MoveTrackCommand(MultitrackModel &model,
820 int fromTrackIndex,
821 int toTrackIndex,
822 QUndoCommand *parent = 0);
823 void redo();
824 void undo();
825
826private:
827 MultitrackModel &m_model;
828 int m_fromTrackIndex;
829 int m_toTrackIndex;
830};
831
832class ChangeBlendModeCommand : public QObject, public QUndoCommand
833{
834 Q_OBJECT
835public:
836 ChangeBlendModeCommand(Mlt::Transition &transition,
837 const QString &propertyName,
838 const QString &mode,
839 QUndoCommand *parent = 0);
840 void redo();
841 void undo();
842signals:
843 void modeChanged(QString &mode);
844
845private:
846 Mlt::Transition m_transition;
847 QString m_propertyName;
848 QString m_newMode;
849 QString m_oldMode;
850};
851
852class ChangeTransitionPropertyCommand : public QObject, public QUndoCommand
853{
854 Q_OBJECT
855public:
856 ChangeTransitionPropertyCommand(int trackIndex,
857 const QString &propertyName,
858 double value,
859 const QString &text,
860 bool mergeable = true,
861 QUndoCommand *parent = 0);
862 void redo();
863 void undo();
864
865protected:
866 int id() const { return UndoIdChangeTransitionProperty; }
867 bool mergeWith(const QUndoCommand *other);
868
869signals:
870 void valueChanged(double value);
871
872private:
873 int m_trackIndex;
874 QString m_propertyName;
875 double m_newValue;
876 double m_oldValue;
877 bool m_mergeable;
878};
879
880// Updates the shadow (user-intended) threshold and, when ducking is enabled, the real
881// threshold together as a single mergeable undo step.
882class ChangeDuckThresholdCommand : public QObject, public QUndoCommand
883{
884 Q_OBJECT
885public:
886 ChangeDuckThresholdCommand(int trackIndex,
887 double value,
888 bool enabled,
889 const QString &text = QString(),
890 bool isToggle = false,
891 QUndoCommand *parent = 0);
892 void redo();
893 void undo();
894
895protected:
896 int id() const { return m_isToggle ? UndoIdChangeDuckEnabled : UndoIdChangeDuckThreshold; }
897 bool mergeWith(const QUndoCommand *other);
898
899signals:
900 void valueChanged(double value);
901
902private:
903 int m_trackIndex;
904 bool m_enabled;
905 bool m_isToggle;
906 double m_newValue;
907 double m_oldValue;
908 double m_oldRealValue;
909};
910
911class UpdateCommand : public QUndoCommand
912{
913public:
914 UpdateCommand(TimelineDock &timeline,
915 int trackIndex,
916 int clipIndex,
917 int position,
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; }
925 void redo();
926 void undo();
927
928private:
929 TimelineDock &m_timeline;
930 int m_trackIndex;
931 int m_clipIndex;
932 int m_position;
933 QString m_xmlAfter;
934 bool m_isFirstRedo;
935 UndoHelper m_undoHelper;
936 bool m_ripple;
937 bool m_rippleAllTracks;
938};
939
940class DetachAudioCommand : public QUndoCommand
941{
942public:
943 DetachAudioCommand(TimelineDock &timeline,
944 int trackIndex,
945 int clipIndex,
946 int position,
947 const QString &xml,
948 QUndoCommand *parent = 0);
949 void redo();
950 void undo();
951
952private:
953 TimelineDock &m_timeline;
954 int m_trackIndex;
955 int m_clipIndex;
956 int m_position;
957 int m_targetTrackIndex;
958 QString m_xml;
959 UndoHelper m_undoHelper;
960 bool m_trackAdded;
961 QUuid m_uuid;
962};
963
964class ReplaceCommand : public QUndoCommand
965{
966public:
967 ReplaceCommand(MultitrackModel &model,
968 int trackIndex,
969 int clipIndex,
970 const QString &xml,
971 QUndoCommand *parent = nullptr);
972 void redo();
973 void undo();
974
975private:
976 MultitrackModel &m_model;
977 int m_trackIndex;
978 int m_clipIndex;
979 QString m_xml;
980 bool m_isFirstRedo;
981 UndoHelper m_undoHelper;
982};
983
984class AlignClipsCommand : public QUndoCommand
985{
986public:
987 AlignClipsCommand(MultitrackModel &model, QUndoCommand *parent = 0);
988 void addAlignment(QUuid uuid, int offset, double speedCompensation);
989 void redo();
990 void undo();
991
992private:
993 MultitrackModel &m_model;
994 UndoHelper m_undoHelper;
995 bool m_redo;
996 struct Alignment
997 {
998 QUuid uuid;
999 int offset;
1000 double speed;
1001 };
1002 QVector<Alignment> m_alignments;
1003};
1004
1005class ApplyFiltersCommand : public QUndoCommand
1006{
1007public:
1008 ApplyFiltersCommand(MultitrackModel &model,
1009 const QString &filterProducerXml,
1010 QUndoCommand *parent = 0);
1011 void addClip(int trackIndex, int clipIndex);
1012 void redo();
1013 void undo();
1014
1015private:
1016 MultitrackModel &m_model;
1017 QString m_xml;
1018 QMap<ClipPosition, QString> m_prevFilters;
1019};
1020
1021class ChangeGainCommand : public QUndoCommand
1022{
1023public:
1024 ChangeGainCommand(MultitrackModel &model,
1025 int trackIndex,
1026 int clipIndex,
1027 double gain,
1028 QUndoCommand *parent = 0);
1029 void redo();
1030 void undo();
1031
1032protected:
1033 int id() const { return UndoIdChangeGain; }
1034 bool mergeWith(const QUndoCommand *other);
1035
1036private:
1037 MultitrackModel &m_model;
1038 int m_trackIndex;
1039 int m_clipIndex;
1040 double m_gain;
1041 double m_previous;
1042};
1043
1044class ChangeTrackGainCommand : public QUndoCommand
1045{
1046public:
1047 ChangeTrackGainCommand(MultitrackModel &model,
1048 int trackIndex,
1049 double gain,
1050 QUndoCommand *parent = 0);
1051 void redo();
1052 void undo();
1053
1054protected:
1055 int id() const { return UndoIdChangeTrackGain; }
1056 bool mergeWith(const QUndoCommand *other);
1057
1058private:
1059 MultitrackModel &m_model;
1060 int m_trackIndex;
1061 double m_gain;
1062 double m_previous;
1063};
1064
1065} // namespace Timeline
1066
1067#endif