Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryMenuManager.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 #ifndef BERRYMENUMANAGER_H_
18 #define BERRYMENUMANAGER_H_
19 
20 #include "berryIMenuManager.h"
22 
24 
25 #include <QIcon>
26 
27 class QMenu;
28 class QMenuProxy;
29 class QAction;
30 
31 namespace berry
32 {
33 
41 class BERRY_UI_QT MenuManager: public QObject, public ContributionManager, public IMenuManager
42 {
43  Q_OBJECT
44 
45 public:
46 
48 
49 private:
50 
54  QString id;
55 
60  QMenuProxy* menu;
61  QAction* menuItem;
62 
68  //SmartPointer<IMenuItem> menuItem;
69 
73  QString menuText;
74 
78  QIcon image;
79 
84 
89 
94  bool removeAllWhenShown;
95 
100  QString definitionId;
101 
102 private:
103 
104  Q_SLOT void HandleAboutToShow();
105  Q_SLOT void HandleAboutToHide();
106 
107 protected:
108 
113  bool visible;
114 
115 public:
116 
117  Q_SIGNAL void AboutToShow(IMenuManager* mm);
118  Q_SIGNAL void AboutToHide(IMenuManager* mm);
119 
128  MenuManager(const QString& text = QString(), const QString& id = QString());
129 
130  ~MenuManager();
131 
140  MenuManager(const QString& text, const QIcon& image,
141  const QString& id);
142 
143  bool IsDirty() const override;
144 
156  QMenu* CreateContextMenu(QWidget* parent);
157 
167  QMenuBar* CreateMenuBar(QWidget* parent);
168 
169  void AddMenuListener(QObject* listener) override;
170  void RemoveMenuListener(QObject *listener) override;
171 
172  /*
173  * @see IContributionItem#Fill(QStatusBar*)
174  */
175  void Fill(QStatusBar* parent) override;
176 
177  /*
178  * @see IContributionItem#Fill(QToolBar*, int)
179  */
180  void Fill(QToolBar* parent, QAction *index) override;
181 
182  /*
183  * @see IContributionItem#Fill(QMenu*, int)
184  */
185  void Fill(QMenu* parent, QAction *before) override;
186 
187  /*
188  * @see IContributionItem#Fill(QMenuBar*, int)
189  */
190  void Fill(QMenuBar* parent, QAction *before) override;
191 
192  /*
193  * @see IMenuManager#FindMenuUsingPath(const QString&)
194  */
195  IMenuManager::Pointer FindMenuUsingPath(const QString& path) const override;
196 
197  /*
198  * @see IMenuManager#FindUsingPath(const QString&)
199  */
200  IContributionItem::Pointer FindUsingPath(const QString& path) const override;
201 
208  QString GetId() const override;
209 
215  QMenu* GetMenu() const;
216 
223  QString GetMenuText() const;
224 
230  QIcon GetImage() const;
231 
232  /*
233  * @see IContributionManager#GetOverrides()
234  */
235  SmartPointer<IContributionManagerOverrides> GetOverrides() override;
236 
242  IContributionManager* GetParent() const;
243 
244  /*
245  * @see IMenuManager#GetRemoveAllWhenShown()
246  */
247  bool GetRemoveAllWhenShown() const override;
248 
249  /*
250  * @see IContributionItem#IsDynamic()
251  */
252  bool IsDynamic() const override;
253 
265  bool IsEnabled() const override;
266 
267  /*
268  * @see IContributionItem#IsGroupMarker()
269  */
270  bool IsGroupMarker() const override;
271 
272  /*
273  * @see IContributionItem#IsSeparator()
274  */
275  bool IsSeparator() const override;
276 
277  /*
278  * @see IContributionItem#IsVisible()
279  */
280  bool IsVisible() const override;
281 
286  void MarkDirty() override;
287 
288  /*
289  * @see IMenuManager#removeMenuListener(IMenuListener)
290  */
291  //void RemoveMenuListener(SmartPointer<IMenuListener> listener);
292 
293  /*
294  * @IContributionItem#SaveWidgetState()
295  */
296  void SaveWidgetState() override;
297 
303  void SetOverrides(SmartPointer<IContributionManagerOverrides> newOverrides);
304 
305  /*
306  * @see IContributionItem#SetParent(IContributionManager)
307  */
308  void SetParent(IContributionManager* manager) override;
309 
310  /*
311  * @see IMenuManager#SetRemoveAllWhenShown(boolean)
312  */
313  void SetRemoveAllWhenShown(bool removeAll) override;
314 
315  /*
316  * @see IContributionItem#SetVisible(bool)
317  */
318  void SetVisible(bool visible) override;
319 
328  void SetCommandId(const QString& definitionId);
329 
330  /*
331  * @see IContributionItem#Update()
332  */
333  void Update() override;
334 
335  void Update(const QString& property) override;
336 
343  void Update(bool force) override;
344 
345  /*
346  * @see IMenuManager#UpdateAll(bool)
347  */
348  void UpdateAll(bool force) override;
349 
350 private:
351 
355  void InitializeMenu();
356 
360  // void DisposeOldImages();
361 
367  void UpdateMenuItem();
368 
369  void FillMenu(QWidget* parent, QAction* before);
370 
371  void DumpActionInfo(QMenuProxy* menu);
372  void DumpActionInfo(QWidget* widget, int level);
373 
374 protected:
375 
389  void DoItemFill(IContributionItem::Pointer ci, QAction *before);
390 
401  void Update(bool force, bool recursive);
402 
403 };
404 
405 }
406 
407 #endif /* BERRYMENUMANAGER_H_ */
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
Implements transparent reference counting.
#define berryObjectMacro(...)
Definition: berryMacros.h:37
The custom viewer plugin implements simple viewer functionality presented in a customized look and feel It was developed to demonstrate extensibility and customizability of the blueberry application framework As an example for the GUI customization capabilities provided by the BlueBerry application the custom viewer plugin was developed It features simple viewer functionality presented in a customized look and feel The custom viewer consists of two i e a viewer perspective and a DICOM perspective As part of the viewer an instance of QmitkDataManagerView allows for data selection Visualization of the selected data is then performed by a simple render window view According data can either be directly loaded from file or be imported as DICOM data DICOM import functionality is accessible from the DICOM perspective incorporating the QmitkDicomExternalDataWidget The customization of Qt Stylesheets is used to give the application a non native look and feel This is further emphasized by a Tab Widget like unification of the perspectives with the according perspective bar In addition to an absence of menu
#define BERRY_UI_QT