swift
registercomponent.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
4 #include "gui/components/registercomponent.h"
5 
6 #include <QtGlobal>
7 
8 #include "ui_registercomponent.h"
9 
11 #include "gui/guiapplication.h"
13 
14 using namespace swift::core;
15 using namespace swift::core::context;
16 using namespace swift::gui::views;
17 
18 namespace swift::gui::components
19 {
20  CRegisterComponent::CRegisterComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CRegisterComponent)
21  {
22  Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
23  Q_ASSERT_X(sGui->getIContextApplication(), Q_FUNC_INFO, "Need application context");
24 
25  ui->setupUi(this);
26  ui->tvp_RegisteredComponents->menuAddItems(CIdentifierView::MenuRefresh);
27 
28  connect(&m_updateTimer, &QTimer::timeout, this, &CRegisterComponent::update);
29  connect(sGui->getIContextApplication(), &IContextApplication::registrationChanged, this,
30  &CRegisterComponent::update);
31  connect(ui->tvp_RegisteredComponents, &CIdentifierView::requestUpdate, this, &CRegisterComponent::update);
32 
33  // timer is there just in case something goes wrong
34  m_updateTimer.setInterval(30 * 1000);
35  m_updateTimer.start();
36  }
37 
39 
40  void CRegisterComponent::update()
41  {
42  // if not supported, do nothing
43  if (!sGui || !sGui->supportsContexts() || sGui->isShuttingDown()) { return; }
44  ui->tvp_RegisteredComponents->updateContainer(sGui->getIContextApplication()->getRegisteredApplications());
45  }
46 } // namespace swift::gui::components
const context::IContextApplication * getIContextApplication() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
bool supportsContexts(bool ignoreShutdownTest=false) const
Supports contexts.
virtual misc::CIdentifierList getRegisteredApplications() const =0
All registered applications.
Show registered applications (registered with core) in the GUI.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
Definition: actionbind.cpp:7
High level reusable GUI components.
Definition: aboutdialog.cpp:13
Views, mainly QTableView.