18#ifndef FILTERCOMMANDS_H
19#define FILTERCOMMANDS_H
21#include "models/attachedfiltersmodel.h"
23#include <MltProducer.h>
24#include <MltProperties.h>
26#include <QUndoCommand>
30class FilterController;
38 UndoIdChangeParameter,
39 UndoIdChangeAddKeyframe,
40 UndoIdChangeRemoveKeyframe,
44class 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<QString> m_serviceNames;
69 std::vector<Mlt::Properties> m_serviceProperties;
70 std::vector<mlt_service_type> m_serviceTypes;
71 Mlt::Producer m_producer;
76class RemoveCommand :
public QUndoCommand
79 RemoveCommand(AttachedFiltersModel &model,
81 Mlt::Service &service,
83 QUndoCommand *parent = 0);
88 AttachedFiltersModel &m_model;
91 Mlt::Producer m_producer;
93 Mlt::Service m_service;
96class MoveCommand :
public QUndoCommand
99 MoveCommand(AttachedFiltersModel &model,
103 QUndoCommand *parent = 0);
108 int id()
const {
return UndoIdMove; }
111 AttachedFiltersModel &m_model;
114 Mlt::Producer m_producer;
115 QUuid m_producerUuid;
118class DisableCommand :
public QUndoCommand
121 DisableCommand(AttachedFiltersModel &model,
125 QUndoCommand *parent = 0);
130 int id()
const {
return UndoIdDisable; }
131 bool mergeWith(
const QUndoCommand *other);
134 AttachedFiltersModel &m_model;
136 Mlt::Producer m_producer;
137 QUuid m_producerUuid;
141class PasteCommand :
public QUndoCommand
144 PasteCommand(AttachedFiltersModel &model,
145 const QString &filterProducerXml,
146 QUndoCommand *parent = 0);
151 AttachedFiltersModel &m_model;
154 QUuid m_producerUuid;
157class UndoParameterCommand :
public QUndoCommand
160 UndoParameterCommand(
const QString &name,
161 FilterController *controller,
163 Mlt::Properties &before,
164 const QString &desc = QString(),
165 QUndoCommand *parent = 0);
166 void update(
const QString &propertyName);
171 int id()
const {
return UndoIdChangeParameter; }
172 bool mergeWith(
const QUndoCommand *other);
176 QUuid m_producerUuid;
177 Mlt::Properties m_before;
178 Mlt::Properties m_after;
179 FilterController *m_filterController;
183class UndoAddKeyframeCommand :
public UndoParameterCommand
186 UndoAddKeyframeCommand(
const QString &name,
187 FilterController *controller,
189 Mlt::Properties &before)
190 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"add keyframe"))
194 int id()
const {
return UndoIdChangeAddKeyframe; }
195 bool mergeWith(
const QUndoCommand *other) {
return false; }
198class UndoRemoveKeyframeCommand :
public UndoParameterCommand
201 UndoRemoveKeyframeCommand(
const QString &name,
202 FilterController *controller,
204 Mlt::Properties &before)
205 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"remove keyframe"))
209 int id()
const {
return UndoIdChangeRemoveKeyframe; }
210 bool mergeWith(
const QUndoCommand *other) {
return false; }
213class UndoModifyKeyframeCommand :
public UndoParameterCommand
216 UndoModifyKeyframeCommand(
const QString &name,
217 FilterController *controller,
219 Mlt::Properties &before,
222 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"modify keyframe"))
223 , m_paramIndex(paramIndex)
224 , m_keyframeIndex(keyframeIndex)
228 int id()
const {
return UndoIdChangeRemoveKeyframe; }
229 bool mergeWith(
const QUndoCommand *other)
231 auto *that =
dynamic_cast<const UndoModifyKeyframeCommand *
>(other);
232 if (!that || m_paramIndex != that->m_paramIndex || m_keyframeIndex != that->m_keyframeIndex)
235 return UndoParameterCommand::mergeWith(other);