18#ifndef FILTERCOMMANDS_H
19#define FILTERCOMMANDS_H
21#include "models/attachedfiltersmodel.h"
22#include <MltService.h>
23#include <MltProducer.h>
24#include <QUndoCommand>
29class FilterController;
37 UndoIdChangeParameter,
38 UndoIdChangeAddKeyframe,
39 UndoIdChangeRemoveKeyframe,
43class AddCommand :
public QUndoCommand
51 AddCommand(AttachedFiltersModel &model,
const QString &name, Mlt::Service &service,
int row,
52 AddCommand::AddType type = AddCommand::AddSingle, QUndoCommand *parent = 0);
60 bool mergeWith(
const QUndoCommand *other);
62 AttachedFiltersModel &m_model;
63 std::vector<int> m_rows;
64 std::vector<Mlt::Service> m_services;
65 Mlt::Producer m_producer;
70class RemoveCommand :
public QUndoCommand
73 RemoveCommand(AttachedFiltersModel &model,
const QString &name, Mlt::Service &service,
int row,
74 QUndoCommand *parent = 0);
78 AttachedFiltersModel &m_model;
81 Mlt::Producer m_producer;
83 Mlt::Service m_service;
86class MoveCommand :
public QUndoCommand
89 MoveCommand(AttachedFiltersModel &model,
const QString &name,
int fromRow,
int toRow,
90 QUndoCommand *parent = 0);
99 AttachedFiltersModel &m_model;
102 Mlt::Producer m_producer;
103 QUuid m_producerUuid;
106class DisableCommand :
public QUndoCommand
109 DisableCommand(AttachedFiltersModel &model,
const QString &name,
int row,
bool disabled,
110 QUndoCommand *parent = 0);
116 return UndoIdDisable;
118 bool mergeWith(
const QUndoCommand *other);
120 AttachedFiltersModel &m_model;
122 Mlt::Producer m_producer;
123 QUuid m_producerUuid;
127class UndoParameterCommand :
public QUndoCommand
130 UndoParameterCommand(
const QString &name, FilterController *controller,
int row,
131 Mlt::Properties &before,
const QString &desc = QString(), QUndoCommand *parent = 0);
132 void update(
const QString &propertyName);
138 return UndoIdChangeParameter;
140 bool mergeWith(
const QUndoCommand *other);
143 QUuid m_producerUuid;
144 Mlt::Properties m_before;
145 Mlt::Properties m_after;
146 FilterController *m_filterController;
150class UndoAddKeyframeCommand :
public UndoParameterCommand
153 UndoAddKeyframeCommand(
const QString &name, FilterController *controller,
int row,
154 Mlt::Properties &before)
155 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"add keyframe"))
160 return UndoIdChangeAddKeyframe;
162 bool mergeWith(
const QUndoCommand *other)
168class UndoRemoveKeyframeCommand :
public UndoParameterCommand
171 UndoRemoveKeyframeCommand(
const QString &name, FilterController *controller,
int row,
172 Mlt::Properties &before)
173 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"remove keyframe"))
178 return UndoIdChangeRemoveKeyframe;
180 bool mergeWith(
const QUndoCommand *other)
186class UndoModifyKeyframeCommand :
public UndoParameterCommand
189 UndoModifyKeyframeCommand(
const QString &name, FilterController *controller,
int row,
190 Mlt::Properties &before,
int paramIndex,
int keyframeIndex)
191 : UndoParameterCommand(name, controller, row, before, QObject::tr(
"modify keyframe"))
192 , m_paramIndex(paramIndex)
193 , m_keyframeIndex(keyframeIndex)
198 return UndoIdChangeRemoveKeyframe;
200 bool mergeWith(
const QUndoCommand *other)
202 auto *that =
dynamic_cast<const UndoModifyKeyframeCommand *
>(other);
203 if (!that || m_paramIndex != that->m_paramIndex || m_keyframeIndex != that->m_keyframeIndex)
206 return UndoParameterCommand::mergeWith(other);