fw4spl
ComponentsTree.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "monitorQt/action/ComponentsTree.hpp"
8 
9 #include <fwCore/base.hpp>
10 
11 #include <fwRuntime/Bundle.hpp>
12 #include <fwRuntime/Extension.hpp>
13 #include <fwRuntime/ExtensionPoint.hpp>
14 #include <fwRuntime/Runtime.hpp>
15 
16 #include <fwServices/macros.hpp>
17 
18 #include <QApplication>
19 #include <QVBoxLayout>
20 
21 namespace monitorQt
22 {
23 namespace action
24 {
25 
26 fwServicesRegisterMacro( ::fwGui::IActionSrv, ::monitorQt::action::ComponentsTree, ::fwData::Object );
27 
28 //------------------------------------------------------------------------------
29 
31 {
32 }
33 
34 //------------------------------------------------------------------------------
35 
37 {
38 }
39 
40 //------------------------------------------------------------------------------
41 
43 {
44  m_treeContainer->clearSelection();
45  m_treeContainer->clear();
46 
48  ::fwRuntime::Runtime::BundleIterator iter_bundles = defaultRuntime->bundlesBegin();
49  while (iter_bundles != defaultRuntime->bundlesEnd())
50  {
51  const std::string bundleName = (*iter_bundles)->getIdentifier();
52  bool isBundleEnable = (*iter_bundles)->isEnable();
53  QTreeWidgetItem* bundleItem = new QTreeWidgetItem();
54  if(!isBundleEnable)
55  {
56  bundleItem->setBackground(0, QBrush(QColor(155, 155, 155)));
57  }
58  bundleItem->setText(0, QString::fromStdString(bundleName));
59  m_treeContainer->addTopLevelItem( bundleItem );
60 
61  //Extensions
62  QTreeWidgetItem* extensionsItem = new QTreeWidgetItem();
63  extensionsItem->setText(0, QObject::tr("Extensions"));
64  bundleItem->addChild( extensionsItem );
65  ::fwRuntime::Bundle::ExtensionConstIterator iter_extension = (*iter_bundles)->extensionsBegin();
66  while (iter_extension != (*iter_bundles)->extensionsEnd())
67  {
68  std::string point = (*iter_extension)->getPoint();
69  bool isExtensionEnable = (*iter_extension)->isEnable();
70  QTreeWidgetItem* item = new QTreeWidgetItem();
71  if(!isExtensionEnable)
72  {
73  item->setBackground(0, QBrush(QColor(155, 155, 155)));
74  }
75  item->setText(0, QString::fromStdString(point));
76  extensionsItem->addChild( item );
77 
78  ++iter_extension;
79  }
80  ++iter_bundles;
81  }
82 
83  m_dialog->show();
84 }
85 
86 //------------------------------------------------------------------------------
87 
89 {
91 }
92 
93 //------------------------------------------------------------------------------
94 
96 {
98 
99  QWidget* parent = qApp->activeWindow();
100  m_dialog = new QDialog(parent);
101  m_dialog->setWindowTitle("Components Tree");
102  m_treeContainer = new QTreeWidget(m_dialog);
103  m_treeContainer->setHeaderHidden(true);
104 
105  QVBoxLayout* topsizer = new QVBoxLayout();
106  topsizer->addWidget(m_treeContainer);
107  topsizer->setContentsMargins(0, 0, 0, 0);
108  m_dialog->setLayout(topsizer);
109 }
110 
111 //------------------------------------------------------------------------------
113 {
114  m_dialog->hide();
115  delete m_treeContainer;
116  delete m_dialog;
117 
119 }
120 
121 //------------------------------------------------------------------------------
122 
123 } // namespace action
124 
125 } // namespace monitorQt
126 
static FWRUNTIME_API Runtime * getDefault()
Retrieves the default runtime instance.
Definition: Runtime.cpp:286
Defines the runtime class.
Definition: Runtime.hpp:37
void updating() override
Fill factory information in m_tree and show the dialog.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
Definition: IActionSrv.cpp:160
MONITORQT_API ComponentsTree() noexcept
Does nothing.
FWRUNTIME_API BundleIterator bundlesBegin()
Retrieves the iterator on the begining of the bundle collection.
Definition: Runtime.cpp:133
Implements an action that show bundle information.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
Definition: IActionSrv.cpp:153
FWRUNTIME_API BundleIterator bundlesEnd()
Retrieves the iterator on the end of the bundle collection.
Definition: Runtime.cpp:140
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
void configuring() override
Calls classic IAction methods to configure.
void starting() override
Prepare dialog box.
FWGUI_API void initialize()
Initialize the action.
Definition: IActionSrv.cpp:69
void stopping() override
Delete dialog box.
ExtensionContainer::const_iterator ExtensionConstIterator
Defines the extension container.
Definition: Bundle.hpp:62
Base class for each data object.
virtual MONITORQT_API ~ComponentsTree() noexcept
Does nothing.
BundleContainer::iterator BundleIterator
Defines the bundle container iterator type.
Definition: Runtime.hpp:47