Medical Imaging Interaction Toolkit  2018.4.99-6a3ea89d
Medical Imaging Interaction Toolkit
berryActionBarAdvisor.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 "berryActionBarAdvisor.h"
14 
17 #include <berryIWorkbenchWindow.h>
18 #include <berryIMemento.h>
19 
20 #include <QAction>
21 
22 namespace berry
23 {
24 
26 {
27  qDeleteAll(actions);
28 }
29 
31  : actionBarConfigurer(configurer)
32 {
33  Q_ASSERT(configurer.IsNotNull());
34 }
35 
37 {
38  return actionBarConfigurer;
39 }
40 
41 void ActionBarAdvisor::FillActionBars(FillFlags flags)
42 {
43  if (!flags.testFlag(FILL_PROXY))
44  {
45  this->MakeActions(actionBarConfigurer->GetWindowConfigurer()->GetWindow().GetPointer());
46  }
47  if (flags.testFlag(FILL_MENU_BAR))
48  {
49  this->FillMenuBar(actionBarConfigurer->GetMenuManager());
50  }
51  if (flags.testFlag(FILL_TOOL_BAR))
52  {
53  this->FillToolBar(actionBarConfigurer->GetToolBarManager());
54  }
55  if (flags.testFlag(FILL_STATUS_LINE))
56  {
57  //this->FillStatusLine(actionBarConfigurer->GetStatusLineManager());
58  }
59 }
60 
62 {
63  // do nothing
64 }
65 
66 void ActionBarAdvisor::Register(QAction* action, const QString& id)
67 {
68  Q_ASSERT_X(action, "nullcheck", "QAction must not be null");
69  actions.insert(id, action);
70 }
71 
72 QAction* ActionBarAdvisor::GetAction(const QString& id) const
73 {
74  auto iter = actions.find(id);
75  return iter == actions.end() ? nullptr : iter.value();
76 }
77 
79 {
80  // do nothing
81 }
82 
83 void ActionBarAdvisor::FillToolBar(IToolBarManager* /*toolBar*/)
84 {
85  // do nothing
86 }
87 
88 void ActionBarAdvisor::FillStatusLine(IStatusLineManager* /*statusLine*/)
89 {
90  // do nothing
91 }
92 
94 {
95  return true;
96 }
97 
99 {
100  return true;
101 }
102 
103 }
virtual void FillStatusLine(IStatusLineManager *statusLine)
virtual void FillToolBar(IToolBarManager *toolBar)
virtual QAction * GetAction(const QString &id) const
Implements transparent reference counting.
virtual void FillMenuBar(IMenuManager *menuBar)
void Register() const
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