CuteLogger
Fast and simple logging solution for Qt based applications
filtercommands.h
1/*
2 * Copyright (c) 2021-2023 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 FILTERCOMMANDS_H
19#define FILTERCOMMANDS_H
20
21#include "models/attachedfiltersmodel.h"
22#include <MltService.h>
23#include <MltProducer.h>
24#include <QUndoCommand>
25#include <QString>
26#include <QUuid>
27
28class QmlMetadata;
29class FilterController;
30
31namespace Filter {
32
33enum {
34 UndoIdAdd = 300,
35 UndoIdMove,
36 UndoIdDisable,
37 UndoIdChange
38};
39
40class AddCommand : public QUndoCommand
41{
42public:
43 typedef enum {
44 AddSingle,
45 AddSet,
46 AddSetLast,
47 } AddType;
48 AddCommand(AttachedFiltersModel &model, const QString &name, Mlt::Service &service, int row,
49 AddCommand::AddType type = AddCommand::AddSingle, QUndoCommand *parent = 0);
50 void redo();
51 void undo();
52protected:
53 int id() const
54 {
55 return UndoIdAdd;
56 }
57 bool mergeWith(const QUndoCommand *other);
58private:
59 AttachedFiltersModel &m_model;
60 std::vector<int> m_rows;
61 std::vector<Mlt::Service> m_services;
62 Mlt::Producer m_producer;
63 QUuid m_producerUuid;
64 AddType m_type;
65};
66
67class RemoveCommand : public QUndoCommand
68{
69public:
70 RemoveCommand(AttachedFiltersModel &model, const QString &name, Mlt::Service &service, int row,
71 QUndoCommand *parent = 0);
72 void redo();
73 void undo();
74private:
75 AttachedFiltersModel &m_model;
76 int m_index;
77 int m_row;
78 Mlt::Producer m_producer;
79 QUuid m_producerUuid;
80 Mlt::Service m_service;
81};
82
83class MoveCommand : public QUndoCommand
84{
85public:
86 MoveCommand(AttachedFiltersModel &model, const QString &name, int fromRow, int toRow,
87 QUndoCommand *parent = 0);
88 void redo();
89 void undo();
90protected:
91 int id() const
92 {
93 return UndoIdMove;
94 }
95private:
96 AttachedFiltersModel &m_model;
97 int m_fromRow;
98 int m_toRow;
99 Mlt::Producer m_producer;
100 QUuid m_producerUuid;
101};
102
103class DisableCommand : public QUndoCommand
104{
105public:
106 DisableCommand(AttachedFiltersModel &model, const QString &name, int row, bool disabled,
107 QUndoCommand *parent = 0);
108 void redo();
109 void undo();
110protected:
111 int id() const
112 {
113 return UndoIdDisable;
114 }
115 bool mergeWith(const QUndoCommand *other);
116private:
117 AttachedFiltersModel &m_model;
118 int m_row;
119 Mlt::Producer m_producer;
120 QUuid m_producerUuid;
121 bool m_disabled;
122};
123
124class ChangeParameterCommand : public QUndoCommand
125{
126public:
127 ChangeParameterCommand(const QString &name, FilterController *controller, int row,
128 QUndoCommand *parent = 0);
129 void update(const QString &propertyName);
130 void redo();
131 void undo();
132protected:
133 int id() const
134 {
135 return UndoIdChange;
136 }
137 bool mergeWith(const QUndoCommand *other);
138private:
139 int m_row;
140 QUuid m_producerUuid;
141 Mlt::Properties m_before;
142 Mlt::Properties m_after;
143 FilterController *m_filterController;
144 bool m_firstRedo;
145};
146
147} // namespace Filter
148
149#endif // FILTERCOMMANDS_H