Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryCommandContributionItem.h
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 
18 #ifndef BERRYCOMMANDCONTRIBUTIONITEM_H_
19 #define BERRYCOMMANDCONTRIBUTIONITEM_H_
20 
21 #include "berryContributionItem.h"
22 
23 #include <QIcon>
24 #include <QKeySequence>
25 
26 namespace berry {
27 
28 struct IMenuService;
29 struct ICommandService;
30 struct ICommandListener;
31 struct IHandlerService;
32 struct IHandler;
33 struct IElementReference;
34 struct IServiceLocator;
35 
36 class CommandEvent;
37 class ParameterizedCommand;
38 class CommandContributionItemParameter;
39 class UIElement;
40 
53 {
54  Q_OBJECT
55 
56 public:
57 
63  static Modes modes;
64 
65 private:
66 
67  //LocalResourceManager localResourceManager;
68 
69  //Listener menuItemListener;
70 
71  QAction* action;
72 
73  IMenuService* menuService;
74 
75  ICommandService* commandService;
76 
77  IHandlerService* handlerService;
78 
79  //IBindingService bindingService;
80 
82 
83  QIcon icon;
84 
85  QString label;
86 
87  QString tooltip;
88 
89  QChar mnemonic;
90 
91  // This is a workaround until key bindings are fully implemented
92  QKeySequence shortcut;
93 
95 
96  bool checkedState;
97 
98  Style style;
99 
100  QScopedPointer<ICommandListener> commandListener;
101 
102  QString dropDownMenuOverride;
103 
104  //IWorkbenchHelpSystem workbenchHelpSystem;
105 
106  QString helpContextId;
107 
108  Modes mode;
109 
114  bool visibleEnabled;
115 
116  // items contributed
117  QString contributedLabel;
118 
119  QIcon contributedIcon;
120 
121  SmartPointer<IServiceLocator> serviceLocator;
122 
123 public:
124 
132  const SmartPointer<CommandContributionItemParameter>& contributionParameters);
133 
135 
137 
138  void Fill(QMenu* parent, QAction* before) override;
139 
140  void Fill(QToolBar* parent, QAction* before) override;
141 
142  void Update() override;
143 
144  void Update(const QString& id) override;
145 
146  bool IsEnabled() const override;
147 
148  bool IsVisible() const override;
149 
150  void UpdateCommandPropertiesInUI(const SmartPointer<const CommandEvent>& commandEvent);
151 
152 
153 private:
154 
155  void SetImages(IServiceLocator* locator, const QString &iconStyle);
156 
157  ICommandListener *GetCommandListener();
158 
159  void UpdateMenuItem();
160 
161  void UpdateToolItem();
162 
163  void UpdateCommandProperties(const SmartPointer<const CommandEvent> commandEvent);
164 
165  bool ShouldRestoreAppearance(const SmartPointer<IHandler>& handler);
166 
167  SmartPointer<ParameterizedCommand> GetCommand() const;
168 
169  void CreateCommand(const QString& commandId, const QHash<QString, Object::Pointer>& parameters);
170 
171  QString GetToolTipText(const QString& text) const;
172 
173  QString UpdateMnemonic(const QString& s);
174 
175 // void disposeOldImages() {
176 // if (localResourceManager != null) {
177 // localResourceManager.dispose();
178 // localResourceManager = null;
179 // }
180 // }
181 
182  //SmartPointer<IUIElementListener> GetItemListener();
183 
193  //TODO Tool item drop down menu contributions
194  //bool OpenDropDownMenu(SmartPointer<GuiTk::Event> event);
195 
196  void SetIcon(const QIcon& icon);
197 
198  void UpdateIcons();
199 
200  void SetText(const QString& text);
201 
202  void SetChecked(bool checked);
203 
204  void SetToolTip(const QString& text);
205 
206 private slots:
207 
208  void HandleActionDestroyed();
209  void HandleWidgetSelection();
210 
211 };
212 
213 }
214 
215 
216 #endif /* BERRYCOMMANDCONTRIBUTIONITEM_H_ */
static MsgHandler handler
Definition: usUtils.cpp:261
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
Implements transparent reference counting.
void Fill(QStatusBar *parent) override
#define BERRY_UI_QT