MementoController.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * \package RobotTrajectoryDesigner::gui-plugins::Controller::MementoController
17 * \author Max Beddies
18 * \date 2018
19 * \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 #ifndef MEMENTOCONTROLLER_H
23 #define MEMENTOCONTROLLER_H
24 #include "AbstractController.h"
25 #include <QPushButton>
26 
27 namespace armarx
28 {
29  /**
30  * @class MementoController
31  * @brief Subcontroller which handles all user interaction with the undo and redo
32  * buttons on the user interface. Communicates with other controllers to
33  * realize the memento pattern.
34  */
36  {
37  Q_OBJECT
38 
39  public:
40  /**
41  * @brief @see AbstractController
42  */
43  void onInitComponent() override;
44 
45  /**
46  * @brief @see AbstractController
47  */
48  void onConnectComponent() override;
49 
50  /**
51  * @brief @see AbstractController
52  */
53  void onDisconnectComponent() override;
54 
55  /**
56  * @brief @see AbstractController
57  */
58  void onExitComponent() override;
59 
60  /**
61  * @brief Creates a new MementoController with two given push buttons
62  * realizing the undo and redo operations
63  * @param undoButton Push button realizing the undo operation
64  * @param redoButton Push button realizing the redo operation
65  */
66  MementoController(QPushButton* undoButton, QPushButton* redoButton);
67 
68  /**
69  * @brief Getter for the undo button
70  * @return Push button realizing the undo operation
71  */
72  QPushButton* getUndoButton();
73 
74  /**
75  * @brief Getter for the redo button
76  * @return Push button realizing the redo operation
77  */
78  QPushButton* getRedoButton();
79 
80  public slots:
81  /**
82  * @brief Enables or disables the undo button
83  * @param enable Determines whether to enable or disable the undo button
84  */
85  void enableUndoButton(bool enable);
86 
87  /**
88  * @brief Enables or disables the redo button
89  * @param enable Determines whether to enable or disable the redo button
90  */
91  void enableRedoButton(bool enable);
92 
93  /**
94  * @brief Enables or disables the redo button
95  * @param enable Determines whether to enable or disable the redo button
96  */
97  void enableRedoButtonVisualization(bool enable);
98 
99  private slots:
100  /**
101  * @brief Undoes the lastly executed operation
102  */
103  void undoOperation();
104 
105  /**
106  * @brief Redoes the lastly undone operation
107  */
108  void redoOperation();
109 
110  signals:
111  /**
112  * @brief Notifies other controllers about undoing the lastly executed operation
113  */
114  void undo();
115 
116  /**
117  * @brief Notifies other controllers about redoing the lastly undone operation
118  */
119  void redo();
120 
121  private:
122  QPushButton* undoButton;
123  QPushButton* redoButton;
124  bool redoBool;
125  };
126 
127  using MementoControllerPtr = std::shared_ptr<MementoController>;
128 }
129 
130 #endif // MEMENTOCONTROLLER_H
armarx::MementoController::onConnectComponent
void onConnectComponent() override
Definition: MementoController.cpp:34
armarx::MementoController::undo
void undo()
Notifies other controllers about undoing the lastly executed operation.
armarx::MementoController::onDisconnectComponent
void onDisconnectComponent() override
Definition: MementoController.cpp:43
armarx::MementoController::getUndoButton
QPushButton * getUndoButton()
Getter for the undo button.
Definition: MementoController.cpp:61
armarx::MementoController::redo
void redo()
Notifies other controllers about redoing the lastly undone operation.
armarx::MementoControllerPtr
std::shared_ptr< MementoController > MementoControllerPtr
Definition: MementoController.h:127
armarx::MementoController::enableRedoButtonVisualization
void enableRedoButtonVisualization(bool enable)
Enables or disables the redo button.
Definition: MementoController.cpp:87
AbstractController.h
armarx::MementoController::MementoController
MementoController(QPushButton *undoButton, QPushButton *redoButton)
Creates a new MementoController with two given push buttons realizing the undo and redo operations.
Definition: MementoController.cpp:53
armarx::MementoController::enableUndoButton
void enableUndoButton(bool enable)
Enables or disables the undo button.
Definition: MementoController.cpp:95
armarx::MementoController::onExitComponent
void onExitComponent() override
Definition: MementoController.cpp:48
armarx::MementoController::onInitComponent
void onInitComponent() override
Definition: MementoController.cpp:26
armarx::MementoController
Subcontroller which handles all user interaction with the undo and redo buttons on the user interface...
Definition: MementoController.h:35
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::AbstractController
Abstract controller providing a set of methods which must be implemented by every controller.
Definition: AbstractController.h:35
armarx::MementoController::getRedoButton
QPushButton * getRedoButton()
Getter for the redo button.
Definition: MementoController.cpp:66
armarx::MementoController::enableRedoButton
void enableRedoButton(bool enable)
Enables or disables the redo button.
Definition: MementoController.cpp:81