Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
berryCommandContributionItem.h
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 
14 #ifndef BERRYCOMMANDCONTRIBUTIONITEM_H_
15 #define BERRYCOMMANDCONTRIBUTIONITEM_H_
16 
17 #include "berryContributionItem.h"
18 
19 #include <QIcon>
20 #include <QKeySequence>
21 
22 namespace berry {
23 
24 struct IMenuService;
25 struct ICommandService;
26 struct ICommandListener;
27 struct IHandlerService;
28 struct IHandler;
29 struct IElementReference;
30 struct IServiceLocator;
31 
32 class CommandEvent;
33 class ParameterizedCommand;
34 class CommandContributionItemParameter;
35 class UIElement;
36 
48 {
49  Q_OBJECT
50 
51 public:
52 
58  static Modes modes;
59 
60 private:
61 
62  //LocalResourceManager localResourceManager;
63 
64  //Listener menuItemListener;
65 
66  QAction* action;
67 
68  IMenuService* menuService;
69 
70  ICommandService* commandService;
71 
72  IHandlerService* handlerService;
73 
74  //IBindingService bindingService;
75 
77 
78  QIcon icon;
79 
80  QString label;
81 
82  QString tooltip;
83 
84  QChar mnemonic;
85 
86  // This is a workaround until key bindings are fully implemented
87  QKeySequence shortcut;
88 
90 
91  bool checkedState;
92 
93  Style style;
94 
95  QScopedPointer<ICommandListener> commandListener;
96 
97  QString dropDownMenuOverride;
98 
99  //IWorkbenchHelpSystem workbenchHelpSystem;
100 
101  QString helpContextId;
102 
103  Modes mode;
104 
109  bool visibleEnabled;
110 
111  // items contributed
112  QString contributedLabel;
113 
114  QIcon contributedIcon;
115 
116  SmartPointer<IServiceLocator> serviceLocator;
117 
118 public:
119 
127  const SmartPointer<CommandContributionItemParameter>& contributionParameters);
128 
129  ~CommandContributionItem() override;
130 
132 
133  void Fill(QMenu* parent, QAction* before) override;
134 
135  void Fill(QToolBar* parent, QAction* before) override;
136 
137  void Update() override;
138 
139  void Update(const QString& id) override;
140 
141  bool IsEnabled() const override;
142 
143  bool IsVisible() const override;
144 
145  void UpdateCommandPropertiesInUI(const SmartPointer<const CommandEvent>& commandEvent);
146 
147 
148 private:
149 
150  void SetImages(IServiceLocator* locator, const QString &iconStyle);
151 
152  ICommandListener *GetCommandListener();
153 
154  void UpdateMenuItem();
155 
156  void UpdateToolItem();
157 
158  void UpdateCommandProperties(const SmartPointer<const CommandEvent> commandEvent);
159 
160  bool ShouldRestoreAppearance(const SmartPointer<IHandler>& handler);
161 
162  SmartPointer<ParameterizedCommand> GetCommand() const;
163 
164  void CreateCommand(const QString& commandId, const QHash<QString, Object::Pointer>& parameters);
165 
166  QString GetToolTipText(const QString& text) const;
167 
168  QString UpdateMnemonic(const QString& s);
169 
170 // void disposeOldImages() {
171 // if (localResourceManager != null) {
172 // localResourceManager.dispose();
173 // localResourceManager = null;
174 // }
175 // }
176 
177  //SmartPointer<IUIElementListener> GetItemListener();
178 
188  //TODO Tool item drop down menu contributions
189  //bool OpenDropDownMenu(SmartPointer<GuiTk::Event> event);
190 
191  void SetIcon(const QIcon& icon);
192 
193  void UpdateIcons();
194 
195  void SetText(const QString& text);
196 
197  void SetChecked(bool checked);
198 
199  void SetToolTip(const QString& text);
200 
201 private slots:
202 
203  void HandleActionDestroyed();
204  void HandleWidgetSelection();
205 
206 };
207 
208 }
209 
210 
211 #endif /* BERRYCOMMANDCONTRIBUTIONITEM_H_ */
berry::CommandContributionItem
Definition: berryCommandContributionItem.h:47
berry::IServiceLocator
Definition: berryIServiceLocator.h:43
berryContributionItem.h
berry::SmartPointer
Implements transparent reference counting.
Definition: berryICommandCategoryListener.h:21
berry::CommandContributionItem::modes
static Modes modes
Definition: berryCommandContributionItem.h:58
berry::ContributionItem::Fill
void Fill(QStatusBar *parent) override
berry::ICommandListener
Definition: berryICommandListener.h:37
berry::ContributionItem
Definition: berryContributionItem.h:26
BERRY_UI_QT
#define BERRY_UI_QT
Definition: org_blueberry_ui_qt_Export.h:26
berry::ICommandService
Definition: berryICommandService.h:51
berry::IHandlerService
Definition: berryIHandlerService.h:53
berry::IMenuService
Definition: berryIMenuService.h:44
berry::ContributionItem::Style
Style
Definition: berryContributionItem.h:45
berry
Definition: QmitkPropertyItemModel.h:24