CuteLogger
Fast and simple logging solution for Qt based applications
playlistcommands.h
1/*
2 * Copyright (c) 2013-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 PLAYLISTCOMMANDS_H
19#define PLAYLISTCOMMANDS_H
20
21#include "models/playlistmodel.h"
22#include <QUndoCommand>
23#include <QString>
24#include <QUuid>
25
26namespace Playlist {
27
28enum {
29 UndoIdTrimClipIn = 0,
30 UndoIdTrimClipOut,
31 UndoIdUpdate
32};
33
34class AppendCommand : public QUndoCommand
35{
36public:
37 AppendCommand(PlaylistModel &model, const QString &xml, bool emitModified = true,
38 QUndoCommand *parent = 0);
39 void redo();
40 void undo();
41private:
42 PlaylistModel &m_model;
43 QString m_xml;
44 bool m_emitModified;
45 QUuid m_uuid;
46};
47
48class InsertCommand : public QUndoCommand
49{
50public:
51 InsertCommand(PlaylistModel &model, const QString &xml, int row, QUndoCommand *parent = 0);
52 void redo();
53 void undo();
54private:
55 PlaylistModel &m_model;
56 QString m_xml;
57 int m_row;
58 QUuid m_uuid;
59};
60
61class UpdateCommand : public QUndoCommand
62{
63public:
64 UpdateCommand(PlaylistModel &model, const QString &xml, int row, QUndoCommand *parent = 0);
65 void redo();
66 void undo();
67protected:
68 int id() const
69 {
70 return UndoIdUpdate;
71 }
72 bool mergeWith(const QUndoCommand *other);
73private:
74 PlaylistModel &m_model;
75 QString m_newXml;
76 QString m_oldXml;
77 int m_row;
78 QUuid m_uuid;
79};
80
81class RemoveCommand : public QUndoCommand
82{
83public:
84 RemoveCommand(PlaylistModel &model, int row, QUndoCommand *parent = 0);
85 void redo();
86 void undo();
87private:
88 PlaylistModel &m_model;
89 QString m_xml;
90 int m_row;
91 QUuid m_uuid;
92};
93
94class MoveCommand : public QUndoCommand
95{
96public:
97 MoveCommand(PlaylistModel &model, int from, int to, QUndoCommand *parent = 0);
98 void redo();
99 void undo();
100private:
101 PlaylistModel &m_model;
102 int m_from;
103 int m_to;
104};
105
106class ClearCommand : public QUndoCommand
107{
108public:
109 ClearCommand(PlaylistModel &model, QUndoCommand *parent = 0);
110 void redo();
111 void undo();
112private:
113 PlaylistModel &m_model;
114 QString m_xml;
115 QVector<QUuid> m_uuids;
116};
117
118class SortCommand : public QUndoCommand
119{
120public:
121 SortCommand(PlaylistModel &model, int column, Qt::SortOrder order, QUndoCommand *parent = 0);
122 void redo();
123 void undo();
124private:
125 PlaylistModel &m_model;
126 int m_column;
127 Qt::SortOrder m_order;
128 QString m_xml;
129 QVector<QUuid> m_uuids;
130};
131
132class TrimClipInCommand : public QUndoCommand
133{
134public:
135 TrimClipInCommand(PlaylistModel &model, int row, int in, QUndoCommand *parent = nullptr);
136 void redo();
137 void undo();
138protected:
139 int id() const
140 {
141 return UndoIdTrimClipIn;
142 }
143 bool mergeWith(const QUndoCommand *other);
144private:
145 PlaylistModel &m_model;
146 int m_row;
147 int m_oldIn;
148 int m_newIn;
149 int m_out;
150};
151
152class TrimClipOutCommand : public QUndoCommand
153{
154public:
155 TrimClipOutCommand(PlaylistModel &model, int row, int out, QUndoCommand *parent = nullptr);
156 void redo();
157 void undo();
158protected:
159 int id() const
160 {
161 return UndoIdTrimClipOut;
162 }
163 bool mergeWith(const QUndoCommand *other);
164private:
165 PlaylistModel &m_model;
166 int m_row;
167 int m_in;
168 int m_oldOut;
169 int m_newOut;
170};
171
172class ReplaceCommand : public QUndoCommand
173{
174public:
175 ReplaceCommand(PlaylistModel &model, const QString &xml, int row, QUndoCommand *parent = 0);
176 void redo();
177 void undo();
178private:
179 PlaylistModel &m_model;
180 QString m_newXml;
181 QString m_oldXml;
182 int m_row;
183 QUuid m_uuid;
184};
185
186}
187
188#endif // PLAYLISTCOMMANDS_H