MementoController.cpp
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 #include "MementoController.h"
23 
24 namespace armarx
25 {
26  void
28  {
29  ARMARX_INFO << "RobotTrajectoryDesigner: MementoController on init";
30 
31  enableUndoButton(false);
32  enableRedoButton(false);
33  }
34 
35  void
37  {
38  // Undo lastly executed operation
39  QObject::connect(undoButton, SIGNAL(clicked()), this, SLOT(undoOperation()));
40 
41  // Redo lastly undone operation
42  QObject::connect(redoButton, SIGNAL(clicked()), this, SLOT(redoOperation()));
43  }
44 
45  void
47  {
48  ARMARX_INFO << "RobotTrajectoryDesigner: MementoController on disconnect";
49  }
50 
51  void
53  {
54  ARMARX_INFO << "RobotTrajectoryDesigner: MementoController on exit";
55  }
56 
57  MementoController::MementoController(QPushButton* undoButton, QPushButton* redoButton) :
58  undoButton(undoButton), redoButton(redoButton)
59  {
62  }
63 
64  QPushButton*
66  {
67  return this->undoButton;
68  }
69 
70  QPushButton*
72  {
73  return this->redoButton;
74  }
75 
76  void
77  MementoController::undoOperation()
78  {
79  emit undo();
80  }
81 
82  void
83  MementoController::redoOperation()
84  {
85  emit redo();
86  }
87 
88  void
90  {
91  this->redoButton->setEnabled(enable);
92  this->redoBool = enable;
93  }
94 
95  void
97  {
98  if (redoBool)
99  {
100  this->redoButton->setEnabled(enable);
101  }
102  }
103 
104  void
106  {
107  this->undoButton->setEnabled(enable);
108  }
109 } // namespace armarx
armarx::MementoController::onConnectComponent
void onConnectComponent() override
Definition: MementoController.cpp:36
armarx::MementoController::undo
void undo()
Notifies other controllers about undoing the lastly executed operation.
armarx::MementoController::onDisconnectComponent
void onDisconnectComponent() override
Definition: MementoController.cpp:46
armarx::MementoController::getUndoButton
QPushButton * getUndoButton()
Getter for the undo button.
Definition: MementoController.cpp:65
armarx::MementoController::redo
void redo()
Notifies other controllers about redoing the lastly undone operation.
MementoController.h
armarx::MementoController::enableRedoButtonVisualization
void enableRedoButtonVisualization(bool enable)
Enables or disables the redo button.
Definition: MementoController.cpp:96
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:57
armarx::MementoController::enableUndoButton
void enableUndoButton(bool enable)
Enables or disables the undo button.
Definition: MementoController.cpp:105
armarx::MementoController::onExitComponent
void onExitComponent() override
Definition: MementoController.cpp:52
armarx::MementoController::onInitComponent
void onInitComponent() override
Definition: MementoController.cpp:27
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::MementoController::getRedoButton
QPushButton * getRedoButton()
Getter for the redo button.
Definition: MementoController.cpp:71
armarx::MementoController::enableRedoButton
void enableRedoButton(bool enable)
Enables or disables the redo button.
Definition: MementoController.cpp:89