Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
18662 files changed
+4115092
-5435
No files matched your search
+95
-73
@@ -1,8 +1,14 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Explosions Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Steve Tougnia, SLTE, 2023-09-05
|
||||
*/
|
||||
|
||||
#include "aes_explosions_edit_adler.h"
|
||||
|
||||
// #include "aes_explosions_edit_helper.h"
|
||||
#include "aes_effector.h"
|
||||
#include "ui_aes_explosions_edit_adler.h"
|
||||
|
||||
@@ -10,18 +16,18 @@
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/Base/aes_base_model.h>
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/Utils/aes_helper.h>
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Services/AreaEffectSimulation/Utils/aes_helper.h>
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <Services/ParticipantManagement/ppm_translation.h>
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <AreaEffectSimulation/settings.h>
|
||||
#include <Services/AreaEffectSimulation/settings.h>
|
||||
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/Gui/ParticipantSelection/participant_selection.h>
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/Gui/ParticipantSelection/participant_selection.h>
|
||||
|
||||
#include <AreaEffectSimulation/aes_translation.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
@@ -33,20 +39,23 @@
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <LtsElevation/lts_elevation_manager.h>
|
||||
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtWidgets/QSpinBox>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QButtonGroup>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QJsonDocument>
|
||||
#include <QSpinBox>
|
||||
#include <QTimer>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
static const char *const VALUE_VALID_PROPERTY_NAME = "VALUE_VALID";
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::ExplosionsEditAdler
|
||||
* \param menuGroup
|
||||
* \param parent
|
||||
*/
|
||||
QString ExplosionsEditAdler::toString(ExplosionsEditAdler::FlighDurationOrPeakHeight val)
|
||||
{
|
||||
switch (val)
|
||||
@@ -64,12 +73,12 @@ QString ExplosionsEditAdler::toString(ExplosionsEditAdler::FlighDurationOrPeakHe
|
||||
return QStringLiteral("PHFD_Unknow");
|
||||
}
|
||||
|
||||
|
||||
// Maximaler Winkel fuer untere Winkelgruppe
|
||||
static double maxAngleUW = 45.0;
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class ExplosionsEditAdler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QStringLiteral("ExplosionsEditAdler"), parent)
|
||||
@@ -86,11 +95,11 @@ ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *pare
|
||||
m_geometrieButtonGroup->addButton(m_ui->geometrieRadialBtn, static_cast<int>(AreaEffectSimulation::AesExplosionGeometry_def::EgRadial));
|
||||
m_geometrieButtonGroup->setExclusive(true);
|
||||
|
||||
m_gearClassFilter = {ProjectDataManagement::GearClass::GearClass_Artillery, ProjectDataManagement::GearClass::GearClass_Mortar};
|
||||
m_gearClassFilter = {ProjectDataManagement::GearClass::Artillery, ProjectDataManagement::GearClass::Mortar};
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableRocket = ps->value(QStringLiteral("aes"), QStringLiteral("enableRocket"), false).toBool();
|
||||
if (enableRocket)
|
||||
m_gearClassFilter += ProjectDataManagement::GearClass::GearClass_Rocket;
|
||||
m_gearClassFilter += ProjectDataManagement::GearClass::Rocket;
|
||||
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lbxActors,
|
||||
@@ -98,21 +107,21 @@ ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *pare
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
|
||||
// "Einschießen" is hidden for now
|
||||
m_ui->lblFire->hide();
|
||||
m_ui->einschlJaBtn->hide();
|
||||
m_ui->einschlNoBtn->hide();
|
||||
|
||||
|
||||
// "Wirkungsfeuer" is hidden for now
|
||||
m_ui->lblFire_2->hide();
|
||||
m_ui->wirkungJaBtn->hide();
|
||||
m_ui->wirkungNoBtn->hide();
|
||||
|
||||
|
||||
|
||||
// DMF EffectMarkingInTa hide currently always true
|
||||
// m_ui->cbEffectMarkingInTa->hide();
|
||||
|
||||
m_ui->rbAngleGroupLower->setChecked(true);
|
||||
|
||||
// disable Tab Additional/Charge for now
|
||||
m_ui->tabWidget->setTabEnabled(1, false);
|
||||
m_ui->tabWidget->setTabEnabled(2, false);
|
||||
|
||||
@@ -121,8 +130,9 @@ ExplosionsEditAdler::ExplosionsEditAdler(const QString &menuGroup, QWidget *pare
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::~ExplosionsEditAdler
|
||||
*/
|
||||
ExplosionsEditAdler::~ExplosionsEditAdler()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
@@ -130,8 +140,12 @@ ExplosionsEditAdler::~ExplosionsEditAdler()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief AreaEffectSimulation::ExplosionsEditAdler::init
|
||||
* \param aesItemId
|
||||
* \param session
|
||||
* \return
|
||||
*/
|
||||
bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession *session)
|
||||
{
|
||||
|
||||
@@ -146,7 +160,7 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
if (!session->getForeignGuiInterface(m_esmActorCbx))
|
||||
return false;
|
||||
|
||||
|
||||
// P _D_ M
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
@@ -162,7 +176,7 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
m_dtc->waitForHistoricalDataExplosionCluster(1000);
|
||||
m_ftc->enableAcknowledgeExternalAesItem();
|
||||
|
||||
|
||||
// P _P_ M
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get ppmDtc";
|
||||
@@ -177,7 +191,7 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
setEffectClusterData(ecData);
|
||||
|
||||
setPbStateChangeName();
|
||||
m_ui->gbEffectMarkingInTa->setChecked(m_aesItem.effectMarkingInTa());
|
||||
m_ui->gbEffectMarkingInTa->setChecked(m_aesItem.effectMarkingInTa()); // always true for explosion cluster
|
||||
}
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::effectClusterChanged, this, &ExplosionsEditAdler::onEffectClusterChanged, Qt::UniqueConnection);
|
||||
@@ -196,11 +210,12 @@ bool ExplosionsEditAdler::init(int aesItemId, bool copy, LtsSession::LtsSession
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdlerStandAlone::showPreviewObject
|
||||
*/
|
||||
void ExplosionsEditAdler::showPreviewObject()
|
||||
{
|
||||
if (!has2DMap(false))
|
||||
if (!has2DMap(false)) // showMsgBoxIfNot2D
|
||||
return;
|
||||
|
||||
switch (m_currentGeometry.underlying())
|
||||
@@ -232,16 +247,16 @@ void ExplosionsEditAdler::showPreviewObject()
|
||||
|
||||
bool ExplosionsEditAdler::isDataSufficiant()
|
||||
{
|
||||
|
||||
// identifier:
|
||||
if (m_ui->lblZpNumber->text().isEmpty())
|
||||
return false;
|
||||
|
||||
|
||||
// originator:
|
||||
bool hasParticipant = !m_ui->lblParticipantUnits->text().isEmpty();
|
||||
if (!hasParticipant)
|
||||
return false;
|
||||
|
||||
|
||||
// target:
|
||||
bool bHasTargetArea = !m_coord.isNull();
|
||||
switch (m_currentGeometry.underlying())
|
||||
{
|
||||
@@ -255,7 +270,7 @@ bool ExplosionsEditAdler::isDataSufficiant()
|
||||
if (!bHasTargetArea)
|
||||
return false;
|
||||
|
||||
|
||||
// ammo
|
||||
const bool bHasAmmo = !m_ui->lblChargeType->text().isEmpty();
|
||||
if (!bHasAmmo)
|
||||
return false;
|
||||
@@ -285,7 +300,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
|
||||
m_ui->dteEffectStart->setMsecsSinceEpoch(effectStart);
|
||||
|
||||
|
||||
// Geometry/Area
|
||||
const AreaEffectSimulation::AesExplosionGeometry_def::type geometryType = ecData.explosionGeometry().underlying();
|
||||
switch (geometryType)
|
||||
{
|
||||
@@ -305,24 +320,24 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
m_ui->geometrieRadialBtn->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
|
||||
// empty
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
|
||||
if (ecData.effectDuration() == DEFAULT_EFFECT_DURATION)
|
||||
m_ui->lblDuration->setText(QStringLiteral("---"));
|
||||
else
|
||||
m_ui->lblDuration->setText(QString::number(ecData.effectDuration() / 1000));
|
||||
m_ui->lblDuration->setText(QString::number(ecData.effectDuration() / 1000)); // msecs -> secs
|
||||
|
||||
|
||||
// 1st GearClass
|
||||
ProjectDataManagement::GearClass gc = m_pdmDtc->gearClassFromChargeTypeId(ecData.chargeStruct().chargeTypeId());
|
||||
m_ui->lblGearClass->setText(ProjectDataManagement::toString(gc));
|
||||
|
||||
|
||||
// 2nd Party
|
||||
if (ecData.partyId().is_set())
|
||||
m_ui->lblParty->setText(ParticipantManagement::trPartyName(m_ppmDtc->party(ecData.partyId().get()).name()));
|
||||
|
||||
|
||||
// 3rd Originator
|
||||
if (ecData.participantId().is_set())
|
||||
m_ui->lblParticipantUnits->setText(QString::fromStdString(m_ppmDtc->participant(ecData.participantId().get()).name()));
|
||||
|
||||
@@ -332,7 +347,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
|
||||
int impactCount = 0;
|
||||
|
||||
|
||||
// delete existing widgets
|
||||
QLayoutItem *item = nullptr;
|
||||
while((item = m_ui->layoutEffectors->takeAt(0)) != nullptr)
|
||||
{
|
||||
@@ -350,7 +365,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
m_ui->lblCannons->setText(QString::number(impactCount));
|
||||
m_ui->lblFirePurpose->setText(m_pdmDtc->trFirePurposeName(ecData.firePurposeId()));
|
||||
|
||||
m_ui->lblZog->setText(QString::number(ecData.tla()));
|
||||
m_ui->lblZog->setText(QString::number(ecData.tla())); // tla == zog
|
||||
|
||||
const AreaEffectSimulation::Area &areaRef = ecData.area();
|
||||
const QPointF bottomLeft(areaRef.cornerBottomLeft().lon(), areaRef.cornerBottomLeft().lat());
|
||||
@@ -387,7 +402,7 @@ void ExplosionsEditAdler::setEffectClusterData(const EffectCluster &ecData)
|
||||
if (ecData.effectors().size())
|
||||
setOWUWFromTrajectory(ecData.effectors().at(0).trajectoryRelative());
|
||||
|
||||
|
||||
// enable second Actor if possible
|
||||
const int amountFireMarker = m_pdmDtc->getAmountFireMarkers(ecData.firePurposeId());
|
||||
m_ui->cbActors_2->setEnabled(amountFireMarker > 1);
|
||||
|
||||
@@ -408,8 +423,10 @@ void ExplosionsEditAdler::setEffector(int participantId, const AreaEffectSimulat
|
||||
m_effectorNumber++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::dialogIdentifier
|
||||
* \return
|
||||
*/
|
||||
QString ExplosionsEditAdler::dialogIdentifier() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "dialogIdentifier";
|
||||
@@ -445,7 +462,7 @@ void ExplosionsEditAdler::onEffectClusterChanged(const EffectCluster &ecData, Da
|
||||
if (m_effectClusterData.effectDuration() == DEFAULT_EFFECT_DURATION)
|
||||
m_ui->lblDuration->setText(QStringLiteral("---"));
|
||||
else
|
||||
m_ui->lblDuration->setText(QString::number(m_effectClusterData.effectDuration() / 1000));
|
||||
m_ui->lblDuration->setText(QString::number(m_effectClusterData.effectDuration() / 1000)); // msec -> sec
|
||||
|
||||
enableUiElements();
|
||||
if (unchangeable())
|
||||
@@ -453,6 +470,8 @@ void ExplosionsEditAdler::onEffectClusterChanged(const EffectCluster &ecData, Da
|
||||
m_ui->pbStateChange->setEnabled(false);
|
||||
m_ui->gbEffectMarkingInTa->setEnabled(false);
|
||||
}
|
||||
|
||||
__unchange__();
|
||||
}
|
||||
|
||||
QPointF ExplosionsEditAdler::centerOfFiringUnitGeo(int particpantUnitId)
|
||||
@@ -467,7 +486,7 @@ QPointF ExplosionsEditAdler::centerOfFiringUnitGeo(int particpantUnitId)
|
||||
const LtsUtils::QPoint3D ¢erCoordGeo = Polygons::calculateFiringUnitCenterNonRecursive(m_ppmDtc, particpantUnitId, singlePositionsOut_unused, m_logger);
|
||||
if (centerCoordGeo.isNull() || std::isnan(centerCoordGeo.x()))
|
||||
{
|
||||
|
||||
// may happen in real life: so WARNING_LOG to DEBUG_LOG
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " calculateFiringUnitCenterNonRecursive failed, particpantUnitId = " << particpantUnitId;
|
||||
return {};
|
||||
}
|
||||
@@ -499,11 +518,12 @@ void ExplosionsEditAdler::showCenterOfFiringUnit(int particpantUnitId)
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " END particpantUnitId: " << particpantUnitId;
|
||||
m_sitMapGuiIfc->objectIndicatorToPoint(centerFiringUnitGeo);
|
||||
m_sitMapGuiIfc->objectIndicatorToPoint(centerFiringUnitGeo); // you can provide a duration: lifetimeMsec = -1
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::retranslate
|
||||
*/
|
||||
void ExplosionsEditAdler::retranslate()
|
||||
{
|
||||
QString title = tr("ADLER Artillery");
|
||||
@@ -542,13 +562,15 @@ void ExplosionsEditAdler::enableUiElements(bool enable)
|
||||
m_ui->pbStateChange->setEnabled(m_effectClusterData.effectorState() != AreaEffectSimulation::AesEffectorState::EsReadyToFire);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ExplosionsEditAdler::apply
|
||||
* \return
|
||||
*/
|
||||
bool ExplosionsEditAdler::apply()
|
||||
{
|
||||
|
||||
int esmParticipantId1 = m_ui->cbActors->currentData().toInt();
|
||||
int esmParticipantId2 = m_ui->cbActors_2->currentData().toInt();
|
||||
// DMF (Actors)
|
||||
int esmParticipantId1 = m_ui->cbActors->currentData().toInt(); // participant ID
|
||||
int esmParticipantId2 = m_ui->cbActors_2->currentData().toInt(); // participant ID
|
||||
|
||||
EffectClusterModifyActorRequest request;
|
||||
request.aesId(m_aesItem.id());
|
||||
@@ -568,7 +590,7 @@ bool ExplosionsEditAdler::apply()
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
//
|
||||
void ExplosionsEditAdler::setPbStateChangeName()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onPbStateChangeName: AesEffectState: " << m_aesItem.effectStateId();
|
||||
@@ -599,7 +621,7 @@ void ExplosionsEditAdler::onPbStateChangeClicked()
|
||||
if (m_ui->gbEffectMarkingInTa->isChecked())
|
||||
apply();
|
||||
|
||||
|
||||
// Re-Enable PB, so we can call it another time, if it does not react...
|
||||
QTimer::singleShot(2000, [this]() { m_ui->pbStateChange->setEnabled(m_effectClusterData.effectorState() != AreaEffectSimulation::AesEffectorState::EsReadyToFire); });
|
||||
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsReceived)
|
||||
@@ -648,8 +670,8 @@ void ExplosionsEditAdler::onEffectorChanged(const AreaEffectSimulation::Effector
|
||||
|
||||
bool ExplosionsEditAdler::isOnlyNameModifiable() const
|
||||
{
|
||||
|
||||
|
||||
// BaseClass::isOnlyNameModifiable() -> EsPaused || EsActivated
|
||||
// m_effectClusterData.isObjectModifiable -> since PreStart and s_calculationOffsetMSec
|
||||
const bool ret = BaseClass::isOnlyNameModifiable() || !m_effectClusterData.isObjectModifiable();
|
||||
return ret;
|
||||
}
|
||||
@@ -658,7 +680,7 @@ void ExplosionsEditAdler::resetTempAndAnnotationStr()
|
||||
{
|
||||
INFO_LOG(m_logger) << " RESET resetTempAndAnnotationStr";
|
||||
m_temporaryData.reset();
|
||||
|
||||
// updateAnnotationStr();
|
||||
}
|
||||
|
||||
void ExplosionsEditAdler::addAnnotationStr(const QString &newAnno)
|
||||
@@ -740,4 +762,4 @@ void ExplosionsEditAdler::setEffectClusterDataFromJson(const std::string &proper
|
||||
m_ui->lblFiringType->setText(AreaEffectSimulation::toString(firingType));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
+537
-378
File diff suppressed because it is too large.
Load diff
+31
-23
@@ -1,18 +1,24 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Namespace for rocket related functions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2026-06-03
|
||||
*/
|
||||
|
||||
#include "aes_rocket_utility.h"
|
||||
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QComboBox>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <AreaEffectSimulation/aes.hpp>
|
||||
#include <AreaEffectSimulation/Trajectory/trajectory_generator.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsUtils/LtsUtilsCore/qpoint3d.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <Proxies/TrainingAreaBase/Plugins/AdlerJson/telegrams.h>
|
||||
|
||||
@@ -41,7 +47,7 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
const QVariant currentData = wirkmittelCombobox->itemData(indexCounter);
|
||||
const ProjectDataManagement::GearClass::type currentGearClass = static_cast<ProjectDataManagement::GearClass::type>(currentData.toInt());
|
||||
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::GearClass_Rocket)
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::Rocket)
|
||||
{
|
||||
QStandardItem *item = cboModel->item(indexCounter);
|
||||
|
||||
@@ -50,7 +56,7 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
|
||||
item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
|
||||
|
||||
// we do not break the loop here because there may be more rocket wirkmittel in the future
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -64,7 +70,7 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
const QVariant currentData = wirkmittelCombobox->itemData(indexCounter);
|
||||
const ProjectDataManagement::GearClass::type currentGearClass = static_cast<ProjectDataManagement::GearClass::type>(currentData.toInt());
|
||||
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::GearClass_Rocket)
|
||||
if (currentGearClass == ProjectDataManagement::GearClass::Rocket)
|
||||
{
|
||||
QStandardItem *item = cboModel->item(indexCounter);
|
||||
|
||||
@@ -73,14 +79,14 @@ void enaDisaWirkmittel(QComboBox *wirkmittelCombobox, AesExplosionGeometry::type
|
||||
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEnabled & ~Qt::ItemIsSelectable);
|
||||
|
||||
|
||||
// if rocket ist currently selected, we have to set another index
|
||||
if (indexCounter == currentIndex && wirkmittelCombobox->count() > 1)
|
||||
{
|
||||
const int newIndex = currentIndex == 0 ? 1 : 0;
|
||||
|
||||
wirkmittelCombobox->setCurrentIndex(newIndex);
|
||||
}
|
||||
|
||||
// we do not break the loop here because there may be more rocket wirkmittel in the future
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -132,18 +138,18 @@ void addRocketPropertiesForLinearGeometry(EffectClusterModifyRequest &request, c
|
||||
wirkmittel.geschoss.anzahl = currentEffector.chargeAmount();
|
||||
treffpunkt.anzahl = wirkmittel.geschoss.anzahl;
|
||||
|
||||
|
||||
// calculate local x
|
||||
double xLocal = request.area().width() * (static_cast<double>(mhpSliceCounter++) / (request.effectors().size() + 1));
|
||||
|
||||
|
||||
// transform local point to UTM
|
||||
const QPointF localPoint(xLocal, yLocal);
|
||||
const QPointF utmPoint = transform.map(localPoint);
|
||||
|
||||
|
||||
// tranform utm point to geographic WGS84 coordinate
|
||||
const UtmCoordinate currentUtm(areaBottomLeftUtm.zone, utmPoint.x(), utmPoint.y());
|
||||
const QPointF mhpGeo = currentUtm.geographic();
|
||||
|
||||
|
||||
// treffpunkt
|
||||
currentEffector.mhpPosition().lon(mhpGeo.x());
|
||||
currentEffector.mhpPosition().lat(mhpGeo.y());
|
||||
treffpunkt.koordinate.koordinate.longitude = currentEffector.mhpPosition().lon() * LtsCoordTrans::rad2deg();
|
||||
@@ -157,14 +163,14 @@ void addRocketPropertiesForLinearGeometry(EffectClusterModifyRequest &request, c
|
||||
|
||||
currentEffector.properties(QJsonDocument(wirkmittelObj).toJson().toStdString());
|
||||
|
||||
|
||||
// trajectory
|
||||
const ParticipantManagement::ParticipantPosition &participantPosition = ppmDtc->participantPosition(currentEffector.participantId());
|
||||
const LtsUtils::QPoint3D trajectoryStart(participantPosition.pos().lon(),
|
||||
participantPosition.pos().lat(),
|
||||
participantPosition.pos().z());
|
||||
const LtsUtils::QPoint3D trajectoryEnd(currentEffector.mhpPosition().lon(),
|
||||
currentEffector.mhpPosition().lat(),
|
||||
currentEffector.mhpPosition().z());
|
||||
currentEffector.mhpPosition().z()); // TODO
|
||||
TrajectoryGeoPosition trajectoryWithoutTime;
|
||||
|
||||
TrajectoryGenerator::getInstance()->generateTrajectoryBiedziak(trajectoryStart, trajectoryEnd, 45.0, trajectoryWithoutTime);
|
||||
@@ -173,6 +179,7 @@ void addRocketPropertiesForLinearGeometry(EffectClusterModifyRequest &request, c
|
||||
const double flightTimeStep = currentEffector.flightTime() / static_cast<double>(trajectoryWithoutTime.size());
|
||||
double currentFlightTime = 0.0;
|
||||
|
||||
currentEffector.trajectoryRelative().clear(); // LS_711_akkumulierende_flugkurven_bei_rakete
|
||||
const LtsCoordTrans::UtmCoordinate utmStartPos = LtsCoordTrans::UtmCoordinate::fromGeographic(participantPosition.pos().lon(), participantPosition.pos().lat());
|
||||
for (const Core::GeoPosition &pos : trajectoryWithoutTime)
|
||||
{
|
||||
@@ -204,7 +211,7 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
wirkmittel.geschoss.anzahl = currentEffector.chargeAmount();
|
||||
treffpunkt.anzahl = wirkmittel.geschoss.anzahl;
|
||||
|
||||
|
||||
// treffpunkt
|
||||
currentEffector.mhpPosition().lon(areaCenterGeo.x());
|
||||
currentEffector.mhpPosition().lat(areaCenterGeo.y());
|
||||
treffpunkt.koordinate.koordinate.longitude = currentEffector.mhpPosition().lon() * LtsCoordTrans::rad2deg();
|
||||
@@ -218,7 +225,7 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
|
||||
currentEffector.properties(QJsonDocument(wirkmittelObj).toJson().toStdString());
|
||||
|
||||
|
||||
// trajectory
|
||||
const ParticipantManagement::ParticipantPosition &participantPosition = ppmDtc->participantPosition(currentEffector.participantId());
|
||||
const LtsUtils::QPoint3D trajectoryStart(participantPosition.pos().lon(),
|
||||
participantPosition.pos().lat(),
|
||||
@@ -234,6 +241,7 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
const double flightTimeStep = currentEffector.flightTime() / static_cast<double>(trajectoryWithoutTime.size());
|
||||
double currentFlightTime = 0.0;
|
||||
|
||||
currentEffector.trajectoryRelative().clear(); // LS_711_akkumulierende_flugkurven_bei_rakete
|
||||
const LtsCoordTrans::UtmCoordinate utmStartPos = LtsCoordTrans::UtmCoordinate::fromGeographic(participantPosition.pos().lon(), participantPosition.pos().lat());
|
||||
for (const Core::GeoPosition &pos : trajectoryWithoutTime)
|
||||
{
|
||||
@@ -244,8 +252,8 @@ void addRocketPropertiesForPointGeometry(EffectClusterModifyRequest &request, co
|
||||
|
||||
currentFlightTime += flightTimeStep;
|
||||
}
|
||||
}
|
||||
} // for (EffectorData ¤tEffector : request.effectors())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace RocketUtility
|
||||
} // namespace AreaEffectSimulation
|
||||
+181
-141
@@ -1,224 +1,264 @@
|
||||
#include "flm_hq_report_converter.h"
|
||||
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <flm_data_plugin_interface.h>
|
||||
#include <Lts/Services/FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_data_plugin_interface.h>
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc_types.h>
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <Symbology/sidc_builder_base.h>
|
||||
#include <Symbology/sidc_codec.h>
|
||||
#include <Symbology/symbol_dictionary.h>
|
||||
#include <SymbologyXML/symbol_types.h>
|
||||
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
FlmHqReportConverter::FlmHqReportConverter() : m_logger(getLogger("HQReportConverter"))
|
||||
FlmHqReportConverter::FlmHqReportConverter()
|
||||
: m_logger(getLogger("HQReportConverter"))
|
||||
{
|
||||
connect(this, &FlmHqReportConverter::allRequestsFinished, this, &FlmHqReportConverter::onRequestsFinished);
|
||||
connect(this, &FlmHqReportConverter::allRequestsFinished, this, &FlmHqReportConverter::onRequestsFinished);
|
||||
}
|
||||
|
||||
bool FlmHqReportConverter::init(LtsSession::LtsSession* session, int currentPartyId)
|
||||
bool FlmHqReportConverter::init(LtsSession::LtsSession *session, int currentPartyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get PPM Dtc.";
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get PPM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
|
||||
if (m_geometryModel != nullptr)
|
||||
{
|
||||
delete m_geometryModel;
|
||||
m_geometryModel = nullptr;
|
||||
}
|
||||
if (m_geometryModel != nullptr)
|
||||
{
|
||||
delete m_geometryModel;
|
||||
m_geometryModel = nullptr;
|
||||
}
|
||||
|
||||
m_geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
m_geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
m_partyId = currentPartyId;
|
||||
m_partyId = currentPartyId;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::addHqToPlanIds(const QMap<int, QList<int>>& hqToPlanIds)
|
||||
void FlmHqReportConverter::addHqToPlanIds(const QMap<int, QSet<int>> &hqToPlanIds)
|
||||
{
|
||||
for (auto it = hqToPlanIds.constBegin(); it != hqToPlanIds.constEnd(); ++it)
|
||||
for (auto it = hqToPlanIds.constBegin(); it != hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planFileId = it.key();
|
||||
const QSet<int> &hqMessageIds = it.value();
|
||||
|
||||
for (int id : hqMessageIds)
|
||||
{
|
||||
m_hqToPlanIds[it.key()].append(it.value());
|
||||
if (id == planFileId) // Eventueller Eintrag in Map wegen QTreeView verhindern
|
||||
continue;
|
||||
|
||||
m_hqToPlanIds[planFileId].append(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::processCollectedHqs()
|
||||
{
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
for (int id : it.value())
|
||||
m_pendingRequests++;
|
||||
}
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<int> &hqMessageIds = it.value();
|
||||
|
||||
for (int id : hqMessageIds)
|
||||
{
|
||||
m_pendingRequests += it.value().size();
|
||||
}
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<int>& reportIds = it.value();
|
||||
|
||||
for (int id : reportIds)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Request File with ID: " << id << " from plan with ID: " << planId;
|
||||
FileManagement::GetFileContentDataRequest request(id);
|
||||
m_flmFtc->getFileContentDataRequest(request, this);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Request File with ID: " << id << " from plan with ID: " << planId;
|
||||
FileManagement::GetFileContentDataRequest request(id);
|
||||
m_flmFtc->getFileContentDataRequest(request, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::createGeometryFromReport(const HqReportData& data)
|
||||
{
|
||||
m_symbolFactory.build(data.art, data, m_geometryModel);
|
||||
}
|
||||
void FlmHqReportConverter::createGeometryFromReport(const HqReportData &data) { m_symbolFactory.build(data.art, data, m_geometryModel); }
|
||||
|
||||
void FlmHqReportConverter::checkIfAllFinished()
|
||||
{
|
||||
if (m_pendingRequests <= 0)
|
||||
emit allRequestsFinished();
|
||||
if (m_pendingRequests <= 0)
|
||||
emit allRequestsFinished();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onGetFileContentDataReply(const FileManagement::GetFileContentDataReply& reply)
|
||||
void FlmHqReportConverter::onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply)
|
||||
{
|
||||
m_pendingRequests--;
|
||||
m_pendingRequests--;
|
||||
|
||||
if (reply.errorString().size() > 0)
|
||||
const int id = static_cast<int>(reply.id());
|
||||
int planId = -1;
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
if (it.value().contains(id))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got onGetFileContentDataReply error: " << reply.errorString();
|
||||
return;
|
||||
planId = it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int id = static_cast<int>(reply.id());
|
||||
int planId = -1;
|
||||
DEBUG_LOG(m_logger) << "Reply File with ID: " << id << " from plan with ID: " << planId;
|
||||
INFO_LOG(m_logger) << "Got reply with id " << id;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Reply File with ID: " << id << " from plan with ID: " << planId;
|
||||
QByteArray fileContent = QByteArray::fromRawData(reinterpret_cast<const char *>(reply.content().data()), reply.content().size());
|
||||
|
||||
INFO_LOG(m_logger) << "Got reply with id " << id << " and errorString " << reply.errorString();
|
||||
DEBUG_LOG(m_logger) << "fileContent: " << fileContent;
|
||||
|
||||
QByteArray fileContent = QByteArray(reinterpret_cast<const char*>(reply.content().data()), reply.content().size());
|
||||
FileManagement::FileContent flc = m_flmDtc->fileContent(reply.id());
|
||||
|
||||
FlmHqReportJsonParser m_parser = FlmHqReportJsonParser();
|
||||
DEBUG_LOG(m_logger) << "FlmHqReportConverter::onGetFileContentDataReply FILECONTENTNAME: " << flc.name();
|
||||
|
||||
HqReportData data = m_parser.parse(fileContent);
|
||||
data.contentFileId = id;
|
||||
HqReportData data = m_parser.parse(fileContent);
|
||||
data.contentFileId = id;
|
||||
data.name = QString::fromStdString(flc.name());
|
||||
|
||||
DEBUG_LOG(m_logger) << "Party: " << m_partyId
|
||||
<< " has Color: " << QColor::fromRgb(QRgb(m_ppmDtc->party(m_partyId).color())).value();
|
||||
data.partyColor = QColor::fromRgb(m_ppmDtc->party(m_partyId).color());
|
||||
|
||||
data.partyColor = QColor::fromRgb(QRgb(m_ppmDtc->party(m_partyId).color()));
|
||||
m_convertedHqToPlanIds[planId].append(std::move(data));
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
if (it.value().contains(id))
|
||||
{
|
||||
planId = it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Content size: " << reply.content().size();
|
||||
|
||||
m_convertedHqToPlanIds[planId].append(data);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Content size: " << reply.content().size();
|
||||
|
||||
checkIfAllFinished();
|
||||
checkIfAllFinished();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onFileContentModifyReply(const Core::FunctionReplyObject& reply)
|
||||
void FlmHqReportConverter::onFileContentModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentModify Reply: " << reply.translated();
|
||||
DEBUG_LOG(m_logger) << "Got FileContentModify Reply: " << reply.translated();
|
||||
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onFileContentRemoveReply(const Core::FunctionReplyObject& reply)
|
||||
void FlmHqReportConverter::onFileContentRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentRemove Reply: " << reply.translated();
|
||||
DEBUG_LOG(m_logger) << "Got FileContentRemove Reply: " << reply.translated();
|
||||
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onRequestsFinished()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ALL REQUESTS FINISHED";
|
||||
DEBUG_LOG(m_logger) << "ALL REQUESTS FINISHED -> STARTING CONTENT FETCH";
|
||||
|
||||
for (auto it = m_convertedHqToPlanIds.constBegin(); it != m_convertedHqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<HqReportData>& reportDatas = it.value();
|
||||
for (auto it = m_convertedHqToPlanIds.constBegin(); it != m_convertedHqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
QList<HqReportData> reportDatas = it.value();
|
||||
const FileManagement::FileContent flc = m_flmDtc->fileContent(planId);
|
||||
FileManagement::GetFileContentDataRequest req;
|
||||
req.fileContentId(planId);
|
||||
|
||||
for (auto& reportData : reportDatas)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "createGeometryFromReport :" << reportData.art;
|
||||
createGeometryFromReport(reportData);
|
||||
}
|
||||
m_flmFtc->getFileContentDataRequest(req,
|
||||
[this, planId, reportDatas = std::move(reportDatas), flc = std::move(flc)](const FileManagement::GetFileContentDataReply &reply)
|
||||
{
|
||||
const auto &fetchedFlc = reply;
|
||||
if (fetchedFlc.content().size() > 0)
|
||||
{
|
||||
QByteArray existingContent
|
||||
= QByteArray::fromRawData(reinterpret_cast<const char *>(fetchedFlc.content().data()), fetchedFlc.content().size());
|
||||
|
||||
const FileManagement::FileContent& flc = m_flmDtc->fileContent(planId);
|
||||
if (!m_geometryModel->fromByteArray(existingContent))
|
||||
WARNING_LOG(m_logger) << "Could not load existing geometry content for planId" << planId;
|
||||
}
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
QJsonArray jsonNameArray;
|
||||
QJsonDocument existingDocs = QJsonDocument::fromJson(QByteArray::fromRawData(flc.properties().data(), flc.properties().size()));
|
||||
|
||||
DEBUG_LOG(m_logger) << "FILE CONTENT: " << flc.name() << " " << flc.folderId();
|
||||
if (existingDocs.isArray())
|
||||
jsonNameArray = existingDocs.array();
|
||||
|
||||
data.id(flc.id());
|
||||
data.name(flc.name());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(flc.folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(m_geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
for (const auto &reportData : reportDatas)
|
||||
{
|
||||
|
||||
m_flmFtc->fileContentModifyRequest(data, this);
|
||||
bool alreadyExists = false;
|
||||
for (const QJsonValue &value : jsonNameArray)
|
||||
{
|
||||
if (value.toString() == reportData.name)
|
||||
{
|
||||
alreadyExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_geometryModel->clearModel();
|
||||
}
|
||||
if (!alreadyExists)
|
||||
{
|
||||
createGeometryFromReport(reportData);
|
||||
jsonNameArray.append(reportData.name);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonDocument jsonDoc(jsonNameArray);
|
||||
QString combinedNames = QString::fromUtf8(jsonDoc.toJson(QJsonDocument::Compact));
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
|
||||
DEBUG_LOG(m_logger) << "FILE CONTENT: " << flc.name() << " " << flc.folderId();
|
||||
|
||||
data.id(flc.id());
|
||||
data.name(flc.name());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(flc.folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(m_geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
data.properties(combinedNames.toStdString());
|
||||
m_flmFtc->fileContentModifyRequest(data, this);
|
||||
m_geometryModel->clearModel();
|
||||
});
|
||||
}
|
||||
}
|
||||
} // namespace FileManagement
|
||||
+50
-39
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <FileManagement/logger.h>
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
|
||||
#include "flm_hq_report_json_parser.h"
|
||||
#include "flm_hq_report_symbol_factory.h"
|
||||
|
||||
#include <Lts/Services/FileManagement/logger.h>
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
@@ -18,53 +18,64 @@ class Dtc;
|
||||
class Ftc;
|
||||
} // namespace Interface
|
||||
|
||||
class FlmHqReportConverter : public QObject,
|
||||
public Interface::Ftc::GetFileContentDataReplyHandler,
|
||||
public Interface::Ftc::FileContentModifyReplyHandler,
|
||||
public Interface::Ftc::FileContentRemoveReplyHandler
|
||||
class FlmHqReportConverter
|
||||
: public QObject
|
||||
, public Interface::Ftc::GetFileContentDataReplyHandler
|
||||
, public Interface::Ftc::FileContentModifyReplyHandler
|
||||
, public Interface::Ftc::FileContentRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlmHqReportConverter();
|
||||
~FlmHqReportConverter() = default;
|
||||
FlmHqReportConverter();
|
||||
~FlmHqReportConverter() = default;
|
||||
|
||||
bool init(LtsSession::LtsSession* session, int currentPartyId);
|
||||
|
||||
void addHqToPlanIds(const QMap<int, QList<int>>& hqToPlanIds);
|
||||
|
||||
void processCollectedHqs();
|
||||
|
||||
void createGeometryFromReport(const HqReportData& data);
|
||||
bool init(LtsSession::LtsSession *session, int currentPartyId);
|
||||
/**
|
||||
* @brief add hqToPlanIds to m_hqToPlanIds
|
||||
* @param const QMap<int, QList<int>> &hqToPlanIds -> <planId, QList<HqIds>>
|
||||
*/
|
||||
void addHqToPlanIds(const QMap<int, QSet<int>> &hqToPlanIds);
|
||||
/**
|
||||
* @brief Iterate and send GetFileContentDataRequest to get File Information HQ
|
||||
*/
|
||||
void processCollectedHqs();
|
||||
/**
|
||||
* @brief create GeometryModel from HQ Report
|
||||
* @param {data} HQ Report Data
|
||||
*/
|
||||
void createGeometryFromReport(const HqReportData &data);
|
||||
|
||||
private:
|
||||
void checkIfAllFinished();
|
||||
void checkIfAllFinished();
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply& reply) override;
|
||||
void onFileContentModifyReply(const Core::FunctionReplyObject& reply) override;
|
||||
void onFileContentRemoveReply(const Core::FunctionReplyObject& reply) override;
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply) override;
|
||||
void onFileContentModifyReply(const Core::FunctionReplyObject &reply) override;
|
||||
void onFileContentRemoveReply(const Core::FunctionReplyObject &reply) override;
|
||||
public slots:
|
||||
void onRequestsFinished();
|
||||
void onRequestsFinished();
|
||||
signals:
|
||||
|
||||
void allRequestsFinished();
|
||||
/**
|
||||
* @brief checks if all getFileContentDataRequests are finished
|
||||
*/
|
||||
void allRequestsFinished();
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
std::shared_ptr<Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_flmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
LOGGER_T m_logger;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
std::shared_ptr<Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_flmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
|
||||
SituationMap::GeometryModel* m_geometryModel{nullptr};
|
||||
QList<SituationMap::GeometryModel::Node> m_planNodes;
|
||||
SymbolFactory m_symbolFactory;
|
||||
SituationMap::GeometryModel *m_geometryModel{nullptr};
|
||||
QList<SituationMap::GeometryModel::Node> m_planNodes;
|
||||
SymbolFactory m_symbolFactory;
|
||||
|
||||
int m_partyId;
|
||||
int m_pendingRequests{0};
|
||||
|
||||
QMap<int, QList<int>> m_hqToPlanIds;
|
||||
QMap<int, int> m_hqToPlanIdsLookup;
|
||||
QMap<int, QList<HqReportData>> m_convertedHqToPlanIds;
|
||||
};
|
||||
int m_partyId;
|
||||
int m_pendingRequests{0};
|
||||
FlmHqReportJsonParser m_parser;
|
||||
QMap<int, QList<int>> m_hqToPlanIds; /// Map<planIds, QList<HQMessageId>>
|
||||
QMap<int, int> m_hqToPlanIdsLookup; /// Map<planIds, HQMessageId> for Lookup
|
||||
QMap<int, QList<HqReportData>> m_convertedHqToPlanIds; /// Map<planIds, QList<convertedHqMessage>>
|
||||
}; // class FlmHqReportConverter
|
||||
} // namespace FileManagement
|
||||
+254
-278
@@ -1,385 +1,361 @@
|
||||
#include "flm_hq_report_edit.h"
|
||||
|
||||
#include "flm_hq_report_model.h"
|
||||
#include "ui_flm_hq_report_edit.h"
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <flm_data_plugin_interface.h>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtWidgets/QInputDialog>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include <SituationMap/GeometryModel/geometry_model.h>
|
||||
#include <SituationMap/GeometryModel/geometry_model_factory.h>
|
||||
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
HQReportEdit::HQReportEdit(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::HQReportEdit),
|
||||
m_menuGroup(menuGroup)
|
||||
HQReportEdit::HQReportEdit(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::HQReportEdit)
|
||||
, m_logger(getLogger("HQReportEdit"))
|
||||
, m_menuGroup(menuGroup)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setText(tr("New Plan"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &HQReportEdit::onCreateNewPlanClicked);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setText(tr("New Plan"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &HQReportEdit::onCreateNewPlanClicked);
|
||||
|
||||
connect(m_ui->pbShift, &QPushButton::clicked, this, &HQReportEdit::onShiftClicked);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-HQReport"));
|
||||
connect(m_ui->pbShift, &QPushButton::clicked, this, &HQReportEdit::onShiftClicked);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-HQReport"));
|
||||
}
|
||||
|
||||
HQReportEdit::~HQReportEdit()
|
||||
HQReportEdit::~HQReportEdit() { delete m_ui; }
|
||||
|
||||
bool HQReportEdit::init(LtsSession::LtsSession *session, int partyId)
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
bool HQReportEdit::init(LtsSession::LtsSession* session, int partyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_session = session;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> partyCboInterface;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> partyCboInterface;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(partyCboInterface))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get Party Combobox Interface.";
|
||||
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(partyCboInterface))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get Party Combobox Interface.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!partyCboInterface->fillPartyComboBox(m_ui->cboParties) || m_ui->cboParties->count() == 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not fill Parties.";
|
||||
|
||||
if (!partyCboInterface->fillPartyComboBox(m_ui->cboParties) || m_ui->cboParties->count() == 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not fill Parties.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// init models
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
|
||||
FlmHQReportModel* planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
FlmHQReportModel* hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
delete hqReportModel;
|
||||
hqReportModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
createModels(partyId);
|
||||
}
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
connect(m_ui->cboParties, qOverload<int>(&QComboBox::currentIndexChanged), this, &HQReportEdit::onPartyChanged);
|
||||
|
||||
int partyIndex = m_ui->cboParties->findData(partyId);
|
||||
m_ui->cboParties->setCurrentIndex(partyIndex < 0 ? 0 : partyIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::createModels(const int partyId)
|
||||
{
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
if (partyFolderId == 0)
|
||||
|
||||
FlmHQReportModel *planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No partyFolderId found for partyId " << partyId;
|
||||
return;
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
auto* planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
return;
|
||||
}
|
||||
FlmHQReportModel *hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
|
||||
auto* hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
delete hqReportModel;
|
||||
return;
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
delete hqReportModel;
|
||||
hqReportModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
// configure listViewPlan
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
m_ui->listViewPlan->setHeaderHidden(true);
|
||||
// configure listViewMessage
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_ui->cboParties, qOverload<int>(&QComboBox::currentIndexChanged), this, &HQReportEdit::onPartyChanged);
|
||||
|
||||
int partyIndex = m_ui->cboParties->findData(partyId); // in case of notification: onPartyChanged() is called when index changes
|
||||
m_ui->cboParties->setCurrentIndex(partyIndex < 0 ? 0 : partyIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::createModels(const int partyId)
|
||||
{
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
if (partyFolderId == 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No partyFolderId found for partyId " << partyId;
|
||||
delete m_planModels.take(partyId);
|
||||
delete m_hqModels.take(partyId);
|
||||
return;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
delete m_planModels.take(partyId);
|
||||
delete m_hqModels.take(partyId);
|
||||
|
||||
auto *planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
return;
|
||||
}
|
||||
|
||||
auto *hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
delete hqReportModel;
|
||||
return;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
bool HQReportEdit::apply()
|
||||
{
|
||||
QMap<int, QList<int>> allHqToPlanIds;
|
||||
QMap<int, QSet<int>> allHqToPlanIds;
|
||||
|
||||
for (auto it = m_planModels.begin(); it != m_planModels.end(); ++it)
|
||||
for (auto it = m_planModels.begin(); it != m_planModels.end(); ++it)
|
||||
{
|
||||
QMap<int, QSet<int>> hqToPlanIds = it.value()->getChangedPlans(); // <planId, hq-message ids>
|
||||
|
||||
for (auto it = hqToPlanIds.constBegin(); it != hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlanIds = it.value()->getHQToPlan();
|
||||
|
||||
for (auto planId : hqToPlanIds.keys())
|
||||
{
|
||||
allHqToPlanIds[planId].append(hqToPlanIds[planId]);
|
||||
|
||||
it.value()->clearMovedData();
|
||||
}
|
||||
allHqToPlanIds[it.key()] += it.value();
|
||||
}
|
||||
}
|
||||
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
FlmHqReportConverter* hqRepConv = new FlmHqReportConverter();
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
FlmHqReportConverter *hqRepConv = new FlmHqReportConverter();
|
||||
|
||||
if (hqRepConv->init(m_session, currentPartyId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Add HQ to Converter";
|
||||
if (hqRepConv->init(m_session, currentPartyId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Add HQ to Converter";
|
||||
|
||||
hqRepConv->addHqToPlanIds(allHqToPlanIds);
|
||||
hqRepConv->addHqToPlanIds(allHqToPlanIds);
|
||||
|
||||
hqRepConv->processCollectedHqs();
|
||||
}
|
||||
hqRepConv->processCollectedHqs();
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("HQ Report"));
|
||||
}
|
||||
void HQReportEdit::retranslate() { translate(m_ui, tr("HQ Report")); }
|
||||
|
||||
void HQReportEdit::onPartyChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(index);
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "onPartyChanged " << currentPartyId;
|
||||
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
createModels(currentPartyId);
|
||||
|
||||
if (!m_planModels.contains(currentPartyId) || !m_hqModels.contains(currentPartyId))
|
||||
{
|
||||
INFO_LOG(m_logger) << "Models for party" << currentPartyId << "not found. Attempting to create...";
|
||||
createModels(currentPartyId);
|
||||
}
|
||||
QAbstractItemModel *hqModel = m_hqModels.value(currentPartyId, nullptr);
|
||||
QAbstractItemModel *planModel = m_planModels.value(currentPartyId, nullptr);
|
||||
|
||||
QAbstractItemModel* hqModel = m_hqModels.value(currentPartyId, nullptr);
|
||||
QAbstractItemModel* planModel = m_planModels.value(currentPartyId, nullptr);
|
||||
if (m_ui->listViewMessage->selectionModel())
|
||||
{
|
||||
m_ui->listViewMessage->selectionModel()->disconnect(this);
|
||||
}
|
||||
if (m_ui->listViewPlan->selectionModel())
|
||||
{
|
||||
m_ui->listViewPlan->selectionModel()->disconnect(this);
|
||||
}
|
||||
|
||||
if (m_ui->listViewMessage->selectionModel())
|
||||
{
|
||||
m_ui->listViewMessage->selectionModel()->disconnect(this);
|
||||
}
|
||||
if (m_ui->listViewPlan->selectionModel())
|
||||
{
|
||||
m_ui->listViewPlan->selectionModel()->disconnect(this);
|
||||
}
|
||||
m_ui->listViewMessage->setModel(hqModel);
|
||||
m_ui->listViewPlan->setModel(planModel);
|
||||
|
||||
m_ui->listViewMessage->setModel(hqModel);
|
||||
m_ui->listViewPlan->setModel(planModel);
|
||||
|
||||
if (hqModel && planModel)
|
||||
{
|
||||
connect(m_ui->listViewMessage->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&HQReportEdit::onSelectionChanged);
|
||||
connect(m_ui->listViewPlan->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&HQReportEdit::onSelectionChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to switch to party" << currentPartyId << ": Models still missing.";
|
||||
}
|
||||
if (hqModel && planModel)
|
||||
{
|
||||
connect(m_ui->listViewMessage->selectionModel(), &QItemSelectionModel::selectionChanged, this, &HQReportEdit::onSelectionChanged);
|
||||
connect(m_ui->listViewPlan->selectionModel(), &QItemSelectionModel::selectionChanged, this, &HQReportEdit::onSelectionChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to switch to party" << currentPartyId << ": Models still missing.";
|
||||
}
|
||||
}
|
||||
|
||||
void HQReportEdit::onCreateNewPlanClicked()
|
||||
{
|
||||
bool ok = false;
|
||||
QString planName =
|
||||
QInputDialog::getText(this, tr("Enter Plan name"), tr("Name:"), QLineEdit::Normal, QString(), &ok);
|
||||
bool ok = false;
|
||||
QString planName = QInputDialog::getText(this, tr("Enter Plan name"), tr("Name:"), QLineEdit::Normal, QString(), &ok);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No name for new plan entered.";
|
||||
if (!ok)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No name for new plan entered.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FlmHQReportModel* planModel = static_cast<FlmHQReportModel*>(m_ui->listViewPlan->model());
|
||||
FlmHQReportModel *planModel = static_cast<FlmHQReportModel *>(m_ui->listViewPlan->model());
|
||||
|
||||
if (planModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> no plan model present.";
|
||||
if (planModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> no plan model present.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SituationMap::GeometryModel* geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
SituationMap::GeometryModel *geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
if (geometryModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
if (geometryModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
if (m_session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
|
||||
data.name(planName.toStdString());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(planModel->folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
data.name(planName.toStdString());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(planModel->folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
|
||||
m_flmFtc->fileContentModifyRequest(data, [this](const Core::FunctionReplyObject& reply) {
|
||||
if (reply.error())
|
||||
{
|
||||
const QString errorMessage = tr("Could not save plan: %1").arg(QString::fromStdString(reply.str()));
|
||||
m_flmFtc->fileContentModifyRequest(data,
|
||||
[this](const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
{
|
||||
const QString errorMessage = tr("Could not save plan: %1").arg(QString::fromStdString(reply.str()));
|
||||
|
||||
ERROR_LOG(m_logger) << errorMessage;
|
||||
ERROR_LOG(m_logger) << errorMessage;
|
||||
|
||||
new LtsWidgets::LtsMessageDialogNew(this, errorMessage, tr("Save failed"));
|
||||
}
|
||||
});
|
||||
new LtsWidgets::LtsMessageDialogNew(this, errorMessage, tr("Save failed"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void HQReportEdit::onSelectionChanged(const QItemSelection&, const QItemSelection&)
|
||||
void HQReportEdit::onSelectionChanged(const QItemSelection &, const QItemSelection &)
|
||||
{
|
||||
m_ui->pbShift->setEnabled(m_ui->listViewMessage->selectionModel()->hasSelection() &&
|
||||
m_ui->listViewPlan->selectionModel()->hasSelection());
|
||||
m_ui->pbShift->setEnabled(m_ui->listViewMessage->selectionModel()->hasSelection() && m_ui->listViewPlan->selectionModel()->hasSelection());
|
||||
}
|
||||
|
||||
void HQReportEdit::onShiftClicked()
|
||||
{
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
|
||||
FlmHQReportModel* messageModel = m_hqModels.value(currentPartyId);
|
||||
FlmHQReportModel* planModel = m_planModels.value(currentPartyId);
|
||||
FlmHQReportModel *messageModel = m_hqModels.value(currentPartyId);
|
||||
FlmHQReportModel *planModel = m_planModels.value(currentPartyId);
|
||||
|
||||
if (messageModel == nullptr || planModel == nullptr)
|
||||
return;
|
||||
if (messageModel == nullptr || planModel == nullptr)
|
||||
return;
|
||||
|
||||
const QModelIndex currentMessageIndex = m_ui->listViewMessage->currentIndex();
|
||||
const QModelIndex currentMessageIndex = m_ui->listViewMessage->currentIndex();
|
||||
|
||||
if (!currentMessageIndex.isValid())
|
||||
return;
|
||||
if (!currentMessageIndex.isValid())
|
||||
return;
|
||||
|
||||
QMimeData* mimeData = messageModel->mimeData({currentMessageIndex});
|
||||
QMimeData *mimeData = messageModel->mimeData({currentMessageIndex});
|
||||
|
||||
if (mimeData == nullptr)
|
||||
return;
|
||||
if (mimeData == nullptr)
|
||||
return;
|
||||
|
||||
if (!planModel->dropMimeData(mimeData, Qt::CopyAction, -1, 0, m_ui->listViewPlan->currentIndex()))
|
||||
return;
|
||||
if (!planModel->dropMimeData(mimeData, Qt::CopyAction, -1, 0, m_ui->listViewPlan->currentIndex()))
|
||||
return;
|
||||
|
||||
m_ui->listViewPlan->viewport()->update();
|
||||
m_ui->listViewPlan->viewport()->update();
|
||||
}
|
||||
|
||||
} // namespace FileManagement
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="2">
|
||||
<widget class="QListView" name="listViewPlan"/>
|
||||
<widget class="QTreeView" name="listViewPlan"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="lblPlans">
|
||||
|
||||
+325
-194
@@ -1,299 +1,430 @@
|
||||
#include "flm_hq_report_model.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <flm_data_plugin_interface.h>
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
namespace FileManagement
|
||||
{
|
||||
FlmHQReportModel::FlmHQReportModel(QObject* parent)
|
||||
: QAbstractListModel(parent), m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger())
|
||||
FlmHQReportModel::FlmHQReportModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_logger(getLogger("HQReportModel"))
|
||||
{
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::init(LtsSession::LtsSession* session, int contentFolderId, const FileType& fileType)
|
||||
bool FlmHQReportModel::init(LtsSession::LtsSession *session, int contentFolderId, const FileType &fileType)
|
||||
{
|
||||
if (!session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid Session";
|
||||
if (!session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid Session";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc";
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_contentFolderId = contentFolderId;
|
||||
m_fileType = fileType;
|
||||
m_contentFolderId = contentFolderId;
|
||||
m_fileType = fileType;
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->waitForHistoricalDataFileContent(3000);
|
||||
m_flmDtc->fileContents(
|
||||
[this](const FileContent& content) { onFileContentChanged(content, DataModification::eAdded); });
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->waitForHistoricalDataFileContent(3000);
|
||||
m_flmDtc->fileContents([this](const FileContent &content) { onFileContentChanged(content, DataModification::eAdded); });
|
||||
|
||||
connect(m_flmDtc.get(), &Interface::Dtc::fileContentChanged, this, &FlmHQReportModel::onFileContentChanged);
|
||||
connect(m_flmDtc.get(), &Interface::Dtc::fileContentChanged, this, &FlmHQReportModel::onFileContentChanged);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int FlmHQReportModel::rowCount(const QModelIndex& parent) const
|
||||
int FlmHQReportModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
if (!parent.isValid())
|
||||
return m_data.count();
|
||||
|
||||
if (parent.internalId() != 0)
|
||||
return 0;
|
||||
|
||||
if (parent.row() >= 0 && parent.row() < m_data.size())
|
||||
{
|
||||
const HQData &data = m_data.at(parent.row());
|
||||
auto it = m_movedData.constFind(data.id);
|
||||
if (it != m_movedData.constEnd())
|
||||
return it.value().count();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariant FlmHQReportModel::data(const QModelIndex& index, int role) const
|
||||
QModelIndex FlmHQReportModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return createText(index.row());
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
return QVariant();
|
||||
quintptr internalId = index.internalId();
|
||||
|
||||
if (internalId == 0)
|
||||
return QModelIndex();
|
||||
|
||||
int parentRow = static_cast<int>(internalId) - 1;
|
||||
|
||||
return createIndex(parentRow, 0, quintptr(0));
|
||||
}
|
||||
|
||||
Qt::ItemFlags FlmHQReportModel::flags(const QModelIndex& index) const
|
||||
QVariant FlmHQReportModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
|
||||
if (!index.isValid())
|
||||
return defaultFlags;
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
quintptr internalId = index.internalId();
|
||||
|
||||
return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
if (internalId == 0)
|
||||
{
|
||||
if (index.row() >= 0 && index.row() < m_data.size())
|
||||
return m_data.at(index.row()).name;
|
||||
}
|
||||
else // Child-Item
|
||||
{
|
||||
int parentRow = static_cast<int>(internalId) - 1;
|
||||
if (parentRow >= 0 && parentRow < m_data.size())
|
||||
{
|
||||
const HQData &parentData = m_data.at(parentRow);
|
||||
auto it = m_movedData.constFind(parentData.id);
|
||||
if (it != m_movedData.constEnd())
|
||||
{
|
||||
const QList<HQData> &children = it.value();
|
||||
if (index.row() >= 0 && index.row() < children.size())
|
||||
return children.at(index.row()).name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDropActions() const
|
||||
Qt::ItemFlags FlmHQReportModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
|
||||
|
||||
if (!index.isValid())
|
||||
return defaultFlags;
|
||||
|
||||
return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDragActions() const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
Qt::DropActions FlmHQReportModel::supportedDropActions() const { return Qt::CopyAction; }
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDragActions() const { return Qt::CopyAction; }
|
||||
|
||||
QStringList FlmHQReportModel::mimeTypes() const
|
||||
{
|
||||
QStringList types;
|
||||
types << mimeType;
|
||||
return types;
|
||||
QStringList types;
|
||||
types << mimeType;
|
||||
return types;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::removeRows(int row, int count, const QModelIndex& parent)
|
||||
bool FlmHQReportModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
if (parent.isValid() || row < 0 || row >= m_data.size() || (row + count) > m_data.size())
|
||||
return false;
|
||||
if (parent.isValid() || row < 0 || row >= m_data.size() || (row + count) > m_data.size())
|
||||
return false;
|
||||
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_data.removeAt(row);
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_data.removeAt(row);
|
||||
|
||||
endRemoveRows();
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QMimeData* FlmHQReportModel::mimeData(const QList<QModelIndex>& indexes) const
|
||||
QMimeData *FlmHQReportModel::mimeData(const QList<QModelIndex> &indexes) const
|
||||
{
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
|
||||
for (const QModelIndex& index : indexes)
|
||||
for (const QModelIndex &index : indexes)
|
||||
{
|
||||
if (index.isValid())
|
||||
{
|
||||
if (index.isValid())
|
||||
HQData md;
|
||||
QString visibleName = index.data(Qt::DisplayRole).toString();
|
||||
|
||||
if (index.internalId() != 0)
|
||||
{
|
||||
int parentRow = static_cast<int>(index.internalId()) - 1;
|
||||
if (parentRow >= 0 && parentRow < m_data.size())
|
||||
{
|
||||
HQData md = m_data.at(index.row());
|
||||
stream << md.id << md.name;
|
||||
const HQData &parentData = m_data.at(parentRow);
|
||||
const auto &children = m_movedData.value(parentData.id);
|
||||
if (index.row() >= 0 && index.row() < children.size())
|
||||
{
|
||||
md = children.at(index.row());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index.row() >= 0 && index.row() < m_data.size())
|
||||
{
|
||||
const HQData &originalData = m_data.at(index.row());
|
||||
md.id = originalData.id;
|
||||
md.name = visibleName;
|
||||
md.properties = originalData.properties;
|
||||
}
|
||||
}
|
||||
md.name = visibleName;
|
||||
stream << md.id << md.name;
|
||||
}
|
||||
mimeData->setData(mimeType, encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
mimeData->setData(mimeType, encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
bool FlmHQReportModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction)
|
||||
return false;
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction)
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData md;
|
||||
if (parent.isValid() && parent.row() >= 0 && parent.row() < m_data.size())
|
||||
DEBUG_LOG(m_logger) << "DROP ZIEL (Parent im Tree): " << m_data.at(parent.row()).name;
|
||||
|
||||
stream >> md.id >> md.name;
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData md;
|
||||
stream >> md.id >> md.name;
|
||||
|
||||
addMovedData(parent.row(), md);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "DROP INHALT aus Stream -> ID: " << md.id << ", NAME: " << md.name;
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
addMovedData(parent, md);
|
||||
}
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction || parent.row() < 0 || parent.row() >= m_data.size())
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
const HQData ¤tParentData = m_data.at(parent.row());
|
||||
|
||||
if (!m_movedData.contains(currentParentData.id))
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
const QList<HQData> &existingChildren = m_movedData.value(currentParentData.id);
|
||||
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction || parent.row() < 0 ||
|
||||
parent.row() >= m_data.size())
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData incomingData;
|
||||
stream >> incomingData.id >> incomingData.name;
|
||||
|
||||
for (const HQData &child : existingChildren)
|
||||
{
|
||||
if (child.id == incomingData.id)
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
const HQData& currentData = m_data.at(parent.row());
|
||||
|
||||
if (!m_movedData.contains(currentData.id))
|
||||
return true;
|
||||
|
||||
const QList<HQData>& movedDataListForCurrentData = m_movedData.value(currentData.id);
|
||||
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData movedData;
|
||||
|
||||
stream >> movedData.id >> movedData.name;
|
||||
|
||||
if (movedDataListForCurrentData.contains(movedData))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addHQReportData(const HQData& data)
|
||||
QModelIndex FlmHQReportModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_data.append(data);
|
||||
endInsertRows();
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
if (!parent.isValid())
|
||||
{
|
||||
if (row >= 0 && row < m_data.size())
|
||||
return createIndex(row, column, quintptr(0)); // internalId = 0 für Parents
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parent.internalId() == 0)
|
||||
{
|
||||
int parentRow = parent.row();
|
||||
return createIndex(row, column, quintptr(parentRow + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
void FlmHQReportModel::addHQReportData(const HQData &data)
|
||||
{
|
||||
QList<HQData> childProperties;
|
||||
HQData copyData = data;
|
||||
|
||||
if (!data.properties.empty())
|
||||
{
|
||||
QJsonDocument doc = QJsonDocument::fromJson(QByteArray::fromStdString(data.properties));
|
||||
// Hole Einträge aus den properties
|
||||
if (doc.isArray())
|
||||
{
|
||||
QJsonArray jsonArray = doc.array();
|
||||
for (const QJsonValue &value : jsonArray)
|
||||
{
|
||||
QString prop = value.toString().trimmed();
|
||||
if (!prop.isEmpty() && prop != data.name)
|
||||
{
|
||||
HQData childData;
|
||||
childData.id = data.id;
|
||||
childData.name = prop;
|
||||
copyData.children.insert(childData.id);
|
||||
childProperties.append(childData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QString prop = QString::fromStdString(data.properties).trimmed();
|
||||
if (!prop.isEmpty() && prop != data.name)
|
||||
{
|
||||
HQData childData;
|
||||
childData.id = data.id;
|
||||
childData.name = prop;
|
||||
childProperties.append(childData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), m_data.count(), m_data.count());
|
||||
m_data.append(copyData);
|
||||
|
||||
if (!childProperties.isEmpty())
|
||||
m_movedData.insert(data.id, childProperties);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void FlmHQReportModel::deleteHQReportData(const HQData& data)
|
||||
void FlmHQReportModel::deleteHQReportData(const HQData &data)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
endInsertRows();
|
||||
const int zeile = m_data.indexOf(data);
|
||||
|
||||
const int zeile = m_data.indexOf(data);
|
||||
|
||||
if (zeile == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
beginRemoveRows(QModelIndex(), zeile, zeile);
|
||||
m_data.removeAt(zeile);
|
||||
endRemoveRows();
|
||||
if (zeile == -1)
|
||||
return;
|
||||
|
||||
beginRemoveRows(QModelIndex(), zeile, zeile);
|
||||
m_data.removeAt(zeile);
|
||||
endRemoveRows();
|
||||
return;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::onFileContentChanged(const FileContent& content, DataModification modType)
|
||||
void FlmHQReportModel::onFileContentChanged(const FileContent &content, DataModification modType)
|
||||
{
|
||||
HQData data;
|
||||
data.id = content.id();
|
||||
data.name = QString::fromStdString(content.name());
|
||||
if (content.folderId() != m_contentFolderId || content.fileType() != m_fileType)
|
||||
return;
|
||||
if (content.folderId() != m_contentFolderId || content.fileType() != m_fileType)
|
||||
return;
|
||||
|
||||
if (content.fileStatus() == FileStatus::Deleted)
|
||||
{
|
||||
if (modType == DataModification::eModified || modType == DataModification::eAdded)
|
||||
{
|
||||
deleteHQReportData(data);
|
||||
}
|
||||
}
|
||||
else if (modType == DataModification::eAdded)
|
||||
{
|
||||
addHQReportData(data);
|
||||
}
|
||||
HQData data;
|
||||
data.id = content.id();
|
||||
data.name = QString::fromStdString(content.name());
|
||||
data.properties = content.properties();
|
||||
|
||||
DEBUG_LOG(m_logger) << "FlmHQReportModel::onFileContentChanged " << "properties " << data.properties << " " << " Name: " << data.name;
|
||||
|
||||
if (content.fileStatus() == FileStatus::Deleted)
|
||||
{
|
||||
if (modType == DataModification::eModified || modType == DataModification::eAdded)
|
||||
deleteHQReportData(data);
|
||||
}
|
||||
else if (modType == DataModification::eAdded)
|
||||
{
|
||||
addHQReportData(data);
|
||||
}
|
||||
}
|
||||
|
||||
int FlmHQReportModel::folderId() const
|
||||
{
|
||||
return m_contentFolderId;
|
||||
}
|
||||
int FlmHQReportModel::folderId() const { return m_contentFolderId; }
|
||||
|
||||
QMap<int, QList<int>> FlmHQReportModel::getHQToPlan() const
|
||||
QMap<int, QSet<int>> FlmHQReportModel::getChangedPlans() const
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlan;
|
||||
QMap<int, QSet<int>> hqToPlan;
|
||||
|
||||
for (auto it = m_movedData.constBegin(); it != m_movedData.constEnd(); ++it)
|
||||
for (auto it = m_movedData.constBegin(); it != m_movedData.constEnd(); ++it)
|
||||
{
|
||||
const QList<HQData> &movedData = it.value();
|
||||
QSet<int> hqIds;
|
||||
|
||||
hqIds.reserve(movedData.size());
|
||||
|
||||
for (const HQData ¤tData : movedData)
|
||||
hqIds.insert(currentData.id);
|
||||
|
||||
HQData myPlan;
|
||||
for (const auto &plan : m_data)
|
||||
{
|
||||
const QList<HQData>& movedData = it.value();
|
||||
QList<int> hqIds;
|
||||
|
||||
hqIds.reserve(movedData.size());
|
||||
|
||||
for (const HQData& currentData : movedData)
|
||||
hqIds.append(currentData.id);
|
||||
|
||||
hqToPlan.insert(it.key(), hqIds);
|
||||
if (plan.id == it.key())
|
||||
{
|
||||
myPlan = plan;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (myPlan.children != hqIds)
|
||||
hqToPlan.insert(it.key(), hqIds);
|
||||
}
|
||||
|
||||
return hqToPlan;
|
||||
return hqToPlan;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::clearMovedData()
|
||||
{
|
||||
m_movedData.clear();
|
||||
if (m_movedData.isEmpty())
|
||||
return;
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, 0));
|
||||
beginResetModel();
|
||||
m_movedData.clear();
|
||||
endResetModel();
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
}
|
||||
|
||||
QString FlmHQReportModel::createText(int dataIndex) const
|
||||
void FlmHQReportModel::addMovedData(const QModelIndex &parentIndex, const HQData &movedData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex;
|
||||
int dataIndex = parentIndex.row();
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return QString();
|
||||
const HQData &data = m_data.at(dataIndex);
|
||||
|
||||
const HQData& data = m_data.at(dataIndex);
|
||||
if (data.id == movedData.id)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DROP ABGEWIESEN: PlanId entspricht der ReportId (" << data.id << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_movedData.contains(data.id))
|
||||
if (!m_movedData.contains(data.id))
|
||||
m_movedData.insert(data.id, QList<HQData>());
|
||||
|
||||
const QList<HQData> &existingChildren = m_movedData[data.id];
|
||||
for (const HQData &child : existingChildren)
|
||||
{
|
||||
if (child.id == movedData.id || child.name.trimmed() == movedData.name.trimmed())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No moved data for " << data.name;
|
||||
return data.name;
|
||||
DEBUG_LOG(m_logger) << "DROP ABGEWIESEN: Element '" << movedData.name << "' ist bereits vorhanden.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const QList<HQData>& movedData = m_movedData.value(data.id);
|
||||
QStringList movedDataNames;
|
||||
int newRow = m_movedData[data.id].size();
|
||||
|
||||
movedDataNames.reserve(movedData.size());
|
||||
|
||||
for (const HQData& currentMovedData : movedData)
|
||||
movedDataNames.append(currentMovedData.name);
|
||||
|
||||
return QString(QStringLiteral("%1 (%2)")).arg(data.name).arg(movedDataNames.join(QLatin1Char(',')));
|
||||
beginInsertRows(parentIndex, newRow, newRow);
|
||||
m_movedData[data.id].append(movedData);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addMovedData(int dataIndex, const HQData& movedData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex << ", movedData.id: " << movedData.id
|
||||
<< ", movedData.name: " << movedData.name;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return;
|
||||
|
||||
const HQData& data = m_data.at(dataIndex);
|
||||
|
||||
if (!m_movedData.contains(data.id))
|
||||
m_movedData.insert(data.id, QList<HQData>());
|
||||
|
||||
m_movedData[data.id].append(movedData);
|
||||
}
|
||||
|
||||
} // namespace FileManagement
|
||||
+49
-48
@@ -1,21 +1,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FileManagement/flm_enums.hpp>
|
||||
#include <Lts/Services/FileManagement/logger.h>
|
||||
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
|
||||
#include <QtCore/QAbstractListModel>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QtCore/QList>
|
||||
#include <QAbstractListModel>
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include <QMimeData>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <FileManagement/flm_enums.hpp>
|
||||
#include <FileManagement/logger.h>
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class FileContent;
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
@@ -31,64 +32,64 @@ namespace FileManagement
|
||||
{
|
||||
struct HQData
|
||||
{
|
||||
int id;
|
||||
QString name;
|
||||
int id{0};
|
||||
QString name;
|
||||
std::string properties;
|
||||
QSet<int> children;
|
||||
|
||||
bool operator==(const HQData& other) const
|
||||
{
|
||||
return id == other.id && name == other.name;
|
||||
}
|
||||
bool operator==(const HQData &other) const { return id == other.id && name == other.name; }
|
||||
};
|
||||
|
||||
class FlmHQReportModel : public QAbstractListModel
|
||||
class FlmHQReportModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FlmHQReportModel(QObject* parent = nullptr);
|
||||
explicit FlmHQReportModel(QObject *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession* session, int contentFolderId, const FileManagement::FileType& fileType);
|
||||
bool init(LtsSession::LtsSession *session, int contentFolderId, const FileManagement::FileType &fileType);
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
QMimeData* mimeData(const QList<QModelIndex>& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
QMimeData *mimeData(const QList<QModelIndex> &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override { return 1; }
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
|
||||
void addHQReportData(const HQData& data);
|
||||
void deleteHQReportData(const HQData& data);
|
||||
void addHQReportData(const HQData &data);
|
||||
void deleteHQReportData(const HQData &data);
|
||||
|
||||
int folderId() const;
|
||||
int folderId() const;
|
||||
|
||||
QMap<int, QList<int>> getHQToPlan() const;
|
||||
void clearMovedData();
|
||||
QMap<int, QSet<int>> getChangedPlans() const;
|
||||
void clearMovedData();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QString createText(int dataIndex) const;
|
||||
void addMovedData(int dataIndex, const HQData& movedData);
|
||||
void addMovedData(const QModelIndex &parentIndex, const HQData &movedData);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFileContentChanged(const FileContent& content, DataModification modType);
|
||||
void onFileContentChanged(const FileContent &content, DataModification modType);
|
||||
|
||||
Q_SIGNALS:
|
||||
void dataAddedOrRemoved();
|
||||
void dataAddedOrRemoved();
|
||||
|
||||
private:
|
||||
QList<HQData> m_data;
|
||||
QMap<int, QList<HQData>> m_movedData;
|
||||
const QString mimeType = QStringLiteral("application/x-custom-hqdata");
|
||||
int m_contentFolderId{-1};
|
||||
FileManagement::FileType m_fileType;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
QList<HQData> m_data;
|
||||
QMap<int, QList<HQData>> m_movedData;
|
||||
const QString mimeType = QStringLiteral("application/x-custom-hqdata");
|
||||
int m_contentFolderId{-1};
|
||||
FileManagement::FileType m_fileType;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace FileManagement
|
||||
|
||||
|
||||
+27
-22
@@ -1,29 +1,35 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for MarkerManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <MarkerManagement/logger.h>
|
||||
#include <MarkerManagement/mrk_ftc.h>
|
||||
#include <MarkerManagement/mrk_dtc.h>
|
||||
#include <Lts/Services/FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_dtc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <Core/core_dtc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <MarkerManagement/mrk_data_plugin_interface.h>
|
||||
#include <MarkerManagement/mrk_gui_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <FilterManagement/flt_data_plugin_interface.h>
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/MarkerManagement/mrk_data_plugin_interface.h>
|
||||
#include <Plugins/MarkerManagement/mrk_gui_plugin_interface.h>
|
||||
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_data_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <Plugins/FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
@@ -64,7 +70,7 @@ public:
|
||||
NGL::INGLLogger &logger);
|
||||
~TopicReplayInterface();
|
||||
|
||||
|
||||
// Script Playback Controls:
|
||||
bool playbackInit(const QJsonObject &attributes) override;
|
||||
bool playbackStart(int secondsOffset) override;
|
||||
bool playbackPause() override;
|
||||
@@ -73,10 +79,9 @@ public:
|
||||
QVector<TopicEditorBase::TopicData> additionalTrackEntries(const QJsonObject &attributes) const override;
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<SituationReplay::ForeignGuiInterface> m_srpIfc;
|
||||
Snapshot m_snapshot;
|
||||
NGL::INGLLogger &m_logger;
|
||||
QByteArray m_originalMapSettings;
|
||||
MarkerManagement::ForeignGuiInterface *m_parentIfc;
|
||||
std::shared_ptr<MarkerManagement::Interface::Dtc> m_mrkDtc;
|
||||
@@ -103,10 +108,10 @@ public:
|
||||
MarkerManagement::SnapshotDialogModel *createSnapshotModel() override final;
|
||||
QSortFilterProxyModel *createSnapshotFilterProxyModel();
|
||||
|
||||
|
||||
// Script Editor Topic Editor:
|
||||
TopicEditorBase::TopicEditor *createTopicEditor(const TopicEditorBase::TopicData &data) override final;
|
||||
|
||||
|
||||
// Script Player:
|
||||
TopicReplay::Interface *createInterface(TopicEditorBase::TopicType) override final;
|
||||
|
||||
void showMarker(int markerId) override final;
|
||||
@@ -161,4 +166,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace MarkerManagement
|
||||
@@ -91,7 +91,7 @@ ADD_INTERFACE_LIBRARY(PpmDataPluginInterface
|
||||
svcPpmCommon
|
||||
)
|
||||
|
||||
IF(QT_VERSION VERSION_GREATER_EQUAL 6.0.0)
|
||||
IF(Qt5WebEngineWidgets_VERSION VERSION_GREATER 5.7.9)
|
||||
#
|
||||
# Combat Power Gui Plugin Interface
|
||||
#
|
||||
@@ -101,3 +101,11 @@ ADD_INTERFACE_LIBRARY(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# GuiElementInterface
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
GuiElementInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/participant_info_gui_element_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
Qt5::Core LtsWidgets
|
||||
)
|
||||
+28
-36
@@ -5,14 +5,6 @@
|
||||
# Created by Mike Wille, SLSE, 2016-05-05
|
||||
#
|
||||
|
||||
# Make ${Qt6_Widgets} optional
|
||||
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
|
||||
set(Qt6_Widgets ${Qt6_Widgets})
|
||||
else()
|
||||
set(Qt6_Widgets "")
|
||||
endif()
|
||||
|
||||
|
||||
SET(participant_info_gui_SRCS
|
||||
participant_info_gui_plugin.cpp
|
||||
participant_info_gui_plugin.h
|
||||
@@ -83,34 +75,34 @@ NGL_WRAP_UI(participant_info_gui_SRCS
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS PpmParticipantInfoGuiPlugin MODULE ${participant_info_gui_SRCS})
|
||||
if(QT6_GUI_AVAILABLE)
|
||||
NGL_TARGET_LINK_LIBRARIES(PpmParticipantInfoGuiPlugin
|
||||
NGLLogger
|
||||
LtsNotification
|
||||
ngltools
|
||||
nglwidgets
|
||||
LtsCoordTrans
|
||||
FltAesGuiPluginInterface
|
||||
PpmCommon
|
||||
PpmParticipantInfoGuiPluginInterface
|
||||
PpmDataPluginInterface
|
||||
PdmDataPluginInterface
|
||||
svcTgtClient
|
||||
PdmGuiPluginInterface
|
||||
${Qt6_Widgets}
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsSettings
|
||||
SituationMapGuiPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
AsbDataPluginInterface
|
||||
AesDataPluginInterface
|
||||
LtsDataView
|
||||
IsmDataPluginInterface
|
||||
)
|
||||
endif()
|
||||
NGL_TARGET_LINK_LIBRARIES(PpmParticipantInfoGuiPlugin
|
||||
NGLLogger
|
||||
LtsNotification
|
||||
ngltools
|
||||
nglwidgets
|
||||
LtsCoordTrans
|
||||
FltAesGuiPluginInterface
|
||||
PpmCommon
|
||||
PpmParticipantInfoGuiPluginInterface
|
||||
PpmDataPluginInterface
|
||||
PdmDataPluginInterface
|
||||
svcTgtClient
|
||||
PdmGuiPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsSettings
|
||||
SituationMapGuiPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
AsbDataPluginInterface
|
||||
AesDataPluginInterface
|
||||
LtsDataView
|
||||
IsmDataPluginInterface
|
||||
LtsPluginLoader
|
||||
GuiElementInterface
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(PpmParticipantInfoGuiPlugin)
|
||||
|
||||
|
||||
+189
-126
@@ -1,5 +1,11 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantInfoDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-01
|
||||
*/
|
||||
|
||||
#include "participant_info_dialog.h"
|
||||
#include "ui_participant_info_dialog.h"
|
||||
@@ -25,18 +31,20 @@
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsCore/outdated_position.h>
|
||||
#include <LtsUtilsCore/outdated_position.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <ParticipantManagement/participant_info_gui_element_interface.h>
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QJsonDocument>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtGui/QTransform>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QToolButton>
|
||||
#include <QTransform>
|
||||
#include <QMenu>
|
||||
#include <QColor>
|
||||
#include <QLabel>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -60,6 +68,7 @@ ParticipantInfoDialog::ParticipantInfoDialog(int participantId, const QString &m
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ParticipantInfoDialog)
|
||||
, m_isTarget(false)
|
||||
, m_logger(getLogger("ParticipantInfoDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_oldSpacerSize.first = m_ui->vsBottom->maximumSize().width();
|
||||
@@ -88,7 +97,7 @@ ParticipantInfoDialog::ParticipantInfoDialog(int participantId, const QString &m
|
||||
|
||||
connect(m_ui->pbUnlockUas, &QToolButton::clicked, this, &ParticipantInfoDialog::onUnlockUAS);
|
||||
|
||||
|
||||
//hide first:
|
||||
m_ui->twGear->hide();
|
||||
m_ui->lblInfo->hide();
|
||||
m_ui->lblInfoText->hide();
|
||||
@@ -164,7 +173,7 @@ bool ParticipantInfoDialog::init(LtsSession::LtsSession *session,
|
||||
connect(m_dtc.get(), &Interface::Dtc::partyChanged,
|
||||
this, &ParticipantInfoDialog::updateCurrentIcon, Qt::UniqueConnection);
|
||||
|
||||
|
||||
// to handle race condition between DynamicParticipantData and DusMineState:
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::dusMineStateChanged,
|
||||
this, &ParticipantInfoDialog::updateCurrentIcon, Qt::UniqueConnection);
|
||||
|
||||
@@ -191,19 +200,20 @@ bool ParticipantInfoDialog::init(LtsSession::LtsSession *session,
|
||||
return setUiValues();
|
||||
}
|
||||
|
||||
|
||||
// private
|
||||
bool ParticipantInfoDialog::setUiValues()
|
||||
{
|
||||
|
||||
|
||||
/* NOTE: This is a hide-all-you-don't-need concept. Everything is shown,
|
||||
* so everything you don't want to show up must be hidden.
|
||||
* Plus, once hidden, widgets must not be shown again. */
|
||||
|
||||
DEBUG_LOG(m_logger) << "------------------setUiValues-----------------";
|
||||
|
||||
if (!m_dtc || !m_ftc || m_participant.id() < 0)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
// m_showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
// QStringLiteral("HasPvSan"));
|
||||
|
||||
m_ui->pbTarget->setVisible(false);
|
||||
|
||||
@@ -211,18 +221,18 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_ui->pbSetInjury->setVisible(false);
|
||||
m_ui->pbSetSanitation->setVisible(false);
|
||||
|
||||
|
||||
//hide findOnMap if no interface available
|
||||
m_ui->pbFindOnMap->setVisible(m_sitMapGuiIfc != nullptr);
|
||||
m_ui->pbMovementTrack->setVisible(m_sitMapGuiIfc != nullptr);
|
||||
m_ui->tbNbc->setVisible(false);
|
||||
m_ui->tbNbc->setVisible(false); //show only if visible
|
||||
|
||||
|
||||
// m_participant.id() was given within ctor
|
||||
const Participant participantData = m_dtc->participant(m_participant.id());
|
||||
const Type type = m_dtc->type(participantData.typeId());
|
||||
m_typeClass = type.typeClass();
|
||||
|
||||
|
||||
|
||||
// uas stuff
|
||||
const bool isUas = m_dtc->isTypeUas(participantData.typeId());
|
||||
DEBUG_LOG(m_logger) << "------------------UAS-----------------"
|
||||
<< " isTypeUas" << isUas
|
||||
@@ -241,23 +251,23 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_ftc->enableModifyUasState();
|
||||
}
|
||||
|
||||
|
||||
// participant might not even be linked to a uas (which isn't even obvious for the operator), so in that case default texts would be shown
|
||||
m_ui->lblBatteryStatus->setText(QStringLiteral("-"));
|
||||
m_ui->lblOperatingMode->setText(QStringLiteral("-"));
|
||||
|
||||
onUasChanged(uas);
|
||||
|
||||
|
||||
// hide all widgets (and labels) that are not available for uas:
|
||||
m_ui->pbBite->setVisible(false);
|
||||
m_ui->pbMessage->setVisible(false);
|
||||
|
||||
|
||||
// these are not supported yet, therefore hidden:
|
||||
m_ui->lblBatteryStatus->setVisible(false);
|
||||
m_ui->lbBatteryStatus->setVisible(false);
|
||||
}
|
||||
else
|
||||
else // not a uas
|
||||
{
|
||||
|
||||
// hide all uas specific widgets (and labels):
|
||||
m_ui->lblBatteryStatus->setVisible(false);
|
||||
m_ui->lbBatteryStatus->setVisible(false);
|
||||
m_ui->lblOperatingMode->setVisible(false);
|
||||
@@ -267,9 +277,9 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
|
||||
|
||||
if (m_typeClass != TypeClass::Human)
|
||||
m_ui->lbKind->setText(tr("Damage Type:"));
|
||||
m_ui->lbKind->setText(tr("Damage Type:")); // translates "Beschaedigungs" for non-Humans.
|
||||
else
|
||||
m_ui->lbKind->setText(tr("Kind:"));
|
||||
m_ui->lbKind->setText(tr("Kind:")); // translates "Verwundung" for Humans.
|
||||
|
||||
bool bUpdateDynamicParticipantData = true;
|
||||
switch (m_typeClass.underlying())
|
||||
@@ -301,7 +311,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
const int32_t participantId = m_participant.id();
|
||||
|
||||
m_ui->pbMovementTrack->setChecked(m_sitMapGuiIfc->isMovementTrackEnabled(participantId));
|
||||
|
||||
// set MovementTrackCallback:
|
||||
std::function<void(const QVector<int32_t> &activeSimIds)> onMovementTrackChangedFunc = [this, participantId](const QVector<int32_t> &activeSimIds)
|
||||
{
|
||||
bool checkedNew = activeSimIds.contains(participantId);
|
||||
@@ -326,7 +336,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_symbolAppearanceSettings->addChangedCallback(this);
|
||||
}
|
||||
|
||||
|
||||
//a unit never has a history
|
||||
m_ui->pbHistory->hide();
|
||||
m_ui->lblEquipNr->hide();
|
||||
m_ui->lbEquipNr->hide();
|
||||
@@ -348,7 +358,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
}
|
||||
case TypeClass::Vessel:
|
||||
case TypeClass::Unknown:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << m_typeClass;
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << m_typeClass;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -376,7 +386,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_typeClass != TypeClass::Unit &&
|
||||
m_typeClass != TypeClass::SupportUnit);
|
||||
|
||||
|
||||
//other connects
|
||||
connect(m_dtc.get(), &Interface::Dtc::typeChanged,
|
||||
this, &ParticipantInfoDialog::onTypeChanged, Qt::UniqueConnection);
|
||||
connect(m_dtc.get(), &Interface::Dtc::dynamicParticipantDataChanged,
|
||||
@@ -384,9 +394,9 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
connect(m_session, &LtsSession::LtsSession::partitionTimeChanged,
|
||||
this, &ParticipantInfoDialog::onPartitionTimeChanged, Qt::UniqueConnection);
|
||||
|
||||
if (m_session->app() == LtsAppDescriptor::App::OC)
|
||||
if (m_session->app() == LtsAppDescriptor::App::OC) // is the plugin loaded by the OC-App?
|
||||
{
|
||||
|
||||
// hide several unused Buttons
|
||||
m_ui->pbBite->hide();
|
||||
m_ui->pbHistory->hide();
|
||||
m_ui->pbMessage->hide();
|
||||
@@ -395,7 +405,7 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_ui->pbSetSanitation->hide();
|
||||
}
|
||||
|
||||
if (m_session->isReplayPartition())
|
||||
if (m_session->isReplayPartition()) // is replay?
|
||||
{
|
||||
m_ui->pbSetStatus->hide();
|
||||
m_ui->pbMessage->hide();
|
||||
@@ -421,8 +431,8 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
m_isTarget = (eqType.wmsTypeClass() == WmsTypeClass::TargetHuman ||
|
||||
eqType.wmsTypeClass() == WmsTypeClass::TargetVehicle);
|
||||
|
||||
|
||||
|
||||
// m_isTarget = 1;
|
||||
// initTargetConfigL400(/*m_isTarget*/ true);
|
||||
|
||||
initTargetConfig(m_isTarget);
|
||||
m_ui->twGear->setColumnHidden(0, m_isTarget);
|
||||
@@ -460,20 +470,50 @@ bool ParticipantInfoDialog::setUiValues()
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Unit"));
|
||||
break;
|
||||
case TypeClass::Unknown:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << m_typeClass;
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << m_typeClass;
|
||||
}
|
||||
|
||||
#if LTS_DEBUG
|
||||
//-- start Test Gui Elment plugin
|
||||
|
||||
auto cb = [this](const LtsPluginManager::PluginInstance &pi) { return loadGuiElementPLugin(pi);};
|
||||
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::GUI_ELEMENT,
|
||||
cb,
|
||||
QStringList());
|
||||
|
||||
//-- end Test Gui Element plugin
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParticipantInfoDialog::loadGuiElementPLugin(const LtsPluginManager::PluginInstance &pi)
|
||||
{
|
||||
WARNING_LOG(m_logger)<<">>>> GUI Element pluginName: "<<pi.fileName;
|
||||
GuiElementInterface *guiElement = qobject_cast<GuiElementInterface *>(pi.plugin);
|
||||
|
||||
if (guiElement->pluginName() == QStringLiteral("KeyValueGuiElement_XY"))
|
||||
{
|
||||
if (!guiElement->init(m_session, m_participant.id()))
|
||||
return false;
|
||||
|
||||
m_ui->gridLayout_2->addWidget(guiElement->createGuiElement(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
//SLOTS
|
||||
|
||||
void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicParticipantData &data, DataModification modType)
|
||||
{
|
||||
if (data.participantId() != m_participant.id() && data.participantId() != 0)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// Do not continue on modType == DataModification::eRemove
|
||||
// otherwise for example the icon would look bad (clover with black on black...)
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
if (m_ui->lblIcon != nullptr)
|
||||
@@ -484,7 +524,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
if (m_ui->lblIcon != nullptr)
|
||||
m_ui->lblIcon->setEnabled(true);
|
||||
|
||||
|
||||
//Current State
|
||||
qWarning() << "stateHistory count" << data.stateHistory().size();
|
||||
bool contaminationListIsEmpty = true;
|
||||
if (!data.stateHistory().empty())
|
||||
@@ -493,9 +533,9 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
|
||||
|
||||
//#define FAKE_HISTORY
|
||||
#ifdef FAKE_HISTORY
|
||||
|
||||
// fake history, where all sis have the same stateTime
|
||||
std::vector<ParticipantManagement::StateInformation> history;
|
||||
|
||||
if (!data.stateHistory().empty())
|
||||
@@ -513,9 +553,9 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
const auto &history = data.stateHistory();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
StateInformation lastState = m_dtc->youngestStateInformation(history );;
|
||||
//LasState is the last "real" state, that has a VBG <=8 (Castastrophic)
|
||||
//It's not the last state received, as there can be other state changes like Sanitation, or NearMiss
|
||||
StateInformation lastState = m_dtc->youngestStateInformation(history/*, true*/ /* debug */);;
|
||||
StateInformation youngestState;
|
||||
youngestState.stateTime(0);
|
||||
for (const StateInformation &si : history)
|
||||
@@ -529,14 +569,14 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
// QStringLiteral("HasPvSan"));
|
||||
m_ui->lblStatus->setText(ProjectDataManagement::toString(lastState.vulnerabilityState(), vc));
|
||||
|
||||
//vitality
|
||||
DEBUG_LOG(m_logger)<<" >>> last state: "<<lastState.vitality() << "last kind: " <<lastState.vulnerabilityKindId();
|
||||
m_ui->lblVitality->setText(QString::number(lastState.vitality()) + QStringLiteral("%"));
|
||||
|
||||
|
||||
// Set Contamination
|
||||
const int NCONTAMINATION = 0x4000;
|
||||
const int BCONTAMINATION = 0x8000;
|
||||
const int CCONTAMINATION = 0x10000;
|
||||
@@ -582,24 +622,24 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
}
|
||||
|
||||
m_ui->lblContamination->setText(contaminationList.join(QStringLiteral("+")));
|
||||
|
||||
|
||||
if (lastState.vulnerabilityKindId() == 459286 && !((lastState.vulnerabilityBits() >> 7) & 1))
|
||||
// VBA
|
||||
//AG 40 HACK!
|
||||
if (lastState.vulnerabilityKindId() == 459286 && !((lastState.vulnerabilityBits() >> 7) & 1)) // VBG7 NOT set in history bits, but kind id still implying that VBG7 is still active
|
||||
m_ui->lblKind->setText(QLatin1String("-"));
|
||||
else
|
||||
m_ui->lblKind->setText(m_pdmDtc->trVulnerabilityKindName(lastState.vulnerabilityKindId(), vc));
|
||||
if (m_showPvSan && vc == ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries )
|
||||
{
|
||||
if (lastState.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CombatReady )
|
||||
|
||||
if (lastState.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CombatReady ) //Maybe there is some side effect to this like
|
||||
//if (data.stateHistory().size() == 1 && lastState.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::CombatReady)
|
||||
{
|
||||
QPalette pal = QApplication::palette(m_ui->lbKind);
|
||||
m_ui->lblKind->setPalette(pal);
|
||||
|
||||
// m_ui->lblVitality->setText(QString::number(100) + QStringLiteral("%")); fixed in PPM-Service
|
||||
}
|
||||
else
|
||||
{
|
||||
setSanitationLabelColor(data.stateHistory().at(data.stateHistory().size()-1).sanitationResult());
|
||||
setSanitationLabelColor(/*m_dtc->proceduresDone(data.stateHistory())*/data.stateHistory().at(data.stateHistory().size()-1).sanitationResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,7 +658,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
DEBUG_LOG(m_logger)<< "setBackgroundColor ="<< data.manipulation().size();
|
||||
setBackgroundColor(m_ui->lblEquipNr, Qt::red, data.manipulation().size());
|
||||
|
||||
|
||||
// Special Sensor State
|
||||
if (!data.specialSensorDataState())
|
||||
{
|
||||
m_ui->stackSpecialSensor->hide();
|
||||
@@ -628,8 +668,13 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
{
|
||||
if (m_typeClass == TypeClass_def::Aircraft)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
CTC_Apache_Sensor_DiffCorrections = 0x01, // Has GPS Differential Corrections
|
||||
CTC_Apache_Sensor_RadarJammer = 0x02, // APR 39
|
||||
CTC_Apache_Sensor_IRJammer = 0x04, // ALQ 144
|
||||
CTC_Apache_Sensor_RadarDetector = 0x08, // ALQ 136
|
||||
CTC_Apache_Sensor_LaserSensor = 0x10 // AVR2A
|
||||
*/
|
||||
|
||||
m_ui->stackSpecialSensor->setCurrentWidget(m_ui->stackPageAircraft);
|
||||
m_ui->ledRadarJammer->setStatus(data.specialSensorDataState() & 0x02);
|
||||
@@ -646,11 +691,25 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
m_ui->stackSpecialSensor->show();
|
||||
}
|
||||
|
||||
|
||||
// Gear Tabelle für Steilfeuer allgemein verstecken //[GUEZE-2871]
|
||||
bool showForArtillery = true;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#ifndef LTS_DEBUG
|
||||
const Participant participantData = m_dtc->participant(m_participant.id());
|
||||
const Type type = m_dtc->type(participantData.typeId());
|
||||
const QString jsData = QString::fromStdString(type.properties()).trimmed();
|
||||
DEBUG_LOG(m_logger)<<">>> >>> properties: "<<jsData<<" /// typeId: "<<type.id();
|
||||
if(!jsData.isEmpty())
|
||||
{
|
||||
const QJsonObject &typObj = QJsonDocument::fromJson(QByteArray::fromStdString(jsData.toStdString())).object();
|
||||
if (!typObj.isEmpty() && typObj[QStringLiteral("isArtillery")].toBool(false))
|
||||
{
|
||||
showForArtillery = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
//Gear
|
||||
if (data.gear().size() == 0 )
|
||||
{
|
||||
m_gearList.clear();
|
||||
@@ -665,7 +724,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
{
|
||||
m_gearList = data.gear();
|
||||
std::vector<GearInformation> tmpGearList = m_gearList;
|
||||
std::sort(tmpGearList.begin(), tmpGearList.end(), &compareGear);
|
||||
std::sort(tmpGearList.begin(), tmpGearList.end(), &compareGear); //sort
|
||||
|
||||
m_ui->twGear->show();
|
||||
m_ui->pbGearRanges->show();
|
||||
@@ -682,7 +741,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
for (const GearInformation &gearInfo : tmpGearList)
|
||||
{
|
||||
QTableWidgetItem *item = nullptr;
|
||||
if (gearInfo.chargeTypeId() == 0)
|
||||
if (gearInfo.chargeTypeId() == 0) //chargTypeId 0 is near miss code
|
||||
{
|
||||
rowCount--;
|
||||
continue;
|
||||
@@ -693,8 +752,8 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
item = new QTableWidgetItem(tr("Unknown gear id %1").arg(gearTypeId & ~unknownTasId));
|
||||
else if (gearTypeId == 0)
|
||||
{
|
||||
|
||||
|
||||
// Hack for old systems which neither send gearTasCode/gearType nor gearSerialNumber/gearId
|
||||
// 1 = Wanne, 2 = Turm
|
||||
switch (gearInfo.gearId())
|
||||
{
|
||||
case 1:
|
||||
@@ -717,27 +776,27 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
{
|
||||
item->setIcon(QIcon(QLatin1String("icon:service.svg")));
|
||||
}
|
||||
|
||||
// If it's the same gearId, don't set the item, but make a row span to the one(s) before.
|
||||
int rowStart = row - 1;
|
||||
while (rowStart >= 0)
|
||||
{
|
||||
QTableWidgetItem *oldItem = m_ui->twGear->item(rowStart, 0);
|
||||
if (oldItem == nullptr)
|
||||
QTableWidgetItem *oldItem = m_ui->twGear->item(rowStart, 0); //Item above
|
||||
if (oldItem == nullptr)// not set due to rowSpan...
|
||||
break;
|
||||
if (oldItem->data(Qt::UserRole).toInt() != gearInfo.gearId() ||
|
||||
oldItem->text() != item->text())
|
||||
if (oldItem->data(Qt::UserRole).toInt() != gearInfo.gearId() || // Different gearId
|
||||
oldItem->text() != item->text()) // Different Text (if gearId not set...)
|
||||
break;
|
||||
--rowStart;
|
||||
}
|
||||
if (rowStart + 1 < row)
|
||||
{
|
||||
m_ui->twGear->setItem(row, 0, item);
|
||||
m_ui->twGear->setItem(row, 0, item); //Need to be set, because of the check above
|
||||
m_ui->twGear->setSpan(rowStart + 1, 0, row - rowStart, 1);
|
||||
}
|
||||
else
|
||||
m_ui->twGear->setItem(row, 0, item);
|
||||
|
||||
if (gearInfo.chargeTypeId() != 0 && gearInfo.chargeTypeId() != -1)
|
||||
if (gearInfo.chargeTypeId() != 0 && gearInfo.chargeTypeId() != -1) // hat Charge (and ignore only chargecounts)
|
||||
{
|
||||
int chargeTypeId = gearInfo.chargeTypeId();
|
||||
if ((chargeTypeId & unknownTasId) == unknownTasId)
|
||||
@@ -750,12 +809,12 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
item->setToolTip(m_pdmDtc->trChargeTypeName(chargeTypeId, true));
|
||||
}
|
||||
m_ui->twGear->setItem(row, 1, item);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//ressourceCount
|
||||
//: Blank in this case refers to blank ammunition used for training
|
||||
// Chris didn't wanted the chargeCounting Flag like: If they don't make it right why should we do it?
|
||||
// presevred old mode so just in case..
|
||||
//UAE wepaons don't send needed telegrams.. so let's hack again..
|
||||
// in order to avoid the faulty SALTs let's hope they never send remaining ammunition below 100...
|
||||
#ifdef GUEZ_MODE
|
||||
item = new QTableWidgetItem((gearInfo.remain() < 0) ? tr("N/A", "Blank Ammunition") : QString::number(gearInfo.remain()));
|
||||
#else
|
||||
@@ -780,13 +839,13 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
}
|
||||
m_ui->twGear->setRowCount(rowCount);
|
||||
m_ui->twGear->resizeColumnsToContents();
|
||||
|
||||
// Avoid shrinking last column (2): It'll auto-stretch afterwards
|
||||
m_ui->twGear->horizontalHeader()->resizeSection(2, 42);
|
||||
|
||||
m_ui->twGear->setColumnHidden(0, m_isTarget);
|
||||
m_ui->twGear->setColumnHidden(1, m_isTarget);
|
||||
|
||||
}
|
||||
} //end Gear
|
||||
if (!showForArtillery)
|
||||
{
|
||||
m_ui->twGear->hide();
|
||||
@@ -797,7 +856,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
DEBUG_LOG(m_logger) << "### data.participantId(): " << data.participantId();
|
||||
DEBUG_LOG(m_logger) << "### data.sampleTime(): " << data.sampleTime();
|
||||
|
||||
|
||||
//sanMat
|
||||
if (data.sanitationMaterialStock().size() == 0)
|
||||
{
|
||||
m_sanMatStock.clear();
|
||||
@@ -817,7 +876,7 @@ void ParticipantInfoDialog::onDynamicParticipantDataChanged(const DynamicPartici
|
||||
m_sanMatStock = data.sanitationMaterialStock();
|
||||
std::vector<SanitationMaterial> tmpSanMatStock = m_sanMatStock;
|
||||
|
||||
std::sort(tmpSanMatStock.begin(), tmpSanMatStock.end(), &compareSanMat);
|
||||
std::sort(tmpSanMatStock.begin(), tmpSanMatStock.end(), &compareSanMat); //sort
|
||||
|
||||
m_ui->twSanMat->clearContents();
|
||||
|
||||
@@ -942,7 +1001,7 @@ void ParticipantInfoDialog::showSpecialSensorData(int specialSensorData)
|
||||
if ((specialSensorData & (1 << 11)) != 0)
|
||||
strSpecialSensorData += QStringLiteral(" F");
|
||||
|
||||
if (specialSensorDataState == 66)
|
||||
if (specialSensorDataState == 66) // CSF Spürbetrieb
|
||||
{
|
||||
const int type = (specialSensorData >> 12) & 0x0F;
|
||||
strSpecialSensorData += QLatin1Char(' ');
|
||||
@@ -974,7 +1033,7 @@ void ParticipantInfoDialog::showSpecialSensorData(int specialSensorData)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (type == 4)
|
||||
if (type == 4) // CSF
|
||||
{
|
||||
const int nbcType = (specialSensorData >> 16) & 0x03;
|
||||
strSpecialSensorData += QLatin1Char(' ');
|
||||
@@ -1023,7 +1082,7 @@ void ParticipantInfoDialog::onPositionChanged(const ParticipantPosition &positio
|
||||
{
|
||||
if (room.id() == position.roomId())
|
||||
{
|
||||
|
||||
// In the case of external OPS transmitters, the building name was output twice
|
||||
if ( room.structureElementTypeId() != InfrastructureManagement::StructureElementType_def::Room )
|
||||
continue;
|
||||
roomName = QString::fromStdString(room.displayName());
|
||||
@@ -1060,7 +1119,7 @@ void ParticipantInfoDialog::onPositionChanged(const ParticipantPosition &positio
|
||||
connect(m_ui->pbMounted, &QToolButton::clicked, this, &ParticipantInfoDialog::onMountedParticipants);
|
||||
}
|
||||
|
||||
|
||||
// hide button when both are not set
|
||||
if (!position.mountedOn().is_set() && !position.mountedParticipants().is_set())
|
||||
m_ui->pbMounted->hide();
|
||||
|
||||
@@ -1112,8 +1171,8 @@ void ParticipantInfoDialog::onParticipantChanged(const Participant &participant,
|
||||
if (participant.id() != m_participant.id())
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// Do not continue on modType == DataModification::eRemove
|
||||
// otherwise for example the icon would look bad (clover with black on black...)
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
@@ -1121,7 +1180,7 @@ void ParticipantInfoDialog::onParticipantChanged(const Participant &participant,
|
||||
{
|
||||
m_ui->lblType->setText(ParticipantManagement::trTypeName(m_dtc->type(participant.typeId()).name()));
|
||||
TypeClass typeClass = m_dtc->type(participant.typeId()).typeClass();
|
||||
|
||||
// If TypeClass changes, close window. Shouldn't ever happen, but for initialization.
|
||||
if (m_typeClass != TypeClass_def::Unknown && m_typeClass != typeClass)
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Close)->click();
|
||||
@@ -1146,7 +1205,7 @@ void ParticipantInfoDialog::onParticipantChanged(const Participant &participant,
|
||||
m_ui->lblEquipNr->setToolTip(QString::number(m_participant.id()));
|
||||
#endif
|
||||
|
||||
|
||||
//hide Info if not exists
|
||||
m_ui->lblInfoText->setText(QString::fromStdString(m_participant.info()));
|
||||
m_ui->lblInfoText->setVisible(m_participant.info().size() > 0);
|
||||
m_ui->lblInfo->setVisible(m_participant.info().size() > 0);
|
||||
@@ -1222,8 +1281,8 @@ void ParticipantInfoDialog::setSanitationLabelColor(SanitationResult proceduresD
|
||||
|
||||
void ParticipantInfoDialog::setKindVisible(bool bVisible)
|
||||
{
|
||||
|
||||
|
||||
// const bool showVulnerabilityKindProject = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
// QStringLiteral("ShowVulnerabilityKind"));
|
||||
if (!m_showVulnerabilityKindProject)
|
||||
bVisible = false;
|
||||
|
||||
@@ -1231,8 +1290,12 @@ void ParticipantInfoDialog::setKindVisible(bool bVisible)
|
||||
m_ui->lbKind->setVisible(bVisible);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ParticipantInfoDialog::setBottomSpacerVisibility
|
||||
* \param isOneListActive
|
||||
* \details If Weapon Table or/and SanMat table is visible -> Hide Bottom Spacer
|
||||
* \author Niklas Schmidt
|
||||
*/
|
||||
void ParticipantInfoDialog::setBottomSpacerVisibility(bool isOneListActive)
|
||||
{
|
||||
|
||||
@@ -1300,7 +1363,7 @@ void ParticipantInfoDialog::setBackgroundColor(QWidget *w, Qt::GlobalColor col
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// reset to default palette
|
||||
w->setPalette(QApplication::palette(w));
|
||||
w->setAutoFillBackground(false);
|
||||
}
|
||||
@@ -1338,14 +1401,14 @@ void ParticipantInfoDialog::onOpenHistory()
|
||||
if (!m_aesDtc)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// {
|
||||
// ParticipantTargetConfigurationDialog* diag = new ParticipantTargetConfigurationDialog(this);
|
||||
// if (diag->init(m_participant.id(), m_dtc, m_ftc, /*m_pdmDtc,*/ m_sitMapGuiIfc))
|
||||
// addDialog(diag, m_menuGroup, QStringLiteral("ParticipantHistory") + QString::number(m_participant.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
// else
|
||||
// delete diag;
|
||||
// }
|
||||
// return;
|
||||
|
||||
|
||||
ParticipantHistoryDialog *diag = new ParticipantHistoryDialog(this);
|
||||
@@ -1431,9 +1494,9 @@ void ParticipantInfoDialog::onGearRanges()
|
||||
m_sitMapGuiIfc->enableGearRanges(m_participant.id(), m_ui->pbGearRanges->isChecked());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
/// Target
|
||||
///////////////////////////////////////////////
|
||||
bool ParticipantInfoDialog::initTargetConfig(bool bShow)
|
||||
{
|
||||
if (bShow)
|
||||
@@ -1443,13 +1506,13 @@ bool ParticipantInfoDialog::initTargetConfig(bool bShow)
|
||||
m_ui->pbSetInjury->hide();
|
||||
m_ui->pbSetSanitation->hide();
|
||||
|
||||
|
||||
|
||||
// Combobox Weapon:
|
||||
// TODO woher kommen die Waffen?
|
||||
m_ui->cbTargetWeapon->addItem(QStringLiteral("AK47"), 1);
|
||||
m_ui->cbTargetWeapon->addItem(QStringLiteral("Pistol"), 5);
|
||||
m_ui->cbTargetWeapon->addItem(QStringLiteral("Shotgun"), 7);
|
||||
|
||||
|
||||
// Combobox Mode:
|
||||
m_ui->cbTargetMode->addItem(TargetManagement::toString(TargetManagement::Mode_def::Deactivated),
|
||||
TargetManagement::Mode_def::Deactivated);
|
||||
m_ui->cbTargetMode->addItem(TargetManagement::toString(TargetManagement::Mode_def::ShootBack),
|
||||
@@ -1515,7 +1578,7 @@ void ParticipantInfoDialog::onTargetConfig()
|
||||
return m_tgtFtc->configureTargetRequest(request, this);
|
||||
};
|
||||
m_requestHelper->startSingleRequest(cb);
|
||||
}
|
||||
} // end of onTargetConfig
|
||||
|
||||
void ParticipantInfoDialog::onTargetConfigChanged(const TargetManagement::TargetConfig &data, DataModification modType)
|
||||
{
|
||||
@@ -1532,7 +1595,7 @@ void ParticipantInfoDialog::onTargetConfigChanged(const TargetManagement::Target
|
||||
m_ui->cbTargetWeapon->setVisible(true);
|
||||
m_ui->cbTargetMode->setCurrentIndex(m_ui->cbTargetMode->findData(data.mode().underlying()));
|
||||
m_ui->cbTargetWeapon->setCurrentIndex(m_ui->cbTargetWeapon->findData(data.weapon()));
|
||||
}
|
||||
} // end of onTargetConfigChanged
|
||||
|
||||
void ParticipantInfoDialog::onTargetModeChangeed()
|
||||
{
|
||||
@@ -1577,7 +1640,7 @@ void ParticipantInfoDialog::onTargetWeaponChanged()
|
||||
|
||||
void ParticipantInfoDialog::onOpenTargetConfigurationL400()
|
||||
{
|
||||
|
||||
// ParticipantTargetConfigurationDialog -> L400
|
||||
ParticipantTargetConfigurationDialog* diag = new ParticipantTargetConfigurationDialog(this);
|
||||
if (diag->init(m_participant.id(), m_dtc, m_ftc, m_sitMapGuiIfc))
|
||||
addDialog(diag, m_menuGroup, QStringLiteral("TargetConfigurationL400") + QString::number(m_participant.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
@@ -1606,12 +1669,12 @@ void ParticipantInfoDialog::onContextMenuRequested(const QPoint &position)
|
||||
actions << restockNowAction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if (m_pdmDtc->canSetDefaults(gear.gearTypeId()))
|
||||
// {
|
||||
// QAction *restockDefaultsAction = new QAction(tr("Restock Defaults"), this);
|
||||
// connect(restockDefaultsAction, &QAction::triggered, this, [=](){ onRestockDefaults(gear.gearId(), gear.gearTypeId()); });
|
||||
// actions << restockDefaultsAction;
|
||||
// }
|
||||
|
||||
if (actions.isEmpty())
|
||||
return;
|
||||
@@ -1641,25 +1704,25 @@ void ParticipantInfoDialog::onRestockDefaults(int gearId, int gearTypeId)
|
||||
|
||||
void ParticipantInfoDialog::onUasChanged(const UAS &uas)
|
||||
{
|
||||
|
||||
// check if changed uas is this uas, on this participant, in this exercise
|
||||
if (uas.id() != m_uasId || uas.exerciseId() != m_session->exerciseId() || uas.participantId() != m_participant.id())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// set text & text color for uas operating mode
|
||||
const QString operatingMode(ProjectDataManagement::toString(uas.uasState()));
|
||||
static const QString textHtml { QStringLiteral("<font color='%1'>%2</font>") };
|
||||
|
||||
switch (uas.uasState().underlying())
|
||||
{
|
||||
case ProjectDataManagement::UasState::UasState_Auto:
|
||||
case ProjectDataManagement::UasState::Auto:
|
||||
{
|
||||
m_ui->lblOperatingMode->setText(textHtml.arg(QStringLiteral("green")).arg(operatingMode));
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::UasState::UasState_Manual:
|
||||
case ProjectDataManagement::UasState::Manual:
|
||||
{
|
||||
m_ui->lblOperatingMode->setText(textHtml.arg(QStringLiteral("orange")).arg(operatingMode));
|
||||
break;
|
||||
@@ -1700,4 +1763,4 @@ void ParticipantInfoDialog::onUnlockUAS()
|
||||
m_requestHelper->startSingleRequest(cb);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
+31
-25
@@ -1,23 +1,29 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - TlnInfoDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
|
||||
//Asb
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
|
||||
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
//DDS
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
@@ -26,18 +32,18 @@
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_symbol_appearance_settings.h>
|
||||
|
||||
//SituationMap
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
|
||||
//AES
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
|
||||
// TargetManagement
|
||||
#include <TargetManagement/tgt_dtc.h>
|
||||
#include <TargetManagement/tgt_ftc.h>
|
||||
#include <TargetManagement/tgt_ftc_types.h>
|
||||
|
||||
|
||||
//Qt
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -54,9 +60,9 @@ namespace ParticipantManagement
|
||||
|
||||
class ParticipantInfoLtdGearComponent;
|
||||
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ParticipantInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantInfoDialog final : public LtsWidgets::LtsDialog
|
||||
, protected FilterManagement::SymbolAppearanceSettings::SettingsChangedCallback
|
||||
, protected TargetManagement::Interface::Ftc::ConfigureTargetReplyHandler
|
||||
@@ -85,7 +91,6 @@ signals:
|
||||
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool setUiValues();
|
||||
static void setBackgroundColor(QWidget *w, Qt::GlobalColor color, bool bSetColor);
|
||||
@@ -101,10 +106,11 @@ private:
|
||||
void setMessageVisible(bool bVisible);
|
||||
void onSymbolAppearanceSettingsChanged(FilterManagement::SymbolAppearanceSettings::Part part) override;
|
||||
QString approachingAngle(const QPointF ¢erPoint, double direction, double distance, int mseId) const;
|
||||
|
||||
// Target (Qatar?)
|
||||
bool initTargetConfig(bool bShow);
|
||||
|
||||
// Target (L400)
|
||||
bool initTargetConfigL400(bool bShow);
|
||||
bool loadGuiElementPLugin(const LtsPluginManager::PluginInstance &pi);
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
@@ -137,19 +143,18 @@ private Q_SLOTS:
|
||||
void onRestockDefaults(int gearId,int gearTypeId);
|
||||
void onRestockNow(int gearId,int gearTypeId);
|
||||
|
||||
|
||||
// Target (Qatar?)
|
||||
void onTargetConfig();
|
||||
void onTargetConfigChanged(const TargetManagement::TargetConfig &data, DataModification modType);
|
||||
void onTargetModeChangeed();
|
||||
void onTargetWeaponChanged();
|
||||
|
||||
|
||||
// Target (L400)
|
||||
void onOpenTargetConfigurationL400();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
Participant m_participant;
|
||||
int m_uasId;
|
||||
int m_uasId; // Needed to release uas again.
|
||||
qint64 m_lastPositionMSec;
|
||||
TypeClass m_typeClass;
|
||||
std::vector<GearInformation> m_gearList;
|
||||
@@ -181,5 +186,6 @@ private:
|
||||
bool m_isTarget;
|
||||
bool m_showPvSan{false};
|
||||
bool m_showVulnerabilityKindProject{false};
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantInfo
|
||||
+30
-23
@@ -1,20 +1,26 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - Party Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-11-11
|
||||
*/
|
||||
|
||||
#include "ppm_party_edit.h"
|
||||
#include "NGLLogger/INGLLogger.h"
|
||||
#include "ui_ppm_party_edit.h"
|
||||
|
||||
#include <QtWidgets/QColorDialog>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonArray>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QColorDialog>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QMessageBox>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <Services/AreaEffectSimulation/aes_operator_rights.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -34,20 +40,21 @@ PartyEdit::PartyEdit(QWidget *parent)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::PartyEdit)
|
||||
, m_logger(getLogger("PartyEdit"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PartyEdit::~PartyEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PartyEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dtc->party(m_partyId), tr("Party"));
|
||||
translate(m_ui, m_dtc->party(m_partyId), trPartyName(m_dtc->party(m_partyId).name()), tr("Party"));
|
||||
m_ppmGuiCbxIfc->fillRoleComboBox(m_ui->cbRole);
|
||||
m_ppmGuiCbxIfc->fillHlaForceIdentifierComboBox(m_ui->cbHlaForceIdentifier);
|
||||
}
|
||||
@@ -88,7 +95,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
|
||||
m_ppmGuiCbxIfc->fillRoleComboBox(m_ui->cbRole);
|
||||
m_ppmGuiCbxIfc->fillHlaForceIdentifierComboBox(m_ui->cbHlaForceIdentifier);
|
||||
if (m_partyId >= 0)
|
||||
if (m_partyId >= 0) // pool has id 0 so is a valid party
|
||||
{
|
||||
const Party &party = m_dtc->party(m_partyId);
|
||||
if(party.id() >= 0)
|
||||
@@ -107,7 +114,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
m_ui->cbHlaForceIdentifier->hide();
|
||||
}
|
||||
|
||||
|
||||
// Could be filled programmatically later
|
||||
m_ui->cbAdlerNotification->setProperty("Notification", NotificationManagement::NotificationType::AdlerNotification);
|
||||
m_ui->cbCombatOrder->setProperty("Notification", NotificationManagement::NotificationType::CombatOrder);
|
||||
|
||||
@@ -132,7 +139,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
connect(m_ui->tbResetAdlerConnection, &QToolButton::clicked, this, &PartyEdit::onResetAdlerConnectionClicked);
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::partyChanged, this, &PartyEdit::onPartyChanged);
|
||||
|
||||
|
||||
// check Notifications
|
||||
notificationCheck();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Parties"));
|
||||
@@ -140,7 +147,7 @@ bool PartyEdit::init(int partyId, LtsSession::LtsSession *session)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//slots
|
||||
bool PartyEdit::apply()
|
||||
{
|
||||
if (!m_partiallyUnchangeable)
|
||||
@@ -253,7 +260,7 @@ void PartyEdit::onPartyChanged(const Party &data, DataModification modType)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//private
|
||||
|
||||
void PartyEdit::setData(const Party &party)
|
||||
{
|
||||
@@ -269,7 +276,7 @@ void PartyEdit::setData(const Party &party)
|
||||
|
||||
void PartyEdit::setColorToButton(QToolButton *button, const QColor &color)
|
||||
{
|
||||
button->setStyleSheet(QStringLiteral("QToolButton{ background: %1; }").arg(color.name()));
|
||||
button->setStyleSheet(QStringLiteral("QToolButton{ background: %1; }").arg(color.name())); // TODO: muss das sein?
|
||||
}
|
||||
|
||||
void PartyEdit::fillJsonSuppressNotifications( QJsonArray ¬if, NotificationManagement::NotificationType notifType)
|
||||
@@ -381,8 +388,8 @@ void PartyEdit::notificationCheck()
|
||||
m_ui->cbAdlerNotification->setCheckState(Qt::Checked);
|
||||
m_ui->cbCombatOrder->setCheckState(Qt::Checked);
|
||||
|
||||
|
||||
|
||||
// Here add another NotificationType, everything else will happen automatically
|
||||
// CheckBox insert in Ui
|
||||
const QList<NotificationManagement::NotificationType> notifTypes { NotificationManagement::NotificationType_def::AdlerNotification,
|
||||
NotificationManagement::NotificationType_def::CombatOrder};
|
||||
|
||||
@@ -407,11 +414,11 @@ void PartyEdit::notificationCheck()
|
||||
|
||||
void PartyEdit::modifyPartyProperties()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
ParticipantManagement::Party requestParty;
|
||||
requestParty = m_dtc->party(m_partyId);
|
||||
|
||||
// Get properties and then update them
|
||||
const QJsonObject &origObj = QJsonDocument::fromJson(requestParty.properties().c_str()).object();
|
||||
QJsonObject adlerPropertiesObj = origObj[QStringLiteral("Adler")].toObject();
|
||||
adlerPropertiesObj[QStringLiteral("saaConnectedState")] = ParticipantManagement::ConnectState::Disconnecting;
|
||||
|
||||
+22
-18
@@ -1,20 +1,26 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - Party Overview Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-11-11
|
||||
*/
|
||||
|
||||
#include "ppm_party_model.h"
|
||||
#include <OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QColor>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// PartyModel
|
||||
//---------------------------------
|
||||
PartyModel::PartyModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ParticipantManagement::Party>({tr("Id"),
|
||||
tr("Name"),
|
||||
@@ -27,6 +33,7 @@ PartyModel::PartyModel(QObject *parent)
|
||||
tr("Szenar Name")},
|
||||
parent)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_logger(getLogger("PartyModel"))
|
||||
{}
|
||||
|
||||
bool PartyModel::initModel(LtsSession::LtsSession *session)
|
||||
@@ -49,7 +56,7 @@ bool PartyModel::initModel(LtsSession::LtsSession *session)
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
m_ppmDtc->partys([this](const ParticipantManagement::Party &party)
|
||||
{
|
||||
if (hasParty(party))
|
||||
if (hasParty(party)) // opm_operator_exercise -> visible_parties
|
||||
insertRow(party);
|
||||
});
|
||||
return true;
|
||||
@@ -98,14 +105,11 @@ QVariant PartyModel::data(const QModelIndex &index, int role) const
|
||||
QString connectState;
|
||||
switch (status.underlying())
|
||||
{
|
||||
case ParticipantManagement::ConnectState::Connected:
|
||||
connectState = tr("Connected");
|
||||
break;
|
||||
case ParticipantManagement::ConnectState::NoHeartbeat:
|
||||
connectState = tr("No Heartbeat");
|
||||
case ParticipantManagement::ConnectState::Undefined:
|
||||
connectState = QStringLiteral("");
|
||||
break;
|
||||
default:
|
||||
connectState = QStringLiteral("");
|
||||
connectState = ParticipantManagement::toString(status);
|
||||
break;
|
||||
}
|
||||
return connectState;
|
||||
@@ -150,7 +154,7 @@ bool PartyModel::hasParty(const Party &party) const
|
||||
{
|
||||
if (exerciseParties.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if (!exerciseParties.visibleParties().is_set())
|
||||
if (!exerciseParties.visibleParties().is_set()) //has_value not support on windows yet so we need depricated is_set
|
||||
return false;
|
||||
for (const auto &partyId : exerciseParties.visibleParties().get())
|
||||
if (partyId == party.id())
|
||||
@@ -167,7 +171,7 @@ bool PartyModel::isPartyHidden(const Party &party) const
|
||||
{
|
||||
if (exerciseParties.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if (!exerciseParties.hiddenParties().is_set())
|
||||
if (!exerciseParties.hiddenParties().is_set()) //has_value not support on windows yet so we need depricated is_set
|
||||
return false;
|
||||
for (const auto &partyId : exerciseParties.hiddenParties().get())
|
||||
if (partyId == party.id())
|
||||
@@ -176,4 +180,4 @@ bool PartyModel::isPartyHidden(const Party &party) const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
+55
-46
@@ -1,5 +1,12 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Editor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-17
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -7,29 +14,29 @@
|
||||
#include "pre_journal_types.h"
|
||||
#include "pre_utils.h"
|
||||
|
||||
#include <Core/core_dtc.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <LtsPluginManager/lts_plugin_manager.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <PluginInterfaces/topic_replay_interface.h>
|
||||
#include <PresentationManagement/Common/topic_assignment.h>
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <PresentationManagement/pre_dtc.h>
|
||||
#include <PresentationManagement/pre_ftc.h>
|
||||
#include <SituationReplayManagement/srm_ftc.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/topic_assignment.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <Services/ExerciseManagement/exm_dtc.h>
|
||||
#include <Services/PresentationManagement/pre_dtc.h>
|
||||
#include <Services/PresentationManagement/pre_ftc.h>
|
||||
#include <Services/SituationReplayManagement/srm_ftc.h>
|
||||
#include <TopicEditorBase/topic_editor_utils.h>
|
||||
#include <LtsWidgets/lts_overlay_loading.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
|
||||
@@ -60,13 +67,13 @@ class CoolExporter;
|
||||
namespace Interface { class Ftc; }
|
||||
|
||||
|
||||
|
||||
//template<typename Type = void *>
|
||||
class Scope
|
||||
{
|
||||
public:
|
||||
explicit Scope(const std::function<void (void)> &ctor, const std::function<void (void)> &dtor)
|
||||
|
||||
|
||||
//: m_fn(fn)
|
||||
//: m_data(ctor())
|
||||
: m_dtor(dtor)
|
||||
{
|
||||
ctor();
|
||||
@@ -77,15 +84,15 @@ public:
|
||||
m_dtor();
|
||||
}
|
||||
|
||||
// Scope(const std::function<Type (void)> &ctor, const std::function<void (Type)> &dtor)
|
||||
// //: m_fn(fn)
|
||||
// : m_data({})
|
||||
// {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
private:
|
||||
|
||||
//Type m_data;
|
||||
std::function<void (void)> m_dtor;
|
||||
};
|
||||
|
||||
@@ -148,7 +155,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// LtsDialog override
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
void aboutToClose() override;
|
||||
@@ -163,16 +170,16 @@ private:
|
||||
);
|
||||
bool getTopicItems();
|
||||
void getSitMapApp() noexcept(false);
|
||||
void getPresentationContent();
|
||||
void getPresentationContent(); // tryAddTopics has to be called first to populate m_topicAssignments
|
||||
void getProjectionWidget(Screen **pointerToWidgetPointer, bool placeAutomatically = false);
|
||||
|
||||
|
||||
// dds stuff
|
||||
bool enableFireEventFlash(bool enable);
|
||||
|
||||
|
||||
// io stuff
|
||||
void exportPresentationContent(const Core::FunctionReply &baseReply);
|
||||
|
||||
|
||||
// ui stuff
|
||||
void disableSessionDialog(LtsSession::LtsSession *session, bool disable);
|
||||
void startEssentialsViewStage2(const Core::ReplayPartition &replay, bool openTopicEditor, int topicType, int topicItemId);
|
||||
static bool hasEssentialsViewTopicType(TopicEditorBase::TopicType topicType);
|
||||
@@ -192,15 +199,15 @@ private:
|
||||
void enaDisa();
|
||||
void startEssentialsView(int topicItemId = -1, int topicType = -1, bool openTopicEditor = false);
|
||||
|
||||
|
||||
// topic stuff
|
||||
void openContextMenu(QPoint pos, int topicItemId);
|
||||
void setTopicDescription(int topicItemId);
|
||||
void enableTopicEditors(bool enable);
|
||||
|
||||
|
||||
// replay stuff
|
||||
qint64 positionTime() const;
|
||||
void setPositionTime(qint64 time, bool setByUser = false);
|
||||
void setPositionTimeActive(qint64 time, bool setByUser = false);
|
||||
void setPositionTimeActive(qint64 time, bool setByUser = false); // setPositionTime, but, if playing, also ticks and resets timeout
|
||||
void playTopic(int topicItemId);
|
||||
void pause();
|
||||
void stop(bool ended = false, bool ignoreFireEventFlashing = false);
|
||||
@@ -208,7 +215,7 @@ private:
|
||||
qint64 nextTopicTime() const;
|
||||
bool hasPreviousTopic() const { return previousTopicTime() > -1; }
|
||||
bool hasNextTopic() const { return nextTopicTime() > -1; }
|
||||
void removeTopicItemFromPlaylist(int topicItemId);
|
||||
void removeTopicItemFromPlaylist(int topicItemId); // WARNING: use a mutable iterator while iterating over m_currentlyPlayingTopics and remove the entry before calling this method!
|
||||
|
||||
bool isTopicAlreadyOpened(const TopicEditorBase::TopicData &data);
|
||||
template <typename TopicEditorInterface>
|
||||
@@ -252,7 +259,7 @@ private:
|
||||
QStringList &resultList,
|
||||
const SpecialTopicType &specialTopicType = SpecialTopicType::Normal)
|
||||
{
|
||||
|
||||
// qWarning() << "mep" << QStringLiteral("%1:%2").arg(QString::fromUtf8(__FILE__).split(QStringLiteral("/")).last()).arg(__LINE__);
|
||||
|
||||
if (isTopicDisabled(topicType))
|
||||
return true;
|
||||
@@ -307,7 +314,7 @@ private slots:
|
||||
void onDiscard();
|
||||
void onNull(QObject *obj);
|
||||
|
||||
|
||||
// io stuff
|
||||
void onLoad();
|
||||
void onExport();
|
||||
void onExport2();
|
||||
@@ -315,7 +322,7 @@ private slots:
|
||||
void onBurnDvD(const QString &strExportPath);
|
||||
void onBurningFinished(bool success);
|
||||
|
||||
|
||||
// ui stuff
|
||||
void onPresentationContent(const GetPresentationContentReply &reply);
|
||||
void onEssentialsView();
|
||||
void onTopicItemPositionChanged(QWidget *previewWidget, int ignoreTopicForReplay);
|
||||
@@ -327,16 +334,16 @@ private slots:
|
||||
void onTopicDesignerChangesMade();
|
||||
void onTopicEditorChangesSaved(const TopicEditorBase::TopicData &data);
|
||||
|
||||
|
||||
// topic stuff
|
||||
void onGetTopicEditor(const TopicEditorBase::TopicData &data);
|
||||
void onEditSelectedTopicItem();
|
||||
void onEditTopicItem(int itemId);
|
||||
void onRemoveSelectedTopics();
|
||||
void onContextMenu(QPoint pos);
|
||||
// void onMergeTopics();
|
||||
// void onSplitTopic();
|
||||
|
||||
|
||||
|
||||
|
||||
// replay stuff
|
||||
void onTimeout();
|
||||
void onPlay();
|
||||
void onPause();
|
||||
@@ -348,7 +355,7 @@ private slots:
|
||||
void onShowStoryboard();
|
||||
void onShowJournal();
|
||||
|
||||
|
||||
// other stuff
|
||||
bool checkBuildingViewerAndEssentialsView();
|
||||
|
||||
signals:
|
||||
@@ -358,14 +365,14 @@ signals:
|
||||
void scriptTick(qint64 positionTime);
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_exerciseSession { nullptr };
|
||||
LtsSession::LtsSession *m_exerciseSession { nullptr }; // aka. script editor app
|
||||
LtsSession::LtsSession *m_replaySession { nullptr };
|
||||
LtsSession::LtsSession *m_sitMapSession { nullptr };
|
||||
LtsSession::LtsSession *m_essentialsViewSession { nullptr };
|
||||
LtsPluginManager::LtsPluginManager *m_essentialsViewApp { nullptr };
|
||||
LtsPluginManager::LtsPluginManager *m_sitMapApp { nullptr };
|
||||
LtsUtils::RequestHelper *m_requestHelper { nullptr };
|
||||
TakeHomePackageGenerator::ExportProcess *m_exportProcess { nullptr };
|
||||
TakeHomePackageGenerator::ExportProcess *m_exportProcess { nullptr }; // OLD exporter!
|
||||
|
||||
std::shared_ptr<Core::Interface::Dtc> m_coreDtc { nullptr };
|
||||
std::shared_ptr<PresentationManagement::Interface::Dtc> m_dtc { nullptr };
|
||||
@@ -402,7 +409,7 @@ private:
|
||||
int m_selectedTeId;
|
||||
QMap<QString, TopicAssignment> m_topicAssignments;
|
||||
QMap<TopicEditorBase::TopicType, TopicAssignment> m_trackEntryToTopicAssignment;
|
||||
QMultiMap<int, LtsScriptTimeline::TrackEntry *> m_topicMap;
|
||||
QMultiMap<int, LtsScriptTimeline::TrackEntry *> m_topicMap; // <seconds, trackEntry>
|
||||
|
||||
QTimer *m_presentationTimer { nullptr };
|
||||
qint64 m_firstTopicTime { -1 };
|
||||
@@ -431,7 +438,8 @@ private:
|
||||
|
||||
Ui::ScriptDialog *m_ui { nullptr };
|
||||
bool m_lastScriptHasEnded { false };
|
||||
QMap<TopicEditorBase::TopicType, int> m_avaibleTopics{};
|
||||
NGL::INGLLogger &m_logger;
|
||||
QMap<TopicEditorBase::TopicType, int> m_avaibleTopics{}; // <data.topicType, data.id>
|
||||
QVector<TopicEditorBase::TopicType> m_modifiedTopicTypesList;
|
||||
|
||||
LtsSession::LtsSession *m_session { nullptr };
|
||||
@@ -456,6 +464,7 @@ private:
|
||||
ScriptTimelineDialog &m_this;
|
||||
std::unique_ptr<LtsWidgets::LtsOverlayLoading> m_loading;
|
||||
bool m_stoppedPrematurely { false };
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace PresentationManagement
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(ScmGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scm_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(ScmDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scm_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
DataPluginInterface
|
||||
svcScmCommon
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY(WS ScmDataPlugin MODULE scm_data_plugin.cpp scm_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(ScmDataPlugin
|
||||
Qt5::Core
|
||||
ScmDataPluginInterface
|
||||
svcScmClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
NGL_INSTALL_TARGET(ScmDataPlugin)
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for ServiceManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#include "scm_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc, false ,true))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
|
||||
}
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ServiceManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/ServiceManagement/scm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:scm")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("ServiceManagement"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
explicit DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc);
|
||||
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(ServiceEdit)
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-03-30
|
||||
#
|
||||
|
||||
SET(scm_edit_gui_SRCS
|
||||
scm_edit_gui_plugin.cpp
|
||||
scm_edit_gui_plugin.h
|
||||
scm_dialog.cpp
|
||||
scm_dialog.h
|
||||
scm_dialog_service.cpp
|
||||
scm_dialog_service.h
|
||||
scm_dialog_group.cpp
|
||||
scm_dialog_group.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(scm_edit_gui_SRCS
|
||||
scm_dialog.ui
|
||||
scm_dialog_service.ui
|
||||
scm_dialog_group.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS ScmEditGuiPlugin MODULE ${scm_edit_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(ScmEditGuiPlugin
|
||||
NGLLogger
|
||||
ScmGuiPluginInterface
|
||||
ScmDataPluginInterface
|
||||
LtsSession
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsUtilsGuiDds
|
||||
svcScmCommon
|
||||
svcExmClient
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(ScmEditGuiPlugin)
|
||||
Executable
+365
@@ -0,0 +1,365 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
|
||||
#include "scm_dialog.h"
|
||||
#include "ui_scm_dialog.h"
|
||||
|
||||
#include "scm_dialog_group.h"
|
||||
#include "scm_dialog_service.h"
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// ServiceManagementDialog
|
||||
//---------------------------------
|
||||
ServiceManagementDialog::ServiceManagementDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ServiceManagementDialog)
|
||||
, m_dtcExm(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_logger(getLogger("ServiceManagementDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// unused yet
|
||||
m_ui->lbGroupsIndicator->hide();
|
||||
m_ui->lbExercise->hide();
|
||||
m_ui->lbServer->hide();
|
||||
m_ui->cbServer->hide();
|
||||
m_ui->cbExercise->hide();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Service_Management"));
|
||||
}
|
||||
|
||||
ServiceManagementDialog::~ServiceManagementDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Service Management"));
|
||||
}
|
||||
|
||||
|
||||
bool ServiceManagementDialog::init(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtcExm = dtcExm;
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::groupInformationChanged,
|
||||
this, &ServiceManagementDialog::slotGroupInformationChanged);
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::serviceInformationChanged,
|
||||
this, &ServiceManagementDialog::slotServiceInformationChanged);
|
||||
|
||||
const QMap<qint32, ServiceManagement::GroupInformation> groupInfo = m_dtc->groupInformations();
|
||||
|
||||
if (groupInfo.isEmpty())
|
||||
{
|
||||
INFO_LOG(m_logger) << "initModel - no groups!";
|
||||
return true;
|
||||
}
|
||||
|
||||
m_ui->lbNoServices->hide();
|
||||
|
||||
INFO_LOG(m_logger) << "initModel - #group information: " << groupInfo.size();
|
||||
|
||||
|
||||
// GROUPS
|
||||
QVector<int> servicesList;
|
||||
for (const ServiceManagement::GroupInformation &gi : groupInfo)
|
||||
{
|
||||
// now that all services of that group are represented by a widget, create the group widget which adds all service widgets
|
||||
//const int id = gi.id();
|
||||
const int server = gi.domainId();
|
||||
const int exercise = gi.exercisePartitionId();
|
||||
const int32_t replayPartitionId = gi.replayPartitionId();
|
||||
const QString groupName = groupEnumToGroupName(gi.type()); // QLatin1String("Group Name"); // TODO: get real group name
|
||||
long long timestamp = gi.timestamp();
|
||||
|
||||
servicesList.clear();
|
||||
servicesList.reserve(gi.services().size());
|
||||
for (auto service : gi.services())
|
||||
servicesList.append(service);
|
||||
|
||||
addGroup(gi.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SERVICES
|
||||
auto cbSvc = [this](const ServiceManagement::ServiceInformation & svc) // create widgets for every service in the group
|
||||
{
|
||||
addService(svc);
|
||||
};
|
||||
m_dtc->serviceInformations(cbSvc); // needed to resolve services for the groups
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
GroupWidget *ServiceManagementDialog::addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp, const QVector<int> &servicesList)
|
||||
{
|
||||
//qWarning() << "ServiceManagementDialog::addGroup: needed services:" << servicesList;
|
||||
|
||||
QString exName = QString::fromStdString(m_dtcExm.get()->exercise(exercise).name());
|
||||
GroupWidget *group = new GroupWidget(groupType, server, exercise, replayPartitionId, exName, timestamp, servicesList); // memleak!
|
||||
|
||||
QString groupObjectName = craftGroupName(server, exercise, groupName);
|
||||
group->setObjectName(groupObjectName);
|
||||
//qWarning() << "Group Object Name =" << groupObjectName;
|
||||
|
||||
connect(group, &GroupWidget::signalRestartGroup, this, &ServiceManagementDialog::slotRestartGroup); // direct connection for const ref on group type enum
|
||||
connect(group, &GroupWidget::signalStartGroup, this, &ServiceManagementDialog::slotStartGroup); // direct connection for const ref on group type enum
|
||||
connect(group, &GroupWidget::signalStopGroup, this, &ServiceManagementDialog::slotStopGroup); // direct connection for const ref on group type enum
|
||||
|
||||
QVBoxLayout *l = qobject_cast<QVBoxLayout *>(m_ui->groupLayoutWidget->layout());
|
||||
if (!l)
|
||||
WARNING_LOG(m_logger) << "ServiceManagementDialog::addGroup: group layout failed, cannot add group";
|
||||
else
|
||||
l->addWidget(group, 0, Qt::AlignTop);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotRestartService(int serviceID)
|
||||
{
|
||||
const RestartServiceRequest req(serviceID);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->restartServiceRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static int s_requestId = 0;
|
||||
void ServiceManagementDialog::slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->restartGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->startGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
|
||||
{
|
||||
const GroupRequest req(groupType,
|
||||
exercise,
|
||||
server,
|
||||
replayPartitionId,
|
||||
++s_requestId,
|
||||
{});
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->stopGroupRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// DTC Modifications
|
||||
void ServiceManagementDialog::slotGroupInformationChanged(ServiceManagement::GroupInformation info, DataModification mod)
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged";
|
||||
|
||||
// find group
|
||||
int server = info.domainId();
|
||||
int exercise = info.exercisePartitionId();
|
||||
int32_t replayPartitionId = info.replayPartitionId();
|
||||
QString groupName = groupEnumToGroupName(info.type());
|
||||
long long timestamp = info.timestamp();
|
||||
|
||||
QString findGroupName = craftGroupName(server, exercise, groupName);
|
||||
|
||||
GroupWidget *gw = m_ui->groupLayoutWidget->findChild<GroupWidget *>(findGroupName);
|
||||
|
||||
if (!gw) // group does not exist? create it!
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group not found, adding it";
|
||||
|
||||
QVector<int> servicesList;
|
||||
servicesList.reserve(info.services().size());
|
||||
for (auto service : info.services())
|
||||
servicesList << service;
|
||||
|
||||
m_ui->lbNoServices->hide();
|
||||
addGroup(info.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (mod)
|
||||
{
|
||||
case DataModification::eAdded: // already exists, so it cant be added - but easily change data in existing group
|
||||
case DataModification::eModified:
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group added or modified";
|
||||
|
||||
m_ui->lbNoServices->hide(); // added/modified = there are groups, which show services
|
||||
|
||||
gw->setType(info.type());
|
||||
gw->setServer(server);
|
||||
gw->setExercise(exercise);
|
||||
gw->setTimestamp(timestamp);
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
//qWarning() << "slotGroupInformationChanged: group removed";
|
||||
|
||||
if (m_ui->groupLayoutWidget->findChildren<GroupWidget *>().isEmpty()) // no groups to show services in?
|
||||
m_ui->lbNoServices->show();
|
||||
|
||||
delete gw; // then delete gw from layout
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ServiceManagementDialog::addService(const ServiceManagement::ServiceInformation &svc)
|
||||
{
|
||||
const int id = svc.id();
|
||||
const long long pid = svc.pid();
|
||||
const QString name(QString::fromStdString(svc.name()));
|
||||
const Core::RunningState &state = svc.state();
|
||||
const QString errorString(QString::fromStdString(svc.errorString()));
|
||||
|
||||
ServiceWidget *service = new ServiceWidget(id, pid, name, state, errorString);
|
||||
service->setObjectName(QLatin1String("service.") + QString::number(id));
|
||||
connect(service, &ServiceWidget::signalRestartService, this, &ServiceManagementDialog::slotRestartService);
|
||||
|
||||
|
||||
const auto groupList = findChildren<GroupWidget *>();
|
||||
for (GroupWidget *gw : groupList)
|
||||
gw->addService(service);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ServiceManagementDialog::slotServiceInformationChanged(ServiceManagement::ServiceInformation info, DataModification mod)
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged";
|
||||
|
||||
// find services (because ONE service can be in MANY groups)
|
||||
|
||||
int32_t serviceId = info.id();
|
||||
QString errorString = QString::fromStdString(info.errorString());
|
||||
QString serviceName = QString::fromStdString(info.name());
|
||||
long long pid = info.pid();
|
||||
const Core::RunningState &state = info.state();
|
||||
long long timestamp = info.timestamp();
|
||||
|
||||
QString findServiceName = QLatin1String("service.") + QString::number(serviceId);
|
||||
|
||||
const auto serviceList = findChildren<ServiceWidget *>(findServiceName);
|
||||
|
||||
if (serviceList.isEmpty() || mod == DataModification::eAdded) // no service found or is going to be added? add it!
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service not found, adding it";
|
||||
|
||||
addService(info);
|
||||
}
|
||||
|
||||
for (ServiceWidget *serviceWidget : serviceList)
|
||||
{
|
||||
switch (mod)
|
||||
{
|
||||
case DataModification::eModified:
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service modified";
|
||||
|
||||
serviceWidget->setErrorString(errorString);
|
||||
serviceWidget->setName(serviceName);
|
||||
serviceWidget->setPid(pid);
|
||||
serviceWidget->setState(state);
|
||||
serviceWidget->setTimestamp(timestamp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
//qWarning() << "slotServiceInformationChanged: service removed";
|
||||
|
||||
delete serviceWidget;
|
||||
serviceWidget = nullptr;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
//qWarning() << "ServiceManagementDialog::slotServiceInformationChanged: unknown or invalid modification!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// tell all groups to set their new statuses (bcuz service states may have changed) !!
|
||||
const auto groupList = findChildren<GroupWidget *>();
|
||||
for (GroupWidget *groupWidget : groupList)
|
||||
groupWidget->checkStatus();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace ServiceManagement
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scm_dialog_group.h"
|
||||
|
||||
#include <ServiceManagement/scm_ftc.h>
|
||||
#include <ServiceManagement/scm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <ServiceManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ServiceManagementDialog;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
//class ExerciseManagementDialogModel;
|
||||
// --------------------------------------------------------
|
||||
// ExerciseManagementDialog
|
||||
// --------------------------------------------------------
|
||||
class ServiceManagementDialog : public LtsWidgets::LtsDialog
|
||||
, protected ServiceManagement::Interface::Ftc::RestartServiceReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::RestartGroupReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::StartGroupReplyHandler
|
||||
, protected ServiceManagement::Interface::Ftc::StopGroupReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ServiceManagementDialog(QWidget *parent = nullptr);
|
||||
~ServiceManagementDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm);
|
||||
|
||||
virtual void onRestartServiceReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onRestartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onStartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
virtual void onStopGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
// TODO: raus, String soll gepublished werden
|
||||
static QString groupEnumToGroupName(const Core::ServiceGroupType &type)
|
||||
{
|
||||
QMap<QString, Core::ServiceGroupType_def::type> groupNameMapping;
|
||||
groupNameMapping.insert(QLatin1String("Master"), Core::ServiceGroupType_def::Master);
|
||||
groupNameMapping.insert(QLatin1String("Core"), Core::ServiceGroupType_def::Core);
|
||||
groupNameMapping.insert(QLatin1String("ExercisePreparation"), Core::ServiceGroupType_def::ExercisePreparation);
|
||||
groupNameMapping.insert(QLatin1String("ExerciseExecution"), Core::ServiceGroupType_def::ExerciseExecution);
|
||||
groupNameMapping.insert(QLatin1String("ExercisePaused"), Core::ServiceGroupType_def::ExercisePaused);
|
||||
groupNameMapping.insert(QLatin1String("ExerciseAfterActionReview"), Core::ServiceGroupType_def::ExerciseAfterActionReview);
|
||||
groupNameMapping.insert(QLatin1String("Playback"), Core::ServiceGroupType_def::Playback);
|
||||
|
||||
return groupNameMapping.key(type.underlying());
|
||||
}
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
static QString craftBaseName(const QString &server, const QString &exercise) { return server + QLatin1Char('.') + exercise + QLatin1Char('.'); }
|
||||
|
||||
GroupWidget *addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp, const QVector<int> &servicesList);
|
||||
void addService(const ServiceInformation &svc);
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
public:
|
||||
static QString craftGroupName(int server, int exercise, const QString &groupName) { return craftBaseName(QString::number(server), QString::number(exercise)) + groupName; }
|
||||
static QString craftServiceName(int server, int exercise, const QString &groupName, int serviceId) { return craftGroupName(server, exercise, groupName) + QLatin1Char('.') + QString::number(serviceId); }
|
||||
static QString craftWildcardedServiceName(int serviceId) { return craftBaseName(QLatin1String("*"), QLatin1String("*")) + QString::number(serviceId); }
|
||||
|
||||
Ui::ServiceManagementDialog *m_ui;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private slots:
|
||||
void slotRestartService(int serviceID);
|
||||
void slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
void slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
void slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
|
||||
|
||||
void slotGroupInformationChanged(ServiceManagement::GroupInformation, DataModification);
|
||||
void slotServiceInformationChanged(ServiceManagement::ServiceInformation, DataModification);
|
||||
};
|
||||
}
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ServiceManagementDialog</class>
|
||||
<widget class="QWidget" name="ServiceManagementDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Service Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbServer">
|
||||
<property name="text">
|
||||
<string>Server:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="cbServer">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbExercise">
|
||||
<property name="text">
|
||||
<string>Exercise:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbExercise">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbNoServices">
|
||||
<property name="text">
|
||||
<string>There are no Services available to view.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbGroupsIndicator">
|
||||
<property name="text">
|
||||
<string>Groups of 'Server.Exercise':</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="groupLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>588</width>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#include "scm_dialog.h"
|
||||
#include "scm_dialog_group.h"
|
||||
#include "ui_scm_dialog_group.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
GroupWidget::GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
|
||||
int32_t replayPartitionId,
|
||||
const QString &groupName /* TODO: groupName not needed */, long long timestamp,
|
||||
const QVector<int> &neededServices, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::GroupWidget)
|
||||
, m_status(ServiceWidget::UNKNOWN)
|
||||
, m_server(server)
|
||||
, m_exercise(exercise)
|
||||
, m_groupName(groupName)
|
||||
, m_replayPartitionId(replayPartitionId)
|
||||
, m_neededServices(neededServices)
|
||||
{
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbRestart, &QToolButton::clicked, this, &GroupWidget::slotRestartGroup);
|
||||
connect(m_ui->pbStart, &QToolButton::clicked, this, &GroupWidget::slotStartGroup);
|
||||
connect(m_ui->pbStop, &QToolButton::clicked, this, &GroupWidget::slotStopGroup);
|
||||
|
||||
setType(groupType);
|
||||
setServer(server);
|
||||
setExercise(exercise);
|
||||
setTimestamp(timestamp);
|
||||
|
||||
if (getStatus() != ServiceWidget::STOPPED) // when not stopped (but unknown), then set as STARTED
|
||||
setStatus(ServiceWidget::STARTED);
|
||||
}
|
||||
|
||||
|
||||
GroupWidget::~GroupWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::addService(ServiceWidget *service)
|
||||
{
|
||||
m_ui->lbNoServices->hide(); // min. 1 service available
|
||||
|
||||
//qWarning() << "GroupWidget::addService: ";
|
||||
|
||||
if (m_neededServices.contains(service->id())) // does this group need this service?
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: service needed";
|
||||
|
||||
if (!findChild<ServiceWidget *>(service->objectName())) // and the service was not found?
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: service currently not found, adding it";
|
||||
|
||||
m_ui->servicesLayout->addWidget(service);
|
||||
checkStatus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//qWarning() << "GroupWidget::addService: I do not need" << service->id() << ", i need" << m_neededServices;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::checkStatus()
|
||||
{
|
||||
// get all service widgets from THIS widget and check our status by their status
|
||||
|
||||
m_status = ServiceWidget::UNKNOWN; // reset status
|
||||
|
||||
|
||||
const QList<ServiceWidget *> serviceList = findChildren<ServiceWidget *>();
|
||||
|
||||
if (serviceList.isEmpty())
|
||||
m_ui->lbNoServices->show(); // no services left (after deleting)
|
||||
|
||||
for (const ServiceWidget *serviceWidget : serviceList)
|
||||
{
|
||||
if (serviceWidget->getStatus() != ServiceWidget::STARTED)
|
||||
setStatus(ServiceWidget::STOPPED); // when a single service is not started, the whole group is stopped (or ERROR?)
|
||||
}
|
||||
|
||||
if (getStatus() != ServiceWidget::STOPPED) // when not stopped (but unknown), then set as STARTED
|
||||
setStatus(ServiceWidget::STARTED);
|
||||
}
|
||||
|
||||
|
||||
ServiceWidget::Status GroupWidget::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::setStatus(ServiceWidget::Status status)
|
||||
{
|
||||
m_status = status;
|
||||
|
||||
QString newCss;
|
||||
switch (m_status)
|
||||
{
|
||||
case ServiceWidget::STARTED:
|
||||
newCss = QLatin1String("background-color: rgb(124, 189, 124);");
|
||||
break;
|
||||
case ServiceWidget::STOPPED:
|
||||
newCss = QLatin1String("background-color: rgb(189, 106, 98);");
|
||||
break;
|
||||
case ServiceWidget::STARTING:
|
||||
case ServiceWidget::STOPPING:
|
||||
case ServiceWidget::UNKNOWN:
|
||||
break;
|
||||
}
|
||||
m_ui->frStatus->setStyleSheet(newCss);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotRestartGroup()
|
||||
{
|
||||
emit signalRestartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotStartGroup()
|
||||
{
|
||||
emit signalStartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::slotStopGroup()
|
||||
{
|
||||
emit signalStopGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
|
||||
}
|
||||
|
||||
|
||||
void GroupWidget::setType(Core::ServiceGroupType type)
|
||||
{
|
||||
m_groupType = type;
|
||||
m_ui->lbGroupName->setText(QStringLiteral("<html><head/><body><p>%1<span style='font-weight:600;'> %2</span></p></body></html>")
|
||||
.arg(tr("Services of %1").arg(ServiceManagement::ServiceManagementDialog::groupEnumToGroupName(type)), m_groupName));
|
||||
}
|
||||
|
||||
void GroupWidget::setServer(int server)
|
||||
{
|
||||
m_server = server;
|
||||
}
|
||||
|
||||
void GroupWidget::setExercise(int exercise)
|
||||
{
|
||||
m_exercise = exercise;
|
||||
}
|
||||
|
||||
void GroupWidget::setTimestamp(long long timestamp)
|
||||
{
|
||||
if (timestamp < 1)
|
||||
{
|
||||
m_ui->lbTimestamp->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->lbTimestamp->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
|
||||
.arg(tr("Last Heartbeat"), QDateTime::fromMSecsSinceEpoch(timestamp).toString()));
|
||||
}
|
||||
} // namespace ServiceManagement
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "scm_dialog_service.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class GroupWidget;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
class GroupWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
|
||||
int32_t replayPartitionId,
|
||||
const QString &groupName, long long timestamp,
|
||||
const QVector<int> &neededServices, QWidget *parent = nullptr);
|
||||
~GroupWidget();
|
||||
|
||||
void addService(ServiceWidget *service);
|
||||
|
||||
void setType(Core::ServiceGroupType type); // sets group name
|
||||
void setServer(int server);
|
||||
void setExercise(int exercise);
|
||||
void setTimestamp(long long timestamp);
|
||||
|
||||
ServiceWidget::Status getStatus() const;
|
||||
void setStatus(ServiceWidget::Status status);
|
||||
|
||||
void checkStatus();
|
||||
|
||||
private:
|
||||
Ui::GroupWidget *m_ui;
|
||||
ServiceWidget::Status m_status;
|
||||
Core::ServiceGroupType m_groupType;
|
||||
int m_server;
|
||||
int m_exercise;
|
||||
QString m_groupName;
|
||||
int32_t m_replayPartitionId;
|
||||
QVector<int> m_neededServices;
|
||||
|
||||
private slots:
|
||||
void slotRestartGroup();
|
||||
void slotStartGroup();
|
||||
void slotStopGroup();
|
||||
|
||||
signals:
|
||||
void signalRestartGroup(const Core::ServiceGroupType &groupType, int, int, int32_t replayPartitionId);
|
||||
void signalStartGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
|
||||
void signalStopGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
|
||||
};
|
||||
} // namespace ServiceManagement
|
||||
Executable
+222
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GroupWidget</class>
|
||||
<widget class="QWidget" name="GroupWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>55</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbGroupName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbTimestamp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbRestart">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Restart this Group of Services (Restarts every Service inside this Group)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/arrow_back.svg</normaloff>:/style/arrow_back.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbStart">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Start this Group of Services (Starts Services inside this Group, that are currently stopped)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">S</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/media-play-slower.svg</normaloff>:/style/media-play-slower.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbStop">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Stop this Group of Services (Stops Services inside this Group, that are currently running / started)</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">E</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/application-exit.svg</normaloff>:/style/application-exit.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="servicesLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbNoServices">
|
||||
<property name="text">
|
||||
<string>No Services available in this Group.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#include "scm_dialog_service.h"
|
||||
#include "ui_scm_dialog_service.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
ServiceWidget::ServiceWidget(int32_t id, long long pid, const QString &name,
|
||||
const Core::RunningState &state, const QString &errorString, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ServiceWidget)
|
||||
, m_status(ServiceWidget::UNKNOWN)
|
||||
, m_id(id)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbRestart, &QToolButton::clicked, this, &ServiceWidget::slotRestartService);
|
||||
|
||||
setName(name);
|
||||
setPid(pid);
|
||||
setErrorString(errorString);
|
||||
setState(state);
|
||||
}
|
||||
|
||||
|
||||
ServiceWidget::~ServiceWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setName(const QString &name)
|
||||
{
|
||||
m_ui->lbServiceName->setText(name);
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setPid(long long pid)
|
||||
{
|
||||
m_ui->lbPID->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
|
||||
.arg(tr("Process ID")).arg(pid));
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setTimestamp(long long timestamp)
|
||||
{
|
||||
if (timestamp < 1)
|
||||
{
|
||||
m_ui->lbTimestamp->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->lbTimestamp->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
|
||||
.arg(tr("Last Heartbeat"), QDateTime::fromMSecsSinceEpoch(timestamp).toString()));
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setErrorString(const QString &errorString)
|
||||
{
|
||||
if (errorString.isEmpty())
|
||||
{
|
||||
m_ui->lbError->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->lbError->setText(QStringLiteral("<html><head/><body><p><span style='color:#aa0000;'>%1:<br/>%2</span></p></body></html>").arg(tr("Error"), errorString));
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setState(Core::RunningState state)
|
||||
{
|
||||
auto status = ServiceWidget::UNKNOWN;
|
||||
switch (state.underlying())
|
||||
{
|
||||
// STARTING
|
||||
case Core::RunningState::inner_enum::Starting:
|
||||
status = ServiceWidget::STARTING;
|
||||
break;
|
||||
|
||||
// STARTED
|
||||
case Core::RunningState::inner_enum::Running:
|
||||
status = ServiceWidget::STARTED;
|
||||
break;
|
||||
|
||||
// STOPPING
|
||||
case Core::RunningState::inner_enum::Stopping:
|
||||
status = ServiceWidget::STOPPING;
|
||||
break;
|
||||
|
||||
// STOPPED
|
||||
case Core::RunningState::inner_enum::StartingError:
|
||||
case Core::RunningState::inner_enum::NotYetStarted:
|
||||
case Core::RunningState::inner_enum::StoppedNormally:
|
||||
case Core::RunningState::inner_enum::StoppedError: // FIXME: how does that look like? was STARTED but is not stoppable and still STARTED?
|
||||
status = ServiceWidget::STOPPED;
|
||||
break;
|
||||
}
|
||||
setStatus(status);
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::setStatus(const Status status)
|
||||
{
|
||||
m_status = status;
|
||||
|
||||
switch (m_status)
|
||||
{
|
||||
case ServiceWidget::STARTED:
|
||||
m_ui->frStatus->setStyleSheet(greenStyleSheet());
|
||||
break;
|
||||
|
||||
case ServiceWidget::STOPPED:
|
||||
m_ui->frStatus->setStyleSheet(redStyleSheet());
|
||||
break;
|
||||
|
||||
default:
|
||||
m_ui->frStatus->setStyleSheet(orangeStyleSheet());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ServiceWidget::Status ServiceWidget::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
void ServiceWidget::slotRestartService()
|
||||
{
|
||||
emit signalRestartService(m_id);
|
||||
}
|
||||
} // namespace ServiceManagement
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <ServiceManagement/scm_dtc.h> // for Core::RunningState
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ServiceWidget;
|
||||
}
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
class ServiceWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Status
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
STARTING,
|
||||
STARTED,
|
||||
STOPPING,
|
||||
STOPPED,
|
||||
};
|
||||
|
||||
ServiceWidget(int32_t id, long long pid, const QString &name,
|
||||
const Core::RunningState &state, const QString &errorString, QWidget *parent = nullptr);
|
||||
~ServiceWidget();
|
||||
|
||||
void setPid(long long pid);
|
||||
void setName(const QString &name);
|
||||
void setTimestamp(long long timestamp);
|
||||
void setState(Core::RunningState state);
|
||||
void setErrorString(const QString &errorString);
|
||||
|
||||
|
||||
void setStatus(const Status status);
|
||||
Status getStatus() const;
|
||||
int32_t id() const { return m_id; }
|
||||
|
||||
private:
|
||||
Ui::ServiceWidget *m_ui;
|
||||
Status m_status;
|
||||
int32_t m_id;
|
||||
|
||||
static QString greenStyleSheet() { return QLatin1String("background-color: rgb(124, 189, 124);"); }
|
||||
static QString orangeStyleSheet() { return QLatin1String("background-color: rgb(212, 190, 128);"); }
|
||||
static QString redStyleSheet() { return QLatin1String("background-color: rgb(202, 122, 122);"); }
|
||||
|
||||
signals:
|
||||
void signalRestartService(int id);
|
||||
|
||||
private slots:
|
||||
void slotRestartService();
|
||||
};
|
||||
} // namespace ServiceManagement
|
||||
Executable
+234
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ServiceWidget</class>
|
||||
<widget class="QWidget" name="ServiceWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>767</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbServiceName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Service Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbRestart">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>28</horstretch>
|
||||
<verstretch>28</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Restart Service</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/arrow_back.svg</normaloff>:/style/arrow_back.svg</iconset>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbTimestamp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbPID">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbError">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
qt6-after/qt6-migrated-legatus/Lts/Plugins/ServiceManagement/Gui/ServiceEdit/scm_edit_gui_plugin.cpp
Executable
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#include "scm_edit_gui_plugin.h"
|
||||
#include "scm_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/ServiceManagement/scm_operator_rights.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Scm.Edit"))
|
||||
, m_dtcExm(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ExerciseManagement::DataInterface>(m_dtcExm))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
}
|
||||
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Services");
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Service Management");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:service.svg"));
|
||||
plData.identifier = QLatin1String("scmServiceEdit");
|
||||
plData.operatorRight = OperatorRights::ServicesEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
m_dtc->enableGroupInformation();
|
||||
m_dtc->enableServiceInformation();
|
||||
|
||||
m_ftc->enableRestartService();
|
||||
|
||||
m_ftc->enableStopGroup();
|
||||
m_ftc->enableStartGroup();
|
||||
m_ftc->enableRestartGroup();
|
||||
|
||||
return LtsWidgets::initDialog(new ServiceManagementDialog(parent),
|
||||
m_dtc, m_ftc, m_dtcExm);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace ServiceManagement
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <ServiceManagement/logger.h>
|
||||
#include <ServiceManagement/scm_ftc.h>
|
||||
#include <ServiceManagement/scm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <Plugins/ServiceManagement/scm_data_plugin_interface.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:scm")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("ServiceManagement"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Global);
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Global; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
|
||||
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ServiceManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <ServiceManagement/scm_dtc.h>
|
||||
#include <ServiceManagement/scm_ftc.h>
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
using DataPluginBase::Interface::Interface;
|
||||
|
||||
virtual std::shared_ptr<ServiceManagement::Interface::Dtc> getDtc() = 0;
|
||||
virtual std::shared_ptr<ServiceManagement::Interface::Ftc> getFtc() = 0;
|
||||
};
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ServiceManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ServiceManagement
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
};
|
||||
|
||||
} // namespace ServiceManagement
|
||||
+63
-54
@@ -1,24 +1,29 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for SituationReplayManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
|
||||
#include "srm_data_plugin.h"
|
||||
#include <utility>
|
||||
|
||||
#include <Core/core_dtc.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <SituationReplayManagement/srm_ftc.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
||||
#include <Core/core_dts_types.h>
|
||||
#include <DDS/Core/core_dts_types.h>
|
||||
#include <DDS/DTS/generic_dts_impl.h>
|
||||
#include <SituationReplayManagement/logger.h>
|
||||
#include <LtsUtils/LtsUtilsCore/await.h>
|
||||
#include <LtsUtilsCore/await.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QPointer>
|
||||
#include <QProcess>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace SituationReplayManagement
|
||||
@@ -44,14 +49,14 @@ public:
|
||||
|
||||
void addSession(ForeignInterfaceImpl *fi, int partitionId)
|
||||
{
|
||||
|
||||
// next 4 lines: comment please
|
||||
m_references += fi;
|
||||
for (const auto &info : std::as_const(m_replayPartitions))
|
||||
for (const auto &info : qAsConst(m_replayPartitions))
|
||||
{
|
||||
fi->write(info);
|
||||
}
|
||||
|
||||
|
||||
// take ownership of 'own' replays
|
||||
for (auto it = m_replayPartitions.begin(); it != m_replayPartitions.end(); ++it)
|
||||
{
|
||||
ReplayPartitionEx &rp = it.value();
|
||||
@@ -67,7 +72,7 @@ public:
|
||||
void removeSession(ForeignInterfaceImpl *fi, bool wait = true) noexcept(false)
|
||||
{
|
||||
m_references -= fi;
|
||||
for (const auto &info : std::as_const(m_replayPartitions))
|
||||
for (const auto &info : qAsConst(m_replayPartitions))
|
||||
fi->remove(info);
|
||||
|
||||
replayPartitionRemoveRequest(fi, 0, 0, 0, wait);
|
||||
@@ -78,11 +83,11 @@ public:
|
||||
int exerciseId, int workstationId, int operatorId, Core::ReplayType replayType, bool wait = true) noexcept(false)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// clarification need for: domainId, partitionId, replayId, idToUse... : same or different?
|
||||
// 'idToUse will become replayPartitionId'
|
||||
// assume: replayId == partitionId == replayPartitionId == idToUse
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " START"
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " START"
|
||||
<< ", domainId = " << domainId
|
||||
<< ", domainIdReplay = " << domainIdReplay
|
||||
<< ", tcpConnectionUrl = " << tcpConnectionUrl.toDisplayString()
|
||||
@@ -92,13 +97,13 @@ public:
|
||||
<< ", replayType = " << replayType
|
||||
<< ", wait = " << wait;
|
||||
|
||||
|
||||
// find free replay id
|
||||
QSet<int> keys;
|
||||
for (auto it = m_replayPartitions.constBegin(); it != m_replayPartitions.constEnd(); ++it)
|
||||
keys += it.key();
|
||||
|
||||
int idToUse = -1;
|
||||
for (int i = 1; i < 20; ++i)
|
||||
for (int i = 1; i < 20; ++i) // why 20??
|
||||
{
|
||||
if (keys.contains(i))
|
||||
continue;
|
||||
@@ -107,10 +112,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " idToUse = " << idToUse;
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " idToUse = " << idToUse;
|
||||
|
||||
|
||||
|
||||
// found a valid one
|
||||
if (idToUse > 0)
|
||||
{
|
||||
ReplayPartitionEx repl;
|
||||
@@ -158,14 +163,14 @@ public:
|
||||
|
||||
m_replayPartitions.insert(idToUse, repl);
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " repl.proc->start()...";
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " repl.proc->start()...";
|
||||
repl.proc->start();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " repl.proc->start()...DONE";
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " repl.proc->start()...DONE";
|
||||
|
||||
if (wait)
|
||||
{
|
||||
|
||||
|
||||
//#define APPROACH_AWAIT_BY_MIKE
|
||||
#ifdef APPROACH_AWAIT_BY_MIKE
|
||||
try
|
||||
{
|
||||
@@ -183,12 +188,12 @@ public:
|
||||
&QProcess::started,
|
||||
repl.proc,
|
||||
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||
60 * 1000);
|
||||
60 * 1000); // 1 min
|
||||
NOTICE_LOG(m_logger) << " LtsUtils::awaitWithCancelationSignal ... DONE";
|
||||
|
||||
processStarted(proc, idToUse);
|
||||
DEBUG_LOG(m_logger) << "Replay started: " << idToUse;
|
||||
return idToUse;
|
||||
return idToUse; // <-- return
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
@@ -198,30 +203,30 @@ public:
|
||||
catch (...)
|
||||
{
|
||||
fprintf(stderr, "awaitWithCancelationSignal has thrown an error ...\n");
|
||||
}
|
||||
} // catch
|
||||
|
||||
#else
|
||||
|
||||
#else // APPROACH_AWAIT_BY_MIKE
|
||||
// rebuild by former version... hopefully it works:
|
||||
|
||||
const bool bIsStartedSuccessfully = repl.proc->waitForStarted(7500);
|
||||
const bool bIsStartedSuccessfully = repl.proc->waitForStarted(7500); // Qt docu: Returns true if the process was started successfully;
|
||||
if (bIsStartedSuccessfully)
|
||||
{
|
||||
processStarted(proc, idToUse);
|
||||
DEBUG_LOG(m_logger) << "Replay started: " << idToUse;
|
||||
return idToUse;
|
||||
return idToUse; // <-- return
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// cleanup:
|
||||
idToUse = -1;
|
||||
wait = false;
|
||||
if (repl.proc)
|
||||
repl.proc->deleteLater();
|
||||
|
||||
|
||||
m_replayPartitions[idToUse].proc = nullptr;
|
||||
repl.proc->deleteLater(); // repl.proc is a QPointer
|
||||
// repl.proc = nullptr; // repl.proc is a QPointer
|
||||
// useless with idToUse == -1 !!??!!
|
||||
m_replayPartitions[idToUse].proc = nullptr; // TODO: don't use operator[] !
|
||||
}
|
||||
#endif
|
||||
#endif // APPROACH_AWAIT_BY_MIKE
|
||||
|
||||
|
||||
}
|
||||
@@ -230,9 +235,9 @@ public:
|
||||
connect(repl.proc, &QProcess::started,
|
||||
this, [this, proc, idToUse]() { processStarted(proc, idToUse); } );
|
||||
}
|
||||
}
|
||||
} // if (idToUse > 0)
|
||||
|
||||
|
||||
// didn't find a valid one!
|
||||
|
||||
if (wait)
|
||||
{
|
||||
@@ -257,7 +262,7 @@ public:
|
||||
}
|
||||
|
||||
const auto &rp = it.value();
|
||||
for (auto ptr : std::as_const(m_references))
|
||||
for (auto ptr : qAsConst(m_references))
|
||||
ptr->remove(rp);
|
||||
|
||||
proc->deleteLater();
|
||||
@@ -276,7 +281,7 @@ public:
|
||||
}
|
||||
|
||||
const ReplayPartitionEx &rp = it.value();
|
||||
for (ForeignInterfaceImpl* ptr : std::as_const(m_references))
|
||||
for (ForeignInterfaceImpl* ptr : qAsConst(m_references))
|
||||
ptr->write(rp);
|
||||
}
|
||||
|
||||
@@ -341,21 +346,21 @@ public:
|
||||
cb();
|
||||
}
|
||||
}
|
||||
else
|
||||
else // dont wait
|
||||
{
|
||||
QTimer::singleShot(10000, rp.proc, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto *ptr : std::as_const(m_references))
|
||||
for (auto *ptr : qAsConst(m_references))
|
||||
ptr->remove(rp);
|
||||
|
||||
it = m_replayPartitions.erase(it);
|
||||
bFoundOne = true;
|
||||
}
|
||||
|
||||
|
||||
// workstationId / operatorId are wildcard operations which may find nothing which is ok
|
||||
if (partitionId == 0)
|
||||
bFoundOne = true;
|
||||
|
||||
@@ -377,7 +382,7 @@ public:
|
||||
return sessionConnector;
|
||||
}
|
||||
|
||||
int domainId = 1;
|
||||
int domainId = 1; // ok since we are using ShmUdpLocalhost
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId,
|
||||
IDL::PartitionType::Exercise,
|
||||
sessionConnector->getPartitionId(),
|
||||
@@ -410,15 +415,17 @@ public:
|
||||
private:
|
||||
struct ReplayPartitionEx : public Core::ReplayPartition
|
||||
{
|
||||
QPointer<QProcess> proc;
|
||||
QPointer<QProcess> proc; // = nullptr;
|
||||
ForeignInterfaceImpl *fi = nullptr;
|
||||
};
|
||||
|
||||
QMap<int, ReplayPartitionEx> m_replayPartitions;
|
||||
QMap<int, ReplayPartitionEx> m_replayPartitions; // idToUse - ReplayPartitionEx
|
||||
QSet<ForeignInterfaceImpl*> m_references;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<DTS::ReplayPartition> m_replayPartion;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
|
||||
@@ -448,6 +455,7 @@ ForeignInterfaceImpl::ForeignInterfaceImpl(const std::shared_ptr<ReplayHandler>
|
||||
LtsSession::LtsSessionDataDds *session)
|
||||
: m_replayHandler(replayHandler)
|
||||
, m_session(session)
|
||||
, m_logger(getLogger("ForeignInterfaceImpl"))
|
||||
{
|
||||
if (m_session->partitionType() == IDL::PartitionType::Exercise ||
|
||||
m_session->partitionType() == IDL::PartitionType::Replay)
|
||||
@@ -456,7 +464,7 @@ ForeignInterfaceImpl::ForeignInterfaceImpl(const std::shared_ptr<ReplayHandler>
|
||||
|
||||
ForeignInterfaceImpl::~ForeignInterfaceImpl()
|
||||
{
|
||||
m_replayHandler->removeSession(this, false );
|
||||
m_replayHandler->removeSession(this, false /* dont' wait for replay service to quit */);
|
||||
}
|
||||
|
||||
void ForeignInterfaceImpl::removeReplayPartitionsWorkstation(const int workstationId) noexcept(false)
|
||||
@@ -496,14 +504,15 @@ int ForeignInterfaceImpl::replayPartitionCreateRequest(int exerciseId, int works
|
||||
int domainId = m_session->domainId();
|
||||
if (m_session->isReplayPartition())
|
||||
{
|
||||
|
||||
|
||||
/* starting a replay partition from a replay partition would normally inc the
|
||||
* domainId to the already inc'd domainId - dec the already inc'd domain id
|
||||
* to keep the same domainId for every replay partition */
|
||||
if (domainId == 1)
|
||||
domainId= 199;
|
||||
else
|
||||
domainId--;
|
||||
}
|
||||
int domainIdReplay = (domainId % 200) + 1;
|
||||
int domainIdReplay = (domainId % 200) + 1; // mod aka "if (domainId > 200) domainId = 0;" - domainIds can never be > 199
|
||||
|
||||
|
||||
return m_replayHandler->replayPartitionCreateRequest(domainId, domainIdReplay,
|
||||
@@ -525,6 +534,6 @@ void ForeignInterfaceImpl::remove(const Core::ReplayPartition &repl)
|
||||
m_replayHandler->dtsReplay(m_session->ddsConnector())->remove(repl);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace SituationReplayManagement
|
||||
|
||||
#include "srm_data_plugin.moc"
|
||||
+18
-13
@@ -1,15 +1,21 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SituationReplayManagement - Marker Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplayManagement/srm_ftc.h>
|
||||
#include <SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <SituationReplayManagement/logger.h>
|
||||
#include <Core/core_dtc.h>
|
||||
#include <Services/SituationReplayManagement/srm_ftc.h>
|
||||
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <Services/SituationReplayManagement/logger.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
@@ -20,9 +26,9 @@ class SituationReplayManagementDialog;
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
class ReplayPartitionDialogModel;
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// SituationReplayManagementDialog
|
||||
// --------------------------------------------------------
|
||||
class SituationReplayManagementDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ReplayPartitionCreateReplyHandler
|
||||
, protected Interface::Ftc::ReplayPartitionRemoveReplyHandler
|
||||
@@ -47,9 +53,6 @@ private slots:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
@@ -58,5 +61,7 @@ NGL::INGLLogger &m_logger;
|
||||
Ui::SituationReplayManagementDialog *m_ui;
|
||||
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> m_srmForeign;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
+13
-8
@@ -1,19 +1,25 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SituationReplayManagement - Replay Partition Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplayManagement/srm_dtc.h>
|
||||
#include <Core/core_dtc.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <SituationReplayManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ReplayPartitionDialogModel
|
||||
// --------------------------------------------------------
|
||||
class ReplayPartitionDialogModel final : public LtsWidgets::LtsAbstractTableModel<Core::ReplayPartition>
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -38,8 +44,6 @@ public:
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override final;
|
||||
|
||||
protected:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool isFiltered(const Core::ReplayPartition &data, DataModification modType) const override
|
||||
{
|
||||
if (data.exerciseId() != m_partitionid)
|
||||
@@ -49,5 +53,6 @@ NGL::INGLLogger &m_logger;
|
||||
private:
|
||||
int m_partitionid;
|
||||
std::shared_ptr<Core::Interface::Dtc> m_dtc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
+17
-8
@@ -1,11 +1,17 @@
|
||||
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin Interface for SituationReplayManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <SituationReplayManagement/srm_ftc.h>
|
||||
#include <Core/core_dtc.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
@@ -19,8 +25,9 @@ class Dtc;
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
class ForeignDataInterface;
|
||||
|
||||
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
@@ -30,8 +37,10 @@ public:
|
||||
virtual std::shared_ptr<ForeignDataInterface> getForeignDataInterface() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief The ForeignInterface class provides methods and signals for foreign plugins, that need
|
||||
* access to the data of this DataPlugin
|
||||
*/
|
||||
class ForeignDataInterface
|
||||
{
|
||||
public:
|
||||
@@ -44,4 +53,4 @@ public:
|
||||
virtual int replayPartitionCreateRequest(int exerciseId, int workstationId, int operatorId, Core::ReplayType replayType) noexcept(false) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} //namespace SituationReplayManagement
|
||||
Reference in new issue
Block a user