Qt6 Migration: Merge latest Qt5 devel content and apply migration fixes
- Merged 292 changed files from dlbo snapshot - Fixed IDL enum collisions (PortType, PdmEventType) - Fixed Grantlee template for C++11 scoped enums - Fixed CMake VERSION_GREATER syntax - Added missing directories (THP, LtsRestClient, etc.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
310 files changed
+2823
-740
No files matched your search
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(QtPluginSystemDemo CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
||||
|
||||
# Ausgabepfad für Plugins definieren
|
||||
set(PLUGIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/plugins")
|
||||
|
||||
add_subdirectory(plugins)
|
||||
add_subdirectory(app)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
add_executable(DlboTestPluginApp main.cpp)
|
||||
target_link_libraries(DlboTestPluginApp PRIVATE Qt5::Widgets)
|
||||
|
||||
# Kopiert die Interfaces virtuell via Include-Pfad (keine statische Link-Abhängigkeit zu .cpp Dateien)
|
||||
target_include_directories(DlboTestPluginApp PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QMainWindow>
|
||||
#include <QMap>
|
||||
#include <QPluginLoader>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "../interfaces/child_interface.h"
|
||||
#include "../interfaces/parent_interface.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QMainWindow mainWindow;
|
||||
QWidget *centralWidget = new QWidget(&mainWindow);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
|
||||
mainWindow.setCentralWidget(centralWidget);
|
||||
|
||||
// Ordnerstruktur auflösen (.../build-.../plugins/)
|
||||
QDir baseDir(QCoreApplication::applicationDirPath());
|
||||
baseDir.cdUp();
|
||||
QDir pluginsDir = baseDir;
|
||||
if (!pluginsDir.cd(QStringLiteral("plugins")))
|
||||
{
|
||||
qCritical() << "Plugins-Ordner nicht gefunden!";
|
||||
return -1;
|
||||
}
|
||||
|
||||
QMap<QString, ParentInterface *> parentPlugins;
|
||||
QList<ChildInterface *> childPlugins;
|
||||
|
||||
// Nur .so-Dateien auflisten (verhindert das Einlesen von cmake_install.cmake)
|
||||
QStringList filters;
|
||||
filters << QStringLiteral("*.so");
|
||||
#ifdef Q_OS_WIN
|
||||
filters << QStringLiteral("*.dll");
|
||||
#else
|
||||
filters << QStringLiteral("*.so");
|
||||
#endif
|
||||
|
||||
// 1. Durchlauf: Plugins laden und katalogisieren
|
||||
for (const QString &fileName : pluginsDir.entryList(filters, QDir::Files))
|
||||
{
|
||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||
QObject *pluginInstance = loader.instance();
|
||||
|
||||
if (!pluginInstance)
|
||||
{
|
||||
qDebug() << "Überspringe Datei:" << fileName << loader.errorString();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ist es ein Parent?
|
||||
auto *parent = qobject_cast<ParentInterface *>(pluginInstance);
|
||||
if (parent)
|
||||
{
|
||||
parentPlugins[parent->pluginName()] = parent;
|
||||
mainLayout->addWidget(parent->widget());
|
||||
qDebug() << "Eltern-Plugin registriert:" << parent->pluginName();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ist es ein Child?
|
||||
auto *child = qobject_cast<ChildInterface *>(pluginInstance);
|
||||
if (child)
|
||||
{
|
||||
childPlugins.append(child);
|
||||
qDebug() << "Kind-Plugin zwischengespeichert:" << child->childName();
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Durchlauf: Zuordnen, Daten übergeben und Signale verbinden
|
||||
for (ChildInterface *child : childPlugins)
|
||||
{
|
||||
QString target = child->targetParentName();
|
||||
|
||||
if (parentPlugins.contains(target))
|
||||
{
|
||||
ParentInterface *parent = parentPlugins[target];
|
||||
|
||||
// A. Widget zuweisen
|
||||
parent->addChildWidget(child->widget());
|
||||
qDebug() << "Kind" << child->childName() << "wurde" << target << "zugeordnet.";
|
||||
|
||||
// B. Initiale Parameterübergabe
|
||||
child->setParentData(QStringLiteral("Konfig-Paket via %1").arg(parent->pluginName()));
|
||||
|
||||
// C. Dynamische Signal-Slot Live-Verbindung (Absturzsicher via Pointer-Check)
|
||||
QObject *parentObj = parent->qobjectInstance();
|
||||
QObject *childObj = dynamic_cast<QObject *>(child);
|
||||
|
||||
if (parentObj && childObj)
|
||||
{
|
||||
bool connected = QObject::connect(parentObj, SIGNAL(dataChangedLive(QString)), childObj, SLOT(updateLiveData(QString)));
|
||||
if (connected)
|
||||
qDebug() << "Live-Signal verbunden für:" << child->childName();
|
||||
else
|
||||
qWarning() << "Verbindung fehlgeschlagen für:" << child->childName();
|
||||
}
|
||||
else
|
||||
qWarning() << "Fehler beim Casten des Plugins" << child->childName() << "zu QObject!";
|
||||
}
|
||||
else
|
||||
qDebug() << "Warnung: Kein Parent gefunden für" << child->childName();
|
||||
}
|
||||
|
||||
mainWindow.resize(500, 450);
|
||||
mainWindow.show();
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
class ChildInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ChildInterface() = default;
|
||||
virtual QString childName() const = 0;
|
||||
virtual QString targetParentName() const = 0;
|
||||
virtual QWidget* widget() = 0;
|
||||
|
||||
// Für die einmalige Übergabe direkt nach dem Laden
|
||||
virtual void setParentData(const QString& data) = 0;
|
||||
|
||||
// Für die dynamischen Live-Updates zur Laufzeit
|
||||
virtual void updateLiveData(const QString& text) = 0;
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_DECLARE_INTERFACE(ChildInterface, "gui:3:ChildInterface")
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <QtPlugin>
|
||||
|
||||
class ParentInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ParentInterface() = default;
|
||||
virtual QString pluginName() const = 0;
|
||||
virtual QWidget *widget() = 0;
|
||||
virtual void addChildWidget(QWidget *childWidget) = 0;
|
||||
|
||||
// Ermöglicht der App den Zugriff auf das QObject für connect()
|
||||
virtual QObject *qobjectInstance() = 0;
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_DECLARE_INTERFACE(ParentInterface, "gui:3:ParentInterface")
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
add_subdirectory(parent_alpha)
|
||||
add_subdirectory(child_beta)
|
||||
add_subdirectory(child_gamma)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
add_library(childBetaGui MODULE child_beta.cpp child_beta.h)
|
||||
target_link_libraries(childBetaGui PRIVATE Qt5::Widgets)
|
||||
target_include_directories(childBetaGui PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
# Plugin in den Laufzeit-Ordner verschieben
|
||||
set_target_properties(childBetaGui PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "child_beta.h"
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
ChildBeta::ChildBeta()
|
||||
{
|
||||
m_widget = new QWidget();
|
||||
QVBoxLayout *layout = new QVBoxLayout(m_widget);
|
||||
m_widget->setStyleSheet(QStringLiteral("border: 1px solid green; background-color: #f0fff0; margin: 5px;"));
|
||||
|
||||
QLabel *title = new QLabel(QStringLiteral("Kind-Widget 1"));
|
||||
title->setStyleSheet(QStringLiteral("font-weight: bold; color: green;"));
|
||||
|
||||
m_staticLabel = new QLabel(QStringLiteral("Warte auf Init-Daten..."));
|
||||
m_liveLabel = new QLabel(QStringLiteral("Warte auf Live-Text..."));
|
||||
|
||||
layout->addWidget(title);
|
||||
layout->addWidget(m_staticLabel);
|
||||
layout->addWidget(m_liveLabel);
|
||||
}
|
||||
|
||||
void ChildBeta::setParentData(const QString &data)
|
||||
{
|
||||
if (m_staticLabel)
|
||||
m_staticLabel->setText(QStringLiteral("Init-Wert: %1").arg(data));
|
||||
}
|
||||
|
||||
void ChildBeta::updateLiveData(const QString &text)
|
||||
{
|
||||
if (m_liveLabel)
|
||||
{
|
||||
m_liveLabel->setText(text.isEmpty() ? QStringLiteral("Warte auf Live-Text...") : QStringLiteral("Beta Live: ") + text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../interfaces/child_interface.h"
|
||||
#include <QLabel>
|
||||
#include <QObject>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
class ChildBeta
|
||||
: public QObject
|
||||
, public ChildInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ChildInterface")
|
||||
Q_INTERFACES(ChildInterface)
|
||||
|
||||
public:
|
||||
ChildBeta();
|
||||
QString childName() const override { return QStringLiteral("BetaChild"); }
|
||||
QString targetParentName() const override { return QStringLiteral("AlphaParent"); }
|
||||
QWidget *widget() override { return m_widget; }
|
||||
|
||||
void setParentData(const QString &data) override;
|
||||
|
||||
public slots:
|
||||
void updateLiveData(const QString &text) override;
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QLabel *m_staticLabel;
|
||||
QLabel *m_liveLabel;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["child_beta"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
add_library(childGammaGui MODULE child_gamma.cpp child_gamma.h)
|
||||
target_link_libraries(childGammaGui PRIVATE Qt5::Widgets)
|
||||
target_include_directories(childGammaGui PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
# Plugin in den Laufzeit-Ordner verschieben
|
||||
set_target_properties(childGammaGui PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "child_gamma.h"
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
ChildGamma::ChildGamma()
|
||||
{
|
||||
m_widget = new QWidget();
|
||||
QVBoxLayout *layout = new QVBoxLayout(m_widget);
|
||||
m_widget->setStyleSheet(QStringLiteral("border: 1px solid purple; background-color: #faf0ff; margin: 5px;"));
|
||||
|
||||
QLabel *title = new QLabel(QStringLiteral("Kind-Widget 2"));
|
||||
title->setStyleSheet(QStringLiteral("font-weight: bold; color: purple;"));
|
||||
|
||||
m_staticLabel = new QLabel(QStringLiteral("Warte auf Init-Daten..."));
|
||||
m_liveLabel = new QLabel(QStringLiteral("Warte auf Live-Text..."));
|
||||
|
||||
layout->addWidget(title);
|
||||
layout->addWidget(m_staticLabel);
|
||||
layout->addWidget(m_liveLabel);
|
||||
}
|
||||
|
||||
void ChildGamma::setParentData(const QString &data)
|
||||
{
|
||||
if (m_staticLabel)
|
||||
m_staticLabel->setText(QStringLiteral("Init-Wert: %1").arg(data));
|
||||
}
|
||||
|
||||
void ChildGamma::updateLiveData(const QString &text)
|
||||
{
|
||||
if (m_liveLabel)
|
||||
{
|
||||
m_liveLabel->setText(text.isEmpty() ? QStringLiteral("Warte auf Live-Text...") : QStringLiteral("Gamma Live: ") + text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../interfaces/child_interface.h"
|
||||
#include <QLabel>
|
||||
#include <QObject>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
class ChildGamma
|
||||
: public QObject
|
||||
, public ChildInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ChildInterface")
|
||||
Q_INTERFACES(ChildInterface)
|
||||
|
||||
public:
|
||||
ChildGamma();
|
||||
QString childName() const override { return QStringLiteral("GammaChild"); }
|
||||
QString targetParentName() const override { return QStringLiteral("AlphaParent"); }
|
||||
QWidget *widget() override { return m_widget; }
|
||||
|
||||
void setParentData(const QString &data) override;
|
||||
|
||||
public slots:
|
||||
void updateLiveData(const QString &text) override;
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QLabel *m_staticLabel;
|
||||
QLabel *m_liveLabel;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["child_gamma"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
add_library(parentAlphaGui MODULE parent_alpha.cpp parent_alpha.h)
|
||||
target_link_libraries(parentAlphaGui PRIVATE Qt5::Widgets)
|
||||
target_include_directories(parentAlphaGui PRIVATE ${CMAKE_SOURCE_DIR}/interfaces)
|
||||
|
||||
# Plugin in den Laufzeit-Ordner verschieben
|
||||
set_target_properties(parentAlphaGui PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "parent_alpha.h"
|
||||
#include <QLabel>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
ParentAlpha::ParentAlpha()
|
||||
{
|
||||
m_widget = new QWidget();
|
||||
m_layout = new QVBoxLayout(m_widget);
|
||||
m_widget->setStyleSheet(QStringLiteral("border: 2px solid blue; padding: 10px; margin: 5px;"));
|
||||
|
||||
QLabel *label = new QLabel(QStringLiteral("Eltern-Widget (AlphaParent)\nBsp.: Tln-Info-Fenster"));
|
||||
label->setStyleSheet(QStringLiteral("font-weight: bold; color: blue; font-size: 14px;"));
|
||||
m_layout->addWidget(label);
|
||||
|
||||
m_inputField = new QLineEdit();
|
||||
m_inputField->setPlaceholderText(QStringLiteral("Live-Eingabe für alle Kinder..."));
|
||||
m_layout->addWidget(m_inputField);
|
||||
|
||||
connect(m_inputField, &QLineEdit::textChanged, this, &ParentAlpha::dataChangedLive);
|
||||
}
|
||||
|
||||
void ParentAlpha::addChildWidget(QWidget *childWidget)
|
||||
{
|
||||
if (childWidget)
|
||||
{
|
||||
m_layout->addWidget(childWidget);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../interfaces/parent_interface.h"
|
||||
#include <QLineEdit>
|
||||
#include <QObject>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace DLBO
|
||||
{
|
||||
class ParentAlpha
|
||||
: public QObject
|
||||
, public ParentInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ParentInterface")
|
||||
Q_INTERFACES(ParentInterface)
|
||||
|
||||
public:
|
||||
ParentAlpha();
|
||||
QString pluginName() const override { return QStringLiteral("AlphaParent"); }
|
||||
QWidget *widget() override { return m_widget; }
|
||||
void addChildWidget(QWidget *childWidget) override;
|
||||
QObject *qobjectInstance() override { return this; }
|
||||
|
||||
signals:
|
||||
void dataChangedLive(const QString &text);
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QVBoxLayout *m_layout;
|
||||
QLineEdit *m_inputField;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Keys": ["parent_alpha"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Confluence: https://confluence-classified.rh-int.de/spaces/GUEZDLBO/pages/186346247/Plugin+Konzept
|
||||
|
||||
Jira: https://devhub.defence-elec.de/jira/browse/LS-671
|
||||
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(GuiElementPlugin CXX)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
|
||||
SET(gui_element_SRCS
|
||||
custom_widget.cpp
|
||||
custom_widget.h
|
||||
gui_element_plugin.cpp
|
||||
gui_element_plugin.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(gui_element_SRCS
|
||||
custom_widget.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS GuiElementPlugin MODULE ${gui_element_SRCS})
|
||||
# Pfad zum Interface-Ordner bekannt machen
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(GuiElementPlugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(GuiElementPlugin
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
GuiElementInterface
|
||||
PpmDataPluginInterface
|
||||
PpmCommon
|
||||
LtsCoordTrans
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "custom_widget.h"
|
||||
#include "LtsCoordTrans/lts_coord_trans.h"
|
||||
#include "ui_custom_widget.h"
|
||||
#include <QDebug>
|
||||
|
||||
CustomWidget::CustomWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::CustomWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &CustomWidget::finOnMapClicked);
|
||||
}
|
||||
|
||||
CustomWidget::~CustomWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void CustomWidget::onPositionChanged(const Core::GeoPosition &position, int participantId)
|
||||
{
|
||||
if (participantId == 0 || std::isnan(position.lon()) || std::isnan(position.lat()))
|
||||
m_ui->lblPos->setText(tr("Invalid Position"));
|
||||
else
|
||||
{
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(position.lon(), position.lat());
|
||||
|
||||
if (!qFuzzyIsNull(position.z()))
|
||||
mgrs += QStringLiteral(" | ") + QString::number(position.z(), 'f', 2);
|
||||
|
||||
m_ui->lblPos->setText(mgrs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/core.hpp"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class CustomWidget;
|
||||
}
|
||||
|
||||
class CustomWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomWidget(QWidget *parent = nullptr);
|
||||
~CustomWidget();
|
||||
void onPositionChanged(const Core::GeoPosition &position, int participantId);
|
||||
|
||||
signals:
|
||||
void finOnMapClicked();
|
||||
private:
|
||||
Ui::CustomWidget *m_ui;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomWidget</class>
|
||||
<widget class="QWidget" name="CustomWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>268</width>
|
||||
<height>88</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Plugin-Test-DEBUG ONLY</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelPos">
|
||||
<property name="text">
|
||||
<string>Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblPos">
|
||||
<property name="text">
|
||||
<string><Position></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="pbFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><TIME OVER TARGET></string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,60 @@
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "gui_element_plugin.h"
|
||||
#include "custom_widget.h"
|
||||
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
GuiElementPlugin::GuiElementPlugin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QWidget *GuiElementPlugin::createGuiElement(QWidget *parent)
|
||||
{
|
||||
m_customWidget = new CustomWidget(parent);
|
||||
if (!m_ppmDtc)
|
||||
{
|
||||
qCritical()<<" ppmDtc not yet init!!!";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
connect(m_customWidget, &CustomWidget::finOnMapClicked, this, &GuiElementPlugin::onFindOnMap);
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
m_customWidget, [=](const ParticipantManagement::ParticipantPosition &ppPos){
|
||||
m_customWidget->onPositionChanged(ppPos.pos(), m_participantId);
|
||||
}, Qt::UniqueConnection);
|
||||
m_customWidget->onPositionChanged(m_ppmDtc->participantPosition(m_participantId).pos(), m_participantId);
|
||||
return m_customWidget;
|
||||
}
|
||||
|
||||
|
||||
bool GuiElementPlugin::init(LtsSession::LtsSession *session, int participantId)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
qCritical()<<"couln't init ppmDtc for gui element ";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc))
|
||||
{
|
||||
qCritical()<<"couln't init sitMapGuiIfc for gui element ";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_participantId = participantId;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiElementPlugin::onFindOnMap()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->centerMapToParticipant(m_participantId);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <Core/core.hpp>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/participant_info_gui_element_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
|
||||
class CustomWidget;
|
||||
|
||||
class GuiElementPlugin : public QObject, public GuiElementInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID IGuiElementPlugin)
|
||||
Q_INTERFACES(GuiElementInterface)
|
||||
|
||||
public:
|
||||
GuiElementPlugin();
|
||||
|
||||
QString pluginName() {return QStringLiteral("KeyValueGuiElement_XY");}
|
||||
QWidget* createGuiElement(QWidget *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession *session, int participantId = 0);
|
||||
void onFindOnMap();
|
||||
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
CustomWidget *m_customWidget;
|
||||
int m_participantId = 0;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user