Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkUndoAction.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkUndoAction.h"
18 
19 #include "internal/org_mitk_gui_qt_application_Activator.h"
20 
21 #include <mitkWorkbenchUtil.h>
22 
23 #include <mitkUndoController.h>
25 
26 #include <berryIPreferences.h>
27 
28 class QmitkUndoActionPrivate
29 {
30 public:
31 
32  void init ( berry::IWorkbenchWindow* window, QmitkUndoAction* action )
33  {
34  m_Window = window;
35  action->setText("&Undo");
36  action->setToolTip("Undo the last action (not supported by all modules)");
37 
38  QObject::connect(action, SIGNAL(triggered(bool)), action, SLOT(Run()));
39  }
40 
41  berry::IWorkbenchWindow* m_Window;
42 };
43 
45  : QAction(0), d(new QmitkUndoActionPrivate)
46 {
47  d->init(window.GetPointer(), this);
48 }
49 
51  : QAction(0), d(new QmitkUndoActionPrivate)
52 {
53  d->init(window.GetPointer(), this);
54  this->setIcon(icon);
55 }
56 
58  : QAction(0), d(new QmitkUndoActionPrivate)
59 {
60  d->init(window, this);
61  this->setIcon(icon);
62 }
63 
65 {
66 }
67 
69 {
71  if (model)
72  {
73  if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast<mitk::VerboseLimitedLinearUndo*>( model ))
74  {
76  verboseundo->GetUndoDescriptions();
77  if (descriptions.size() >= 1)
78  {
79  MITK_INFO << "Undo " << descriptions.front().second;
80  }
81  }
82  model->Undo();
83  }
84  else
85  {
86  MITK_ERROR << "No undo model instantiated";
87  }
88 }
#define MITK_INFO
Definition: mitkLogMacros.h:22
#define MITK_ERROR
Definition: mitkLogMacros.h:24
virtual bool Undo()=0
QmitkUndoAction(berry::IWorkbenchWindow::Pointer window)
superclass for all UndoModels
Definition: mitkUndoModel.h:36
A limited linear undo model providing GUI elements with stack status information. ...
virtual void Run()
ObjectType * GetPointer() const
static UndoModel * GetCurrentUndoModel()
gives access to the currently used UndoModel Introduced to access special functions of more specific ...
std::vector< StackDescriptionItem > StackDescription