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 {
27  {
28  ARMARX_INFO << "RobotTrajectoryDesigner: MementoController on init";
29 
30  enableUndoButton(false);
31  enableRedoButton(false);
32  }
33 
35  {
36  // Undo lastly executed operation
37  QObject::connect(undoButton, SIGNAL(clicked()), this, SLOT(undoOperation()));
38 
39  // Redo lastly undone operation
40  QObject::connect(redoButton, SIGNAL(clicked()), this, SLOT(redoOperation()));
41  }
42 
44  {
45  ARMARX_INFO << "RobotTrajectoryDesigner: MementoController on disconnect";
46  }
47 
49  {
50  ARMARX_INFO << "RobotTrajectoryDesigner: MementoController on exit";
51  }
52 
53  MementoController::MementoController(QPushButton* undoButton, QPushButton* redoButton) :
54  undoButton(undoButton),
55  redoButton(redoButton)
56  {
59  }
60 
62  {
63  return this->undoButton;
64  }
65 
67  {
68  return this->redoButton;
69  }
70 
71  void MementoController::undoOperation()
72  {
73  emit undo();
74  }
75 
76  void MementoController::redoOperation()
77  {
78  emit redo();
79  }
80 
82  {
83  this->redoButton->setEnabled(enable);
84  this->redoBool = enable;
85  }
86 
88  {
89  if (redoBool)
90  {
91  this->redoButton->setEnabled(enable);
92  }
93  }
94 
96  {
97  this->undoButton->setEnabled(enable);
98  }
99 }
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.
MementoController.h
armarx::MementoController::enableRedoButtonVisualization
void enableRedoButtonVisualization(bool enable)
Enables or disables the redo button.
Definition: MementoController.cpp:87
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_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
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