fw4spl
ClassFactoryRegistryInfo.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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/ClassFactoryRegistryInfo.hpp"
8 
9 #include <fwCore/base.hpp>
10 
11 #include <fwServices/macros.hpp>
12 #include <fwServices/registry/ServiceFactory.hpp>
13 
14 #include <QHBoxLayout>
15 
16 namespace monitorQt
17 {
18 namespace action
19 {
20 
22 
23 //------------------------------------------------------------------------------
24 
26 {
27 }
28 
29 //------------------------------------------------------------------------------
30 
32 {
33 }
34 
35 //------------------------------------------------------------------------------
36 
38 {
39  m_tree->clearSelection();
40  m_tree->clear();
41 
42  typedef ::fwServices::registry::ServiceFactory ServiceRegistry;
43  const ServiceRegistry::KeyVectorType& factoryKeys = ServiceRegistry::getDefault()->getFactoryKeys();
44 
45  for( ServiceRegistry::KeyVectorType::value_type key : factoryKeys )
46  {
47  const auto objImpl = ServiceRegistry::getDefault()->getServiceObjects(key);
48  QTreeWidgetItem* srvItem = new QTreeWidgetItem();
49  srvItem->setText(0, QString::fromStdString(key));
50  srvItem->setText(1, QString::fromStdString(objImpl[0]));
51  m_tree->addTopLevelItem( srvItem );
52  }
53  m_dialog->show();
54 }
55 
56 //------------------------------------------------------------------------------
57 
59 {
61 }
62 
63 //------------------------------------------------------------------------------
64 
66 {
68 
69  QWidget* parent = qApp->activeWindow();
70  m_dialog = new QDialog(parent);
71  m_dialog->setWindowTitle("ServiceFactoryRegistry");
72  m_dialog->setMinimumSize(800, 600);
73 
74  QHBoxLayout* sizer = new QHBoxLayout();
75  m_tree = new QTreeWidget( m_dialog );
76  QStringList headerList = (QStringList() << "Service" << "Object");
77  m_tree->setColumnCount(2);
78  m_tree->setHeaderLabels(headerList);
79  m_tree->setColumnWidth(0, 300);
80  m_tree->setColumnWidth(1, 460);
81  m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
82  m_tree->setAlternatingRowColors( true );
83 
84  sizer->addWidget( m_tree );
85  m_dialog->setLayout( sizer );
86 }
87 
88 //------------------------------------------------------------------------------
89 
91 {
92  m_dialog->hide();
93  delete m_tree;
94  delete m_dialog;
95 
97 }
98 
99 //------------------------------------------------------------------------------
100 
101 } // namespace action
102 
103 } // namespace monitorQt
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
Definition: IActionSrv.cpp:160
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
Definition: IActionSrv.cpp:153
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
virtual MONITORQT_API ~ClassFactoryRegistryInfo() noexcept
Does nothing.
MONITORQT_API ClassFactoryRegistryInfo() noexcept
Does nothing.
FWGUI_API void initialize()
Initialize the action.
Definition: IActionSrv.cpp:69
Base class for each data object.
Implements an action to show services registered in factory.
void updating() override
Fill factory information in m_tree and show the dialog.
void configuring() override
Calls classic IAction methods to configure.
void starting() override
Prepare dialog box.