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 <QPushButton>
25
26#include "AbstractController.h"
27
28namespace armarx
29{
30 /**
31 * @class MementoController
32 * @brief Subcontroller which handles all user interaction with the undo and redo
33 * buttons on the user interface. Communicates with other controllers to
34 * realize the memento pattern.
35 */
37 {
38 Q_OBJECT
39
40 public:
41 /**
42 * @brief @see AbstractController
43 */
44 void onInitComponent() override;
45
46 /**
47 * @brief @see AbstractController
48 */
49 void onConnectComponent() override;
50
51 /**
52 * @brief @see AbstractController
53 */
54 void onDisconnectComponent() override;
55
56 /**
57 * @brief @see AbstractController
58 */
59 void onExitComponent() override;
60
61 /**
62 * @brief Creates a new MementoController with two given push buttons
63 * realizing the undo and redo operations
64 * @param undoButton Push button realizing the undo operation
65 * @param redoButton Push button realizing the redo operation
66 */
67 MementoController(QPushButton* undoButton, QPushButton* redoButton);
68
69 /**
70 * @brief Getter for the undo button
71 * @return Push button realizing the undo operation
72 */
73 QPushButton* getUndoButton();
74
75 /**
76 * @brief Getter for the redo button
77 * @return Push button realizing the redo operation
78 */
79 QPushButton* getRedoButton();
80
81 public slots:
82 /**
83 * @brief Enables or disables the undo button
84 * @param enable Determines whether to enable or disable the undo button
85 */
86 void enableUndoButton(bool enable);
87
88 /**
89 * @brief Enables or disables the redo button
90 * @param enable Determines whether to enable or disable the redo button
91 */
92 void enableRedoButton(bool enable);
93
94 /**
95 * @brief Enables or disables the redo button
96 * @param enable Determines whether to enable or disable the redo button
97 */
98 void enableRedoButtonVisualization(bool enable);
99
100 private slots:
101 /**
102 * @brief Undoes the lastly executed operation
103 */
104 void undoOperation();
105
106 /**
107 * @brief Redoes the lastly undone operation
108 */
109 void redoOperation();
110
111 signals:
112 /**
113 * @brief Notifies other controllers about undoing the lastly executed operation
114 */
115 void undo();
116
117 /**
118 * @brief Notifies other controllers about redoing the lastly undone operation
119 */
120 void redo();
121
122 private:
123 QPushButton* undoButton;
124 QPushButton* redoButton;
125 bool redoBool;
126 };
127
128 using MementoControllerPtr = std::shared_ptr<MementoController>;
129} // namespace armarx
130
131#endif // MEMENTOCONTROLLER_H
Abstract controller providing a set of methods which must be implemented by every controller.
void undo()
Notifies other controllers about undoing the lastly executed operation.
void enableUndoButton(bool enable)
Enables or disables the undo button.
void onDisconnectComponent() override
QPushButton * getRedoButton()
Getter for the redo button.
MementoController(QPushButton *undoButton, QPushButton *redoButton)
Creates a new MementoController with two given push buttons realizing the undo and redo operations.
void enableRedoButtonVisualization(bool enable)
Enables or disables the redo button.
void enableRedoButton(bool enable)
Enables or disables the redo button.
void redo()
Notifies other controllers about redoing the lastly undone operation.
QPushButton * getUndoButton()
Getter for the undo button.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< MementoController > MementoControllerPtr