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