Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "QmitkUndoAction.h"
14 
15 #include "internal/org_mitk_gui_qt_application_Activator.h"
16 
17 #include <mitkWorkbenchUtil.h>
18 
19 #include <mitkUndoController.h>
21 
22 #include <berryIPreferences.h>
23 
24 class QmitkUndoActionPrivate
25 {
26 public:
27 
28  void init ( berry::IWorkbenchWindow* window, QmitkUndoAction* action )
29  {
30  m_Window = window;
31  action->setText("&Undo");
32  action->setToolTip("Undo the last action (not supported by all modules)");
33 
34  QObject::connect(action, SIGNAL(triggered(bool)), action, SLOT(Run()));
35  }
36 
37  berry::IWorkbenchWindow* m_Window;
38 };
39 
41  : QAction(nullptr), d(new QmitkUndoActionPrivate)
42 {
43  d->init(window.GetPointer(), this);
44 }
45 
47  : QAction(nullptr), d(new QmitkUndoActionPrivate)
48 {
49  d->init(window.GetPointer(), this);
50  this->setIcon(icon);
51 }
52 
54  : QAction(nullptr), d(new QmitkUndoActionPrivate)
55 {
56  d->init(window, this);
57  this->setIcon(icon);
58 }
59 
61 {
62 }
63 
65 {
67  if (model)
68  {
69  if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast<mitk::VerboseLimitedLinearUndo*>( model ))
70  {
72  verboseundo->GetUndoDescriptions();
73  if (descriptions.size() >= 1)
74  {
75  MITK_INFO << "Undo " << descriptions.front().second;
76  }
77  }
78  model->Undo();
79  }
80  else
81  {
82  MITK_ERROR << "No undo model instantiated";
83  }
84 }
#define MITK_INFO
Definition: mitkLogMacros.h:18
#define MITK_ERROR
Definition: mitkLogMacros.h:20
~QmitkUndoAction() override
virtual bool Undo()=0
QmitkUndoAction(berry::IWorkbenchWindow::Pointer window)
superclass for all UndoModels
Definition: mitkUndoModel.h:32
A limited linear undo model providing GUI elements with stack status information. ...
virtual void Run()
static UndoModel * GetCurrentUndoModel()
gives access to the currently used UndoModel Introduced to access special functions of more specific ...
std::vector< StackDescriptionItem > StackDescription
void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage)
ObjectType * GetPointer() const