1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
/************************************************************************
*
* Copyright (C) 2009-2023 IRCAD France
* Copyright (C) 2012-2018 IHU Strasbourg
*
* This file is part of Sight.
*
* Sight is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sight. If not, see <https://www.gnu.org/licenses/>.
*
***********************************************************************/
#include "module/ui/debug/action/class_factory_registry_info.hpp"
#include <core/base.hpp>
#include <service/extension/factory.hpp>
#include <service/macros.hpp>
#include <QHBoxLayout>
namespace sight::module::ui::debug::action
{
//------------------------------------------------------------------------------
class_factory_registry_info::class_factory_registry_info() noexcept =
default;
//------------------------------------------------------------------------------
class_factory_registry_info::~class_factory_registry_info() noexcept =
default;
//------------------------------------------------------------------------------
void class_factory_registry_info::updating()
{
m_tree->clearSelection();
m_tree->clear();
const auto& factory_keys = service::extension::factory::get()->get_factory_keys();
for(const auto& key : factory_keys)
{
const auto obj_impl = service::extension::factory::get()->get_service_objects(key);
auto* srv_item = new QTreeWidgetItem();
srv_item->setText(0, QString::fromStdString(key));
srv_item->setText(1, QString::fromStdString(obj_impl[0]));
m_tree->addTopLevelItem(srv_item);
}
m_dialog->show();
}
//------------------------------------------------------------------------------
void class_factory_registry_info::configuring()
{
this->sight::ui::action::initialize();
}
//------------------------------------------------------------------------------
void class_factory_registry_info::starting()
{
this->sight::ui::action::action_service_starting();
QWidget* parent = qApp->activeWindow();
m_dialog = new QDialog(parent);
m_dialog->setWindowTitle("ServiceFactoryRegistry");
m_dialog->setMinimumSize(800, 600);
auto* sizer = new QHBoxLayout();
m_tree = new QTreeWidget(m_dialog);
QStringList header_list = (QStringList() << "Service" << "Object");
m_tree->setColumnCount(2);
m_tree->setHeaderLabels(header_list);
m_tree->setColumnWidth(0, 300);
m_tree->setColumnWidth(1, 460);
m_tree->setSelectionMode(QAbstractItemView::SingleSelection);
m_tree->setAlternatingRowColors(true);
sizer->addWidget(m_tree);
m_dialog->setLayout(sizer);
}
//------------------------------------------------------------------------------
void class_factory_registry_info::stopping()
{
m_dialog->hide();
delete m_tree;
delete m_dialog;
this->sight::ui::action::action_service_stopping();
}
//------------------------------------------------------------------------------
} // namespace sight::module::ui::debug::action
|