LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
undocommandgroup.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_UNDOCOMMANDGROUP_H
21 #define LIBREPCB_UNDOCOMMANDGROUP_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "undocommand.h"
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 
35 /*******************************************************************************
36  * Class UndoCommandGroup
37  ******************************************************************************/
38 
43 class UndoCommandGroup : public UndoCommand {
44  Q_DECLARE_TR_FUNCTIONS(UndoCommandGroup)
45 
46 public:
47  // Constructors / Destructor
48  UndoCommandGroup() = delete;
49  UndoCommandGroup(const UndoCommandGroup& other) = delete;
50  explicit UndoCommandGroup(const QString& text) noexcept;
51  virtual ~UndoCommandGroup() noexcept;
52 
53  // Getters
54  int getChildCount() const noexcept { return mChilds.count(); }
55 
56  // General Methods
57 
73  bool appendChild(UndoCommand* cmd);
74 
75  // Operator Overloadings
76  UndoCommandGroup& operator=(const UndoCommandGroup& rhs) = delete;
77 
78 protected:
80  virtual bool performExecute() override;
81 
83  virtual void performUndo() override;
84 
86  virtual void performRedo() override;
87 
95  void execNewChildCmd(UndoCommand* cmd);
96 
97 private:
104  QList<UndoCommand*> mChilds;
105 };
106 
107 /*******************************************************************************
108  * End of File
109  ******************************************************************************/
110 
111 } // namespace librepcb
112 
113 #endif // LIBREPCB_UNDOCOMMANDGROUP_H
bool appendChild(UndoCommand *cmd)
Append a new command to the list of child commands.
Definition: undocommandgroup.cpp:53
void execNewChildCmd(UndoCommand *cmd)
Helper method for derived classes to execute and add new child commands.
Definition: undocommandgroup.cpp:118
QList< UndoCommand * > mChilds
All child commands.
Definition: undocommandgroup.h:104
The UndoCommandGroup class makes it possible to pack multiple undo commands together (it acts as a pa...
Definition: undocommandgroup.h:43
int getChildCount() const noexcept
Definition: undocommandgroup.h:54
UndoCommandGroup & operator=(const UndoCommandGroup &rhs)=delete
virtual bool performExecute() override
Execute the command the first time.
Definition: undocommandgroup.cpp:80
virtual void performRedo() override
Redo the command.
Definition: undocommandgroup.cpp:104
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:47
virtual void performUndo() override
Undo the command.
Definition: undocommandgroup.cpp:94
virtual ~UndoCommandGroup() noexcept
Definition: undocommandgroup.cpp:42