CuteLogger
Fast and simple logging solution for Qt based applications
markercommands.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 MARKERCOMMANDS_H
19#define MARKERCOMMANDS_H
20
21#include "models/markersmodel.h"
22#include <QUndoCommand>
23
24namespace Markers {
25
26enum {
27 UndoIdUpdate = 200,
28};
29
30class DeleteCommand : public QUndoCommand
31{
32public:
33 DeleteCommand(MarkersModel &model, const Marker &delMarker, int index);
34 void redo();
35 void undo();
36private:
37 MarkersModel &m_model;
38 Marker m_delMarker;
39 int m_index;
40};
41
42class AppendCommand : public QUndoCommand
43{
44public:
45 AppendCommand(MarkersModel &model, const Marker &newMarker, int index);
46 void redo();
47 void undo();
48private:
49 MarkersModel &m_model;
50 Marker m_newMarker;
51 int m_index;
52};
53
54class UpdateCommand : public QUndoCommand
55{
56public:
57 UpdateCommand(MarkersModel &model, const Marker &newMarker, const Marker &oldMarker, int index);
58 void redo();
59 void undo();
60protected:
61 int id() const
62 {
63 return UndoIdUpdate;
64 }
65 bool mergeWith(const QUndoCommand *other);
66private:
67 MarkersModel &m_model;
68 Marker m_newMarker;
69 Marker m_oldMarker;
70 int m_index;
71};
72
73class ClearCommand : public QUndoCommand
74{
75public:
76 ClearCommand(MarkersModel &model, QList<Marker> &clearMarkers);
77 void redo();
78 void undo();
79private:
80 MarkersModel &m_model;
81 QList<Marker> m_clearMarkers;
82};
83
84}
85
86#endif // MARKERCOMMANDS_H