VPTissue Reference Manual
PTreeUndoCommands.h
Go to the documentation of this file.
1 #ifndef PTREE_UNDO_COMMANDS_H_INCLUDED
2 #define PTREE_UNDO_COMMANDS_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "PTreeModel.h"
23 #include <QUndoCommand>
24 
25 namespace SimShell {
26 namespace Gui {
27 
28 class Item;
29 
34 {
35 public:
44  EditKeyCommand(PTreeModel* m, Item* i, QModelIndex const & x,
45  QVariant const & old_value, QVariant const & new_value);
46  virtual ~EditKeyCommand();
47 
51  virtual void undo();
52 
56  virtual void redo();
57 
58 private:
59  PTreeModel* model;
60  Item* item;
61  QPersistentModelIndex index;
62  QVariant old_value;
63  QVariant new_value;
64 };
65 
70 {
71 public:
80  EditDataCommand(PTreeModel* m, Item* i, QModelIndex const & x,
81  QVariant const & old_value, QVariant const & new_value);
82  virtual ~EditDataCommand();
83 
87  virtual void undo();
88 
92  virtual void redo();
93 
94 private:
95  PTreeModel* model;
96  Item* item;
97  QPersistentModelIndex index;
98  QVariant old_value;
99  QVariant new_value;
100 };
101 
107 {
108 public:
118  InsertRowsCommand(PTreeModel* m, Item* parent,
119  QModelIndex const & parent_index, int row, int count);
120 
130  InsertRowsCommand(PTreeModel* m, Item* parent,
131  QModelIndex const & parent_index, int row, boost::property_tree::ptree const& t);
132  virtual ~InsertRowsCommand();
133 
137  virtual void undo();
138 
142  virtual void redo();
143 
144 private:
145  PTreeModel* model;
146  Item* parent;
147  QPersistentModelIndex parent_index;
148  int row;
149  int count;
150  bool undone;
151  Item** items;
152 };
153 
159 {
160 public:
170  RemoveRowsCommand(PTreeModel* m, Item* parent, QModelIndex const & parent_index, int row, int count);
171  virtual ~RemoveRowsCommand();
172 
176  virtual void undo();
177 
181  virtual void redo();
182 
183 private:
184  PTreeModel* model;
185  Item* parent;
186  QPersistentModelIndex parent_index;
187  int row;
188  int count;
189  bool undone;
190  Item** items;
191 };
192 
198 {
199 public:
212  MoveRowsCommand(PTreeModel* m, Item* old_parent, QModelIndex const& old_parent_index, int old_row,
213  Item* new_parent, QModelIndex const& new_parent_index, int new_row, int count);
214  virtual ~MoveRowsCommand();
215 
219  virtual void undo();
220 
224  virtual void redo();
225 
226 private:
227  PTreeModel* model;
228  Item* old_parent;
229  Item* new_parent;
230  QPersistentModelIndex old_parent_index;
231  QPersistentModelIndex new_parent_index;
232  int old_row;
233  int new_row;
234  int count;
235  Item** items;
236 };
237 
238 } // namespace
239 } // namespace
240 
241 #endif // end_of_inclde_guard
InsertRowsCommand(PTreeModel *m, Item *parent, QModelIndex const &parent_index, int row, int count)
Undo command that represents a single edit operation for a data value of PTreeModel.
RemoveRowsCommand(PTreeModel *m, Item *parent, QModelIndex const &parent_index, int row, int count)
virtual void undo()
See QUndoCommand documentation for details.
EditKeyCommand(PTreeModel *m, Item *i, QModelIndex const &x, QVariant const &old_value, QVariant const &new_value)
Undo command that represents a single move operation of rows inside a PTreeModel. ...
virtual void redo()
See QUndoCommand documentation for details.
Qt model reflecting hierarchical structure of a ptree.
Definition: PTreeModel.h:37
virtual void undo()
See QUndoCommand documentation for details.
virtual void redo()
See QUndoCommand documentation for details.
virtual void redo()
See QUndoCommand documentation for details.
virtual void undo()
See QUndoCommand documentation for details.
see the online Qt documentation
virtual void redo()
See QUndoCommand documentation for details.
Undo command that represents a single insertion operation of rows into a PTreeModel.
virtual void undo()
See QUndoCommand documentation for details.
MoveRowsCommand(PTreeModel *m, Item *old_parent, QModelIndex const &old_parent_index, int old_row, Item *new_parent, QModelIndex const &new_parent_index, int new_row, int count)
Interface for PTreeModel.
EditDataCommand(PTreeModel *m, Item *i, QModelIndex const &x, QVariant const &old_value, QVariant const &new_value)
virtual void undo()
See QUndoCommand documentation for details.
Undo command that represents a single edit operation for a key value of PTreeModel.
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
Undo command that represents a single removal operation of rows from a PTreeModel.
virtual void redo()
See QUndoCommand documentation for details.