18 #ifndef FILTERCOMMANDS_H
19 #define FILTERCOMMANDS_H
21 #include "models/attachedfiltersmodel.h"
23 #include <MltProducer.h>
24 #include <MltService.h>
26 #include <QUndoCommand>
30 class FilterController;
38 UndoIdChangeParameter,
39 UndoIdChangeAddKeyframe,
40 UndoIdChangeRemoveKeyframe,
44 class AddCommand :
public QUndoCommand
52 AddCommand(AttachedFiltersModel &model,
54 Mlt::Service &service,
56 AddCommand::AddType type = AddCommand::AddSingle,
57 QUndoCommand *parent = 0);
62 int id()
const {
return UndoIdAdd; }
63 bool mergeWith(
const QUndoCommand *other);
66 AttachedFiltersModel &m_model;
67 std::vector<int> m_rows;
68 std::vector<Mlt::Service> m_services;
69 Mlt::Producer m_producer;
74 class RemoveCommand :
public QUndoCommand
77 RemoveCommand(AttachedFiltersModel &model,
79 Mlt::Service &service,
81 QUndoCommand *parent = 0);
86 AttachedFiltersModel &m_model;
89 Mlt::Producer m_producer;
91 Mlt::Service m_service;
94 class MoveCommand :
public QUndoCommand
97 MoveCommand(AttachedFiltersModel &model,
101 QUndoCommand *parent = 0);
106 int id()
const {
return UndoIdMove; }
109 AttachedFiltersModel &m_model;
112 Mlt::Producer m_producer;
113 QUuid m_producerUuid;
116 class DisableCommand :
public QUndoCommand
119 DisableCommand(AttachedFiltersModel &model,
123 QUndoCommand *parent = 0);
128 int id()
const {
return UndoIdDisable; }
129 bool mergeWith(
const QUndoCommand *other);
132 AttachedFiltersModel &m_model;
134 Mlt::Producer m_producer;
135 QUuid m_producerUuid;
139 class PasteCommand :
public QUndoCommand
142 PasteCommand(AttachedFiltersModel &model,
143 const QString &filterProducerXml,
144 QUndoCommand *parent = 0);
149 AttachedFiltersModel &m_model;
152 QUuid m_producerUuid;
155 class UndoParameterCommand :
public QUndoCommand
158 UndoParameterCommand(
const QString &name,
159 FilterController *controller,
161 Mlt::Properties &before,
162 const QString &desc = QString(),
163 QUndoCommand *parent = 0);
164 void update(
const QString &propertyName);
169 int id()
const {
return UndoIdChangeParameter; }
170 bool mergeWith(
const QUndoCommand *other);
174 QUuid m_producerUuid;
175 Mlt::Properties m_before;
176 Mlt::Properties m_after;
177 FilterController *m_filterController;
181 class UndoAddKeyframeCommand :
public UndoParameterCommand
184 UndoAddKeyframeCommand(
const QString &name,
185 FilterController *controller,
187 Mlt::Properties &before)
188 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"add keyframe"))
192 int id()
const {
return UndoIdChangeAddKeyframe; }
193 bool mergeWith(
const QUndoCommand *other) {
return false; }
196 class UndoRemoveKeyframeCommand :
public UndoParameterCommand
199 UndoRemoveKeyframeCommand(
const QString &name,
200 FilterController *controller,
202 Mlt::Properties &before)
203 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"remove keyframe"))
207 int id()
const {
return UndoIdChangeRemoveKeyframe; }
208 bool mergeWith(
const QUndoCommand *other) {
return false; }
211 class UndoModifyKeyframeCommand :
public UndoParameterCommand
214 UndoModifyKeyframeCommand(
const QString &name,
215 FilterController *controller,
217 Mlt::Properties &before,
220 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"modify keyframe"))
221 , m_paramIndex(paramIndex)
222 , m_keyframeIndex(keyframeIndex)
226 int id()
const {
return UndoIdChangeRemoveKeyframe; }
227 bool mergeWith(
const QUndoCommand *other)
229 auto *that =
dynamic_cast<const UndoModifyKeyframeCommand *
>(other);
230 if (!that || m_paramIndex != that->m_paramIndex || m_keyframeIndex != that->m_keyframeIndex)
233 return UndoParameterCommand::mergeWith(other);