Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerModulesMenu.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Julien Finet, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __qSlicerModulesMenu_h
22 #define __qSlicerModulesMenu_h
23 
24 // Qt includes
25 #include <QMenu>
26 
27 // CTK includes
28 #include "qSlicerBaseQTGUIExport.h"
29 
31 class qSlicerModulesMenuPrivate;
33 
37 class Q_SLICER_BASE_QTGUI_EXPORT qSlicerModulesMenu: public QMenu
38 {
39  Q_OBJECT
40  Q_PROPERTY(QString currentModule READ currentModule WRITE setCurrentModule NOTIFY currentModuleChanged)
48  Q_PROPERTY(bool duplicateActions READ duplicateActions WRITE setDuplicateActions)
49 
56  Q_PROPERTY(bool showHiddenModules READ showHiddenModules WRITE setShowHiddenModules)
57 public:
58  typedef QMenu Superclass;
59 
63  qSlicerModulesMenu(const QString& title, QWidget* parent = 0);
64  qSlicerModulesMenu(QWidget* parent = 0);
65  virtual ~qSlicerModulesMenu();
66 
68  QAction* moduleAction(const QString& moduleName)const;
69 
71  inline void addModules(const QStringList& moduleNames);
72 
74  inline void removeModules(const QStringList& moduleNames);
75 
77  QString currentModule()const;
78 
80  void setModuleManager(qSlicerModuleManager* moduleManager);
81  qSlicerModuleManager* moduleManager()const;
82 
83  void setDuplicateActions(bool duplicate);
84  bool duplicateActions()const;
85 
88  void setShowHiddenModules(bool show);
89  bool showHiddenModules()const;
90 
91 public slots:
99  void addModule(const QString& moduleName);
100 
102  void removeModule(const QString& moduleName);
103 
105  void setCurrentModuleByTitle(const QString& title);
106 
108  void setCurrentModule(const QString& moduleName);
109 
110 signals:
113  void currentModuleChanged(const QString& name);
114 
115 protected slots:
116  void onActionTriggered();
117  void actionSelected(QAction* action);
118 
119 protected:
120  QScopedPointer<qSlicerModulesMenuPrivate> d_ptr;
121 
122  void addModule(qSlicerAbstractCoreModule*);
123  void removeModule(qSlicerAbstractCoreModule*);
124 
125 private:
126  Q_DECLARE_PRIVATE(qSlicerModulesMenu);
127  Q_DISABLE_COPY(qSlicerModulesMenu);
128 };
129 
130 //---------------------------------------------------------------------------
131 void qSlicerModulesMenu::addModules(const QStringList& moduleNames)
132 {
133  foreach(const QString& moduleName, moduleNames)
134  {
135  this->addModule(moduleName);
136  }
137 }
138 
139 //---------------------------------------------------------------------------
140 void qSlicerModulesMenu::removeModules(const QStringList& moduleNames)
141 {
142  foreach(const QString& moduleName, moduleNames)
143  {
144  this->removeModule(moduleName);
145  }
146 }
147 
148 #endif
qSlicerAbstractCoreModule is the base class of any module in Slicer.
void removeModules(const QStringList &moduleNames)
Add a list of module available for selection.