Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryActionBarAdvisor.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
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 "berryActionBarAdvisor.h"
18 
21 #include <berryIWorkbenchWindow.h>
22 #include <berryIMemento.h>
23 
24 #include <QAction>
25 
26 namespace berry
27 {
28 
30 {
31  qDeleteAll(actions);
32 }
33 
35  : actionBarConfigurer(configurer)
36 {
37  Q_ASSERT(configurer.IsNotNull());
38 }
39 
41 {
42  return actionBarConfigurer;
43 }
44 
45 void ActionBarAdvisor::FillActionBars(FillFlags flags)
46 {
47  if (!flags.testFlag(FILL_PROXY))
48  {
49  this->MakeActions(actionBarConfigurer->GetWindowConfigurer()->GetWindow().GetPointer());
50  }
51  if (flags.testFlag(FILL_MENU_BAR))
52  {
53  this->FillMenuBar(actionBarConfigurer->GetMenuManager());
54  }
55  if (flags.testFlag(FILL_TOOL_BAR))
56  {
57  this->FillToolBar(actionBarConfigurer->GetToolBarManager());
58  }
59  if (flags.testFlag(FILL_STATUS_LINE))
60  {
61  //this->FillStatusLine(actionBarConfigurer->GetStatusLineManager());
62  }
63 }
64 
66 {
67  // do nothing
68 }
69 
70 void ActionBarAdvisor::Register(QAction* action, const QString& id)
71 {
72  Q_ASSERT_X(action, "nullcheck", "QAction must not be null");
73  actions.insert(id, action);
74 }
75 
76 QAction* ActionBarAdvisor::GetAction(const QString& id) const
77 {
78  auto iter = actions.find(id);
79  return iter == actions.end() ? nullptr : iter.value();
80 }
81 
83 {
84  // do nothing
85 }
86 
87 void ActionBarAdvisor::FillToolBar(IToolBarManager* /*toolBar*/)
88 {
89  // do nothing
90 }
91 
92 void ActionBarAdvisor::FillStatusLine(IStatusLineManager* /*statusLine*/)
93 {
94  // do nothing
95 }
96 
98 {
99  return true;
100 }
101 
103 {
104  return true;
105 }
106 
107 }
void Register() const
virtual QAction * GetAction(const QString &id) const
virtual void FillStatusLine(IStatusLineManager *statusLine)
virtual void FillToolBar(IToolBarManager *toolBar)
Implements transparent reference counting.
virtual void FillMenuBar(IMenuManager *menuBar)
virtual void FillActionBars(FillFlags flags)
virtual void MakeActions(IWorkbenchWindow *window)
ActionBarAdvisor(const SmartPointer< IActionBarConfigurer > &configurer)
virtual bool RestoreState(SmartPointer< IMemento > memento)
virtual bool SaveState(SmartPointer< IMemento > memento)
virtual SmartPointer< IActionBarConfigurer > GetActionBarConfigurer() const