Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,107 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-05-05
|
||||
#
|
||||
|
||||
SET(participant_info_gui_SRCS
|
||||
participant_info_gui_plugin.cpp
|
||||
participant_info_gui_plugin.h
|
||||
participant_info_dialog.cpp
|
||||
participant_info_dialog.h
|
||||
participant_info_ltd_gear_component.cpp
|
||||
participant_info_ltd_gear_component.h
|
||||
participant_config_dialog.h
|
||||
participant_config_dialog.cpp
|
||||
participant_config_model.cpp
|
||||
participant_config_model.h
|
||||
participant_bite_dialog.h
|
||||
participant_bite_dialog.cpp
|
||||
participant_history_dialog.cpp
|
||||
participant_history_dialog.h
|
||||
participant_history_dialog_model.cpp
|
||||
participant_history_dialog_model.h
|
||||
participant_info_helper.h
|
||||
participant_info_table_dialog.cpp
|
||||
participant_info_table_dialog.h
|
||||
participant_info_table_model.cpp
|
||||
participant_info_table_model.h
|
||||
participant_info_table_add_dialog.cpp
|
||||
participant_info_table_add_dialog.h
|
||||
participants_mounted_table_dialog.cpp
|
||||
participants_mounted_table_dialog.h
|
||||
participants_mounted_table_model.cpp
|
||||
participants_mounted_table_model.h
|
||||
participant_search_dialog.h
|
||||
participant_search_dialog.cpp
|
||||
participant_hitline_info_dialog.h
|
||||
participant_hitline_info_dialog.cpp
|
||||
participant_follow_dialog.h
|
||||
participant_follow_dialog.cpp
|
||||
participant_set_injury_dialog.h
|
||||
participant_set_injury_dialog.cpp
|
||||
participant_set_sanitation_dialog.h
|
||||
participant_set_sanitation_dialog.cpp
|
||||
participant_gear_restock.h
|
||||
participant_gear_restock.cpp
|
||||
participant_gear_restock_charge.h
|
||||
participant_gear_restock_charge.cpp
|
||||
participant_search_widget.cpp
|
||||
participant_search_widget.h
|
||||
participant_target_config_dialog.h
|
||||
participant_target_config_dialog.cpp
|
||||
participant_shootback_area_model.h
|
||||
participant_shootback_area_model.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(participant_info_gui_SRCS
|
||||
participant_info_dialog.ui
|
||||
participant_history_dialog.ui
|
||||
participant_config_dialog.ui
|
||||
participant_bite_dialog.ui
|
||||
participant_info_table_dialog.ui
|
||||
participant_info_table_add_dialog.ui
|
||||
participants_mounted_table_dialog.ui
|
||||
participant_search_dialog.ui
|
||||
participant_hitline_info_dialog.ui
|
||||
participant_follow_dialog.ui
|
||||
participant_set_injury_dialog.ui
|
||||
participant_set_sanitation_dialog.ui
|
||||
participant_gear_restock.ui
|
||||
participant_gear_restock_charge.ui
|
||||
participant_search_widget.ui
|
||||
participant_target_config_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS PpmParticipantInfoGuiPlugin MODULE ${participant_info_gui_SRCS})
|
||||
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
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(PpmParticipantInfoGuiPlugin)
|
||||
|
||||
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - ParticipantBiteDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#include "participant_bite_dialog.h"
|
||||
#include "ui_participant_bite_dialog.h"
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
ParticipantBiteDialog::ParticipantBiteDialog(int ddsId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ddsId(ddsId)
|
||||
, m_eqipNr(-1)
|
||||
, m_fromDetailData(false)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(nullptr)
|
||||
, m_layout(nullptr)
|
||||
, m_ui(new Ui::ParticipantBiteDialog)
|
||||
, m_logger(getLogger("ParticipantBiteDialog"))
|
||||
, m_ccsMap()
|
||||
, m_bctMap()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setUnchangeable();
|
||||
}
|
||||
|
||||
ParticipantBiteDialog::~ParticipantBiteDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantBiteDialog::retranslate()
|
||||
{
|
||||
QString id(tr("<UNKNOWN>"));
|
||||
if (m_eqipNr > 0)
|
||||
id = QString::number(m_eqipNr);
|
||||
|
||||
translate(m_ui, id, false, tr("BITE Participant"));
|
||||
}
|
||||
|
||||
bool ParticipantBiteDialog::init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
bool bBiteWithSelfTest,
|
||||
const QJsonObject &detailData)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_pdmDtc = pdmDtc;
|
||||
|
||||
if (!m_dtc || !m_ftc || !pdmDtc)
|
||||
return false;
|
||||
|
||||
m_ccsMap = pdmDtc->canComponentStrings();
|
||||
m_bctMap = pdmDtc->biteComponentTexts();
|
||||
|
||||
if (detailData.isEmpty())
|
||||
{
|
||||
Participant participant = m_dtc->participant(m_ddsId);
|
||||
if (participant.equipmentNumber().is_set())
|
||||
m_eqipNr = participant.equipmentNumber().get();
|
||||
|
||||
//start a new request
|
||||
connect(m_dtc.get(), &Interface::Dtc::biteChanged, this, &ParticipantBiteDialog::onBiteChanged);
|
||||
CallBiteRequest req(bBiteWithSelfTest, {m_ddsId});
|
||||
|
||||
if (!m_requestHelper)
|
||||
m_requestHelper = new LtsUtils::RequestHelper(this);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->callBiteRequest(req, this);
|
||||
});
|
||||
|
||||
//we may show old values when the timestamp is set.
|
||||
}
|
||||
else // take Bite from the apple, uh, the detail data
|
||||
{
|
||||
m_fromDetailData = true;
|
||||
|
||||
const QJsonArray biteErrors(detailData[QStringLiteral("BiteErrors")].toArray());
|
||||
|
||||
Bite bite;
|
||||
bite.batteryState(detailData[QStringLiteral("BatteryState")].toInt());
|
||||
bite.biteState(detailData[QStringLiteral("BiteState")].toInt());
|
||||
bite.configState(detailData[QStringLiteral("ConfigState")].toInt());
|
||||
|
||||
BiteError biteError;
|
||||
bite.biteErrors().reserve(biteErrors.size());
|
||||
for (const QJsonValue &biteErrorValue : biteErrors)
|
||||
{
|
||||
const QJsonObject biteErrorObject(biteErrorValue.toObject());
|
||||
biteError.errorNumber(biteErrorObject[QStringLiteral("ErrorNo")].toInt());
|
||||
biteError.canDeviceNumber(biteErrorObject[QStringLiteral("CanDeviceNumber")].toInt());
|
||||
biteError.subdeviceNumber(biteErrorObject[QStringLiteral("SubdeviceNumber")].toInt());
|
||||
biteError.uniqueId(biteErrorObject[QStringLiteral("UniqueId")].toInt());
|
||||
|
||||
bite.biteErrors().push_back(biteError);
|
||||
}
|
||||
onBiteChanged(bite);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//private
|
||||
|
||||
int ParticipantBiteDialog::checkArguments(bool available, bool statusOk, qint64 bitValue, int i)
|
||||
{
|
||||
QString name;
|
||||
for (const ProjectDataManagement::CanComponentString &ccs : qAsConst(m_ccsMap))
|
||||
{
|
||||
if (ccs.bitMask() == bitValue)
|
||||
{
|
||||
name = m_pdmDtc->trCanComponentStringName(ccs.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (available)
|
||||
{
|
||||
addLabel(name, i, 0);
|
||||
if (statusOk)
|
||||
{
|
||||
addLabel(tr("Ok"), i, 1, LabelType::Ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
addLabel(tr("Error"), i, 1, LabelType::Error);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
else if (statusOk)
|
||||
{
|
||||
addLabel(name, i, 0);
|
||||
addLabel(tr("Communication error"), i, 1, LabelType::Error);
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int ParticipantBiteDialog::checkArgument(bool bError, const QString &name, int i)
|
||||
{
|
||||
if (bError)
|
||||
{
|
||||
addLabel(name, i, 0, LabelType::Error);
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void ParticipantBiteDialog::addLabel(const QString &text, int row, int column, LabelType labelType)
|
||||
{
|
||||
QLabel *label = new QLabel(text);
|
||||
|
||||
if (labelType == LabelType::Error)
|
||||
label->setStyleSheet(QLatin1String("color: rgb(255, 0, 0);font: bold;"));
|
||||
else if (labelType == LabelType::Ok)
|
||||
label->setStyleSheet(QLatin1String("color: rgb(0, 139, 0);font: bold;"));
|
||||
|
||||
m_layout->addWidget(label, row, column);
|
||||
m_internalWidgets += label;
|
||||
}
|
||||
|
||||
|
||||
//private Slots
|
||||
void ParticipantBiteDialog::onBiteChanged(const Bite &bite)
|
||||
{
|
||||
if (bite.equipmentNumber() != m_eqipNr && !m_fromDetailData)
|
||||
return;
|
||||
|
||||
m_ui->lblLastChange->setText(DTG::toStringMSec(bite.sampleTime()));
|
||||
delete m_ui->scrollAreaWidgetContents->layout();
|
||||
m_layout = new QGridLayout(m_ui->scrollAreaWidgetContents);
|
||||
|
||||
qDeleteAll(m_internalWidgets);
|
||||
m_internalWidgets.clear();
|
||||
|
||||
int row = 0;
|
||||
|
||||
for (int it = 0 ; it < 32; it++)
|
||||
{
|
||||
quint32 bitValue = 1U << it;
|
||||
row = checkArguments(((bite.biteState() & bitValue) == bitValue),
|
||||
((bite.configState() & bitValue) == bitValue), bitValue, row);
|
||||
}
|
||||
|
||||
row = checkArgument(bite.configError() != 0, tr("Configcheck error", "BITE CAN"), row);
|
||||
if (row > 0)
|
||||
m_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), row++, 0);
|
||||
row = checkArgument(bite.batteryState() != 0, tr("Battery Warning", "BITE CAN"), row);
|
||||
m_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), row++, 0);
|
||||
|
||||
for (const auto &bitEr : bite.biteErrors())
|
||||
{
|
||||
QLabel *labl = nullptr;
|
||||
if (bitEr.subdeviceNumber() != 0)
|
||||
labl = new QLabel(tr("Error: %1 \nComponent: %2 \nSubdev: %3 \nUId: %4 ")
|
||||
.arg(getErrorString(bitEr),
|
||||
getCanDeviceName(bitEr.canDeviceNumber()),
|
||||
getSubDeviceName(bitEr.subdeviceNumber()))
|
||||
.arg(QString::number( bitEr.uniqueId(), 16 ).toUpper()));
|
||||
// .arg(bitEr.uniqueId()));
|
||||
else if (bitEr.canDeviceNumber() != 0)
|
||||
labl = new QLabel(tr("Error: %1 \nComponent: %2")
|
||||
.arg(getErrorString(bitEr),
|
||||
getCanDeviceName(bitEr.canDeviceNumber())));
|
||||
|
||||
if (labl)
|
||||
{
|
||||
m_layout->addWidget(labl , row++, 0);
|
||||
m_internalWidgets.append(labl);
|
||||
}
|
||||
}
|
||||
|
||||
m_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding), row, 0);
|
||||
}
|
||||
|
||||
QString ParticipantBiteDialog::getErrorString(const ParticipantManagement::BiteError &error) const
|
||||
{
|
||||
const bool subDevice = (error.subdeviceNumber() != 0);
|
||||
for (const ProjectDataManagement::BiteComponentText &bct : m_bctMap)
|
||||
{
|
||||
if (((subDevice && bct.subDeviceId() == error.subdeviceNumber()) ||
|
||||
(bct.canDeviceId() == error.canDeviceNumber())) &&
|
||||
(bct.errorNumber() == error.errorNumber()))
|
||||
return m_pdmDtc->trBiteComponentTextName(bct.id());
|
||||
}
|
||||
return tr("Unknown (%1)").arg(error.errorNumber());
|
||||
}
|
||||
|
||||
QString ParticipantBiteDialog::getCanDeviceName(int id) const
|
||||
{
|
||||
for (const ProjectDataManagement::CanComponentString &ccs : m_ccsMap)
|
||||
{
|
||||
if (ccs.canDeviceId() == id)
|
||||
return m_pdmDtc->trCanComponentStringName(ccs.id());
|
||||
}
|
||||
return tr("Unknown (%1)").arg(id);
|
||||
}
|
||||
|
||||
QString ParticipantBiteDialog::getSubDeviceName(int id) const
|
||||
{
|
||||
for (const ProjectDataManagement::CanComponentString &ccs : m_ccsMap)
|
||||
{
|
||||
if (ccs.subDeviceId() == id)
|
||||
return m_pdmDtc->trCanComponentStringName(ccs.id());
|
||||
}
|
||||
return tr("Unknown (%1)").arg(id);
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantBiteDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
//Qt
|
||||
#include <QJsonObject>
|
||||
#include <QVector>
|
||||
#include <QGridLayout>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ParticipantBiteDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
//enum class?
|
||||
enum LabelType
|
||||
{
|
||||
Normal = 1,
|
||||
Ok,
|
||||
Error
|
||||
};
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ParticipantBiteDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantBiteDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::CallBiteReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantBiteDialog(int ddsId, QWidget *parent = nullptr);
|
||||
~ParticipantBiteDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
bool bBiteWithSelfTest,
|
||||
const QJsonObject &detailData = QJsonObject());
|
||||
|
||||
void onCallBiteReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void addLabel(const QString &text, int row, int column, LabelType labelType = LabelType::Normal);
|
||||
int checkArguments(bool available, bool statusOk, qint64 bitValue, int i);
|
||||
int checkArgument(bool bError, const QString &name, int i);
|
||||
|
||||
private Q_SLOTS :
|
||||
void onBiteChanged(const ParticipantManagement::Bite &bite);
|
||||
|
||||
private:
|
||||
QString getErrorString(const ParticipantManagement::BiteError &error) const;
|
||||
QString getCanDeviceName(int id) const;
|
||||
QString getSubDeviceName(int id) const;
|
||||
|
||||
int m_ddsId;
|
||||
int m_eqipNr;
|
||||
bool m_fromDetailData;
|
||||
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
QGridLayout *m_layout;
|
||||
QVector<QWidget *> m_internalWidgets;
|
||||
|
||||
Ui::ParticipantBiteDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
QMap<int, ProjectDataManagement::CanComponentString> m_ccsMap;
|
||||
QMap<int, ProjectDataManagement::BiteComponentText> m_bctMap;
|
||||
};
|
||||
} // namespace ParticipantInfo
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantBiteDialog</class>
|
||||
<widget class="QWidget" name="ParticipantBiteDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>290</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Participant BITE</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Last Change:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblLastChange">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>352</width>
|
||||
<height>247</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+820
@@ -0,0 +1,820 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - ParticipantConfigDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#include "participant_config_dialog.h"
|
||||
#include "ui_participant_config_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/Gui/Common/participant_vulnerability_types.h>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
int ParticipantConfigDialog::s_preselectedParty = -1;
|
||||
|
||||
ParticipantConfigDialog::ParticipantConfigDialog(int ddsId, DialogType type, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_dialogType(type)
|
||||
, m_ddsId(ddsId)
|
||||
, m_typeClass(TypeClass::Human)
|
||||
, m_model(nullptr)
|
||||
, m_maxChars(80)
|
||||
, m_eqId(0)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_pdmGuiIfc(nullptr)
|
||||
, m_ppmCbxIfc(nullptr)
|
||||
, m_stateChanged(false)
|
||||
, m_modeChanged(false)
|
||||
, m_windowTitle(tr("Set Participant Status"))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ParticipantConfigDialog)
|
||||
, m_isTarget(false)
|
||||
, m_logger(getLogger("ParticipantConfigDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->cbStatus, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->cbResetGearCharge, &QCheckBox::toggled, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->cbResetManipulation, &QCheckBox::toggled, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->cbResetMedSupplies, &QCheckBox::toggled, this, &ParticipantConfigDialog::onStateAreaChanged);
|
||||
connect(m_ui->teMail, &QPlainTextEdit::textChanged, this, &ParticipantConfigDialog::onTextChanged);
|
||||
connect(m_ui->cbLanguage, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbCheating, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbPersonalProtection, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbProtectionLevel, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbGrenadeSearchMode, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbInternationalMode, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->cbABCProtectionMode, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
|
||||
connect(m_ui->cbVest, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
|
||||
connect(m_ui->cbHelmet, &LtsWidgets::LtsComboBox::currentTextChanged, this, &ParticipantConfigDialog::onModeChanged);
|
||||
connect(m_ui->slDecontamination, &QSlider::valueChanged, this, [this](int value)
|
||||
{
|
||||
changeLabelText(m_ui->lbDecontamination, value);
|
||||
});
|
||||
connect(m_ui->slMaintenance, &QSlider::valueChanged, this, [this](int value)
|
||||
{
|
||||
changeLabelText(m_ui->lbMaintenance, value);
|
||||
});
|
||||
connect(m_ui->slMedical, &QSlider::valueChanged, this, [this](int value)
|
||||
{
|
||||
changeLabelText(m_ui->lbMedical, value);
|
||||
});
|
||||
connect(m_ui->tvParticipants, &QTreeView::clicked, this, [this]() { retranslate(); });
|
||||
|
||||
setUnchangeable(true);
|
||||
connect(this, &ParticipantConfigDialog::signalChangesReset, this, [this]()
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(true);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
|
||||
});
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(true);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantConfigDialog::slotPartyChanged);
|
||||
connect(m_ui->cbAll, &QCheckBox::toggled, this, &ParticipantConfigDialog::slotPartyChanged);
|
||||
|
||||
// maybe Add Icon?
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setText(tr("Send and Close"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setText(tr("Send"));
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(m_maxChars));
|
||||
QFontMetricsF fm(m_ui->lblCharsLeft->font());
|
||||
m_ui->lblCharsLeft->setFixedWidth(fm.width(m_ui->lblCharsLeft->text()));
|
||||
|
||||
const bool bEnableProtectionLevel = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("ProtectionLevel"));
|
||||
m_ui->lbProtectionLevel->setVisible(bEnableProtectionLevel);
|
||||
m_ui->cbProtectionLevel->setVisible(bEnableProtectionLevel);
|
||||
|
||||
const bool bEnablePersonalProtection = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("PersonalProtection"));
|
||||
m_ui->cbPersonalProtection->setVisible(bEnablePersonalProtection);
|
||||
m_ui->lbPersonalProtection->setVisible(bEnablePersonalProtection);
|
||||
|
||||
const bool bEnableCheatingCheck = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("CheatingCheck"));
|
||||
m_ui->cbCheating->setVisible(bEnableCheatingCheck);
|
||||
m_ui->lbCheating->setVisible(bEnableCheatingCheck);
|
||||
|
||||
const bool bHgrSearchMode = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantStatus"),
|
||||
QStringLiteral("HgrSearchMode"));
|
||||
m_ui->lbGrenadeSearchMode->setVisible(bHgrSearchMode);
|
||||
m_ui->cbGrenadeSearchMode->setVisible(bHgrSearchMode);
|
||||
|
||||
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
QStringLiteral("HasPvSan"));
|
||||
m_ui->cbVitality->setVisible(showPvSan);
|
||||
m_ui->lblVitality->setVisible(showPvSan);
|
||||
m_ui->cbResetMedSupplies->setVisible(showPvSan);
|
||||
if (m_dialogType == DialogType::Config)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Set_Participant_Status"));
|
||||
else if (m_dialogType == DialogType::ConfigMulti)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Set_Participant_Status_Multi"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Send_Participant_Message"));
|
||||
|
||||
bool showABCProtectionMode = strcmp(PROJECTBUILD, "commaster") == 0 ? true : false;
|
||||
m_ui->cbABCProtectionMode->setVisible(showABCProtectionMode);
|
||||
m_ui->lbABCProtectionMode->setVisible(showABCProtectionMode);
|
||||
|
||||
}
|
||||
|
||||
ParticipantConfigDialog::~ParticipantConfigDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::retranslate()
|
||||
{
|
||||
QString id;
|
||||
if (m_eqId > 0)
|
||||
id = QString::number(m_eqId);
|
||||
else if (m_ui->tvParticipants && m_ui->tvParticipants->selectionModel())
|
||||
{
|
||||
QModelIndexList idxList = m_ui->tvParticipants->selectionModel()->selectedIndexes();
|
||||
if (!idxList.isEmpty())
|
||||
id = QString::number(m_model->data(idxList.first(), Qt::DisplayRole).toInt());
|
||||
}
|
||||
|
||||
QString title = m_windowTitle;
|
||||
if (!id.isEmpty())
|
||||
title += QStringLiteral(": ") + id;
|
||||
|
||||
translate(m_ui, title);
|
||||
fillCbx();
|
||||
fillVitalityCbx();
|
||||
fillCbxWithActualValue();
|
||||
}
|
||||
|
||||
bool ParticipantConfigDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc)
|
||||
{
|
||||
bool setCurrentValues = false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
if (!m_dtc || !m_ftc)
|
||||
return false;
|
||||
m_dtc->enableParticipant();
|
||||
m_dtc->enableParticipantMode();
|
||||
m_dtc->enableDynamicParticipantData();
|
||||
m_dtc->waitForHistoricalDataDynamicParticipantData(1000);
|
||||
m_dtc->waitForHistoricalDataParticipantMode(1000);
|
||||
m_dtc->waitForHistoricalDataParticipant(1000);
|
||||
|
||||
|
||||
if (!session->getForeignGuiInterface<ProjectDataManagement::ForeignGuiInterface>(m_pdmGuiIfc))
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmCbxIfc))
|
||||
return false;
|
||||
fillVitalityCbx();
|
||||
|
||||
switch (m_dialogType)
|
||||
{
|
||||
case Config:
|
||||
m_ui->gbParticipants->hide();
|
||||
setCurrentValues = true;
|
||||
Q_FALLTHROUGH();
|
||||
case ConfigMulti:
|
||||
m_ui->gbMessage->hide();
|
||||
break;
|
||||
case Message:
|
||||
m_ui->gbParticipants->hide();
|
||||
setCurrentValues = true;
|
||||
Q_FALLTHROUGH();
|
||||
case MessageMulti:
|
||||
m_ui->gbMode->hide();
|
||||
m_ui->gbRes->hide();
|
||||
m_ui->gbState->hide();
|
||||
m_windowTitle = tr("Send Message");
|
||||
m_uiRequirements->addRequirement({ m_ui->lblTextMailBold, [this]() { return (m_ui->teMail->toPlainText().size() > 0); }});
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_ddsId > 0)
|
||||
{
|
||||
const Participant participant = m_dtc->participant(m_ddsId);
|
||||
if (participant.equipmentNumber().is_set())
|
||||
m_eqId = participant.equipmentNumber().get();
|
||||
if (!m_eqId && (m_dialogType == Config || m_dialogType == Message))
|
||||
return false;
|
||||
m_typeClass = m_dtc->type(participant.typeId()).typeClass();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_eqId = 0;
|
||||
m_typeClass = TypeClass::Unknown;
|
||||
}
|
||||
m_stateChanged = false;
|
||||
|
||||
|
||||
if (m_typeClass != TypeClass::Human && m_ddsId > 0)
|
||||
{
|
||||
m_ui->cbHelmet->setHidden(true);
|
||||
m_ui->lbHelmet->setHidden(true);
|
||||
m_ui->cbVest->setHidden(true);
|
||||
m_ui->lbVest->setHidden(true);
|
||||
m_ui->cbPersonalProtection->setHidden(true);
|
||||
m_ui->lbPersonalProtection->setHidden(true);
|
||||
m_ui->cbProtectionLevel->setHidden(true);
|
||||
m_ui->lbProtectionLevel->setHidden(true);
|
||||
m_ui->cbGrenadeSearchMode->setHidden(true);
|
||||
m_ui->lbGrenadeSearchMode->setHidden(true);
|
||||
m_ui->lbInternationalMode->setHidden(true);
|
||||
m_ui->cbInternationalMode->setHidden(true);
|
||||
m_ui->lbABCProtectionMode->setHidden(true);
|
||||
m_ui->cbABCProtectionMode->setHidden(true);
|
||||
}else if (m_typeClass == TypeClass::Human && m_ddsId > 0)
|
||||
{
|
||||
m_maxChars = 16;
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(m_maxChars));
|
||||
QFontMetricsF fm(m_ui->lblCharsLeft->font());
|
||||
m_ui->lblCharsLeft->setFixedWidth(fm.width(m_ui->lblCharsLeft->text()));
|
||||
}
|
||||
|
||||
if (m_dialogType == MessageMulti)
|
||||
{
|
||||
m_maxChars = 16;
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(m_maxChars));
|
||||
QFontMetricsF fm(m_ui->lblCharsLeft->font());
|
||||
m_ui->lblCharsLeft->setFixedWidth(fm.width(m_ui->lblCharsLeft->text()));
|
||||
}
|
||||
|
||||
m_modeChanged = false;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
m_model = new ParticipantConfigModel(this, m_dtc, asbIfc);
|
||||
if (m_dialogType == DialogType::MessageMulti || m_dialogType == DialogType::ConfigMulti)
|
||||
{
|
||||
m_ui->tvParticipants->setModel(m_model);
|
||||
connect(m_ui->tvParticipants->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ParticipantConfigDialog::onSelectionChanged);
|
||||
fillCbx();
|
||||
if (setCurrentValues == true)
|
||||
fillCbxWithActualValue();
|
||||
slotPartyChanged();
|
||||
for (int column = 0; column < m_model->columnCount(); column++)
|
||||
m_ui->tvParticipants->resizeColumnToContents(column);
|
||||
}
|
||||
|
||||
if (m_ddsId == 0)
|
||||
{
|
||||
auto cb = [this]()
|
||||
{
|
||||
if (m_ui->cbAll->isChecked())
|
||||
return true;
|
||||
return !m_ui->tvParticipants->selectionModel()->selectedRows().isEmpty();
|
||||
};
|
||||
m_uiRequirements->addRequirement({ m_ui->lbParty, cb });
|
||||
}
|
||||
// Target display:
|
||||
{
|
||||
const Participant participant = m_dtc->participant(m_ddsId);
|
||||
if (participant.equipmentNumber().is_set())
|
||||
{
|
||||
const Type type = m_dtc->type(participant.typeId());
|
||||
const EquipmentType eqType = m_dtc->equipmentType(type.equipmentTypeId());
|
||||
if (eqType.wmsTypeClass() == WmsTypeClass::TargetHuman ||
|
||||
eqType.wmsTypeClass() == WmsTypeClass::TargetVehicle)
|
||||
{
|
||||
NOTICE_LOG(m_logger) << "isTarget = true";
|
||||
m_ui->gbMode->setHidden(true);
|
||||
m_ui->gbRes->setHidden(true);
|
||||
m_isTarget = true;
|
||||
}
|
||||
}
|
||||
//UAS
|
||||
if (m_dtc->isTypeUas(participant.typeId()) && m_ddsId > 0)
|
||||
{
|
||||
m_ui->cbResetManipulation->hide();
|
||||
m_ui->cbResetGearCharge->hide();
|
||||
m_ui->gbRes->hide();
|
||||
m_ui->gbMode->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
QStringLiteral("HasPvSan"))
|
||||
&& m_typeClass == TypeClass::Human;
|
||||
m_ui->cbVitality->setVisible(showPvSan);
|
||||
m_ui->lblVitality->setVisible(showPvSan);
|
||||
m_ui->cbResetMedSupplies->setVisible(showPvSan && m_typeClass == TypeClass::Human);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//private
|
||||
|
||||
void ParticipantConfigDialog::slotPartyChanged()
|
||||
{
|
||||
if (m_ui->cbAll->isChecked())
|
||||
{
|
||||
m_ui->cbParty->setEnabled(false);
|
||||
m_ui->tvParticipants->setEnabled(false);
|
||||
m_model->resetModel();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbParty->setEnabled(true);
|
||||
m_ui->tvParticipants->setEnabled(true);
|
||||
int curPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = curPartyId;
|
||||
m_model->onReinitModel(curPartyId);
|
||||
m_ui->tvParticipants->expandAll();
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::onSelectionChanged()
|
||||
{
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->tvParticipants->selectionModel()->selectedIndexes();
|
||||
//bool isPureHuman = true;
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected row =" << index.row() << " column=" << index.column();
|
||||
ParticipantManagement::ParticipantData data = m_model->getParticipantData(index);
|
||||
TypeClass tc = m_dtc->type(data.typeId()).typeClass();
|
||||
if (tc != TypeClass::Human && tc != TypeClass::Unit)
|
||||
{
|
||||
//isPureHuman = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->cbHelmet->setEnabled(true);
|
||||
m_ui->cbVest->setEnabled(true);
|
||||
m_ui->cbPersonalProtection->setEnabled(true);
|
||||
m_ui->cbProtectionLevel->setEnabled(true);
|
||||
m_ui->cbGrenadeSearchMode->setEnabled(true);
|
||||
m_ui->cbInternationalMode->setEnabled(true);
|
||||
m_ui->cbABCProtectionMode->setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::fillCbx()
|
||||
{
|
||||
// Party (required by setting all participants)
|
||||
if (!m_ddsId)
|
||||
m_ppmCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
|
||||
QSignalBlocker(m_ui->cbStatus);
|
||||
m_ui->cbStatus->clear();
|
||||
//Vulnerability
|
||||
m_ui->cbStatus->addItem(tr("No Change"), -1);
|
||||
if ( m_isTarget)
|
||||
{
|
||||
m_ui->cbStatus->addItem(tr("CombatReady"), ProjectDataManagement::VulnerabilityState::CombatReady);
|
||||
m_ui->cbStatus->addItem(tr("Catastrophic Kill / Killed"), ProjectDataManagement::VulnerabilityState::CatastrophicKill);
|
||||
}
|
||||
else
|
||||
insertVulnerabilityStates(m_ui->cbStatus, m_typeClass);
|
||||
|
||||
// Player language
|
||||
m_pdmGuiIfc->fillPlayerLanguageComboBox(m_ui->cbLanguage);
|
||||
|
||||
// Player operation mode
|
||||
m_pdmGuiIfc->fillPlayerOperationModeComboBox(m_ui->cbCheating);
|
||||
|
||||
// Player mode helmet
|
||||
m_pdmGuiIfc->fillPlayerModeHelmetComboBox(m_ui->cbHelmet);
|
||||
|
||||
// Player mode vest
|
||||
m_pdmGuiIfc->fillPlayerModeVestComboBox(m_ui->cbVest);
|
||||
|
||||
// Player personal Protection
|
||||
m_pdmGuiIfc->fillPlayerPersonalProtectionComboBox(m_ui->cbPersonalProtection);
|
||||
|
||||
// Player protection level
|
||||
m_pdmGuiIfc->fillPlayerProtectionLevelComboBox(m_ui->cbProtectionLevel);
|
||||
|
||||
// Player handgrenade search mode
|
||||
m_pdmGuiIfc->fillPlayerHandgrenadeSearchModeComboBox(m_ui->cbGrenadeSearchMode);
|
||||
|
||||
m_pdmGuiIfc->fillPlayerInternationalModeComboBox(m_ui->cbInternationalMode);
|
||||
|
||||
m_pdmGuiIfc->fillABCProtectionComboBox(m_ui->cbABCProtectionMode);
|
||||
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::fillVitalityCbx()
|
||||
{
|
||||
QSignalBlocker(m_ui->cbVitality);
|
||||
m_ui->cbVitality->disconnect();
|
||||
m_ui->cbVitality->clear();
|
||||
m_ui->cbVitality->addItem(tr("No Change"), 0);
|
||||
if (!m_dtc)
|
||||
return;
|
||||
|
||||
bool setEnabled = false;
|
||||
if (m_dialogType == Config && m_dtc->type(m_dtc->participant(m_ddsId).typeId()).typeClass() == TypeClass::Human)
|
||||
setEnabled = true;
|
||||
switch (m_ui->cbStatus->currentData().toInt())
|
||||
{
|
||||
case -1:
|
||||
{
|
||||
m_ui->cbVitality->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::LightDamage:
|
||||
{
|
||||
for (int i = 90 ; i >= 70; i -= 10)
|
||||
m_ui->cbVitality->addItem(QString::number(i), i);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::MediumDamage:
|
||||
{
|
||||
for (int i = 60 ; i >= 40; i -= 10)
|
||||
m_ui->cbVitality->addItem(QString::number(i), i);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::HeavyDamage:
|
||||
{
|
||||
for (int i = 30 ; i >= 10; i -= 10)
|
||||
m_ui->cbVitality->addItem(QString::number(i), i);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::VulnerabilityState::CombatReady:
|
||||
{
|
||||
m_ui->cbVitality->removeItem(0);
|
||||
m_ui->cbVitality->addItem(QString::number(100), 100);
|
||||
setEnabled = false;
|
||||
//m_ui->cbVitality->setCurrentIndex(m_ui->cbVitality->findData(100));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
setEnabled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
connect(m_ui->cbVitality, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this, [this]
|
||||
{
|
||||
m_stateChanged = true;
|
||||
});
|
||||
m_ui->cbVitality->setEnabled(setEnabled);
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::setCbxForInitEnabled(bool enabled)
|
||||
{
|
||||
//fixup apache reset and reactivate
|
||||
#ifndef GUEZ_MODE
|
||||
if (enabled && m_ddsId > 0 )
|
||||
{
|
||||
const Participant participant = m_dtc->participant(m_ddsId);
|
||||
const TypeClass tc = m_dtc->type(participant.typeId()).typeClass();
|
||||
if (tc == TypeClass::Aircraft && m_ui->cbStatus->currentIndex() < 1)
|
||||
enabled = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_ui->cbResetGearCharge->setEnabled(enabled);
|
||||
m_ui->cbResetGearCharge->setCheckable(enabled);
|
||||
m_ui->cbResetManipulation->setEnabled(enabled);
|
||||
m_ui->cbResetManipulation->setCheckable(enabled);
|
||||
m_ui->cbResetMedSupplies->setCheckable(enabled);
|
||||
m_ui->cbResetMedSupplies->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::fillCbxWithActualValue()
|
||||
{
|
||||
if(m_eqId <= 0)
|
||||
return;
|
||||
int partId = m_dtc->participantIdByEquipmentNumber(m_eqId);
|
||||
|
||||
ParticipantManagement::ParticipantMode mode = m_dtc->participantMode(partId);
|
||||
m_ui->cbHelmet->setCurrentIndex(m_ui->cbHelmet->findData(mode.modeHelmet().underlying()));
|
||||
m_ui->cbLanguage->setCurrentIndex(m_ui->cbLanguage->findData(mode.language().underlying()));
|
||||
m_ui->cbPersonalProtection->setCurrentIndex(m_ui->cbPersonalProtection->findData(mode.modePersonalProtection().underlying()));
|
||||
m_ui->cbProtectionLevel->setCurrentIndex(m_ui->cbProtectionLevel->findData(mode.protectionLevel().underlying()));
|
||||
m_ui->cbGrenadeSearchMode->setCurrentIndex(m_ui->cbGrenadeSearchMode->findData(mode.handgrenadeSearchMode().underlying()));
|
||||
m_ui->cbInternationalMode->setCurrentIndex(m_ui->cbInternationalMode->findData(mode.internationalMode().underlying()));
|
||||
m_ui->cbABCProtectionMode->setCurrentIndex(m_ui->cbABCProtectionMode->findData(mode.abcProtectionMode().underlying()));
|
||||
m_ui->cbVest->setCurrentIndex(m_ui->cbVest->findData(mode.modeVest().underlying()));
|
||||
m_modeChanged = false;
|
||||
|
||||
m_ui->cbStatus->setCurrentIndex(0);
|
||||
m_ui->cbVitality->setCurrentIndex(0);
|
||||
|
||||
std::vector< ParticipantManagement::StateInformation> stateHistory = m_dtc->dynamicParticipantData(partId).stateHistory();
|
||||
if (stateHistory.size() > 0)
|
||||
{
|
||||
auto stateInfo = m_dtc->youngestStateInformation(stateHistory);
|
||||
|
||||
int statusIndex = m_ui->cbStatus->findData(stateInfo.vulnerabilityState().underlying());
|
||||
if(statusIndex != -1)
|
||||
m_ui->cbStatus->setCurrentIndex(statusIndex);
|
||||
|
||||
int vitalityIndex = m_ui->cbVitality->findData(stateInfo.vitality());
|
||||
if(vitalityIndex != -1)
|
||||
m_ui->cbVitality->setCurrentIndex(vitalityIndex);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Slots
|
||||
|
||||
void ParticipantConfigDialog::onStateAreaChanged()
|
||||
{
|
||||
m_stateChanged = false;
|
||||
|
||||
setCbxForInitEnabled(m_ui->cbStatus->currentIndex() < 2);
|
||||
|
||||
fillVitalityCbx();
|
||||
|
||||
if (m_ui->cbStatus->currentIndex() == 0 &&
|
||||
!m_ui->cbResetManipulation->isChecked() &&
|
||||
!m_ui->cbResetMedSupplies->isChecked() &&
|
||||
!m_ui->cbResetGearCharge->isChecked())
|
||||
return;
|
||||
m_stateChanged = true;
|
||||
}
|
||||
|
||||
bool ParticipantConfigDialog::apply()
|
||||
{
|
||||
bool bAll = m_ui->cbAll->isChecked();
|
||||
|
||||
|
||||
// Which participant should be updated
|
||||
const std::set<int> participantIdSet(bAll ? std::set<int>({0}) : getParticipantIds());
|
||||
|
||||
if (participantIdSet.empty())
|
||||
return false;
|
||||
|
||||
const std::vector<int> participantIds(participantIdSet.begin(), participantIdSet.end());
|
||||
|
||||
|
||||
switch (m_dialogType)
|
||||
{
|
||||
|
||||
case Config:
|
||||
case ConfigMulti:
|
||||
{
|
||||
if (!m_modeChanged && !m_stateChanged)
|
||||
return false;
|
||||
|
||||
if (m_stateChanged)
|
||||
{
|
||||
if (m_ui->cbStatus->currentData().toInt() > 100)
|
||||
{
|
||||
OcCommandRequest req;
|
||||
// InitParticipantRequest req;
|
||||
req.action(m_ui->cbStatus->currentData().toInt() - 100);
|
||||
req.participantIds(participantIds);
|
||||
|
||||
m_ftc->ocCommandRequest(req);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ProjectDataManagement::VulnerabilityState state = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cbStatus->currentData().toInt());
|
||||
if (m_ui->cbStatus->currentIndex() == 1 ||
|
||||
m_ui->cbResetGearCharge->isChecked() ||
|
||||
m_ui->cbResetMedSupplies->isChecked() ||
|
||||
m_ui->cbResetManipulation->isChecked()) // (1) Ready for action or button checked -> init
|
||||
{
|
||||
InitParticipantRequest req;
|
||||
req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
req.restockCharges(m_ui->cbResetGearCharge->isChecked());
|
||||
req.resetManipulation(m_ui->cbResetManipulation->isChecked());
|
||||
req.resetVulnerabilityState(state == ProjectDataManagement::VulnerabilityState::CombatReady);
|
||||
req.restockSanitationMaterial(m_ui->cbResetMedSupplies->isChecked());
|
||||
req.participantIds(participantIds);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->initParticipantRequest(req, this);
|
||||
});
|
||||
}
|
||||
else //set new State
|
||||
{
|
||||
// Invalid enum value -1
|
||||
if (m_ui->cbStatus->currentData().toInt() != -1 || m_ui->cbVitality->currentData().toInt() != 0)
|
||||
{
|
||||
ModifyStateRequest req;
|
||||
req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
req.vulnerabilityState(state == ProjectDataManagement::VulnerabilityState::NoChange ? ProjectDataManagement::VulnerabilityState::CombatReady : state);
|
||||
req.participantIds(participantIds);
|
||||
req.vitality(m_ui->cbVitality->currentData().toInt());
|
||||
if(req.vitality() > 0) //if we set the vitality directly send base kind for pvSan
|
||||
req.vulnerabilityKind(2048);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->modifyStateRequest(req, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_modeChanged)
|
||||
{
|
||||
ProjectDataManagement::LanguageConfiguration lang = static_cast<ProjectDataManagement::LanguageConfiguration_def::type>(m_ui->cbLanguage->currentData().toInt());
|
||||
ProjectDataManagement::OperationMode opMode = static_cast<ProjectDataManagement::OperationMode_def::type>(m_ui->cbCheating->currentData().toInt());
|
||||
ProjectDataManagement::WphMode helmet = static_cast<ProjectDataManagement::WphMode_def::type>(m_ui->cbHelmet->currentData().toInt());
|
||||
ProjectDataManagement::WphMode vest = static_cast<ProjectDataManagement::WphMode_def::type>(m_ui->cbVest->currentData().toInt());
|
||||
ProjectDataManagement::PersonalProtection personalProtection = static_cast<ProjectDataManagement::PersonalProtection_def::type>(m_ui->cbPersonalProtection->currentData().toInt());
|
||||
ProjectDataManagement::ProtectionLevel protectionLevel = static_cast<ProjectDataManagement::ProtectionLevel_def::type>(m_ui->cbProtectionLevel->currentData().toInt());
|
||||
ProjectDataManagement::HandgrenadeSearchMode grenadeSearch;
|
||||
if(!m_ui->cbGrenadeSearchMode->isHidden())
|
||||
{
|
||||
grenadeSearch = static_cast<ProjectDataManagement::HandgrenadeSearchMode_def::type>(m_ui->cbGrenadeSearchMode->currentData().toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
grenadeSearch = ProjectDataManagement::HandgrenadeSearchMode::NoChange;
|
||||
}
|
||||
|
||||
ProjectDataManagement::InternationalMode internationalMode = static_cast<ProjectDataManagement::InternationalMode_def::type>(m_ui->cbInternationalMode->currentData().toInt());
|
||||
ProjectDataManagement::ABCProtectionMode abcProtectionMode = static_cast<ProjectDataManagement::ABCProtectionMode_def::type>(m_ui->cbABCProtectionMode->currentData().toInt());
|
||||
|
||||
int reactDecontMinutes = m_ui->slDecontamination->value() * 10;
|
||||
int reactMaintenanceMinutes = m_ui->slMaintenance->value() * 10;
|
||||
int reactMedicMinutes = m_ui->slMedical->value() * 10;
|
||||
SetParticipantModeRequest req(lang,
|
||||
opMode,
|
||||
reactDecontMinutes,
|
||||
reactMaintenanceMinutes,
|
||||
reactMedicMinutes,
|
||||
vest,
|
||||
helmet,
|
||||
personalProtection,
|
||||
protectionLevel,
|
||||
grenadeSearch,
|
||||
internationalMode,
|
||||
abcProtectionMode,
|
||||
0);
|
||||
|
||||
for (int participantId : participantIds)
|
||||
{
|
||||
if(participantId != 0)
|
||||
{
|
||||
auto data = m_dtc->participant(participantId);
|
||||
TypeClass tc = m_dtc->type(data.typeId()).typeClass();
|
||||
if (tc != TypeClass::Human)
|
||||
continue;
|
||||
}
|
||||
req.participantId(participantId);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->setParticipantModeRequest(req, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Message:
|
||||
case MessageMulti:
|
||||
{
|
||||
SendMessageRequest req;
|
||||
req.message(m_ui->teMail->toPlainText().toStdString());
|
||||
req.participantIds(participantIds);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->sendMessageRequest(req, this);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//now start Requests
|
||||
|
||||
bool ret = m_requestHelper->startRequests();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::onTextChanged()
|
||||
{
|
||||
QString plainText(m_ui->teMail->toPlainText());
|
||||
int currentUsedChars = plainText.toUtf8().size();
|
||||
bool bNeedSetNew = false;
|
||||
|
||||
while (currentUsedChars > m_maxChars)
|
||||
{
|
||||
plainText.chop(1);
|
||||
currentUsedChars = plainText.toUtf8().size();
|
||||
bNeedSetNew = true; // do not set text directly, results in recursion
|
||||
}
|
||||
|
||||
// if text longer than allowed
|
||||
if (bNeedSetNew)
|
||||
{
|
||||
m_ui->teMail->setPlainText(plainText);
|
||||
m_ui->teMail->moveCursor(QTextCursor::End);
|
||||
}
|
||||
int charsLeft = m_maxChars - currentUsedChars;
|
||||
if (charsLeft > 9)
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(QString::number(m_maxChars - currentUsedChars)));
|
||||
else
|
||||
m_ui->lblCharsLeft->setText(tr("Characters left: %1").arg(QString::number(m_maxChars - currentUsedChars)));
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::changeLabelText(QLabel *label, int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
label->setText(tr("No Change"));
|
||||
break;
|
||||
case 255:
|
||||
label->setText(tr("No Resurrection"));
|
||||
break;
|
||||
default:
|
||||
label->setText(QStringLiteral("%1 min").arg(value * 10));
|
||||
break;
|
||||
}
|
||||
onModeChanged();
|
||||
}
|
||||
|
||||
void ParticipantConfigDialog::onModeChanged()
|
||||
{
|
||||
m_modeChanged = false;
|
||||
if (m_ui->cbLanguage->currentIndex() == 0 &&
|
||||
m_ui->cbCheating->currentIndex() == 0 &&
|
||||
m_ui->cbPersonalProtection->currentIndex() == 0 &&
|
||||
m_ui->cbHelmet->currentIndex() == 0 &&
|
||||
m_ui->cbProtectionLevel->currentIndex() == 0 &&
|
||||
m_ui->cbGrenadeSearchMode->currentIndex() == 0 &&
|
||||
m_ui->cbInternationalMode->currentIndex() == 0 &&
|
||||
m_ui->cbABCProtectionMode->currentIndex() == 0 &&
|
||||
m_ui->slDecontamination->value() == 0 &&
|
||||
m_ui->slMaintenance->value() == 0 &&
|
||||
m_ui->slMedical->value() == 0
|
||||
)
|
||||
return;
|
||||
|
||||
m_modeChanged = true;
|
||||
}
|
||||
|
||||
std::set<int> ParticipantConfigDialog::getParticipantIds() const
|
||||
{
|
||||
if (m_ddsId) // single
|
||||
return {m_ddsId};
|
||||
|
||||
const QItemSelectionModel *selectionModel = m_ui->tvParticipants->selectionModel();
|
||||
const QModelIndexList rows = selectionModel->selectedRows();
|
||||
|
||||
std::set<int> ret;
|
||||
for (const QModelIndex &row : rows)
|
||||
{
|
||||
const auto c = getParticipantIds(row);
|
||||
for(auto id : c)
|
||||
{
|
||||
ret.insert(id);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVector<int> ParticipantConfigDialog::getParticipantIds(const QModelIndex &parent) const
|
||||
{
|
||||
QVector<int> ret;
|
||||
|
||||
const ParticipantManagement::ParticipantData dataParent(m_model->getParticipantData(parent));
|
||||
if (dataParent.equipmentNumber().is_set())
|
||||
ret.append(dataParent.id());
|
||||
|
||||
// if(dataParent.equipmentNumber().get() == m_eqId)
|
||||
// {
|
||||
// DEBUG_LOG(m_logger)<<" >>>>>> [SET PP STATUS] participantId: "<< dataParent.id()<<" for equipNumb: "<< dataParent.equipmentNumber();
|
||||
// }
|
||||
const int rowCount = m_model->rowCount(parent);
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
const QModelIndex childIndex = m_model->index(row, 0, parent);
|
||||
ret += getParticipantIds(childIndex);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantConfigDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "participant_config_model.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
|
||||
//DDS
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
//Qt
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantConfigDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// ParticipantConfigDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantConfigDialog : public LtsWidgets::LtsDialog
|
||||
, protected ParticipantManagement::Interface::Ftc::ModifyStateReplyHandler
|
||||
, protected ParticipantManagement::Interface::Ftc::InitParticipantReplyHandler
|
||||
, protected ParticipantManagement::Interface::Ftc::SendMessageReplyHandler
|
||||
, protected ParticipantManagement::Interface::Ftc::SetParticipantModeReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum DialogType
|
||||
{
|
||||
Config,
|
||||
Message,
|
||||
ConfigMulti,
|
||||
MessageMulti
|
||||
};
|
||||
|
||||
explicit ParticipantConfigDialog(int ddsId, DialogType type, QWidget *parent = nullptr);
|
||||
~ParticipantConfigDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc);
|
||||
|
||||
|
||||
private:
|
||||
void onModifyStateReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onInitParticipantReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onSendMessageReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onSetParticipantModeReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void fillCbx();
|
||||
void fillVitalityCbx();
|
||||
void checkPendingTopics();
|
||||
void setCbxForInitEnabled(bool enabled);
|
||||
void fillCbxWithActualValue();
|
||||
void retranslate() override;
|
||||
|
||||
private slots:
|
||||
void onStateAreaChanged();
|
||||
void onTextChanged();
|
||||
void onModeChanged();
|
||||
void slotPartyChanged();
|
||||
void onSelectionChanged();
|
||||
|
||||
private:
|
||||
bool apply() override final;
|
||||
void changeLabelText(QLabel *label, int value);
|
||||
|
||||
std::set<int> getParticipantIds() const;
|
||||
QVector<int> getParticipantIds(const QModelIndex &parent) const;
|
||||
|
||||
DialogType m_dialogType;
|
||||
int m_ddsId;
|
||||
TypeClass m_typeClass;
|
||||
|
||||
ParticipantConfigModel *m_model;
|
||||
|
||||
int m_maxChars;
|
||||
int m_eqId;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::ForeignGuiInterface> m_pdmGuiIfc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmCbxIfc;
|
||||
|
||||
bool m_stateChanged;
|
||||
bool m_modeChanged;
|
||||
bool m_sendTextMessage;
|
||||
QString m_windowTitle;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
static int s_preselectedParty;
|
||||
|
||||
Ui::ParticipantConfigDialog *m_ui;
|
||||
bool m_isTarget;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace ParticipantInfo
|
||||
+527
@@ -0,0 +1,527 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantConfigDialog</class>
|
||||
<widget class="QWidget" name="ParticipantConfigDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>723</width>
|
||||
<height>842</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Participant Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbParticipants">
|
||||
<property name="title">
|
||||
<string>Participants</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbParty">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="3">
|
||||
<widget class="QTreeView" name="tvParticipants">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>47</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="cbAll">
|
||||
<property name="text">
|
||||
<string>All Participants</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbState">
|
||||
<property name="title">
|
||||
<string>State</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbVitality"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblVitality">
|
||||
<property name="text">
|
||||
<string>Vitality:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="cbResetManipulation">
|
||||
<property name="text">
|
||||
<string>Reset Manipulation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblIDSBold">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="cbResetMedSupplies">
|
||||
<property name="text">
|
||||
<string>Reset Medical Supplies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="cbResetGearCharge">
|
||||
<property name="text">
|
||||
<string>Reset Gear Charge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbMode">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbCheating">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbInternationalMode"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbProtectionLevel">
|
||||
<property name="text">
|
||||
<string>Protection Level:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbHelmet">
|
||||
<property name="text">
|
||||
<string>Body Armour Helmet:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbPersonalProtection">
|
||||
<property name="text">
|
||||
<string>Personal Protection:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbVest">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbGrenadeSearchMode">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbInternationalMode">
|
||||
<property name="text">
|
||||
<string>International Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbProtectionLevel">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbLanguage">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbCheating">
|
||||
<property name="text">
|
||||
<string>Cheating:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbVest">
|
||||
<property name="text">
|
||||
<string>Body Armour Vest:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbLanguage">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbHelmet">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbGrenadeSearchMode">
|
||||
<property name="text">
|
||||
<string>Handgrenade Search Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbPersonalProtection">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="lbABCProtectionMode">
|
||||
<property name="text">
|
||||
<string>ABC Protection:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbABCProtectionMode"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbRes">
|
||||
<property name="title">
|
||||
<string>Automatic Resurrect</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lbMaintenance">
|
||||
<property name="text">
|
||||
<string>No Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="lbMedical">
|
||||
<property name="text">
|
||||
<string>No Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lblHelmetMonitoringBold_4">
|
||||
<property name="text">
|
||||
<string>Medical:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblHelmetMonitoringBold_2">
|
||||
<property name="text">
|
||||
<string>Decontamination:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QSlider" name="slMedical">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lbDecontamination">
|
||||
<property name="text">
|
||||
<string>No Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblHelmetMonitoringBold_3">
|
||||
<property name="text">
|
||||
<string>Maintenance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>124</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QSlider" name="slDecontamination">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QSlider" name="slMaintenance">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>2</width>
|
||||
<height>2</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbMessage">
|
||||
<property name="title">
|
||||
<string>Mail</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblTextMailBold">
|
||||
<property name="text">
|
||||
<string>Text Mail:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="3">
|
||||
<widget class="QPlainTextEdit" name="teMail">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblCharsLeft">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Characters left: 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cbParty</tabstop>
|
||||
<tabstop>tvParticipants</tabstop>
|
||||
<tabstop>cbAll</tabstop>
|
||||
<tabstop>cbStatus</tabstop>
|
||||
<tabstop>cbResetManipulation</tabstop>
|
||||
<tabstop>cbResetGearCharge</tabstop>
|
||||
<tabstop>cbLanguage</tabstop>
|
||||
<tabstop>cbCheating</tabstop>
|
||||
<tabstop>cbHelmet</tabstop>
|
||||
<tabstop>cbVest</tabstop>
|
||||
<tabstop>cbPersonalProtection</tabstop>
|
||||
<tabstop>cbProtectionLevel</tabstop>
|
||||
<tabstop>cbGrenadeSearchMode</tabstop>
|
||||
<tabstop>slDecontamination</tabstop>
|
||||
<tabstop>slMaintenance</tabstop>
|
||||
<tabstop>slMedical</tabstop>
|
||||
<tabstop>teMail</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+1535
File diff suppressed because it is too large.
Load diff
+315
@@ -0,0 +1,315 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - Participant Edit Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Plugins/ParticipantManagement/Gui/Common/participant_icon_model_base.h"
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
#include <QSet>
|
||||
|
||||
|
||||
class QTreeView;
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class CheckedTreeItem;
|
||||
|
||||
|
||||
//=============================================================================================================================
|
||||
// ParticipantConfigModel
|
||||
//=============================================================================================================================
|
||||
class ParticipantConfigModel : public ParticipantIconModelBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ColDesignator,
|
||||
ColIdentifier,
|
||||
ColTypeClass,
|
||||
ColType,
|
||||
ColEquipmentNumber,
|
||||
ColProtection,
|
||||
ColInternationalMode,
|
||||
ColInfo,
|
||||
ColSign
|
||||
};
|
||||
|
||||
class CheckedTreeItem final : public NGLTreeItem
|
||||
{
|
||||
public:
|
||||
using NGLTreeItem::NGLTreeItem;
|
||||
|
||||
ParticipantData participant;
|
||||
bool bIsChecked = false;
|
||||
};
|
||||
|
||||
ParticipantConfigModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc);
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
Qt::DropActions supportedDropActions() const override { return Qt::MoveAction; }
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::MoveAction; }
|
||||
|
||||
virtual bool onReinitModel(int partyId, const QSet<int> &checkedParticipants = QSet<int>(), Qt::CheckState cs = Qt::Checked);
|
||||
|
||||
bool insertRow(int row, const QModelIndex &parent, NGLTreeItem *item);
|
||||
bool removeRow(int row, const QModelIndex &parent = QModelIndex());
|
||||
bool isRowRemovable(const CheckedTreeItem *parentItem) const;
|
||||
|
||||
bool rowsCheckable() const { return m_bRowsAreCheckable; }
|
||||
bool unitsSelectable() const { return m_bUnitsSelectable; }
|
||||
int partyId() const { return m_partyId; }
|
||||
|
||||
void dataCommitted();
|
||||
void processMissingSuperiorId();
|
||||
void selectItemByParticipantId(int participantId,
|
||||
const std::function<void(const QModelIndex &)> &selectItem,
|
||||
const QModelIndex &parent = QModelIndex());
|
||||
|
||||
QModelIndexList getIndexesByParticipantIds(const std::vector<int32_t> &participantIds,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
void setRowsCheckable(bool bCheckable);
|
||||
void setUnitsSelectable(bool bSelectable) { m_bUnitsSelectable = bSelectable; }
|
||||
bool setCheckStateForParticipants(const QSet<int> &checkedParticipants, Qt::CheckState cs);
|
||||
|
||||
ParticipantManagement::ParticipantData getParticipantData(const QModelIndex &idx) const;
|
||||
std::vector<ParticipantData> participantData(bool bOnlyModified = true) const;
|
||||
QSet<int> participantIds() const;
|
||||
QSet<int> checkStateForParticipants(Qt::CheckState cs) const;
|
||||
|
||||
CheckedTreeItem *privateData(const QModelIndex &index);
|
||||
const CheckedTreeItem *privateData(const QModelIndex &index) const;
|
||||
|
||||
QModelIndex indexFromParticipantId(int participantId) const;
|
||||
|
||||
QString getHierarchyFromIndex(const QModelIndex &index) const;
|
||||
|
||||
protected:
|
||||
void gatherParticipants(QHash<int, ParticipantData> &tmap,
|
||||
QHash<int, QSet<int>> &parentId2id) const;
|
||||
|
||||
std::vector<ParticipantData> getChildrenOf(NGLTreeItem *item,
|
||||
int parentId,
|
||||
int hierarchyNumber,
|
||||
bool bOnlyModifed,
|
||||
int &highestModId) const;
|
||||
bool updateChildrenOf(int parentId,
|
||||
NGLTreeItem *parent,
|
||||
const QHash<int, QSet<int>> &parentId2id,
|
||||
const QHash<int, ParticipantData> &tmap);
|
||||
void insertChildrenOf(int parentId,
|
||||
NGLTreeItem *parent,
|
||||
const QModelIndex &parentIdx,
|
||||
const QHash<int, QSet<int>> &parentId2id,
|
||||
const QHash<int, ParticipantData> &tmap,
|
||||
const QSet<int> &checkedParticipants,
|
||||
Qt::CheckState cs);
|
||||
|
||||
bool isParentOf(const NGLTreeItem *item, int participantId) const;
|
||||
|
||||
QSet<int> participantIds(NGLTreeItem *parentItem) const;
|
||||
QSet<int> checkState(CheckedTreeItem *parentItem, Qt::CheckState cs) const;
|
||||
|
||||
void setCheckState(CheckedTreeItem *parentItem, const QSet<int> &checkedParticipants, Qt::CheckState cs);
|
||||
|
||||
QModelIndex indexFromParticipantId(int participantId, const CheckedTreeItem *cti) const;
|
||||
int participantIdFromItem(NGLTreeItem *item) const;
|
||||
CheckedTreeItem *searchParticipant(const NGLTreeItem *parentItem, int participantId) const;
|
||||
|
||||
NGLTreeItem *createItem(const QVariant &data, const QIcon &icon) const override;
|
||||
QVariant getItemData(const NGLTreeItem *item) const override;
|
||||
private:
|
||||
QString buildProtectionString(const ParticipantManagement::ParticipantMode &mode) const;
|
||||
QString buildWphModeString(const ProjectDataManagement::WphMode &wphMode) const;
|
||||
QString buildInternationalModeString(const ProjectDataManagement::InternationalMode &inMode) const;
|
||||
public slots:
|
||||
int insertParticipant(const QModelIndex &parent, ParticipantData participantData, bool bNewParticipant);
|
||||
int onInsertRow(const QModelIndex &parent, const ParticipantData &participantData);
|
||||
bool onUpdateRow(const QModelIndex &index, const ParticipantData &participantData);
|
||||
bool onDeleteRow(const QModelIndex &idx, bool isFirstItem = true);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
|
||||
signals:
|
||||
void internalDataChanged();
|
||||
|
||||
protected:
|
||||
int m_partyId;
|
||||
bool m_bRowsAreCheckable;
|
||||
bool m_bUnitsSelectable;
|
||||
std::vector<ParticipantManagement::ParticipantData> m_dataToDelete;
|
||||
QTimer *m_missingSuperiorIdTimer;
|
||||
QSet<int> m_missingSuperiorId;
|
||||
QSet<int> m_usedTypeIds;
|
||||
QSet<TypeClass> m_usedTypeClassIds;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================================================================
|
||||
// ParticipantTreeFilterProxyConfigModel
|
||||
//=============================================================================================================================
|
||||
class ParticipantTreeFilterProxyConfigModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
void setAllowedTypes(const QSet<int> &allowedTypes);
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
|
||||
int partyId() const { return m_sourceModel ? m_sourceModel->partyId() : -1; }
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
bool filterTypeRecursive(const ParticipantConfigModel::CheckedTreeItem *item) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
QSet<int> m_allowedTypes;
|
||||
ParticipantConfigModel *m_sourceModel{nullptr};
|
||||
|
||||
}; // class ParticipantTreeFilterProxyConfigModel
|
||||
|
||||
|
||||
//=============================================================================================================================
|
||||
// ParticipantTableFilterProxyConfigModel
|
||||
//=============================================================================================================================
|
||||
/**
|
||||
* @brief The ParticipantTableFilterProxyConfigModel class enables a hierarchical tree model of
|
||||
* participants to be treated like a flat table model.
|
||||
*
|
||||
* Important connect statements that must be implemented are:
|
||||
* - LtsDataView::filterChanged -> onFilter()
|
||||
* - LtsDataView::sortOrderChanged -> onSort()
|
||||
* - ParticipantConfigModel::internalDataChanged -> init()
|
||||
* In order to keep the selection after sorting, LtsDataView::sortOrderChanged can be connected to
|
||||
* another function that handles that and calls onSort() instead. Otherwise, after sorting, the same
|
||||
* row will be selected with most likely a different tree item than the one selected before sorting.
|
||||
*
|
||||
* When using this model in parallel to a standard tree model, in order to have two views that are
|
||||
* consistent with each other, additional connects and workarounds are necessary. Connects include:
|
||||
* - LtsDataView::filterChanged -> some function that asserts consistency
|
||||
* - LtsDataView::selectionChanged -> some function that asserts consistency
|
||||
* An important workaround is required when the party is changed (s.
|
||||
* ParticipantEdit::onPartyChanged).
|
||||
*/
|
||||
class ParticipantTableFilterProxyConfigModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct SortData
|
||||
{
|
||||
bool isActive{false};
|
||||
int column{-1};
|
||||
Qt::SortOrder order{Qt::DescendingOrder};
|
||||
bool ascending() const
|
||||
{
|
||||
return order == Qt::AscendingOrder;
|
||||
}
|
||||
bool descending() const
|
||||
{
|
||||
return order == Qt::DescendingOrder;
|
||||
}
|
||||
QString toString()
|
||||
{
|
||||
QString str{QStringLiteral("active=")};
|
||||
str += isActive ? QStringLiteral("true") : QStringLiteral("false");
|
||||
str += QStringLiteral(", column=") + QString::number(column) + QStringLiteral(", order=");
|
||||
str += order == Qt::DescendingOrder ? QStringLiteral("Descending") : QStringLiteral("Ascending");
|
||||
return str;
|
||||
}
|
||||
}; // struct SortData
|
||||
|
||||
explicit ParticipantTableFilterProxyConfigModel(QObject *parent = nullptr);
|
||||
|
||||
void init();
|
||||
void resetMapping();
|
||||
void disableSorting() { m_sortData.isActive = false; }
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
|
||||
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &child) const override;
|
||||
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
|
||||
|
||||
bool isFilterActive() const { return m_isFilterActive; }
|
||||
bool hasChildren(const QModelIndex &parent) const override;
|
||||
|
||||
SortData sortData() const { return m_sortData; }
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
|
||||
bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
bool filterAcceptsRowInternal(int sourceRow, const QModelIndex &sourceParent) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief mapTreeToTable initializes m_mapFromSource and m_mapToSource. Do NOT USE this method
|
||||
* directly! Call init() instead.
|
||||
* @param parent index of the parent in the source model
|
||||
* @param row parent's child at rowth position
|
||||
* @return current row count
|
||||
*/
|
||||
int mapTreeToTable(const QModelIndex &parent = QModelIndex(), int row = 0);
|
||||
|
||||
public slots:
|
||||
void onFilter();
|
||||
void onSort(int column, Qt::SortOrder order);
|
||||
|
||||
private:
|
||||
QHash<int, QModelIndex> m_mapToSource;
|
||||
QHash<QModelIndex, int> m_mapFromSource;
|
||||
QHash<int, QModelIndex> m_mapToSourceInternal;
|
||||
QHash<QModelIndex, int> m_mapFromSourceInternal;
|
||||
QHash<int, QModelIndex> m_mapToSourceFiltered;
|
||||
QHash<QModelIndex, int> m_mapFromSourceFiltered;
|
||||
QVector<int> m_sortMap;
|
||||
|
||||
bool m_isFilterActive{false};
|
||||
SortData m_sortData;
|
||||
|
||||
ParticipantConfigModel *m_sourceModel{nullptr};
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
}; // class ParticipantTableFilterProxyConfigModel
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
|
||||
//Q_DECLARE_METATYPE(ParticipantManagement::ParticipantData)
|
||||
+424
@@ -0,0 +1,424 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - ParticipantFollowDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#include "participant_follow_dialog.h"
|
||||
#include "ui_participant_follow_dialog.h"
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
int ParticipantFollowDialog::s_preselectedParty = -1;
|
||||
bool ParticipantFollowDialog::s_preselectedAllParticipants = true;
|
||||
|
||||
ParticipantFollowDialog::ParticipantFollowDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_equipNo(0)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmCbxIfc(nullptr)
|
||||
, m_ui(new Ui::ParticipantFollowDialog)
|
||||
, m_followParticipantId(-1)
|
||||
, m_followEquipmentNo(-1)
|
||||
, m_logger(getLogger("ParticipantFollowDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->leEquipNo->setValidator(new QIntValidator(0, 100000, m_ui->leEquipNo));
|
||||
setUnchangeable();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &ParticipantFollowDialog::onStartFollowClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ParticipantFollowDialog::onStopFollowClicked);
|
||||
|
||||
m_updateObjectIndicator = new QTimer(this);
|
||||
m_updateObjectIndicator->setSingleShot(true);
|
||||
m_updateObjectIndicator->setInterval(100);
|
||||
connect(m_updateObjectIndicator, &QTimer::timeout, this, &ParticipantFollowDialog::updateObjectIndicator);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Find_Participant"));
|
||||
}
|
||||
|
||||
ParticipantFollowDialog::~ParticipantFollowDialog()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removeObjectIndicator();
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Participant Follow"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Start Follow Participant on Map"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Stop Follow Participant on Map"));
|
||||
}
|
||||
|
||||
bool ParticipantFollowDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ParticipantFollowDialog::init";
|
||||
m_dtc = dtc;
|
||||
m_ppmGuiIfc = ppmGuiIfc;
|
||||
enadisa();
|
||||
|
||||
if (!m_dtc)
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmCbxIfc))
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
|
||||
m_ui->cbAll->setChecked(s_preselectedAllParticipants);
|
||||
|
||||
m_model = new ParticipantEditModel(this, m_dtc, asbIfc);
|
||||
m_ui->tvParticipants->setModel(m_model);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantFollowDialog::changeParty);
|
||||
|
||||
QItemSelectionModel *selectionModel = m_ui->tvParticipants->selectionModel();
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
||||
this, &ParticipantFollowDialog::slotLookup);
|
||||
|
||||
connect(m_ui->tvParticipants, &QTreeView::doubleClicked,
|
||||
this, &ParticipantFollowDialog::onDoubleClicked);
|
||||
|
||||
connect(m_ui->slEquipmentNumber, &QSlider::valueChanged, this, &ParticipantFollowDialog::slotLookup);
|
||||
connect(m_ui->pbLookup, &QPushButton::clicked, this, &ParticipantFollowDialog::slotLookup);
|
||||
connect(m_ui->leEquipNo, &QLineEdit::returnPressed, this, &ParticipantFollowDialog::slotLookup);
|
||||
connect(m_ui->cbAll, &QCheckBox::toggled, this, &ParticipantFollowDialog::changeParty);
|
||||
|
||||
m_ppmCbxIfc->fillPartyComboBox(m_ui->cbParty, ForeignGuiComboboxInterface::CbxPartyFilter::All);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
|
||||
changeParty();
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(false);
|
||||
|
||||
enadisa();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::setFollower(const int equipmentNumber, const int participantId)
|
||||
{
|
||||
m_followEquipmentNo = equipmentNumber;
|
||||
m_followParticipantId = participantId;
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::slotLookup()
|
||||
{
|
||||
//block all signals here
|
||||
QSignalBlocker blx2(m_ui->slEquipmentNumber);
|
||||
QSignalBlocker blx3(m_ui->leEquipNo);
|
||||
|
||||
//set sliderposition to current value
|
||||
int newEquipNo = -1;
|
||||
|
||||
if (qobject_cast<QSlider *>(sender()))
|
||||
newEquipNo = changeLabelText(m_ui->slEquipmentNumber->value());
|
||||
if (qobject_cast<QLineEdit *>(sender()) ||
|
||||
qobject_cast<QPushButton *>(sender()))
|
||||
{
|
||||
//get Number from
|
||||
newEquipNo = m_ui->leEquipNo->text().toInt();
|
||||
}
|
||||
if (qobject_cast<QItemSelectionModel *>(sender()))
|
||||
{
|
||||
newEquipNo = onSelectionChanged();
|
||||
//selection cleared (do we allow a deselct?)
|
||||
// if (newEquipNo < 0 )
|
||||
// {
|
||||
// m_equipNo = newEquipNo;
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
if (newEquipNo == m_equipNo)
|
||||
return;
|
||||
|
||||
m_equipNo = newEquipNo;
|
||||
|
||||
//set Label and update lineEdit
|
||||
if (m_equipNo > 0)
|
||||
m_ui->leEquipNo->setText(QString::number(m_equipNo));
|
||||
changeSliderPosition(m_equipNo);
|
||||
|
||||
//finally enable show button if found
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(m_participantMap.contains(m_equipNo));
|
||||
|
||||
//function for itemselection
|
||||
auto cb = [this](const QModelIndex & idx)
|
||||
{
|
||||
m_ui->tvParticipants->setCurrentIndex(idx);
|
||||
};
|
||||
auto it = m_participantMap.find(m_equipNo);
|
||||
if (it == m_participantMap.end() && !qobject_cast<QItemSelectionModel *>(sender()))
|
||||
{
|
||||
m_ui->tvParticipants->setCurrentIndex(QModelIndex());
|
||||
return;
|
||||
}
|
||||
m_model->selectItemByParticipantId(it.value(), cb);
|
||||
|
||||
|
||||
// update ObjectIndicator:
|
||||
if (m_updateObjectIndicator)
|
||||
m_updateObjectIndicator->start(); // start is restart
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::updateObjectIndicator()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
int participantId = m_participantMap.value(m_equipNo, -1);
|
||||
|
||||
if (participantId >= 0)
|
||||
m_sitMapGuiIfc->objectIndicatorToParticipant(participantId);
|
||||
else
|
||||
m_sitMapGuiIfc->removeObjectIndicator();
|
||||
enadisa();
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::enterEvent(QEvent *e)
|
||||
{
|
||||
BaseClass::enterEvent(e);
|
||||
updateObjectIndicator();
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::leaveEvent(QEvent *e)
|
||||
{
|
||||
BaseClass::leaveEvent(e);
|
||||
// to early, remove obj at dtor
|
||||
// if (m_sitMapGuiIfc)
|
||||
// m_sitMapGuiIfc->removeObjectIndicator();
|
||||
}
|
||||
|
||||
|
||||
//private
|
||||
|
||||
int ParticipantFollowDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndex index = m_ui->tvParticipants->currentIndex();
|
||||
|
||||
//finally enable show button
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(true);
|
||||
|
||||
ParticipantManagement::ParticipantData data;
|
||||
data = m_model->getParticipantData(index);
|
||||
if (!data.equipmentNumber().is_set())
|
||||
return -1;
|
||||
|
||||
enadisa();
|
||||
return data.equipmentNumber().get();
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::onDoubleClicked()
|
||||
{
|
||||
QModelIndex index = m_ui->tvParticipants->currentIndex();
|
||||
|
||||
ParticipantManagement::ParticipantData data;
|
||||
data = m_model->getParticipantData(index);
|
||||
m_followParticipantId = data.id();
|
||||
m_followEquipmentNo = getEquipmentNumber(m_followParticipantId);
|
||||
enadisa();
|
||||
DEBUG_LOG(m_logger) << "onDoubleClicked follow Participant Id =" << m_followParticipantId
|
||||
<< " m_followEquipmentNo=" << m_followEquipmentNo;
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::clearSelections()
|
||||
{
|
||||
changeSliderPosition(-1);
|
||||
m_ui->leEquipNo->clear();
|
||||
m_equipNo = 0;
|
||||
m_ui->tvParticipants->setCurrentIndex(QModelIndex());
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(false);
|
||||
}
|
||||
|
||||
//Slots
|
||||
void ParticipantFollowDialog::changeParty()
|
||||
{
|
||||
s_preselectedAllParticipants = m_ui->cbAll->isChecked();
|
||||
if (m_ui->cbAll->isChecked())
|
||||
{
|
||||
m_ui->cbParty->setEnabled(false);
|
||||
m_ui->tvParticipants->setEnabled(false);
|
||||
m_model->resetModel();
|
||||
fillMapFromDtc();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbParty->setEnabled(true);
|
||||
m_ui->tvParticipants->setEnabled(true);
|
||||
int partyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = partyId;
|
||||
m_model->onReinitModel(partyId);
|
||||
m_ui->tvParticipants->expandAll();
|
||||
fillParticipantMapFromTree();
|
||||
}
|
||||
|
||||
m_ui->slEquipmentNumber->setRange(0, m_participantMap.size() - 1);
|
||||
clearSelections();
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::fillMapFromDtc()
|
||||
{
|
||||
m_participantMap.clear();
|
||||
auto cb = [this](const Participant & data)
|
||||
{
|
||||
if (data.equipmentNumber().is_set())
|
||||
m_participantMap.insert(data.equipmentNumber().get(), data.id());
|
||||
};
|
||||
m_dtc->participants(cb);
|
||||
}
|
||||
|
||||
int ParticipantFollowDialog::changeLabelText(int value)
|
||||
{
|
||||
if (value < 0 || value >= m_participantMap.size())
|
||||
return -1;
|
||||
|
||||
auto it = m_participantMap.begin();
|
||||
it += value;
|
||||
int newEqNr = it.key();
|
||||
|
||||
m_ui->lblEquipmentNumber->setText(QString::number(newEqNr));
|
||||
m_ui->leEquipNo->setText(QString::number(newEqNr));
|
||||
return newEqNr;
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::changeSliderPosition(int equipNo)
|
||||
{
|
||||
int i = 0;
|
||||
int pos = -1;
|
||||
for (auto it = m_participantMap.cbegin(); it != m_participantMap.cend(); ++it)
|
||||
{
|
||||
if (equipNo == it.key())
|
||||
{
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (pos >= 0)
|
||||
{
|
||||
m_ui->lblEquipmentNumber->setText(QString::number(equipNo));
|
||||
m_ui->slEquipmentNumber->setSliderPosition(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->slEquipmentNumber->setSliderPosition(-1);
|
||||
m_ui->lblEquipmentNumber->setText(tr("Not found"));
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::fillParticipantMapFromTree()
|
||||
{
|
||||
m_participantMap.clear();
|
||||
|
||||
fillParticipantMapFromTree(QModelIndex());
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::fillParticipantMapFromTree(const QModelIndex &parent)
|
||||
{
|
||||
const int rc = m_model->rowCount(parent);
|
||||
for (int row = 0; row < rc; ++row)
|
||||
fillParticipantMapFromTree(m_model->index(row, 0, parent));
|
||||
|
||||
const ParticipantManagement::ParticipantData data(m_model->getParticipantData(parent));
|
||||
if (data.equipmentNumber().is_set())
|
||||
m_participantMap.insert(data.equipmentNumber().get(), data.id());
|
||||
}
|
||||
|
||||
int ParticipantFollowDialog::getEquipmentNumber(const int participantId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getEquipmentNumber(" << participantId << ")";
|
||||
int equipmentNumber = 0;
|
||||
|
||||
QMapIterator<int, int> iter(m_participantMap);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
DEBUG_LOG(m_logger) << iter.key() << " : " << iter.value();
|
||||
if (iter.value() == participantId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "return: " << iter.key();
|
||||
return (iter.key());
|
||||
}
|
||||
}
|
||||
return equipmentNumber;
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::onStartFollowClicked()
|
||||
{
|
||||
int participantId = m_participantMap.value(m_equipNo);
|
||||
DEBUG_LOG(m_logger) << "Follow Participant id=" << participantId << " on Map";
|
||||
|
||||
if (!m_ui->cbAll->isChecked())
|
||||
onDoubleClicked();
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Start Follow Participant id=" << participantId << " on Map";
|
||||
m_followParticipantId = participantId;
|
||||
m_followEquipmentNo = m_equipNo;
|
||||
}
|
||||
enadisa();
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::onStopFollowClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Stop Follow Participant id=" << m_followParticipantId << " on Map";
|
||||
m_followParticipantId = 0;
|
||||
m_followEquipmentNo = 0;
|
||||
enadisa();
|
||||
}
|
||||
|
||||
void ParticipantFollowDialog::enadisa()
|
||||
{
|
||||
if (m_followParticipantId > 0)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
}
|
||||
else if (m_followParticipantId == 0)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
}
|
||||
QString labelText = tr("Map follows");
|
||||
|
||||
QString equipNoStr = QString::number(m_followEquipmentNo);
|
||||
labelText.append(QStringLiteral(": "));
|
||||
labelText.append(m_dtc->hierarchyFromParticipant(m_followParticipantId));
|
||||
if (m_followEquipmentNo > 0)
|
||||
{
|
||||
labelText.append(QStringLiteral(" ("));
|
||||
labelText.append(equipNoStr);
|
||||
labelText.append(QStringLiteral(")"));
|
||||
}
|
||||
m_ui->lbFollow->setText(labelText);
|
||||
DEBUG_LOG(m_logger) << "labelText=" << labelText;
|
||||
DEBUG_LOG(m_logger) << " m_ui->lbFollow->getText()" << m_ui->lbFollow->text();
|
||||
DEBUG_LOG(m_logger) << "newFollowEquipment(" << m_followEquipmentNo << ", "
|
||||
<< m_followParticipantId << ")";
|
||||
emit newFollowEquipment(m_followEquipmentNo,m_followParticipantId );
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantFollowDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
//#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <Plugins/ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
|
||||
// SituationMap
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
//DDS
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
//Qt
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantFollowDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// ParticipantFollowDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantFollowDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
using BaseClass = LtsWidgets::LtsDialog;
|
||||
|
||||
public:
|
||||
explicit ParticipantFollowDialog(QWidget *parent = nullptr);
|
||||
~ParticipantFollowDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc);
|
||||
void setFollower(const int equipmentNumber, const int participantId);
|
||||
Q_SIGNALS:
|
||||
void newFollowEquipment(const int equipmentNumber, const int participantId);
|
||||
|
||||
private slots:
|
||||
void slotLookup();
|
||||
void updateObjectIndicator();
|
||||
void enterEvent(QEvent *e) override;
|
||||
void leaveEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
int changeLabelText(int value);
|
||||
void onStartFollowClicked();
|
||||
void onStopFollowClicked();
|
||||
void changeParty();
|
||||
void fillMapFromDtc();
|
||||
void changeSliderPosition(int equipNo);
|
||||
int onSelectionChanged();
|
||||
void onDoubleClicked();
|
||||
void clearSelections();
|
||||
|
||||
void fillParticipantMapFromTree();
|
||||
void fillParticipantMapFromTree(const QModelIndex &parent);
|
||||
void enadisa();
|
||||
int getEquipmentNumber(const int participantId);
|
||||
|
||||
|
||||
ParticipantEditModel *m_model;
|
||||
int m_equipNo;
|
||||
|
||||
// ObjectIndicator: (ObjectIndicator schould not be updated to much, don`t know why...)
|
||||
QTimer *m_updateObjectIndicator = nullptr;
|
||||
|
||||
|
||||
// EquipNo, ParticipantId, QMap as it must be sorted, see changeSliderPosition()
|
||||
QMap<int, int> m_participantMap;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmCbxIfc;
|
||||
std::shared_ptr<ForeignParticipantInfoGuiInterface> m_ppmGuiIfc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
static int s_preselectedParty;
|
||||
static bool s_preselectedAllParticipants;
|
||||
Ui::ParticipantFollowDialog *m_ui;
|
||||
int m_followParticipantId; // 0 = Follow Participant = false
|
||||
int m_followEquipmentNo;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace ParticipantInfo
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantFollowDialog</class>
|
||||
<widget class="QWidget" name="ParticipantFollowDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>751</width>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>692</width>
|
||||
<height>342</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Participant Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbParticipants">
|
||||
<property name="title">
|
||||
<string>Participants</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2" rowspan="3">
|
||||
<widget class="QTreeView" name="tvParticipants">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbParty">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>159</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="cbAll">
|
||||
<property name="text">
|
||||
<string>All Participants</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Participant Follow</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Equipment Number:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leEquipNo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbLookup">
|
||||
<property name="text">
|
||||
<string>Lookup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="slEquipmentNumber">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblEquipmentNumber">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">88888</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbFollow">
|
||||
<property name="text">
|
||||
<string notr="true">Map follows:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cbParty</tabstop>
|
||||
<tabstop>tvParticipants</tabstop>
|
||||
<tabstop>cbAll</tabstop>
|
||||
<tabstop>leEquipNo</tabstop>
|
||||
<tabstop>pbLookup</tabstop>
|
||||
<tabstop>slEquipmentNumber</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Restock Charges - Restocks Charges of a distinct weapon selectively. Or their defaults. Or both.
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog - 2022-03-17
|
||||
*/
|
||||
|
||||
#include "participant_gear_restock.h"
|
||||
#include "ui_participant_gear_restock.h"
|
||||
#include "participant_gear_restock_charge.h"
|
||||
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
ParticipantGearRestock::ParticipantGearRestock(int gearId, int gearTypeId, const Participant &participant, DialogMode dialogMode, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_gearId(gearId)
|
||||
, m_gearTypeId(gearTypeId)
|
||||
, m_participant(participant)
|
||||
, m_dialogMode(dialogMode)
|
||||
, m_ui(new Ui::ParticipantGearRestock)
|
||||
, m_logger(getLogger("ParticipantGearRestock"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
// Defaultmäßig restocken...
|
||||
m_ui->cbRestockNow->setChecked(true);
|
||||
m_ui->cbRestockNow->setVisible(dialogMode == DM_SetRestockDefaults);
|
||||
}
|
||||
|
||||
ParticipantGearRestock::~ParticipantGearRestock()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantGearRestock::retranslate()
|
||||
{
|
||||
QString eqNoString;
|
||||
if (m_participant.equipmentNumber().is_set())
|
||||
eqNoString = QString::number(m_participant.equipmentNumber().get());
|
||||
else
|
||||
eqNoString = tr("[Participant Id: %1]").arg(m_participant.id());
|
||||
|
||||
if (m_dialogMode == DM_Restock)
|
||||
translate(m_ui, tr("Set %1's Restock Defaults of Participant %2").arg(m_pdmDtc->trGearTypeName(m_gearTypeId), eqNoString));
|
||||
// translate(m_ui, tr("Restock %1 of Participant %2").arg(m_pdmDtc->trGearTypeName(m_gearTypeId), eqNoString));
|
||||
// else
|
||||
}
|
||||
|
||||
bool ParticipantGearRestock::init(LtsSession::LtsSession *session, bool showAllOptions)
|
||||
{
|
||||
|
||||
|
||||
if (!session)
|
||||
return false;
|
||||
|
||||
m_session = session;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!session->getFtc<ParticipantManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!m_pdmDtc->canRestock(m_gearTypeId) && m_dialogMode == DialogMode::DM_Restock)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Not possible to restock gearTypeId = " << m_gearTypeId;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_pdmDtc->canSetDefaults(m_gearTypeId) && m_dialogMode == DialogMode::DM_SetRestockDefaults)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Not possible to set restock defaults gearTypeId = " << m_gearTypeId;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_max = m_pdmDtc->maxCharges(m_gearTypeId);
|
||||
m_ui->lblMaxCharges->setText(QString::number(m_max));
|
||||
QHBoxLayout * hLayoutMaxCharge = new QHBoxLayout();
|
||||
|
||||
QLabel *lblMax = new QLabel();
|
||||
QLabel *lblMaxCharges = new QLabel();
|
||||
|
||||
lblMaxCharges->setTextFormat(Qt::TextFormat::RichText);
|
||||
lblMaxCharges->setText(QStringLiteral("<b>") + QString::number(m_max) + QStringLiteral("</b>"));
|
||||
lblMax->setText(QStringLiteral("Max:"));
|
||||
|
||||
|
||||
lblMax->setVisible(m_max > 0);
|
||||
lblMaxCharges->setVisible(m_max > 0);
|
||||
|
||||
// m_ui->lblMax->setVisible(m_max > 0);
|
||||
// m_ui->lblMaxCharges->setVisible(m_max > 0);
|
||||
|
||||
m_ui->lblMax->setVisible(false);
|
||||
m_ui->lblMaxCharges->setVisible(false);
|
||||
|
||||
QVBoxLayout* vLayout = new QVBoxLayout(m_ui->scrollArea);
|
||||
vLayout->setMargin(0);
|
||||
m_ui->scrollArea->setLayout(vLayout);
|
||||
|
||||
for (const ProjectDataManagement::GearTypeChargeType &gearType2ChargeType : m_pdmDtc->gearTypeChargeTypes())
|
||||
{
|
||||
if (gearType2ChargeType.gearTypeId() != m_gearTypeId)
|
||||
continue;
|
||||
|
||||
int chargeTypeId = gearType2ChargeType.chargeTypeId();
|
||||
int maxCharge = m_pdmDtc->maxCharge(m_gearTypeId, chargeTypeId);
|
||||
|
||||
DEBUG_LOG(m_logger) << "maxCharge = " << maxCharge;
|
||||
|
||||
ParticipantGearRestockCharge* pgrc = new ParticipantGearRestockCharge(m_ui->scrollArea, showAllOptions);
|
||||
pgrc->init(chargeTypeId, m_pdmDtc->trChargeTypeShortName(chargeTypeId, true), m_pdmDtc->factoryDefault(m_gearTypeId, chargeTypeId), maxCharge);
|
||||
connect(pgrc, &ParticipantGearRestockCharge::valueChanged, this, &ParticipantGearRestock::validate);
|
||||
vLayout->addWidget(pgrc);
|
||||
}
|
||||
hLayoutMaxCharge->addWidget(lblMax);
|
||||
hLayoutMaxCharge->addWidget(lblMaxCharges);
|
||||
hLayoutMaxCharge->setMargin(8);
|
||||
hLayoutMaxCharge->setSpacing(0);
|
||||
vLayout->addLayout(hLayoutMaxCharge);
|
||||
validate(0);
|
||||
setUnchangeable(true);
|
||||
connect(this, &ParticipantGearRestock::signalChangesReset, this, [this]()
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(true);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
|
||||
});
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(true);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParticipantGearRestock::apply()
|
||||
{
|
||||
SelectiveReammunitionRequest req;
|
||||
req.id(m_participant.id());
|
||||
req.gearId(m_gearId);
|
||||
for (ParticipantGearRestockCharge* pgrc : m_ui->scrollArea->findChildren<ParticipantGearRestockCharge*>())
|
||||
{
|
||||
Reammunition ra;
|
||||
ra.chargeTypeId(pgrc->chargeTypeId());
|
||||
ra.tracerRatio(0);
|
||||
ra.newStock((m_dialogMode == DM_Restock || m_ui->cbRestockNow->isChecked()) ? pgrc->value() : 0xfffe);
|
||||
ra.newDefaultStock(m_dialogMode == DM_SetRestockDefaults ? pgrc->value() : 0xfffe);
|
||||
|
||||
req.reammunition().push_back(ra);
|
||||
}
|
||||
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->selectiveReammunitionRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void ParticipantGearRestock::validate(int newVal)
|
||||
{
|
||||
Q_UNUSED(newVal);
|
||||
if (m_max <= 0)
|
||||
return;
|
||||
|
||||
int total = 0;
|
||||
auto items = m_ui->scrollArea->findChildren<ParticipantGearRestockCharge*>();
|
||||
for (ParticipantGearRestockCharge* pgrc : items)
|
||||
total += pgrc->value();
|
||||
|
||||
for (ParticipantGearRestockCharge* pgrc : items)
|
||||
pgrc->setMaxValue(m_max + pgrc->value() - total);
|
||||
}
|
||||
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Restock Charges - Restocks Charges of a distinct weapon selectively. Or their defaults. Or both.
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog - 2022-03-17
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantGearRestock;
|
||||
}
|
||||
|
||||
namespace ProjectDataManagement {
|
||||
namespace Interface {
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface {
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
class ParticipantGearRestock : public LtsWidgets::LtsDialog
|
||||
, protected ParticipantManagement::Interface::Ftc::SelectiveReammunitionReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum DialogMode
|
||||
{
|
||||
DM_Restock,
|
||||
DM_SetRestockDefaults
|
||||
};
|
||||
|
||||
explicit ParticipantGearRestock(int gearId, int gearTypeId, const Participant &participant, DialogMode dialogMode, QWidget *parent = nullptr);
|
||||
~ParticipantGearRestock();
|
||||
|
||||
bool init(LtsSession::LtsSession *session, bool showAllOptions = false);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
void onSelectiveReammunitionReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private slots:
|
||||
void validate(int newVal);
|
||||
|
||||
private:
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LtsSession::LtsSession *m_session;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
|
||||
int m_gearId{-1};
|
||||
int m_gearTypeId{-1};
|
||||
Participant m_participant;
|
||||
int m_max{9999};
|
||||
DialogMode m_dialogMode{DM_SetRestockDefaults};
|
||||
|
||||
Ui::ParticipantGearRestock *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantGearRestock</class>
|
||||
<widget class="QWidget" name="ParticipantGearRestock">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>810</width>
|
||||
<height>377</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="scrollArea" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>766</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>303</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbRestockNow">
|
||||
<property name="text">
|
||||
<string>Restock Now</string>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblMax">
|
||||
<property name="text">
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblMaxCharges">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">9999</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblNote">
|
||||
<property name="text">
|
||||
<string>Initial values are factory defaults. They may differ from the weapon's actually configured values.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Restock Charges - UI Element for a single charge.
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog - 2022-03-17
|
||||
*/
|
||||
|
||||
#include "participant_gear_restock_charge.h"
|
||||
#include "ui_participant_gear_restock_charge.h"
|
||||
|
||||
ParticipantGearRestockCharge::ParticipantGearRestockCharge(QWidget *parent, bool showAllOptions)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ParticipantGearRestockCharge)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->rbValue->setVisible(showAllOptions);
|
||||
m_ui->rbDefault->setVisible(showAllOptions);
|
||||
m_ui->rbNoChange->setVisible(showAllOptions);
|
||||
m_ui->rbUnlimited->setVisible(showAllOptions);
|
||||
}
|
||||
|
||||
ParticipantGearRestockCharge::~ParticipantGearRestockCharge()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool ParticipantGearRestockCharge::init(int chargeTypeId, const QString &chargeName, int initialValue, int maxThisCharge)
|
||||
{
|
||||
m_chargeTypeId = chargeTypeId;
|
||||
m_maxThisCharge = maxThisCharge;
|
||||
m_ui->lblChargeName->setText(chargeName);
|
||||
m_ui->sbValue->setRange(0,9999);
|
||||
m_ui->sbValue->setValue(initialValue);
|
||||
m_ui->sbValue->setFixedWidth(50);
|
||||
|
||||
setObjectName(QStringLiteral("pgrc-")+QString::number(m_chargeTypeId));
|
||||
|
||||
connect(m_ui->sbValue, QOverload<int>::of(&QSpinBox::valueChanged), this, &ParticipantGearRestockCharge::valueChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantGearRestockCharge::setMaxValue(int maxVal)
|
||||
{
|
||||
if (m_maxThisCharge > 0)
|
||||
m_ui->sbValue->setMaximum(qMin(maxVal, m_maxThisCharge));
|
||||
else
|
||||
m_ui->sbValue->setMaximum(maxVal);
|
||||
}
|
||||
|
||||
int ParticipantGearRestockCharge::value() const
|
||||
{
|
||||
if (m_ui->rbDefault->isChecked())
|
||||
return 0xffff;
|
||||
if (m_ui->rbNoChange->isChecked())
|
||||
return 0xfffe;
|
||||
if (m_ui->rbUnlimited->isChecked())
|
||||
return 0xfffd;
|
||||
|
||||
return m_ui->sbValue->value();
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Restock Charges - UI Element for a single charge.
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Iuliana Ojog - 2022-03-17
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ParticipantGearRestockCharge;
|
||||
}
|
||||
|
||||
class ParticipantGearRestockCharge : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantGearRestockCharge(QWidget *parent = nullptr, bool showAllOptions = false);
|
||||
~ParticipantGearRestockCharge();
|
||||
|
||||
bool init(int chargeTypeId, const QString &chargeName, int initialValue, int maxThisCharge);
|
||||
int value() const;
|
||||
int chargeTypeId() const { return m_chargeTypeId; }
|
||||
|
||||
public slots:
|
||||
void setMaxValue(int maxVal); // If this is higher than "maxThisCharge", maxThisCharge is taken!
|
||||
|
||||
signals:
|
||||
void valueChanged(int newVal);
|
||||
|
||||
private:
|
||||
int m_chargeTypeId{-1};
|
||||
int m_maxThisCharge{9999};
|
||||
Ui::ParticipantGearRestockCharge *m_ui;
|
||||
};
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantGearRestockCharge</class>
|
||||
<widget class="QWidget" name="ParticipantGearRestockCharge">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>517</width>
|
||||
<height>44</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblChargeName">
|
||||
<property name="text">
|
||||
<string notr="true">[ChargeName]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="rbValue">
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="sbValue">
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QRadioButton" name="rbDefault">
|
||||
<property name="text">
|
||||
<string>Factory Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QRadioButton" name="rbNoChange">
|
||||
<property name="text">
|
||||
<string>No Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QRadioButton" name="rbUnlimited">
|
||||
<property name="text">
|
||||
<string>Unlimited</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - ParticipantHistoryDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include "participant_history_dialog.h"
|
||||
#include "ui_participant_history_dialog.h"
|
||||
#include <QDebug>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
ParticipantHistoryDialog::ParticipantHistoryDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ddsId(-1)
|
||||
, m_model(new ParticipantHistoryDialogModel(this))
|
||||
, m_proxyModel(new ParticipantHistorySortModel(this))
|
||||
, m_dtc(nullptr)
|
||||
, m_ui(new Ui::ParticipantHistoryDialog)
|
||||
, m_logger(getLogger("ParticipantHistoryDialog"))
|
||||
{
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->setupUi(this);
|
||||
m_ui->tvHistory->setModel(m_proxyModel);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->tvHistory->hideColumn(ParticipantHistoryDialogModel::VulnerabilityBits);
|
||||
#endif
|
||||
|
||||
const bool showVulnerabilityKindProject = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
QStringLiteral("ShowVulnerabilityKind"));
|
||||
if (!showVulnerabilityKindProject)
|
||||
m_ui->tvHistory->hideColumn(ParticipantHistoryDialogModel::Vulnerability);
|
||||
|
||||
|
||||
|
||||
setUnchangeable();
|
||||
}
|
||||
|
||||
ParticipantHistoryDialog::~ParticipantHistoryDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantHistoryDialog::retranslate()
|
||||
{
|
||||
const dds::core::optional<int32_t> eqId = m_dtc->participant(m_ddsId).equipmentNumber();
|
||||
const QString id = (eqId.is_set() ? QString::number(eqId.get()) : QString());
|
||||
|
||||
translate(m_ui, id, false, tr("Participant History"));
|
||||
}
|
||||
|
||||
bool ParticipantHistoryDialog::init(int ddsId,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
||||
{
|
||||
m_ddsId = ddsId;
|
||||
m_dtc = dtc;
|
||||
|
||||
if (!m_dtc)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
if (m_model->initModel(m_ddsId, m_dtc, pdmDtc, aesDtc))
|
||||
{
|
||||
m_ui->tvHistory->syncSearchHeaderAndTableContentColumnSize();
|
||||
bool isHuman = m_dtc->type(m_dtc->participant(m_ddsId).typeId()).typeClass() == ParticipantManagement::TypeClass::Human;
|
||||
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
|
||||
QStringLiteral("HasPvSan"));
|
||||
|
||||
if (!showPvSan || !isHuman)
|
||||
m_ui->tvHistory->hideColumn(ParticipantHistoryDialogModel::Vitality);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantHistoryDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include "participant_history_dialog_model.h"
|
||||
|
||||
namespace Ui {
|
||||
class ParticipantHistoryDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// ParticipantHistoryDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantHistoryDialog final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantHistoryDialog(QWidget *parent = nullptr);
|
||||
~ParticipantHistoryDialog();
|
||||
|
||||
bool init(int ddsId,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
int m_ddsId;
|
||||
ParticipantHistoryDialogModel *m_model;
|
||||
ParticipantHistorySortModel *m_proxyModel;
|
||||
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
Ui::ParticipantHistoryDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace ParticipantManagement
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantHistoryDialog</class>
|
||||
<widget class="QWidget" name="ParticipantHistoryDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>408</width>
|
||||
<height>230</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Player History </string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="tvHistory"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+350
@@ -0,0 +1,350 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for ParticipantHistory
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "participant_history_dialog_model.h"
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <ngltranslator/ngltranslator.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// ParticipantHistoryDialogModel
|
||||
//---------------------------------
|
||||
ParticipantHistoryDialogModel::ParticipantHistoryDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<StateInformation>(
|
||||
{
|
||||
tr("Time"),
|
||||
tr("State"),
|
||||
tr("Vitality"),
|
||||
tr("Originator"),
|
||||
tr("Vulnerability"),
|
||||
tr("Vulnerability bits")
|
||||
},
|
||||
parent)
|
||||
, m_ddsId(-1)
|
||||
, m_vulnerabilityClass(ProjectDataManagement::VulnerabilityClass::SoldierInjuries)
|
||||
, m_dtc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
, m_logger(getLogger("ParticipantHistoryDialogModel"))
|
||||
{}
|
||||
|
||||
bool ParticipantHistoryDialogModel::initModel(int dds_id,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
||||
{
|
||||
m_ddsId = dds_id;
|
||||
m_dtc = dtc;
|
||||
m_pdmDtc = pdmDtc;
|
||||
m_aesDtc = aesDtc;
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::dynamicParticipantDataChanged,
|
||||
this, &ParticipantHistoryDialogModel::onDynamicParticipantDataChanged);
|
||||
|
||||
const auto &part = m_dtc->participant(m_ddsId);
|
||||
const auto typeClass = dtc->type(part.typeId()).typeClass();
|
||||
|
||||
m_vulnerabilityClass = (typeClass == TypeClass::Human) ?
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
|
||||
reinitModel(m_dtc->dynamicParticipantData(m_ddsId).stateHistory());
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant ParticipantHistoryDialogModel::dataInternal(const QModelIndex &index) const
|
||||
{
|
||||
const StateInformation &data = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case Time:
|
||||
return QDateTime::fromMSecsSinceEpoch(data.stateTime());
|
||||
case VulnerabilityState:
|
||||
{
|
||||
if(data.originatorType().underlying() == ProjectDataManagement::StateChangeOriginator::Sanitation)
|
||||
return {};
|
||||
|
||||
if (data.vulnerabilityState() == ProjectDataManagement::VulnerabilityState::NotReady)
|
||||
return {};
|
||||
|
||||
std::bitset<sizeof(data.vulnerabilityBits()) * 8> bits(data.vulnerabilityBits());
|
||||
bits.set(data.vulnerabilityState().underlying());
|
||||
// show either 0,1,2 *or* 3 but not a combination of them
|
||||
for (int i = ProjectDataManagement::VulnerabilityState_def::HeavyDamage; i >= 0; --i)
|
||||
{
|
||||
if (!bits.test(i))
|
||||
continue;
|
||||
for (int j = 0; j < i; ++j)
|
||||
bits.reset(j);
|
||||
break;
|
||||
}
|
||||
// when killed then we don't want to show anything else
|
||||
if (bits.test(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill))
|
||||
{
|
||||
for (int j = 0; j < ProjectDataManagement::VulnerabilityState_def::CatastrophicKill; ++j)
|
||||
bits.reset(j);
|
||||
bits.reset(ProjectDataManagement::VulnerabilityState_def::TemporarySeverance);
|
||||
}
|
||||
|
||||
QStringList sl;
|
||||
for (int i = 0; i <= ProjectDataManagement::VulnerabilityState_def::CContamination; ++i)
|
||||
{
|
||||
if (!bits.test(i))
|
||||
continue;
|
||||
const ProjectDataManagement::VulnerabilityState vs(static_cast<ProjectDataManagement::VulnerabilityState_def::type>(i));
|
||||
sl += ProjectDataManagement::toString(vs, m_vulnerabilityClass);
|
||||
}
|
||||
sl.prepend(QLatin1String()); // Prefix
|
||||
return sl;
|
||||
}
|
||||
case Originator:
|
||||
{
|
||||
QString originatorType(ProjectDataManagement::toString(data.originatorType()));
|
||||
QString originator;
|
||||
switch (data.originatorType().underlying())
|
||||
{
|
||||
case ProjectDataManagement::StateChangeOriginator::DusMine:
|
||||
case ProjectDataManagement::StateChangeOriginator::ImprovisedExplosiveDevice:
|
||||
originator = QString::number(data.originatorId() < 0 ? 0 - data.originatorId() : data.originatorId());
|
||||
break;
|
||||
case ProjectDataManagement::StateChangeOriginator::Participant:
|
||||
{
|
||||
if (data.originatorId() < 0) //is probablby ParticipantId or unkown EquipmentNumber decoded
|
||||
{
|
||||
originator = QString::number(-data.originatorId());
|
||||
}
|
||||
else
|
||||
{
|
||||
const Participant participant = m_dtc->participant(data.originatorId());
|
||||
if (participant.equipmentNumber().is_set())
|
||||
originator = QString::number(participant.equipmentNumber().get());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::Party:
|
||||
{
|
||||
const Party party = m_dtc->party(data.originatorId());
|
||||
originator = QString::fromStdString(party.name());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation:
|
||||
case ProjectDataManagement::StateChangeOriginator::FunctionalArea:
|
||||
{
|
||||
if (m_aesDtc)
|
||||
{
|
||||
// AreaEffectSimulation::AesItem aesItem;
|
||||
// m_aesDtc->aesItemFromId(data.originatorId(), aesItem);
|
||||
// if (aesItem.id() > 0)
|
||||
// originator = QString::fromStdString(aesItem.name());
|
||||
originator = m_aesDtc->aesItemNameFromEntityId(data.originatorId());
|
||||
|
||||
}
|
||||
if (data.originatorId() == 0 && data.originatorType().underlying() == ProjectDataManagement::StateChangeOriginator::FunctionalArea)
|
||||
{
|
||||
//Functional Area without ID: special case Auto Reset
|
||||
originatorType = tr("Autoreset");
|
||||
originator.clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::Sanitation:
|
||||
{
|
||||
const Participant participant = m_dtc->participant(data.originatorId());
|
||||
if (participant.equipmentNumber().is_set())
|
||||
originator = QString::number(participant.equipmentNumber().get());
|
||||
else if (data.originatorId() < 0)
|
||||
originator = QString::number(-data.originatorId());
|
||||
else if (data.originatorId() == 0)
|
||||
originator = tr("Exercise Control");
|
||||
QStringList san;
|
||||
san += QStringLiteral("%1 (%2 - %3) - ").arg(tr("Treatment"), originator, ParticipantManagement::toString(static_cast<Qualification::inner_enum>(data.originatorChargeTypeId())));
|
||||
san += m_pdmDtc->sanitationProceduresList(data.sanitationProceduresTaken());
|
||||
return san;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::ObserverController:
|
||||
{
|
||||
QString oc;
|
||||
if (data.originatorChargeTypeId() == 1 )
|
||||
{
|
||||
oc = tr ("9-Liner created");
|
||||
}
|
||||
else if (data.originatorChargeTypeId() == 2)
|
||||
{
|
||||
oc = tr("Qualif. Transport initiated");
|
||||
}
|
||||
else
|
||||
oc = ProjectDataManagement::toString(data.originatorType());
|
||||
|
||||
if (data.originatorChargeTypeId() == 8)
|
||||
oc.append(tr( " - Wound increase paused")); //: Verwundung Pausiert
|
||||
else if (data.originatorChargeTypeId() == 35)
|
||||
oc.append(tr( " - Wound increase continued")); //: Verwundung Fortgesetzt
|
||||
return oc;
|
||||
}
|
||||
#ifdef GUEZ_MODE
|
||||
case ProjectDataManagement::StateChangeOriginator::MedicalTimeout:
|
||||
{
|
||||
QString mo = tr("Injury increased - "); //Verwundung steigerung
|
||||
switch(data.sanitationResult().underlying())
|
||||
{
|
||||
case SanitationResult::Unhandled:
|
||||
mo.append(tr("No Care"));
|
||||
break;
|
||||
case SanitationResult::Insufficient:
|
||||
mo.append(tr("Insufficient Care"));
|
||||
break;
|
||||
case SanitationResult::Sufficient:
|
||||
mo.append(tr("Sufficient Care"));
|
||||
break;
|
||||
case SanitationResult::Optimal:
|
||||
mo.append(tr("Optimal Care"));
|
||||
break;
|
||||
default:
|
||||
mo.append(ProjectDataManagement::toString(data.originatorType()));
|
||||
}
|
||||
return mo;
|
||||
}
|
||||
#endif
|
||||
case ProjectDataManagement::StateChangeOriginator::ExerciseControl:
|
||||
case ProjectDataManagement::StateChangeOriginator::WoundTreatmentDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::MaintainanceDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::Initialization:
|
||||
case ProjectDataManagement::StateChangeOriginator::Unknown:
|
||||
return ProjectDataManagement::toString(data.originatorType());
|
||||
}
|
||||
|
||||
QString chargeType = m_pdmDtc->trChargeTypeShortName(data.originatorChargeTypeId());
|
||||
if (!originator.isEmpty() && !chargeType.isEmpty())
|
||||
originatorType += QStringLiteral("(%1 - %2)").arg(originator, chargeType);
|
||||
else if (!originator.isEmpty())
|
||||
originatorType += QStringLiteral(" (%1)").arg(originator);
|
||||
else if (!chargeType.isEmpty())
|
||||
originatorType += QStringLiteral(" (%1)").arg(chargeType);
|
||||
return originatorType;
|
||||
}
|
||||
case Vulnerability:
|
||||
if(data.originatorType().underlying() == ProjectDataManagement::StateChangeOriginator::Sanitation)
|
||||
return {};
|
||||
//AG 40 HACK!
|
||||
if (data.vulnerabilityKindId() == 459286 && !((data.vulnerabilityBits() >> 7) & 1)) // VBG7 NOT set in history bits, but kind id still implying that VBG7 is still active
|
||||
return QLatin1String("-");
|
||||
return m_pdmDtc->trVulnerabilityKindName(data.vulnerabilityKindId(), m_vulnerabilityClass);
|
||||
case VulnerabilityBits:
|
||||
return QString::number(data.vulnerabilityBits(), 16).toUpper().prepend(QStringLiteral("0x"));
|
||||
case Vitality:
|
||||
// [GUEZE-3163] PVSan Teilnehmerhistorie keine Vitalitaet
|
||||
// if(data.originatorType().underlying() == ProjectDataManagement::StateChangeOriginator::Sanitation)
|
||||
// return {};
|
||||
|
||||
if (data.vitality() <= 100)
|
||||
return QString::number(data.vitality());
|
||||
return QStringLiteral("--");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
QVariant ParticipantHistoryDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return {};
|
||||
|
||||
QVariant srcTxt = dataInternal(index);
|
||||
if (role == Qt::ToolTipRole)
|
||||
{
|
||||
if (!srcTxt.canConvert(QMetaType::QStringList))
|
||||
return {};
|
||||
QStringList sl = srcTxt.toStringList();
|
||||
if (sl.size() == 1)
|
||||
return {}; // No Tooltip for things without a StringList.
|
||||
return sl.join(QStringLiteral("\n"));
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
if (!srcTxt.canConvert(QMetaType::QStringList))
|
||||
return srcTxt;
|
||||
QStringList sl = srcTxt.toStringList();
|
||||
if (sl.size() <= 1)
|
||||
return sl;
|
||||
|
||||
QString prefix = sl.takeFirst();
|
||||
return prefix.append(QStringLiteral(" ")).append(sl.join(QStringLiteral(", ")));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
void ParticipantHistoryDialogModel::onDynamicParticipantDataChanged(const DynamicParticipantData &data, DataModification modType)
|
||||
{
|
||||
if (m_ddsId != data.participantId())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_vecData.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
reinitModel(data.stateHistory());
|
||||
}
|
||||
|
||||
void ParticipantHistoryDialogModel::reinitModel(const std::vector<ParticipantManagement::StateInformation> &newData)
|
||||
{
|
||||
beginResetModel();
|
||||
m_vecData = LtsUtils::convert<QVector<StateInformation>>(newData);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ParticipantHistorySortModel
|
||||
// --------------------------------------------------------
|
||||
void ParticipantHistorySortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<ParticipantHistoryDialogModel *>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool ParticipantHistorySortModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel)
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
if (!m_sourceModel->indexIsValid(source_left) ||
|
||||
!m_sourceModel->indexIsValid(source_right))
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
const StateInformation &siLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const StateInformation &siRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
if (source_left.column() == ParticipantHistoryDialogModel::Time)
|
||||
{
|
||||
if (siLeft.stateTime() != siRight.stateTime())
|
||||
return siLeft.stateTime() < siRight.stateTime();
|
||||
//Die 8 gewinnt immer! (Totalausfall
|
||||
if ( siRight.vulnerabilityState().underlying() == 8)
|
||||
return true;
|
||||
if ( siLeft.vulnerabilityState().underlying() == 8)
|
||||
return false;
|
||||
return siLeft.vulnerabilityState() < siRight.vulnerabilityState();
|
||||
}
|
||||
if (source_left.column() == ParticipantHistoryDialogModel::Vulnerability)
|
||||
{
|
||||
if (siLeft.vulnerabilityState() != siRight.vulnerabilityState())
|
||||
return siLeft.vulnerabilityState() < siRight.vulnerabilityState();
|
||||
return siLeft.stateTime() < siRight.stateTime();
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for Participant History
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// ParticipantHistoryDialogModel
|
||||
// --------------------------------------------------------
|
||||
class ParticipantHistoryDialogModel final : public LtsWidgets::LtsAbstractTableModel<StateInformation>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Column
|
||||
{
|
||||
Time,
|
||||
VulnerabilityState,
|
||||
Vitality,
|
||||
Originator,
|
||||
Vulnerability,
|
||||
VulnerabilityBits
|
||||
};
|
||||
explicit ParticipantHistoryDialogModel(QObject *parent = nullptr);
|
||||
~ParticipantHistoryDialogModel() = default;
|
||||
|
||||
bool initModel(int dds_id,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onDynamicParticipantDataChanged(const DynamicParticipantData &data, DataModification modType);
|
||||
|
||||
private:
|
||||
void reinitModel(const std::vector<StateInformation> &newData);
|
||||
QVariant dataInternal(const QModelIndex &index) const;
|
||||
|
||||
int m_ddsId;
|
||||
|
||||
ProjectDataManagement::VulnerabilityClass m_vulnerabilityClass;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
friend class ParticipantHistorySortModel;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ParticipantHistorySortModel
|
||||
// --------------------------------------------------------
|
||||
class ParticipantHistorySortModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
ParticipantHistoryDialogModel *m_sourceModel = nullptr;
|
||||
};
|
||||
} //namespace ParticipantManagement
|
||||
Executable
+184
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for HitLine - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, NLSE, 2018-01-19
|
||||
*/
|
||||
#include "participant_hitline_info_dialog.h"
|
||||
#include "ui_participant_hitline_info_dialog.h"
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
HitLineInfoDialog::HitLineInfoDialog(int hitLineId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_hitLineId(hitLineId)
|
||||
, m_typeClass(TypeClass::Human)
|
||||
, m_isInitialized(false)
|
||||
, m_dtc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_ui(new Ui::HitLineInfoDialog)
|
||||
, m_logger(getLogger("ParticipantHitLineInfoDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbOriginatorFindOnMap, &QToolButton::clicked,
|
||||
this, &HitLineInfoDialog::onFindOriginatorOnMap);
|
||||
connect(m_ui->pbInjuryFindOnMap, &QToolButton::clicked,
|
||||
this, &HitLineInfoDialog::onFindInjuryOnMap);
|
||||
|
||||
// Debug Infos
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lbHitLineId->hide();
|
||||
m_ui->lblHitLineId->hide();
|
||||
m_ui->lbChargeTypeId->hide();
|
||||
m_ui->lblChargeTypeId->hide();
|
||||
// m_ui->lbChargeType->hide();
|
||||
// m_ui->lblChargeType->hide();
|
||||
#endif
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Hitline"));
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
HitLineInfoDialog::~HitLineInfoDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Hit Line Info"));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool HitLineInfoDialog::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_pdmDtc = pdmDtc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
|
||||
// Geht ueber alle HitLineInfos in der Map
|
||||
m_dtc->hitLineInfos([this](const ParticipantManagement::HitLineInfo & data)
|
||||
{
|
||||
if (data.id() == m_hitLineId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Found HitLine Id: " << data.id();
|
||||
m_hitLineInfo = data;
|
||||
|
||||
// Daten der Participants beschaffen
|
||||
m_participantOriginator = m_dtc->participant(data.originatorParticipantId());
|
||||
m_participantInjury = m_dtc->participant(data.injuryParticipantId());
|
||||
|
||||
showHitLineInfos();
|
||||
}
|
||||
});
|
||||
|
||||
if (!m_isInitialized)
|
||||
WARNING_LOG(m_logger) << "Non HitLineInfo data found for id: " << m_hitLineId;
|
||||
return m_isInitialized;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::showHitLineInfos()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " id:" << m_hitLineId;
|
||||
|
||||
if (m_participantOriginator.id() <= 0 || m_participantInjury.id() <= 0)
|
||||
return;
|
||||
|
||||
m_ui->lblHitLineId->setText(QString::number(m_hitLineId));
|
||||
|
||||
// SampleTime
|
||||
m_ui->lblSampleTime->setText(DTG::toStringMSec(m_hitLineInfo.sampleTime()));
|
||||
|
||||
// Originator Id
|
||||
Participant participant = m_dtc->participant(m_participantOriginator.id());
|
||||
m_ui->lblOriginatorEquipNr->setText(QString::number(participant.equipmentNumber().get()));
|
||||
// Originator Party
|
||||
m_ui->lblOriginatorParty->setText(ParticipantManagement::trPartyName(m_dtc->party(m_hitLineInfo.originatorPartyId()).name()));
|
||||
// Originator Designator
|
||||
m_ui->lblOriginatorDesignator->setText(QString::fromStdString(m_participantOriginator.designator()));
|
||||
// Originator Tact.Identifier
|
||||
m_ui->lblOriginatorTactIdentifier->setText(QString::fromStdString(m_participantOriginator.tacticalIdentifier()));
|
||||
// Originator Type
|
||||
m_ui->lblOriginatorType->setText(ParticipantManagement::trTypeName(m_dtc->type(m_participantOriginator.typeId()).name()));
|
||||
// Originator Position
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(m_hitLineInfo.originatorPos().lon(), m_hitLineInfo.originatorPos().lat());
|
||||
if (qFuzzyIsNull(m_hitLineInfo.originatorPos().z()))
|
||||
m_ui->lblOriginatorPos->setText(tr("Position: %1").arg(mgrs));
|
||||
else
|
||||
m_ui->lblOriginatorPos->setText(tr("Position: %1 %2").arg(mgrs).arg(m_hitLineInfo.originatorPos().z()));
|
||||
|
||||
// Injury Id
|
||||
participant = m_dtc->participant(m_participantInjury.id());
|
||||
m_ui->lblInjuryEquipNr->setText(QString::number(participant.equipmentNumber().get()));
|
||||
// Injury Party
|
||||
m_ui->lblInjuryParty->setText(ParticipantManagement::trPartyName(m_dtc->party(m_participantInjury.partyId()).name()));
|
||||
// Injury Designator
|
||||
m_ui->lblInjuryDesignator->setText(QString::fromStdString(m_participantInjury.designator()));
|
||||
// Injury Tact.Identifier
|
||||
m_ui->lblInjuryTactIdentifier->setText(QString::fromStdString(m_participantInjury.tacticalIdentifier()));
|
||||
// Injury Type
|
||||
m_ui->lblInjuryType->setText(ParticipantManagement::trTypeName(m_dtc->type(m_participantInjury.typeId()).name()));
|
||||
// Injury Position
|
||||
mgrs = LtsCoordTrans::mgrsFromGeographic(m_hitLineInfo.injuryPos().lon(), m_hitLineInfo.injuryPos().lat());
|
||||
if (qFuzzyIsNull(m_hitLineInfo.injuryPos().z()))
|
||||
m_ui->lblInjuryPos->setText(tr("Position: %1").arg(mgrs));
|
||||
else
|
||||
m_ui->lblInjuryPos->setText(tr("Position: %1 %2").arg(mgrs).arg(m_hitLineInfo.injuryPos().z()));
|
||||
// Injury State
|
||||
m_typeClass = m_dtc->type(m_participantInjury.typeId()).typeClass();
|
||||
|
||||
ParticipantManagement::DynamicParticipantData data = m_dtc->dynamicParticipantData(m_participantInjury.id());
|
||||
|
||||
const ProjectDataManagement::VulnerabilityClass vc = m_typeClass == TypeClass::Human ?
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
|
||||
const StateInformation &lastState = m_dtc->youngestStateInformation(data.stateHistory());
|
||||
m_ui->lblInjuryStatus->setText(ProjectDataManagement::toString(lastState.vulnerabilityState(), vc));
|
||||
|
||||
// Charge Type
|
||||
m_ui->lblChargeTypeId->setText(QString::number(m_hitLineInfo.chargeTypeId()));
|
||||
|
||||
m_ui->lblChargeType->setText(m_pdmDtc->trChargeTypeShortName(m_hitLineInfo.chargeTypeId()));
|
||||
m_ui->lblChargeType->setToolTip(m_pdmDtc->trChargeTypeName(m_hitLineInfo.chargeTypeId()));
|
||||
|
||||
m_isInitialized = true;
|
||||
} // end of showHitLineInfos()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::onFindOriginatorOnMap()
|
||||
{
|
||||
findOnMap(m_participantOriginator.id());
|
||||
} // end of onFindOriginatorOnMap()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::onFindInjuryOnMap()
|
||||
{
|
||||
findOnMap(m_participantInjury.id());
|
||||
} // end of onFindInjuryOnMap()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::findOnMap(int id)
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->centerMapToParticipant(id);
|
||||
} // end of onFindOnMap()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for HitLine - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, NLSE, 2018-01-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
//DDS
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
|
||||
//SituationMap
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class HitLineInfoDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
// --------------------------------------------------------
|
||||
// HitLineInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class HitLineInfoDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HitLineInfoDialog(int hitLineId, QWidget *parent = nullptr);
|
||||
~HitLineInfoDialog();
|
||||
|
||||
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void showHitLineInfos();
|
||||
void findOnMap(int id);
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFindInjuryOnMap();
|
||||
void onFindOriginatorOnMap();
|
||||
|
||||
private:
|
||||
int m_hitLineId;
|
||||
HitLineInfo m_hitLineInfo;
|
||||
Participant m_participantOriginator;
|
||||
Participant m_participantInjury;
|
||||
TypeClass m_typeClass;
|
||||
bool m_isInitialized;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
Ui::HitLineInfoDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace ParticipantManagement
|
||||
+434
@@ -0,0 +1,434 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HitLineInfoDialog</class>
|
||||
<widget class="QWidget" name="HitLineInfoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>341</width>
|
||||
<height>696</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>257</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Hit Line Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>93</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>127</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbHitLineId">
|
||||
<property name="text">
|
||||
<string>HitLine Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblHitLineId">
|
||||
<property name="text">
|
||||
<string notr="true"><HITLINE_ID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbSampleTime">
|
||||
<property name="text">
|
||||
<string>Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblSampleTime">
|
||||
<property name="text">
|
||||
<string notr="true"><SAMPLETIME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Originator</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorEquipNr">
|
||||
<property name="text">
|
||||
<string>Equip. No:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorEquipNr">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_EQUIP_NO></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorParty">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorParty">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_PARTY></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorTactIdentifier">
|
||||
<property name="text">
|
||||
<string>Tact. Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorTactIdentifier">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_TACTIDENTIFIER></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorDesignator">
|
||||
<property name="text">
|
||||
<string>Designator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorDesignator">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_DESIGNATOR></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorType">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorType">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_TYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblOriginatorPos">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_POS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QToolButton" name="pbOriginatorFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on Map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Injury</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbInjuryEquipNr">
|
||||
<property name="text">
|
||||
<string>Equip. No:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblInjuryEquipNr">
|
||||
<property name="text">
|
||||
<string notr="true"><INJURY_EQUIP_NO></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbInjuryParty">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblInjuryParty">
|
||||
<property name="text">
|
||||
<string notr="true"><INJURY_PARTY></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbInjuryTactIdentifier">
|
||||
<property name="text">
|
||||
<string>Tact. Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblInjuryTactIdentifier">
|
||||
<property name="text">
|
||||
<string notr="true"><INJURY_TACTIDENTIFIER></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbInjuryDesignator">
|
||||
<property name="text">
|
||||
<string>Designator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblInjuryDesignator">
|
||||
<property name="text">
|
||||
<string notr="true"><INJURY_DESIGNATOR></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbInjuryType">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblInjuryType">
|
||||
<property name="text">
|
||||
<string notr="true"><INJURY_TYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbInjuryStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QLabel" name="lblInjuryStatus">
|
||||
<property name="text">
|
||||
<string notr="true"><INJURYSTATUS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblInjuryPos">
|
||||
<property name="text">
|
||||
<string notr="true"><INJURY_POS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QToolButton" name="pbInjuryFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on Map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="lbChargeTypeId">
|
||||
<property name="text">
|
||||
<string>Charge Type Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="lbChargeType">
|
||||
<property name="text">
|
||||
<string>Charge Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="3">
|
||||
<widget class="QLabel" name="lblChargeTypeId">
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPEID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="3">
|
||||
<widget class="QLabel" name="lblChargeType">
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
+1734
File diff suppressed because it is too large.
Load diff
+190
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* @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 <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//Asb
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
|
||||
//DDS
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_symbol_appearance_settings.h>
|
||||
|
||||
//SituationMap
|
||||
#include <Plugins/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
|
||||
{
|
||||
class ParticipantInfoDialog;
|
||||
}
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class ParticipantInfoLtdGearComponent;
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ParticipantInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantInfoDialog final : public LtsWidgets::LtsDialog
|
||||
, protected FilterManagement::SymbolAppearanceSettings::SettingsChangedCallback
|
||||
, protected TargetManagement::Interface::Ftc::ConfigureTargetReplyHandler
|
||||
, protected ParticipantManagement::Interface::Ftc::CreateModifyUasReplyHandler
|
||||
, protected ParticipantManagement::Interface::Ftc::ModifyUasStateReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantInfoDialog(int participantId, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~ParticipantInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbInterface,
|
||||
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc);
|
||||
|
||||
void onConfigureTargetReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onCreateModifyUasReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); };
|
||||
void onModifyUasStateReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); };
|
||||
signals:
|
||||
void entityInfoChanged(const QString &text);
|
||||
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool setUiValues();
|
||||
static void setBackgroundColor(QWidget *w, Qt::GlobalColor color, bool bSetColor);
|
||||
void updateIcon(const Participant &participant);
|
||||
void updateIcon(const QColor &color, const QString &sidc);
|
||||
void setSanitationLabelColor(SanitationResult proceduresDone);
|
||||
void setKindVisible(bool bVisible);
|
||||
void setBottomSpacerVisibility(bool isOneListActive);
|
||||
void setStatusVisible(bool bVisible);
|
||||
void setHistoryVisible(bool bVisible);
|
||||
void setEquipNrVisible(bool bVisible);
|
||||
void setBiteVisible(bool bVisible);
|
||||
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);
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onDynamicParticipantDataChanged(const DynamicParticipantData &data, DataModification modType = DataModification::eModified);
|
||||
void onPositionChanged(const ParticipantPosition &position);
|
||||
void onUasChanged(const UAS &uas);
|
||||
void onUnlockUAS();
|
||||
void onUnitPositionChanged(const UnitPosition &position);
|
||||
void onUpdatePosition(int participantId, const Core::GeoPosition &position, qint64 sampleTime);
|
||||
void onParticipantChanged(const Participant &participant, DataModification modType = DataModification::eModified);
|
||||
void onTypeChanged(const Type &type, DataModification modType);
|
||||
void updateCurrentIcon();
|
||||
|
||||
void onOpenSetStatusDialog();
|
||||
void onOpenSetInjuryDialog();
|
||||
void onOpenSetSanitationDialog();
|
||||
void onOpenHistory();
|
||||
void onOpenBite();
|
||||
void onOpenMessage();
|
||||
void onFindOnMap();
|
||||
void onMovementTrack();
|
||||
void onParticipantMountedOn();
|
||||
void onMountedParticipants();
|
||||
void onPartitionTimeChanged(qint64 newPartitionTime);
|
||||
void onGearRanges();
|
||||
|
||||
void showSpecialSensorData(int specialSensorData);
|
||||
void onContextMenuRequested(const QPoint &position);
|
||||
|
||||
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:
|
||||
Participant m_participant;
|
||||
int m_uasId; // Needed to release uas again.
|
||||
qint64 m_lastPositionMSec;
|
||||
TypeClass m_typeClass;
|
||||
std::vector<GearInformation> m_gearList;
|
||||
std::vector<SanitationMaterial> m_sanMatStock;
|
||||
int m_roomId;
|
||||
|
||||
QString m_menuGroup;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<TargetManagement::Interface::Dtc> m_tgtDtc;
|
||||
std::shared_ptr<TargetManagement::Interface::Ftc> m_tgtFtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asbiIfc;
|
||||
std::shared_ptr<ForeignParticipantInfoGuiInterface> m_ppmGuiIfc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<FilterManagement::SymbolAppearanceSettings> m_symbolAppearanceSettings;
|
||||
std::shared_ptr<FilterManagement::ForeignFltParticipantGuiInterface> m_fltParticipantIfc;
|
||||
AdvancedSymbology::SymbolResultWatcherLabel *m_symbolWatcher;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
ParticipantInfoLtdGearComponent *m_ltdGearComponent { nullptr };
|
||||
|
||||
Ui::ParticipantInfoDialog *m_ui;
|
||||
QPair<int,int> m_oldSpacerSize;
|
||||
bool m_isTarget;
|
||||
bool m_showPvSan{false};
|
||||
bool m_showVulnerabilityKindProject{false};
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace ParticipantInfo
|
||||
+1037
File diff suppressed because it is too large.
Load diff
+541
@@ -0,0 +1,541 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - ParticipantInfo
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "participant_info_gui_plugin.h"
|
||||
#include "participant_info_dialog.h"
|
||||
#include "participant_info_table_dialog.h"
|
||||
#include "participant_config_dialog.h"
|
||||
#include "participant_search_dialog.h"
|
||||
#include "participant_follow_dialog.h"
|
||||
#include "participant_hitline_info_dialog.h"
|
||||
#include "participant_bite_dialog.h"
|
||||
|
||||
#include <Common/participant_search_modal.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_events.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_operator_rights.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsNotification/lts_notification.h>
|
||||
|
||||
#include <QShortcut>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
|
||||
const QString InterfaceImpl::s_participantInfoScheme = QStringLiteral("ParticipantInfo");
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Ppm.ParticipantInfo"))
|
||||
{
|
||||
qApp->installEventFilter(this); // for link events
|
||||
}
|
||||
|
||||
QString participantFollowIdentifier() { return QStringLiteral("ParticipantFollow"); }
|
||||
|
||||
void InterfaceImpl::onShowSearchParticipant()
|
||||
{
|
||||
if (m_participantShowModalPtr)
|
||||
return;
|
||||
|
||||
m_participantShowModalPtr = new ParticipantSearchModal(m_session->baseLayout());
|
||||
|
||||
// #define TEST_LIFETIME
|
||||
#ifdef TEST_LIFETIME // Ein Test fuer wen's interessiert
|
||||
QTimer *t = new QTimer(m_participantShowModalPtr.data());
|
||||
connect(t, &QTimer::timeout, this, [this, t]() { ERROR_LOG(m_logger) << "TEST_LIFETIME: " << (qintptr)t << " @ " << (qintptr)m_session->baseLayout() << " still alive"; });
|
||||
t->start(1000);
|
||||
#endif
|
||||
|
||||
if (!m_participantShowModalPtr->init(m_dtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "initialization of ParticipantSearchModal failed - cannot show participant search modal";
|
||||
m_participantShowModalPtr->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
connect(m_participantShowModalPtr.data(), &ParticipantSearchModal::participantSelected,
|
||||
this, [this](int participantId)
|
||||
{
|
||||
showParticipantInfoWindow(participantId);
|
||||
});
|
||||
|
||||
m_participantShowModalPtr->setAttribute(Qt::WA_DeleteOnClose); // auto delete on close
|
||||
m_participantShowModalPtr->show();
|
||||
}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
|
||||
if (appId() != LtsAppDescriptor::App::BuildingViewer)
|
||||
{
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
plData.menuText = tr("Participant Search");
|
||||
plData.identifier = QLatin1String("ParticipantSearch");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:select_player.svg"));
|
||||
plData.operatorRight = OperatorRights::ParticipantInfo::ParticipantInfoSearch;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onShowParticipantSearchDialog(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
if (appId() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
if (appId() != LtsAppDescriptor::App::BuildingViewer)
|
||||
{
|
||||
LtsWidgets::PluginData plData1;
|
||||
plData1.menuGroup = menuGroup();
|
||||
|
||||
plData1.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
plData1.menuText = tr("Participant Follow");
|
||||
plData1.identifier = participantFollowIdentifier();
|
||||
plData1.menuIcon = QIcon(QLatin1String("icon:center_to_object.svg"));
|
||||
plData1.operatorRight = OperatorRights::ParticipantInfo::ParticipantInfoSearch;
|
||||
plData1.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData1.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onShowParticipantFollowDialog(parent);
|
||||
};
|
||||
ret.append(plData1);
|
||||
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eInfoTab;
|
||||
plData.menuText = tr("Participant Info Table");
|
||||
plData.identifier = QLatin1String("ParticipantInfoTable");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:service_group.svg"));
|
||||
plData.operatorRight = OperatorRights::ParticipantInfo::ParticipantInfoTableShow;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onShowParticipantInfoTableDialog(parent);
|
||||
};
|
||||
|
||||
ret.append(plData);
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
plData.menuText = tr("Set Participant Status");
|
||||
plData.identifier = QLatin1String("ParticipantSetStatus");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:set_player_status.svg"));
|
||||
plData.operatorRight = OperatorRights::ParticipantInfo::ParticipantInfoSendConfig;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onShowParticipantConfigDialog(false, parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableMassages = ps->value(QStringLiteral("msg"),
|
||||
QStringLiteral("enableMessages")).toBool();
|
||||
|
||||
if (enableMassages)
|
||||
{
|
||||
plData.menuText = tr("Send Participant Messages");
|
||||
plData.identifier = QLatin1String("ParticipantSendMessages");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:send_player_message.svg"));
|
||||
plData.operatorRight = OperatorRights::ParticipantInfo::ParticipantInfoSendMessage;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onShowParticipantConfigDialog(true, parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
}
|
||||
|
||||
LtsWidgets::PluginData plData2;
|
||||
plData2.menuGroup = menuGroup();
|
||||
plData2.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
|
||||
plData2.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
if (m_session->app() != LtsAppDescriptor::App::Situation &&
|
||||
m_session->app() != LtsAppDescriptor::App::OrgChart &&
|
||||
m_session->app() != LtsAppDescriptor::App::Snapshot &&
|
||||
m_session->app() != LtsAppDescriptor::App::BuildingViewer &&
|
||||
m_session->app() != LtsAppDescriptor::App::ScriptEditorEssentialsView)
|
||||
return;
|
||||
|
||||
if (m_scSearchParticipant != nullptr)
|
||||
return;
|
||||
|
||||
m_scSearchParticipant = new QShortcut(QKeySequence(Qt::Key_F4), m_session->baseLayout());
|
||||
m_scSearchParticipant->setContext(Qt::WindowShortcut);
|
||||
connect(m_scSearchParticipant, &QShortcut::activated,
|
||||
this, &InterfaceImpl::onShowSearchParticipant);
|
||||
};
|
||||
ret.append(plData2);
|
||||
|
||||
|
||||
//
|
||||
// only pariticpant search and function Key-F4 in replay
|
||||
//
|
||||
if (m_session->partitionType() == IDL::PartitionType::Replay)
|
||||
return ret;
|
||||
|
||||
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
this, &InterfaceImpl::onParticipantPositionChanged);
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::unitPositionChanged,
|
||||
this, &InterfaceImpl::onUnitPositionChanged);
|
||||
}
|
||||
else // if (appId() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
LtsWidgets::PluginData plData3;
|
||||
plData3.menuGroup = menuGroup();
|
||||
plData3.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
|
||||
plData3.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
m_notiSearchParticipant = m_session->createNotification(QStringLiteral("TabOcSearchParticipant"));
|
||||
m_notiSearchParticipant->setIcon(QIcon(QLatin1String("icon:search.svg")));
|
||||
m_notiSearchParticipant->setToolTip(tr("Search Participant"));
|
||||
m_notiSearchParticipant->setAction([this]()
|
||||
{
|
||||
if (m_participantSearchWidget)
|
||||
{
|
||||
m_participantSearchWidget->show();
|
||||
m_participantSearchWidget->raise();
|
||||
m_participantSearchWidget->activateWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
m_participantSearchWidget = new ParticipantSearchWidget(m_session->baseLayout());
|
||||
m_participantSearchWidget->setAttribute(Qt::WA_DeleteOnClose); // auto delete on close
|
||||
if (!m_participantSearchWidget->init(this->m_dtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "initialization of ParticipantSearchModal failed - cannot show participant search modal";
|
||||
m_participantSearchWidget->deleteLater();
|
||||
return;
|
||||
}
|
||||
connect(m_participantSearchWidget, &ParticipantSearchWidget::participantSelected,
|
||||
this, [this](int participantId)
|
||||
{
|
||||
showParticipantInfoWindow(participantId);
|
||||
});
|
||||
|
||||
connect(m_participantSearchWidget, &QObject::destroyed,
|
||||
this, [this]()
|
||||
{
|
||||
m_participantSearchWidget = nullptr;
|
||||
});
|
||||
|
||||
m_participantSearchWidget->setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint ); // hints..
|
||||
|
||||
QPoint wPos = m_session->baseLayout()->geometry().center();
|
||||
wPos.setX(wPos.x() - m_participantSearchWidget->size().width());
|
||||
wPos.setY(wPos.y()/2);
|
||||
m_participantSearchWidget->move(wPos);
|
||||
|
||||
m_participantSearchWidget->show();
|
||||
});
|
||||
};
|
||||
ret.append(plData3);
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Participants");
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
// if (appId() == LtsAppDescriptor::App::OC) // do the hack now
|
||||
// return true;
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<ParticipantManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!m_session->getForeignGuiInterface<ProjectDataManagement::ForeignGuiInterface>(m_pdmGuiIfc))
|
||||
return false;
|
||||
if (!m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(m_asbIfc))
|
||||
return false;
|
||||
|
||||
//optional
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitmapGuIfc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_sitmapGuIfc = nullptr;
|
||||
m_asbIfc = nullptr;
|
||||
m_pdmGuiIfc = nullptr;
|
||||
m_pdmDtc = nullptr;
|
||||
m_ppmGuiIfc = nullptr;
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removeObjectIndicator();
|
||||
}
|
||||
|
||||
// ForeignDataInterface
|
||||
void InterfaceImpl::showParticipantInfoWindow(const QVector<int> &entityIds)
|
||||
{
|
||||
for (auto id : entityIds)
|
||||
this->showParticipantInfoWindow(id);
|
||||
}
|
||||
|
||||
void InterfaceImpl::showHitLineInfoWindow(const QVector<int> &hitLineIds)
|
||||
{
|
||||
for (auto id : hitLineIds)
|
||||
this->showHitLineInfoWindow(id);
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::showBiteWindow(const QJsonObject &detailData)
|
||||
{
|
||||
static int s_counter = 1234567890;
|
||||
m_session->addWidget(LtsWidgets::initDialog(new ParticipantBiteDialog(-1),
|
||||
m_dtc, m_ftc, m_pdmDtc, false, detailData),
|
||||
menuGroup(), QStringLiteral("BiteInfo%1").arg(s_counter++ /* FIXME: UGLY HACK!! missing unique id here.. */), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::showParticipantInfoWindow(int entityId, bool hideSituationMapRelatedButtons)
|
||||
{
|
||||
if (!m_ppmGuiIfc)
|
||||
m_session->getForeignGuiInterface<ParticipantManagement::ForeignParticipantInfoGuiInterface>(m_ppmGuiIfc);
|
||||
|
||||
ParticipantInfoDialog *ti = new ParticipantInfoDialog(entityId, menuGroup());
|
||||
bool ok = ti->init(m_session, m_dtc, m_ftc, m_pdmDtc, hideSituationMapRelatedButtons ? nullptr: m_sitmapGuIfc, m_asbIfc, m_ppmGuiIfc);
|
||||
if (!ok)
|
||||
{
|
||||
delete ti;
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->addWidget(ti, menuGroup(), QStringLiteral("TlnInfo%1").arg(entityId), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
void InterfaceImpl::showHitLineInfoWindow(int hitLineId)
|
||||
{
|
||||
HitLineInfoDialog *hli = new HitLineInfoDialog(hitLineId);
|
||||
|
||||
bool bOk = hli->init(m_dtc, m_pdmDtc, m_sitmapGuIfc);
|
||||
if (!bOk)
|
||||
{
|
||||
delete hli;
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->addWidget(hli, menuGroup(), QStringLiteral("HitLineInfo%1").arg(hitLineId), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowParticipantInfoTableDialog(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new ParticipantInfoTableDialog(menuGroup(), parent),
|
||||
m_session, m_dtc);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowParticipantConfigDialog(bool isMessage, QWidget *parent)
|
||||
{
|
||||
ParticipantConfigDialog::DialogType type = isMessage ? ParticipantConfigDialog::DialogType::MessageMulti : ParticipantConfigDialog::DialogType::ConfigMulti;
|
||||
return LtsWidgets::initDialog(new ParticipantConfigDialog(0, type, parent),
|
||||
m_session, m_dtc, m_ftc);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowParticipantSearchDialog(QWidget *parent)
|
||||
{
|
||||
if (!m_ppmGuiIfc)
|
||||
m_session->getForeignGuiInterface<ParticipantManagement::ForeignParticipantInfoGuiInterface>(m_ppmGuiIfc);
|
||||
if (!m_ppmOcGuiIfc)
|
||||
m_session->getForeignGuiInterface<OcSituationClient::ForeignParticipantInfoGuiInterface>(m_ppmOcGuiIfc);
|
||||
return LtsWidgets::initDialog(new ParticipantSearchDialog(parent),
|
||||
m_session, m_dtc, m_ppmGuiIfc, m_ppmOcGuiIfc);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowParticipantFollowDialog(QWidget *parent)
|
||||
{
|
||||
if (!m_ppmGuiIfc)
|
||||
m_session->getForeignGuiInterface<ParticipantManagement::ForeignParticipantInfoGuiInterface>(m_ppmGuiIfc);
|
||||
|
||||
DEBUG_LOG(m_logger) << "initDialog";
|
||||
ParticipantFollowDialog *participantFollowDialogPtr =new ParticipantFollowDialog(parent);
|
||||
connect (participantFollowDialogPtr, &ParticipantFollowDialog::newFollowEquipment,
|
||||
this, &InterfaceImpl::onNewFollowEquipment);
|
||||
participantFollowDialogPtr->setFollower(m_followEquipmentNumber, m_followParticipantId);
|
||||
return LtsWidgets::initDialog(participantFollowDialogPtr,
|
||||
m_session, m_dtc, m_ppmGuiIfc);
|
||||
}
|
||||
|
||||
bool InterfaceImpl::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == qApp &&
|
||||
!event->isAccepted() &&
|
||||
event->type() == LtsWidgets::LtsLinkEvent::eventTypeId())
|
||||
{
|
||||
auto ev = static_cast<LtsWidgets::LtsLinkEvent*>(event);
|
||||
|
||||
const auto isChildOfSession = [this](QWidget *w)
|
||||
{
|
||||
if (!w)
|
||||
return true;
|
||||
auto baseLayout = m_session->baseLayout();
|
||||
return baseLayout->isAncestorOf(w);
|
||||
};
|
||||
if (isChildOfSession(ev->sourceBaseLayoutWidget()) && ev->url().host() == s_participantInfoScheme.toLower())
|
||||
{
|
||||
bool ok = false;
|
||||
const int pId = ev->url().path().mid(1).toInt(&ok);
|
||||
if (ok)
|
||||
{
|
||||
showParticipantInfoWindow(pId);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
// bool InterfaceImpl::event(QEvent *event) // show participant info dialog on link clicked
|
||||
// {
|
||||
// if (event->type() != LtsWidgets::LinkEvent::eventId())
|
||||
// {
|
||||
// qWarning() << "no link";
|
||||
// return QObject::event(event);
|
||||
// }
|
||||
|
||||
// qWarning() << "LINK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
||||
|
||||
// LtsWidgets::LinkEvent *linkEvent = dynamic_cast<LtsWidgets::LinkEvent *>(event);
|
||||
// if (linkEvent == nullptr || linkEvent->url().scheme() != s_participantInfoScheme)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// bool ok = false;
|
||||
// const int eqId = linkEvent->url().host().toInt(&ok);
|
||||
// if (!ok)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// showParticipantInfoWindow(eqId);
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
void InterfaceImpl::onNewFollowEquipment(const int equipmentNumber, const int participantId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onNewFollowEquipment equipmentNumber=" << equipmentNumber
|
||||
<< " participantId=" << participantId;
|
||||
m_followEquipmentNumber = equipmentNumber;
|
||||
m_followParticipantId = participantId;
|
||||
if (m_followParticipantId > 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "createNotification";
|
||||
if (!m_noti)
|
||||
{
|
||||
m_noti = m_session->createNotification(QStringLiteral("FollowMap"));
|
||||
m_noti->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_noti->setToolTip(tr("The map follows the participant"));
|
||||
m_noti->setAction([this]()
|
||||
{
|
||||
m_session->addWidget(onShowParticipantFollowDialog(nullptr), menuGroup(), participantFollowIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
});
|
||||
}
|
||||
QString labeltext = tr("Map follows Participant: %1").arg(m_dtc->hierarchyFromParticipant(m_followParticipantId));
|
||||
if (m_followEquipmentNumber > 0)
|
||||
labeltext += QStringLiteral(" (%1)").arg(m_followEquipmentNumber);
|
||||
m_noti->setToolTip(labeltext);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_noti)
|
||||
{
|
||||
m_noti->deleteLater();
|
||||
m_noti = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InterfaceImpl::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onParticipantPositionChanged id=" << data.participantId()
|
||||
<< " m_followParticipantId=" << m_followParticipantId ;
|
||||
if (m_followParticipantId == 0)
|
||||
return;
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "m_participantsOutsideMap.remove participantId: " << data.participantId();
|
||||
//m_participantsOutsideMap.remove(data.participantId());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.participantId() == m_followParticipantId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Center Map to participantId=" << data.participantId();
|
||||
DEBUG_LOG(m_logger) << "onParticipantPositionChanged()"
|
||||
<< " participantId; " << data.participantId()
|
||||
<< " participantTypeId: " << data.participantTypeId()
|
||||
<< " partyId: " << data.partyId();
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(data.pos().lon(), data.pos().lat()));
|
||||
}
|
||||
}
|
||||
} // end of onParticipantPositionChanged()
|
||||
|
||||
void InterfaceImpl::onUnitPositionChanged(const ParticipantManagement::UnitPosition &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onUnitPositionChanged id=" << data.participantId()
|
||||
<< " m_followParticipantId=" << m_followParticipantId ;
|
||||
if (m_followParticipantId == 0)
|
||||
return;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
if (data.participantId() == m_followParticipantId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Center Map to participantId=" << data.participantId()
|
||||
<< ", onUnitPositionChanged()"
|
||||
<< " participantId; " << data.participantId();
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
const int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
if (!m_fltParticipantIfc)
|
||||
m_session->getForeignGuiInterface<FilterManagement::ForeignFltParticipantGuiInterface>(m_fltParticipantIfc);
|
||||
m_symbolAppearanceSettings = m_fltParticipantIfc->symbolAppearanceForOperator(operatorId, m_session->workspaceId());
|
||||
const bool bCenter = m_symbolAppearanceSettings &&
|
||||
(m_symbolAppearanceSettings->settings().symbolSettings.unitSymbolPosition == FilterManagement::SymbolAppearanceSettings::UnitSymbolPosition::Center);
|
||||
if (bCenter)
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(data.positionCenter().lon(), data.positionCenter().lat()));
|
||||
else
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(data.positionLeader().lon(), data.positionLeader().lat()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Gui Plugin for ParticipantManagement - ParticipantInfo
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
#include <Plugins/OcSituationClient/osc_participant_info_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_symbol_appearance_settings.h>
|
||||
#include "participant_search_widget.h"
|
||||
|
||||
namespace LtsNotification
|
||||
{
|
||||
class LtsNotification;
|
||||
}
|
||||
|
||||
class QShortcut;
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class ParticipantSearchModal;
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ppm.participantinfo")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("ParticipantManagement.GuiPlugin.ParticipantInfo"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Global ||
|
||||
partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay);
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public ForeignParticipantInfoGuiInterface, 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::Exercise ||
|
||||
partition == IDL::PartitionType::Replay; }
|
||||
|
||||
// ForeignDataInterface
|
||||
void showParticipantInfoWindow(const QVector<int> &entityIds) override;
|
||||
void showParticipantInfoWindow(int entityId, bool hideSituationMapRelatedButtons = false) override;
|
||||
void showBiteWindow(const QJsonObject &detailData) override;
|
||||
void showHitLineInfoWindow(const QVector<int> &hitLineIds) override;
|
||||
void showHitLineInfoWindow(int hitLineId) override;
|
||||
static const QString s_participantInfoScheme;
|
||||
|
||||
public slots:
|
||||
void onNewFollowEquipment(const int equipmentNumber, const int participantId);
|
||||
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
||||
void onUnitPositionChanged(const ParticipantManagement::UnitPosition &data, DataModification modType);
|
||||
|
||||
private slots:
|
||||
void onShowSearchParticipant();
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowParticipantInfoTableDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowParticipantConfigDialog(bool isMessage, QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowParticipantSearchDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowParticipantFollowDialog(QWidget *parent);
|
||||
bool eventFilter(QObject *obj, QEvent *event) override; // show participant info dialog on clicked link
|
||||
// bool event(QEvent *event) override; // show participant info dialog on clicked link
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<ProjectDataManagement::ForeignGuiInterface> m_pdmGuiIfc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitmapGuIfc;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asbIfc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> m_ppmGuiIfc;
|
||||
std::shared_ptr<OcSituationClient::ForeignParticipantInfoGuiInterface> m_ppmOcGuiIfc;
|
||||
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
std::shared_ptr<FilterManagement::SymbolAppearanceSettings> m_symbolAppearanceSettings;
|
||||
std::shared_ptr<FilterManagement::ForeignFltParticipantGuiInterface> m_fltParticipantIfc;
|
||||
|
||||
QShortcut *m_scSearchParticipant = nullptr;
|
||||
QPointer<ParticipantSearchModal> m_participantShowModalPtr;
|
||||
LtsNotification::LtsNotification *m_noti = nullptr;
|
||||
int m_followEquipmentNumber = 0;
|
||||
int m_followParticipantId = 0;
|
||||
LtsNotification::LtsNotification *m_notiSearchParticipant = nullptr;
|
||||
ParticipantSearchWidget *m_participantSearchWidget = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Helper for Player Info Dialogues
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
inline bool compareGear(const GearInformation &a,
|
||||
const GearInformation &b)
|
||||
{
|
||||
if (a.gearId() != b.gearId())
|
||||
return a.gearId() < b.gearId();
|
||||
return a.chargeTypeId() < b.chargeTypeId();
|
||||
}
|
||||
|
||||
inline bool compareSanMat(const SanitationMaterial &a,
|
||||
const SanitationMaterial &b)
|
||||
{
|
||||
return a.materialId() < b.materialId();
|
||||
}
|
||||
|
||||
} //namespace
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Class for managing LTD data in the info dialog
|
||||
* $Id: participant_info_dialog.h 59174 2023-03-27 06:45:08Z karwat $
|
||||
* $HeadURL: svn://10.196.0.54/TDS/branches/product/features/24_vulcano/Lts/Plugins/ParticipantManagement/Gui/ParticipantInfo/participant_info_dialog.h $
|
||||
* $Author: karwat $
|
||||
* Created by Hannes Fritsche, ESZS, 2023-02-20
|
||||
*/
|
||||
|
||||
#include "participant_info_ltd_gear_component.h"
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
#include <LtsWidgets/lts_led_widget.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
ParticipantInfoLtdGearComponent::ParticipantInfoLtdGearComponent(QTableWidget *tableWidget)
|
||||
: m_tableWidget(tableWidget)
|
||||
, m_logger(getLogger("ParticipantInfoGearLtsComponent"))
|
||||
{
|
||||
if (!m_tableWidget)
|
||||
ERROR_LOG(m_logger) << "Got invalid table widget.";
|
||||
}
|
||||
|
||||
void ParticipantInfoLtdGearComponent::updateData(const std::vector<LaserDesignation> &newData)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
if (!m_tableWidget)
|
||||
return;
|
||||
|
||||
for (const LaserDesignation &laserDesignation : newData)
|
||||
{
|
||||
if (m_rowPerGearId.contains(laserDesignation.gearId()))
|
||||
updateRow(laserDesignation);
|
||||
}
|
||||
|
||||
removeOutdatedData(newData);
|
||||
}
|
||||
|
||||
void ParticipantInfoLtdGearComponent::addGear(int gearId, int row)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
if (!m_tableWidget)
|
||||
return;
|
||||
|
||||
LtdRow ltdRow;
|
||||
ltdRow.chargeType = new QTableWidgetItem(QString::number(0));
|
||||
ltdRow.remain = new LtsWidgets::LtsLedWidget(m_tableWidget, Qt::green, Qt::red);
|
||||
ltdRow.remain->setStatus(false);
|
||||
ltdRow.remain->setAspectHint(LtsWidgets::LtsLedWidget::AspectHint::WidthIsHeight);
|
||||
|
||||
m_tableWidget->setItem(row, CHARGE_TYPE, ltdRow.chargeType);
|
||||
m_tableWidget->setCellWidget(row, REMAIN, ltdRow.remain);
|
||||
|
||||
m_rowPerGearId.insert(gearId, std::move(ltdRow));
|
||||
}
|
||||
|
||||
void ParticipantInfoLtdGearComponent::clear()
|
||||
{
|
||||
m_rowPerGearId.clear();
|
||||
}
|
||||
|
||||
void ParticipantInfoLtdGearComponent::updateRow(const LaserDesignation &laserDesignation)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << ": " << laserDesignation;
|
||||
|
||||
if (!m_rowPerGearId.contains(laserDesignation.gearId()) || !m_rowPerGearId.value(laserDesignation.gearId()).isValid())
|
||||
return;
|
||||
|
||||
m_rowPerGearId.value(laserDesignation.gearId()).chargeType->setText(QString::number(laserDesignation.code()));
|
||||
m_rowPerGearId.value(laserDesignation.gearId()).remain->setStatus(laserDesignation.outputPower());
|
||||
}
|
||||
|
||||
void ParticipantInfoLtdGearComponent::removeOutdatedData(const std::vector<LaserDesignation> &newData)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
if (!m_tableWidget)
|
||||
return;
|
||||
|
||||
for (auto it = m_rowPerGearId.constBegin(); it != m_rowPerGearId.constEnd(); ++it)
|
||||
{
|
||||
auto findIt = std::find_if(newData.begin(), newData.end(), [it](const LaserDesignation &laserDesignation) { return laserDesignation.gearId() == it.key(); });
|
||||
|
||||
if (findIt == newData.end())
|
||||
updateRow({it.key(), {}, 0, .0});
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Class for managing LTD data in the info dialog
|
||||
* $Id: participant_info_dialog.h 59174 2023-03-27 06:45:08Z karwat $
|
||||
* $HeadURL: svn://10.196.0.54/TDS/branches/product/features/24_vulcano/Lts/Plugins/ParticipantManagement/Gui/ParticipantInfo/participant_info_dialog.h $
|
||||
* $Author: karwat $
|
||||
* Created by Hannes Fritsche, ESZS, 2023-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
class QTableWidget;
|
||||
class QTableWidgetItem;
|
||||
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LtsLedWidget;
|
||||
}
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class LaserDesignation;
|
||||
class GearInformation;
|
||||
|
||||
class ParticipantInfoLtdGearComponent
|
||||
{
|
||||
public:
|
||||
explicit ParticipantInfoLtdGearComponent(QTableWidget *tableWidget);
|
||||
void updateData(const std::vector<LaserDesignation> &newData);
|
||||
void addGear(int gearId, int row);
|
||||
void removeGear(int gearId);
|
||||
void clear();
|
||||
|
||||
static const int LTD_ID {1043};
|
||||
private:
|
||||
struct LtdRow
|
||||
{
|
||||
QTableWidgetItem *chargeType {nullptr} ;
|
||||
LtsWidgets::LtsLedWidget *remain {nullptr} ;
|
||||
|
||||
bool isValid() const { return chargeType && remain; }
|
||||
};
|
||||
|
||||
enum Columns
|
||||
{
|
||||
CHARGE_TYPE = 1,
|
||||
REMAIN = 2
|
||||
};
|
||||
|
||||
void updateRow(const LaserDesignation &laserDesignation);
|
||||
void removeOutdatedData(const std::vector<LaserDesignation> &newData);
|
||||
|
||||
QTableWidget *m_tableWidget;
|
||||
QMap<int, LtdRow> m_rowPerGearId;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace ParticipantManagement
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* TlnInfo Table Add Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Mueller, SGAS, 2017-07-11
|
||||
*/
|
||||
|
||||
#include "participant_info_table_add_dialog.h"
|
||||
#include "ui_participant_info_table_add_dialog.h"
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
InfoTableAddDialog::InfoTableAddDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::InfoTableAddDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect (m_ui->tvParticipant, &LtsDataView::LtsDataView::selectionChanged, this, &InfoTableAddDialog::slotChangesMade);
|
||||
}
|
||||
|
||||
InfoTableAddDialog::~InfoTableAddDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool InfoTableAddDialog::init(LtsSession::LtsSession *session, const std::shared_ptr<Interface::Dtc> &dtc)
|
||||
{
|
||||
m_infoTableModel = new ParticipantInfoTableModel(this);
|
||||
m_infoTableModel->initModel(session, dtc, false);
|
||||
m_infoTableModel->initializeDataView();
|
||||
m_ui->tvParticipant->setModel(m_infoTableModel);
|
||||
m_ui->tvParticipant->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->tvParticipant->hideColumn(ParticipantInfoTableModel::Position);
|
||||
m_ui->tvParticipant->hideColumn(ParticipantInfoTableModel::BiteResult);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InfoTableAddDialog::apply()
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->tvParticipant->selectedRows();
|
||||
|
||||
QSet<int> selectedIds;
|
||||
for (const QModelIndex &idx : selectedRows)
|
||||
{
|
||||
if (idx.isValid())
|
||||
selectedIds.insert(m_infoTableModel->getRowData(idx.row()).id());
|
||||
}
|
||||
emit signalFinishedSelectParticipantIds(selectedIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
void InfoTableAddDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Add Participants to Participant Info Table"));
|
||||
}
|
||||
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* TlnInfo Table Add Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Mueller, SGAS, 2017-07-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "participant_info_table_model.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class InfoTableAddDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class InfoTableAddDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit InfoTableAddDialog(QWidget *parent);
|
||||
~InfoTableAddDialog();
|
||||
bool init(LtsSession::LtsSession *session, const std::shared_ptr<Interface::Dtc> &dtc);
|
||||
|
||||
private:
|
||||
bool apply() override;
|
||||
void retranslate() override;
|
||||
|
||||
signals:
|
||||
void signalFinishedSelectParticipantIds(const QSet<int> &participantIds);
|
||||
|
||||
private:
|
||||
|
||||
Ui::InfoTableAddDialog *m_ui;
|
||||
ParticipantInfoTableModel *m_infoTableModel;
|
||||
};
|
||||
|
||||
}
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>InfoTableAddDialog</class>
|
||||
<widget class="QWidget" name="InfoTableAddDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>570</width>
|
||||
<height>664</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="tvParticipant"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - TlnInfoTableDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Mueller, SGAS, 2017-07-10
|
||||
*/
|
||||
|
||||
#include "participant_info_table_dialog.h"
|
||||
#include "ui_participant_info_table_dialog.h"
|
||||
|
||||
#include "participant_info_table_add_dialog.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QMenu>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
ParticipantInfoTableDialog::ParticipantInfoTableDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_session(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmGuiIfc(nullptr)
|
||||
, m_ui(new Ui::ParticipantInfoTableDialog)
|
||||
, m_logger(getLogger("ParticipantInfoTableDialog"))
|
||||
, m_infoTableModel(nullptr)
|
||||
, m_sortFilterProxyModel(nullptr)
|
||||
, m_visibleColumns()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// Add-Button used as 'Hinzufuegen' as 'Erstellen'-Button
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Add"));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add,
|
||||
this,
|
||||
&ParticipantInfoTableDialog::onAddClicked);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove,
|
||||
this,
|
||||
&ParticipantInfoTableDialog::onRemoveClicked);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Participant_Info_Table"));
|
||||
}
|
||||
|
||||
ParticipantInfoTableDialog::~ParticipantInfoTableDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantInfoTableDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Participant Info Table"));
|
||||
}
|
||||
|
||||
bool ParticipantInfoTableDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** init";
|
||||
|
||||
m_session = session;
|
||||
m_dtc = dtc;
|
||||
|
||||
m_session->getForeignGuiInterface<ParticipantManagement::ForeignParticipantInfoGuiInterface>(m_ppmGuiIfc); // optional
|
||||
|
||||
m_infoTableModel = new ParticipantInfoTableModel(this);
|
||||
m_infoTableModel->initModel(session, m_dtc, true);
|
||||
m_sortFilterProxyModel = new QSortFilterProxyModel(this);
|
||||
m_sortFilterProxyModel->setSourceModel(m_infoTableModel);
|
||||
m_ui->tvParticipant->setModel(m_sortFilterProxyModel);
|
||||
m_ui->tvParticipant->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_ui->tvParticipant->resizeColumnsToContents();
|
||||
m_ui->tvParticipant->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
for (int i = 0; i < m_infoTableModel->columnCount(); ++i)
|
||||
{
|
||||
if (m_ui->tvParticipant->isColumnHidden(i))
|
||||
continue;
|
||||
m_visibleColumns.append(i);
|
||||
}
|
||||
|
||||
QItemSelectionModel *selectionModel = m_ui->tvParticipant->selectionModel();
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
||||
this, &ParticipantInfoTableDialog::onSelectionChanged);
|
||||
|
||||
connect(m_ui->tvParticipant, &QTableView::doubleClicked,
|
||||
this, &ParticipantInfoTableDialog::onShowTlnInfo);
|
||||
|
||||
connect(m_ui->tvParticipant->horizontalHeader(), &QHeaderView::customContextMenuRequested,
|
||||
this, &ParticipantInfoTableDialog::onColumnContextMenu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantInfoTableDialog::onColumnContextMenu(const QPoint &position)
|
||||
{
|
||||
QAbstractScrollArea *w = qobject_cast<QAbstractScrollArea*>(sender());
|
||||
QMenu contextMenu;
|
||||
for (int col=0; col<m_infoTableModel->columnCount(); ++col)
|
||||
{
|
||||
QAction *a = contextMenu.addAction(m_infoTableModel->headerData(col, Qt::Horizontal).toString());
|
||||
a->setCheckable(true);
|
||||
a->setChecked(!m_ui->tvParticipant->isColumnHidden(col));
|
||||
connect(a, &QAction::toggled, [this, col](bool checked){m_ui->tvParticipant->setColumnHidden(col, !checked);});
|
||||
}
|
||||
contextMenu.exec(w->viewport()->mapToGlobal(position));
|
||||
}
|
||||
|
||||
void ParticipantInfoTableDialog::onAddClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onAddClicked() ";
|
||||
InfoTableAddDialog *addParticipantsDialog = new InfoTableAddDialog(this);
|
||||
addParticipantsDialog->init(m_session, m_dtc);
|
||||
|
||||
addDialog(addParticipantsDialog, m_menuGroup, QLatin1String("AddParticipantsToParticipantTable"),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
|
||||
connect(addParticipantsDialog, &InfoTableAddDialog::signalFinishedSelectParticipantIds,
|
||||
this, &ParticipantInfoTableDialog::onAddParticipants);
|
||||
|
||||
}
|
||||
|
||||
void ParticipantInfoTableDialog::onRemoveClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onRemoveClicked() ";
|
||||
const QModelIndexList selectedRows = m_ui->tvParticipant->selectionModel()->selectedRows();
|
||||
|
||||
if (!selectedRows.count())
|
||||
return;
|
||||
|
||||
QVector<int> selectedIds;
|
||||
selectedIds.reserve(selectedRows.size());
|
||||
for (const QModelIndex &idx : selectedRows)
|
||||
{
|
||||
QModelIndex realIdx = m_sortFilterProxyModel->mapToSource(idx);
|
||||
if (realIdx.isValid())
|
||||
selectedIds.append(m_infoTableModel->getRowData(realIdx.row()).id());
|
||||
}
|
||||
m_infoTableModel->removeItems(selectedIds);
|
||||
}
|
||||
|
||||
void ParticipantInfoTableDialog::onSelectionChanged(const QItemSelection &selected,
|
||||
const QItemSelection &deselected)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged";
|
||||
Q_UNUSED(selected);
|
||||
Q_UNUSED(deselected);
|
||||
|
||||
bool enable = !m_ui->tvParticipant->selectionModel()->selectedRows().empty();
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, enable);
|
||||
}
|
||||
|
||||
void ParticipantInfoTableDialog::onShowTlnInfo(const QModelIndex &idx)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onDoubleClick --> showTlnInfo";
|
||||
QModelIndex realIdx = m_sortFilterProxyModel->mapToSource(idx);
|
||||
|
||||
const int id = m_infoTableModel->getRowData(realIdx.row()).id();
|
||||
if (m_ppmGuiIfc)
|
||||
m_ppmGuiIfc->showParticipantInfoWindow(id);
|
||||
}
|
||||
|
||||
void ParticipantInfoTableDialog::onAddParticipants(const QSet<int> &participantIds)
|
||||
{
|
||||
m_infoTableModel->updateDataView(participantIds);
|
||||
m_ui->tvParticipant->sortByColumn(0, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for ParticipantManagement - TlnInfoTableDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Mueller, SGAS, 2017-07-10
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <participant_info_table_model.h>
|
||||
|
||||
//DDS
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
|
||||
//Qt
|
||||
class QSortFilterProxyModel;
|
||||
class QItemSelection;
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantInfoTableDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class InfoTableConfigureDialog;
|
||||
// --------------------------------------------------------
|
||||
// ParticipantInfoTableDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantInfoTableDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantInfoTableDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~ParticipantInfoTableDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc);
|
||||
|
||||
private slots:
|
||||
void onColumnContextMenu(const QPoint &position);
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged(const QItemSelection &selected,
|
||||
const QItemSelection &deselected);
|
||||
void onShowTlnInfo(const QModelIndex &idx);
|
||||
void onAddParticipants(const QSet<int> &participantIds);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
QString m_menuGroup;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ForeignParticipantInfoGuiInterface> m_ppmGuiIfc;
|
||||
|
||||
Ui::ParticipantInfoTableDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
ParticipantInfoTableModel *m_infoTableModel;
|
||||
QSortFilterProxyModel *m_sortFilterProxyModel;
|
||||
QVector<int> m_visibleColumns;
|
||||
};
|
||||
} // namespace ParticipantManagement
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantInfoTableDialog</class>
|
||||
<widget class="QWidget" name="ParticipantInfoTableDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="tvParticipant">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for TlnInfo Table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Mueller, SGAS, 2017-07-10
|
||||
*/
|
||||
|
||||
#include "participant_info_table_model.h"
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsUtilsCore/outdated_position.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QSet>
|
||||
#include <QTimer>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
ParticipantInfoTableModel::ParticipantInfoTableModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ParticipantInfo>({tr("Equip. No."),
|
||||
tr("Tact. Status"),
|
||||
tr("Designator"),
|
||||
tr("Tact. Identifier"),
|
||||
tr("Position"),
|
||||
tr("BITE Result")},
|
||||
parent)
|
||||
, m_session(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_ppmGuiCbxIfc(nullptr)
|
||||
, m_partitionTime(0)
|
||||
, m_timeoutCheckTimer(new QTimer(this))
|
||||
, m_bWithPositionandBiteResult(true)
|
||||
, m_logger(getLogger("ParticipantInfoTableModel"))
|
||||
{
|
||||
m_timeoutCheckTimer->setSingleShot(false);
|
||||
connect(m_timeoutCheckTimer, &QTimer::timeout,
|
||||
this, &ParticipantInfoTableModel::onTimeoutCheck);
|
||||
}
|
||||
|
||||
ParticipantInfoTableModel::~ParticipantInfoTableModel()
|
||||
{
|
||||
}
|
||||
|
||||
bool ParticipantInfoTableModel::initModel(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
bool bWithPositionandBiteResult)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** initModel";
|
||||
|
||||
m_session = session;
|
||||
m_ppmDtc = ppmDtc;
|
||||
session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc);
|
||||
m_bWithPositionandBiteResult = bWithPositionandBiteResult;
|
||||
|
||||
connect(m_ppmDtc.get(),
|
||||
&ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged,
|
||||
this, &ParticipantInfoTableModel::onParticipantChanged);
|
||||
connect(m_ppmDtc.get(),
|
||||
&ParticipantManagement::Interface::Dtc::partyChanged,
|
||||
this, &ParticipantInfoTableModel::onPartyChanged);
|
||||
if (m_bWithPositionandBiteResult)
|
||||
{
|
||||
connect(m_ppmDtc.get(),
|
||||
&ParticipantManagement::Interface::Dtc::biteChanged,
|
||||
this, &ParticipantInfoTableModel::onBiteChanged);
|
||||
connect(m_ppmDtc.get(),
|
||||
&ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
this, &ParticipantInfoTableModel::onPositionChanged);
|
||||
connect(m_session, &LtsSession::LtsSession::partitionTimeChanged,
|
||||
this, &ParticipantInfoTableModel::onPartitionTimeChanged);
|
||||
|
||||
m_timeoutCheckTimer->start(2000);
|
||||
}
|
||||
auto cbParty = [this](const ParticipantManagement::Party &party)
|
||||
{
|
||||
onPartyChanged(party, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->partys(cbParty);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::initializeDataView()
|
||||
{
|
||||
beginResetModel();
|
||||
m_vecData.clear();
|
||||
auto cb = [this](const Participant &p)
|
||||
{
|
||||
if (!p.equipmentNumber().is_set() || p.equipmentNumber().get() == 0)
|
||||
return;
|
||||
m_vecData += setInfoData(p);
|
||||
};
|
||||
m_ppmDtc->participants(cb);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QVariant ParticipantInfoTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ParticipantInfo &data = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case EquipmentNumber:
|
||||
if (data.isManipulated)
|
||||
return QColor(Qt::red);
|
||||
break;
|
||||
case Position:
|
||||
if (data.isOutdated)
|
||||
return QColor(Qt::red);
|
||||
break;
|
||||
case BiteResult:
|
||||
if (data.biteSampleTime < (m_session->partitionTime() - (2 * 60 *1000)) ) //<- so 2 minutes
|
||||
return (QColor(Qt::darkGray));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::ToolTipRole && index.column() == TacticalStatus)
|
||||
return vulnerabilityStateString(data);
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
if (index.column() == TacticalStatus)
|
||||
{
|
||||
static const QIcon green(QLatin1String("icon:green_light.svg"));
|
||||
static const QIcon yellow(QLatin1String("icon:yellow_light.svg"));
|
||||
static const QIcon red(QLatin1String("icon:red_light.svg"));
|
||||
|
||||
switch (data.vulnerabilityState.underlying())
|
||||
{
|
||||
case ProjectDataManagement::VulnerabilityState::CombatReady:
|
||||
return green;
|
||||
case ProjectDataManagement::VulnerabilityState::CatastrophicKill:
|
||||
return red;
|
||||
default:
|
||||
return yellow;
|
||||
}
|
||||
}
|
||||
if (index.column() == EquipmentNumber)
|
||||
return m_partyIcons.value(data.partyId);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case EquipmentNumber:
|
||||
if (data.equipmentNumber > 0)
|
||||
return data.equipmentNumber;
|
||||
return QVariant();
|
||||
case TacticalIdentifier:
|
||||
return data.tacticalIdentifier;
|
||||
case Designator:
|
||||
return data.designator;
|
||||
case Position:
|
||||
return data.positionString;
|
||||
case BiteResult:
|
||||
return data.biteResult;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool ParticipantInfoTableModel::removeItems(const QVector<int> &selectedIds)
|
||||
{
|
||||
if (selectedIds.isEmpty())
|
||||
return true;
|
||||
|
||||
for (int id : selectedIds)
|
||||
removeRow(findRowForId(id));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::updateDataView(const QSet<int> &participantIds)
|
||||
{
|
||||
if (participantIds.isEmpty())
|
||||
return;
|
||||
|
||||
QSet<int> participantIdsToAdd(participantIds);
|
||||
// remove all which are already in list
|
||||
for (const auto &p : qAsConst(m_vecData))
|
||||
participantIdsToAdd.remove(p.id());
|
||||
|
||||
if (participantIdsToAdd.isEmpty())
|
||||
return;
|
||||
|
||||
std::function<bool(const ParticipantManagement::Participant &)> cb =
|
||||
[this, &participantIdsToAdd](const ParticipantManagement::Participant &part)
|
||||
{
|
||||
auto it = participantIdsToAdd.find(part.id());
|
||||
if (it != participantIdsToAdd.end())
|
||||
{
|
||||
participantIdsToAdd.erase(it);
|
||||
insertRow(setInfoData(part));
|
||||
}
|
||||
// return true when no more ids to add to stop loop
|
||||
return participantIdsToAdd.isEmpty();
|
||||
};
|
||||
m_ppmDtc->participants(cb);
|
||||
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::onParticipantChanged(const ParticipantManagement::DynamicParticipantData &data,
|
||||
DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** participantDataChanged";
|
||||
|
||||
const int row = findRowForId(data.participantId());
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
ParticipantInfo info = getRowData(row);
|
||||
if (info.participantId != data.participantId())
|
||||
fillParticipantContent(info, data);
|
||||
|
||||
info.vulnerabilityState = m_ppmDtc->youngestStateInformation(data.stateHistory()).vulnerabilityState();
|
||||
info.isManipulated = data.manipulation().size();
|
||||
setRowData(row, info);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
removeRow(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ParticipantInfo ParticipantInfoTableModel::setInfoData(const Participant &part) const
|
||||
{
|
||||
ParticipantInfo data;
|
||||
|
||||
const int participantId = part.id();
|
||||
fillParticipantContent(data, part);
|
||||
|
||||
if (m_bWithPositionandBiteResult)
|
||||
{
|
||||
ParticipantManagement::Bite participantBite;
|
||||
std::function<bool(const ParticipantManagement::Bite &)> cbBite =
|
||||
[&participantBite, participantId](const ParticipantManagement::Bite &bite)
|
||||
{
|
||||
if (participantId != bite.participantId())
|
||||
return false;
|
||||
participantBite = bite;
|
||||
return true;
|
||||
};
|
||||
m_ppmDtc->bites(cbBite);
|
||||
data.biteResult = biteStringFromBite(participantBite);
|
||||
data.biteSampleTime = participantBite.sampleTime();
|
||||
|
||||
std::function<bool(const ParticipantManagement::ParticipantPosition &data)> cbPos =
|
||||
[this, &data, participantId](const ParticipantManagement::ParticipantPosition &pos)
|
||||
{
|
||||
if (participantId != pos.participantId())
|
||||
return false;
|
||||
updatePosition(data, pos);
|
||||
return true;
|
||||
};
|
||||
m_ppmDtc->participantPositions(cbPos);
|
||||
}
|
||||
|
||||
const auto dynPart = m_ppmDtc->dynamicParticipantData(participantId);
|
||||
data.vulnerabilityState = m_ppmDtc->youngestStateInformation(dynPart.stateHistory()).vulnerabilityState();
|
||||
data.isManipulated = dynPart.manipulation().size() != 0;
|
||||
data.designator = QString::fromStdString(part.designator());
|
||||
data.tacticalIdentifier = QString::fromStdString(part.tacticalIdentifier());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::onPositionChanged(const ParticipantManagement::ParticipantPosition &position,
|
||||
DataModification modType)
|
||||
{
|
||||
if ((modType != DataModification::eAdded) &&
|
||||
(modType != DataModification::eModified))
|
||||
return;
|
||||
|
||||
const int row = findRowForId(position.participantId());
|
||||
if (row < 0)
|
||||
return;
|
||||
ParticipantInfo &info = m_vecData[row];
|
||||
updatePosition(info, position);
|
||||
emit dataChanged(index(row, Position), index(row, Position), {Qt::BackgroundRole, Qt::DisplayRole});
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::onBiteChanged(const ParticipantManagement::Bite &bite,
|
||||
DataModification modType)
|
||||
{
|
||||
if ((modType != DataModification::eAdded) &&
|
||||
(modType != DataModification::eModified))
|
||||
return;
|
||||
|
||||
const int row = findRowForId(bite.participantId());
|
||||
if (row < 0)
|
||||
return;
|
||||
ParticipantInfo &info = m_vecData[row];
|
||||
info.biteSampleTime = bite.sampleTime();
|
||||
info.biteResult = biteStringFromBite(bite);
|
||||
|
||||
emit dataChanged(index(row, BiteResult), index(row, BiteResult), {Qt::BackgroundRole, Qt::DisplayRole});
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::onPartitionTimeChanged(qint64 newPartitionTime)
|
||||
{
|
||||
m_partitionTime = newPartitionTime;
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::onPartyChanged(const ParticipantManagement::Party &party,
|
||||
DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
if (m_ppmGuiCbxIfc)
|
||||
m_partyIcons[party.id()] = m_ppmGuiCbxIfc->pixmapFromParty(QColor::fromRgb(QRgb(party.color())));
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::onTimeoutCheck()
|
||||
{
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
auto &data = m_vecData[i];
|
||||
if (data.isOutdated)
|
||||
continue;
|
||||
if (isOutdated(data.positionSampleTime))
|
||||
{
|
||||
data.isOutdated = true;
|
||||
const QModelIndex idx(index(i, Position));
|
||||
emit dataChanged(idx, idx, {Qt::BackgroundRole});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::fillParticipantContent(ParticipantInfo &info,
|
||||
const ParticipantManagement::DynamicParticipantData &data) const
|
||||
{
|
||||
fillParticipantContent(info, m_ppmDtc->participant(data.participantId()));
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::fillParticipantContent(ParticipantInfo &info,
|
||||
const ParticipantManagement::Participant &part) const
|
||||
|
||||
{
|
||||
info.participantId = part.id();
|
||||
info.equipmentNumber = part.equipmentNumber().is_set() ? part.equipmentNumber().get() : 0;
|
||||
info.partyId = part.partyId();
|
||||
info.typeClass = m_ppmDtc->type(part.typeId()).typeClass();
|
||||
}
|
||||
|
||||
void ParticipantInfoTableModel::updatePosition(ParticipantInfo &info,
|
||||
const ParticipantManagement::ParticipantPosition &position) const
|
||||
{
|
||||
if (!std::isnan(position.pos().lon()) && !std::isnan(position.pos().lat()))
|
||||
{
|
||||
info.positionString = LtsCoordTrans::mgrsFromGeographic(position.pos().lon(),
|
||||
position.pos().lat());
|
||||
if (!qFuzzyIsNull(position.pos().z()))
|
||||
info.positionString.append(QStringLiteral(" ") + QString::number(position.pos().z(), 'f', 2));
|
||||
}
|
||||
else
|
||||
info.positionString = tr("Invalid position");
|
||||
info.positionSampleTime = position.sampleTime();
|
||||
info.isOutdated = isOutdated(info.positionSampleTime);
|
||||
}
|
||||
|
||||
bool ParticipantInfoTableModel::isOutdated(qint64 sampleTime) const
|
||||
{
|
||||
return LtsUtils::isPositionTimeOutdated(m_partitionTime, sampleTime);
|
||||
}
|
||||
|
||||
QString ParticipantInfoTableModel::biteStringFromBite(const ParticipantManagement::Bite &bite) const
|
||||
{
|
||||
if (!(bite.sampleTime() > 0))
|
||||
return tr("--");
|
||||
|
||||
bool bitStat = bite.biteState() != bite.configState();
|
||||
bool batW = bite.batteryState() > 0;
|
||||
bool confError = bite.configError();
|
||||
if (!bitStat && !batW && !confError )
|
||||
return tr("Ok");
|
||||
|
||||
QStringList ret;
|
||||
if (confError)
|
||||
ret.append(tr("Config Error"));
|
||||
if (batW)
|
||||
ret.append(tr("Battery Warning"));
|
||||
if (bitStat)
|
||||
ret.append(tr("Bite Error"));
|
||||
return ret.join(QStringLiteral(", "));
|
||||
}
|
||||
|
||||
QString ParticipantInfoTableModel::vulnerabilityStateString(const ParticipantInfo &data)
|
||||
{
|
||||
const ProjectDataManagement::VulnerabilityClass vc = data.typeClass == ParticipantManagement::TypeClass::Human ?
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
|
||||
return ProjectDataManagement::toString(data.vulnerabilityState, vc);
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for TlnInfo Table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Mueller, SGAS, 2017-07-10
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
struct ParticipantInfo
|
||||
{
|
||||
qint64 biteSampleTime = 0;
|
||||
qint64 positionSampleTime = 0;
|
||||
ProjectDataManagement::VulnerabilityState vulnerabilityState;
|
||||
ParticipantManagement::TypeClass typeClass;
|
||||
int participantId = 0;
|
||||
int partyId = 0;
|
||||
int equipmentNumber = 0;
|
||||
QString positionString;
|
||||
QString designator;
|
||||
QString tacticalIdentifier;
|
||||
QString biteResult;
|
||||
bool isManipulated = false;
|
||||
bool isOutdated = false;
|
||||
|
||||
int id() const { return participantId; }
|
||||
};
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ParticipantInfoTableModel
|
||||
// --------------------------------------------------------
|
||||
class ParticipantInfoTableModel final : public LtsWidgets::LtsAbstractTableModel<ParticipantInfo>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
EquipmentNumber,
|
||||
TacticalStatus,
|
||||
Designator,
|
||||
TacticalIdentifier,
|
||||
Position,
|
||||
BiteResult
|
||||
};
|
||||
|
||||
explicit ParticipantInfoTableModel(QObject *parent = nullptr);
|
||||
~ParticipantInfoTableModel();
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
bool bWithPositionandBiteResult);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool removeItems(const QVector<int> &selectedIds);
|
||||
void initializeDataView();
|
||||
public Q_SLOTS:
|
||||
void updateDataView(const QSet<int> &participantIds);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onParticipantChanged(const ParticipantManagement::DynamicParticipantData &data,
|
||||
DataModification modType);
|
||||
void onPositionChanged(const ParticipantManagement::ParticipantPosition &position,
|
||||
DataModification modType);
|
||||
void onBiteChanged(const ParticipantManagement::Bite &bite,
|
||||
DataModification modType);
|
||||
void onPartitionTimeChanged(qint64 newPartitionTime);
|
||||
void onPartyChanged(const ParticipantManagement::Party &party,
|
||||
DataModification modType);
|
||||
void onTimeoutCheck();
|
||||
|
||||
private:
|
||||
ParticipantInfo setInfoData(const ParticipantManagement::Participant &part) const;
|
||||
void fillParticipantContent(ParticipantInfo &info,
|
||||
const DynamicParticipantData &data) const;
|
||||
void fillParticipantContent(ParticipantInfo &info,
|
||||
const Participant &part) const;
|
||||
void updatePosition(ParticipantInfo &info,
|
||||
const ParticipantManagement::ParticipantPosition &position) const;
|
||||
bool isOutdated(qint64 sampleTime) const;
|
||||
QString biteStringFromBite(const ParticipantManagement::Bite &bite) const;
|
||||
static QString vulnerabilityStateString(const ParticipantInfo &data);
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
|
||||
qint64 m_partitionTime;
|
||||
QTimer *m_timeoutCheckTimer;
|
||||
QHash<int, QIcon> m_partyIcons;
|
||||
bool m_bWithPositionandBiteResult;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
+347
@@ -0,0 +1,347 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ParticipantManagement - ParticipantSearchDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#include "participant_search_dialog.h"
|
||||
#include "ui_participant_search_dialog.h"
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
int ParticipantSearchDialog::s_preselectedParty = -1;
|
||||
bool ParticipantSearchDialog::s_preselectedAllParticipants = true;
|
||||
|
||||
ParticipantSearchDialog::ParticipantSearchDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_equipNo(0)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmCbxIfc(nullptr)
|
||||
, m_ui(new Ui::ParticipantSearchDialog)
|
||||
, m_logger(getLogger("ParticipantSearchDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->leEquipNo->setValidator(new QIntValidator(0, 100000, m_ui->leEquipNo));
|
||||
setUnchangeable();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &ParticipantSearchDialog::onClicked);
|
||||
|
||||
m_updateObjectIndicator = new QTimer(this);
|
||||
m_updateObjectIndicator->setSingleShot(true);
|
||||
m_updateObjectIndicator->setInterval(100);
|
||||
connect(m_updateObjectIndicator, &QTimer::timeout, this, &ParticipantSearchDialog::updateObjectIndicator);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Find_Participant"));
|
||||
}
|
||||
|
||||
ParticipantSearchDialog::~ParticipantSearchDialog()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removeObjectIndicator();
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Participant Search"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Show Participant Info"));
|
||||
}
|
||||
|
||||
bool ParticipantSearchDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc,
|
||||
const std::shared_ptr<OcSituationClient::ForeignParticipantInfoGuiInterface> &ppmOcGuiIfc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmGuiIfc = ppmGuiIfc;
|
||||
m_ocParticipantInfoIfc = ppmOcGuiIfc;
|
||||
|
||||
if (!m_dtc)
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmCbxIfc))
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
|
||||
m_ui->cbAll->setChecked(s_preselectedAllParticipants);
|
||||
|
||||
m_model = new ParticipantEditModel(this, m_dtc, asbIfc);
|
||||
m_ui->tvParticipants->setModel(m_model);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantSearchDialog::changeParty);
|
||||
|
||||
QItemSelectionModel *selectionModel = m_ui->tvParticipants->selectionModel();
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
||||
this, &ParticipantSearchDialog::slotLookup);
|
||||
|
||||
connect(m_ui->tvParticipants, &QTreeView::doubleClicked,
|
||||
this, &ParticipantSearchDialog::onDoubleClicked);
|
||||
|
||||
connect(m_ui->slEquipmentNumber, &QSlider::valueChanged, this, &ParticipantSearchDialog::slotLookup);
|
||||
connect(m_ui->pbLookup, &QPushButton::clicked, this, &ParticipantSearchDialog::slotLookup);
|
||||
connect(m_ui->leEquipNo, &QLineEdit::returnPressed, this, &ParticipantSearchDialog::slotLookup);
|
||||
connect(m_ui->cbAll, &QCheckBox::toggled, this, &ParticipantSearchDialog::changeParty);
|
||||
|
||||
m_ppmCbxIfc->fillPartyComboBox(m_ui->cbParty, ForeignGuiComboboxInterface::CbxPartyFilter::All);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
|
||||
changeParty();
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::slotLookup()
|
||||
{
|
||||
//block all signals here
|
||||
QSignalBlocker blx2(m_ui->slEquipmentNumber);
|
||||
QSignalBlocker blx3(m_ui->leEquipNo);
|
||||
|
||||
//set sliderposition to current value
|
||||
int newEquipNo = -1;
|
||||
|
||||
if (qobject_cast<QSlider *>(sender()))
|
||||
newEquipNo = changeLabelText(m_ui->slEquipmentNumber->value());
|
||||
if (qobject_cast<QLineEdit *>(sender()) ||
|
||||
qobject_cast<QPushButton *>(sender()))
|
||||
{
|
||||
//get Number from
|
||||
newEquipNo = m_ui->leEquipNo->text().toInt();
|
||||
}
|
||||
if (qobject_cast<QItemSelectionModel *>(sender()))
|
||||
{
|
||||
newEquipNo = onSelectionChanged();
|
||||
//selection cleared (do we allow a deselct?)
|
||||
// if (newEquipNo < 0 )
|
||||
// {
|
||||
// m_equipNo = newEquipNo;
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
if (newEquipNo == m_equipNo)
|
||||
return;
|
||||
|
||||
m_equipNo = newEquipNo;
|
||||
|
||||
//set Label and update lineEdit
|
||||
if (m_equipNo > 0)
|
||||
m_ui->leEquipNo->setText(QString::number(m_equipNo));
|
||||
changeSliderPosition(m_equipNo);
|
||||
|
||||
//finally enable show button if found
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(m_participantMap.contains(m_equipNo));
|
||||
|
||||
//function for itemselection
|
||||
auto cb = [this](const QModelIndex & idx)
|
||||
{
|
||||
m_ui->tvParticipants->setCurrentIndex(idx);
|
||||
};
|
||||
auto it = m_participantMap.find(m_equipNo);
|
||||
if (it == m_participantMap.end() && !qobject_cast<QItemSelectionModel *>(sender()))
|
||||
{
|
||||
m_ui->tvParticipants->setCurrentIndex(QModelIndex());
|
||||
return;
|
||||
}
|
||||
m_model->selectItemByParticipantId(it.value(), cb);
|
||||
|
||||
|
||||
// update ObjectIndicator:
|
||||
if (m_updateObjectIndicator)
|
||||
m_updateObjectIndicator->start(); // start is restart
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::updateObjectIndicator()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
int participantId = m_participantMap.value(m_equipNo, -1);
|
||||
|
||||
if (participantId >= 0)
|
||||
m_sitMapGuiIfc->objectIndicatorToParticipant(participantId);
|
||||
else
|
||||
m_sitMapGuiIfc->removeObjectIndicator();
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::enterEvent(QEvent *e)
|
||||
{
|
||||
BaseClass::enterEvent(e);
|
||||
updateObjectIndicator();
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::leaveEvent(QEvent *e)
|
||||
{
|
||||
BaseClass::leaveEvent(e);
|
||||
// to early, remove obj at dtor
|
||||
// if (m_sitMapGuiIfc)
|
||||
// m_sitMapGuiIfc->removeObjectIndicator();
|
||||
}
|
||||
|
||||
|
||||
//private
|
||||
|
||||
int ParticipantSearchDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndex index = m_ui->tvParticipants->currentIndex();
|
||||
|
||||
//finally enable show button
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(true);
|
||||
|
||||
ParticipantManagement::ParticipantData data;
|
||||
data = m_model->getParticipantData(index);
|
||||
if (!data.equipmentNumber().is_set())
|
||||
return -1;
|
||||
|
||||
return data.equipmentNumber().get();
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::onDoubleClicked()
|
||||
{
|
||||
QModelIndex index = m_ui->tvParticipants->currentIndex();
|
||||
|
||||
ParticipantManagement::ParticipantData data;
|
||||
data = m_model->getParticipantData(index);
|
||||
|
||||
if (m_ppmGuiIfc)
|
||||
m_ppmGuiIfc->showParticipantInfoWindow(data.id());
|
||||
if (m_ocParticipantInfoIfc)
|
||||
m_ocParticipantInfoIfc->showOcParticipantInfoWindow(data.id());
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::clearSelections()
|
||||
{
|
||||
changeSliderPosition(-1);
|
||||
m_ui->leEquipNo->clear();
|
||||
m_equipNo = 0;
|
||||
m_ui->tvParticipants->setCurrentIndex(QModelIndex());
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(false);
|
||||
}
|
||||
|
||||
//Slots
|
||||
void ParticipantSearchDialog::changeParty()
|
||||
{
|
||||
s_preselectedAllParticipants = m_ui->cbAll->isChecked();
|
||||
if (m_ui->cbAll->isChecked())
|
||||
{
|
||||
m_ui->cbParty->setEnabled(false);
|
||||
m_ui->tvParticipants->setEnabled(false);
|
||||
m_model->resetModel();
|
||||
fillMapFromDtc();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbParty->setEnabled(true);
|
||||
m_ui->tvParticipants->setEnabled(true);
|
||||
int partyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = partyId;
|
||||
m_model->onReinitModel(partyId);
|
||||
m_ui->tvParticipants->expandAll();
|
||||
fillParticipantMapFromTree();
|
||||
}
|
||||
|
||||
m_ui->slEquipmentNumber->setRange(0, m_participantMap.size() - 1);
|
||||
clearSelections();
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::fillMapFromDtc()
|
||||
{
|
||||
m_participantMap.clear();
|
||||
auto cb = [this](const Participant & data)
|
||||
{
|
||||
if (data.equipmentNumber().is_set())
|
||||
m_participantMap.insert(data.equipmentNumber().get(), data.id());
|
||||
};
|
||||
m_dtc->participants(cb);
|
||||
}
|
||||
|
||||
int ParticipantSearchDialog::changeLabelText(int value)
|
||||
{
|
||||
if (value < 0 || value >= m_participantMap.size())
|
||||
return -1;
|
||||
|
||||
auto it = m_participantMap.begin();
|
||||
it += value;
|
||||
int newEqNr = it.key();
|
||||
|
||||
m_ui->lblEquipmentNumber->setText(QString::number(newEqNr));
|
||||
m_ui->leEquipNo->setText(QString::number(newEqNr));
|
||||
return newEqNr;
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::changeSliderPosition(int equipNo)
|
||||
{
|
||||
int i = 0;
|
||||
int pos = -1;
|
||||
for (auto it = m_participantMap.cbegin(); it != m_participantMap.cend(); ++it)
|
||||
{
|
||||
if (equipNo == it.key())
|
||||
{
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (pos >= 0)
|
||||
{
|
||||
m_ui->lblEquipmentNumber->setText(QString::number(equipNo));
|
||||
m_ui->slEquipmentNumber->setSliderPosition(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->slEquipmentNumber->setSliderPosition(-1);
|
||||
m_ui->lblEquipmentNumber->setText(tr("Not found"));
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::fillParticipantMapFromTree()
|
||||
{
|
||||
m_participantMap.clear();
|
||||
|
||||
fillParticipantMapFromTree(QModelIndex());
|
||||
}
|
||||
|
||||
void ParticipantSearchDialog::fillParticipantMapFromTree(const QModelIndex &parent)
|
||||
{
|
||||
const int rc = m_model->rowCount(parent);
|
||||
for (int row = 0; row < rc; ++row)
|
||||
fillParticipantMapFromTree(m_model->index(row, 0, parent));
|
||||
|
||||
const ParticipantManagement::ParticipantData data(m_model->getParticipantData(parent));
|
||||
if (data.equipmentNumber().is_set())
|
||||
m_participantMap.insert(data.equipmentNumber().get(), data.id());
|
||||
}
|
||||
|
||||
|
||||
void ParticipantSearchDialog::onClicked()
|
||||
{
|
||||
int participantId = m_participantMap.value(m_equipNo);
|
||||
|
||||
if (!m_ui->cbAll->isChecked())
|
||||
onDoubleClicked();
|
||||
else
|
||||
{
|
||||
//ERROR_LOG(m_logger) << "ParticipantId: " << participantId
|
||||
|
||||
if (m_ppmGuiIfc)
|
||||
m_ppmGuiIfc->showParticipantInfoWindow(participantId);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantSearchDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-06-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
//#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <Plugins/ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
#include <Plugins/OcSituationClient/osc_participant_info_gui_plugin_interface.h>
|
||||
// SituationMap
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
//DDS
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
//Qt
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantSearchDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// ParticipantSearchDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantSearchDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
using BaseClass = LtsWidgets::LtsDialog;
|
||||
|
||||
public:
|
||||
explicit ParticipantSearchDialog(QWidget *parent = nullptr);
|
||||
~ParticipantSearchDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc,
|
||||
const std::shared_ptr<OcSituationClient::ForeignParticipantInfoGuiInterface> &ppmOcGuiIfc);
|
||||
|
||||
private slots:
|
||||
void slotLookup();
|
||||
void updateObjectIndicator();
|
||||
void enterEvent(QEvent *e) override;
|
||||
void leaveEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
int changeLabelText(int value);
|
||||
void onClicked();
|
||||
void changeParty();
|
||||
void fillMapFromDtc();
|
||||
void changeSliderPosition(int equipNo);
|
||||
int onSelectionChanged();
|
||||
void onDoubleClicked();
|
||||
void clearSelections();
|
||||
|
||||
void fillParticipantMapFromTree();
|
||||
void fillParticipantMapFromTree(const QModelIndex &parent);
|
||||
|
||||
ParticipantEditModel *m_model;
|
||||
int m_equipNo;
|
||||
|
||||
// ObjectIndicator: (ObjectIndicator schould not be updated to much, don`t know why...)
|
||||
QTimer *m_updateObjectIndicator = nullptr;
|
||||
|
||||
|
||||
// EquipNo, ParticipantId, QMap as it must be sorted, see changeSliderPosition()
|
||||
QMap<int, int> m_participantMap;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmCbxIfc;
|
||||
std::shared_ptr<ForeignParticipantInfoGuiInterface> m_ppmGuiIfc;
|
||||
std::shared_ptr<OcSituationClient::ForeignParticipantInfoGuiInterface> m_ocParticipantInfoIfc;
|
||||
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
static int s_preselectedParty;
|
||||
static bool s_preselectedAllParticipants;
|
||||
Ui::ParticipantSearchDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace ParticipantInfo
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantSearchDialog</class>
|
||||
<widget class="QWidget" name="ParticipantSearchDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>751</width>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>692</width>
|
||||
<height>342</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Participant Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbParticipants">
|
||||
<property name="title">
|
||||
<string>Participants</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2" rowspan="3">
|
||||
<widget class="QTreeView" name="tvParticipants">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbParty">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>159</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="cbAll">
|
||||
<property name="text">
|
||||
<string>All Participants</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Participant Search</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Equipment Number:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leEquipNo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbLookup">
|
||||
<property name="text">
|
||||
<string>Lookup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="slEquipmentNumber">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblEquipmentNumber">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">88888</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cbParty</tabstop>
|
||||
<tabstop>tvParticipants</tabstop>
|
||||
<tabstop>cbAll</tabstop>
|
||||
<tabstop>leEquipNo</tabstop>
|
||||
<tabstop>pbLookup</tabstop>
|
||||
<tabstop>slEquipmentNumber</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#include "participant_search_widget.h"
|
||||
#include "ui_participant_search_widget.h"
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
ParticipantSearchWidget::ParticipantSearchWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::ParticipantSearchWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->pbCancel, &QPushButton::clicked, this, &ParticipantSearchWidget::close);
|
||||
connect(m_ui->pbOk, &QPushButton::clicked, this, &ParticipantSearchWidget::onOkay);
|
||||
connect(m_ui->leEquipmentNo, &QLineEdit::returnPressed, this, &ParticipantSearchWidget::onOkay);
|
||||
}
|
||||
|
||||
ParticipantSearchWidget::~ParticipantSearchWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
void ParticipantSearchWidget::onOkay()
|
||||
{
|
||||
int participantId = m_eqId2PartId.value(m_ui->leEquipmentNo->text().toInt());
|
||||
if (participantId > 0)
|
||||
emit participantSelected(participantId);
|
||||
close();
|
||||
}
|
||||
void ParticipantSearchWidget::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
{
|
||||
const int newEqId = data.equipmentNumber().is_set() ? data.equipmentNumber().get() : 0;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
const int oldEqId = m_partId2EqId.value(data.id());
|
||||
if (oldEqId == newEqId)
|
||||
return;
|
||||
if (oldEqId != 0)
|
||||
m_eqId2PartId.remove(oldEqId);
|
||||
if (newEqId == 0)
|
||||
return;
|
||||
m_partId2EqId[data.id()] = newEqId;
|
||||
m_eqId2PartId[newEqId] = data.id();
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
const int oldEqId = m_partId2EqId.value(data.id());
|
||||
m_partId2EqId.remove(data.id());
|
||||
if (oldEqId != 0)
|
||||
m_eqId2PartId.remove(oldEqId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
bool ParticipantSearchWidget::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc)
|
||||
{
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
auto cb = [this](const Participant &data)
|
||||
{
|
||||
if (!data.equipmentNumber().is_set())
|
||||
return;
|
||||
const int newEqId = data.equipmentNumber().get();
|
||||
m_partId2EqId[data.id()] = newEqId;
|
||||
m_eqId2PartId[newEqId] = data.id();
|
||||
};
|
||||
dtc->participants(cb);
|
||||
connect(dtc.get(), &Interface::Dtc::participantChanged,
|
||||
this, &ParticipantSearchWidget::onParticipantChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#ifndef FORM1_H
|
||||
#define FORM1_H
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <QWidget>
|
||||
#include <QMap>
|
||||
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
|
||||
enum class DataModification;
|
||||
namespace Ui {
|
||||
class ParticipantSearchWidget;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class Participant;
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
class ParticipantSearchWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantSearchWidget(QWidget *parent = nullptr);
|
||||
~ParticipantSearchWidget();
|
||||
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc);
|
||||
|
||||
signals:
|
||||
void participantSelected(int participantId);
|
||||
|
||||
public slots:
|
||||
void onOkay();
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
|
||||
private:
|
||||
Ui::ParticipantSearchWidget *m_ui;
|
||||
QMap<int,int> m_eqId2PartId;
|
||||
QMap<int,int> m_partId2EqId;
|
||||
};
|
||||
|
||||
}//namespace
|
||||
#endif // FORM1_H
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantSearchWidget</class>
|
||||
<widget class="QWidget" name="ParticipantSearchWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>252</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Search Participant</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Equipment Nr.:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leEquipmentNo"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbOk">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbCancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantSetInjury
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2020-05-13
|
||||
*/
|
||||
|
||||
#include "participant_set_injury_dialog.h"
|
||||
#include "ui_participant_set_injury_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
|
||||
#include <ParticipantManagement/Gui/Common/participant_vulnerability_types.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
ParticipantSetInjuryDialog::ParticipantSetInjuryDialog(int participantId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_participantId(participantId)
|
||||
, m_eqId(-1)
|
||||
, m_session(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_ppmCbxIfc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_bgInjury(nullptr)
|
||||
, m_bgBodypart(nullptr)
|
||||
, m_bgSide(nullptr)
|
||||
, m_ui(new Ui::ParticipantSetInjuryDialog)
|
||||
, m_logger(getLogger("ParticipantSetInjuryDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
bool ParticipantSetInjuryDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtcPdm)
|
||||
{
|
||||
if (!session || !dtc || !ftc || !dtcPdm)
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmCbxIfc))
|
||||
return false;
|
||||
|
||||
m_session = session;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtcPdm = dtcPdm;
|
||||
|
||||
if(!m_dtcPdm->enableSanitationInjury() || !m_dtcPdm->enableSanitationInjuryKind()
|
||||
|| !m_dtcPdm->enableSanitationInjuryPlace1() || !m_dtcPdm->enableSanitationInjuryPlace2())
|
||||
return false;
|
||||
|
||||
m_dtcPdm->waitForHistoricalDataSanitationInjury(1000);
|
||||
m_dtcPdm->waitForHistoricalDataSanitationInjuryKind(1000);
|
||||
m_dtcPdm->waitForHistoricalDataSanitationInjuryPlace1(1000);
|
||||
m_dtcPdm->waitForHistoricalDataSanitationInjuryPlace2(1000);
|
||||
|
||||
const Participant participant = m_dtc->participant(m_participantId);
|
||||
if (participant.equipmentNumber().is_set())
|
||||
m_eqId = participant.equipmentNumber().get();
|
||||
|
||||
if (m_dtc->type(participant.typeId()).typeClass() != TypeClass::Human)
|
||||
return false;
|
||||
auto vec = vulnerabilityStatesForTypeClass(TypeClass::Human);
|
||||
if (!vec.contains(ProjectDataManagement::VulnerabilityState::LightDamage)
|
||||
|| !vec.contains(ProjectDataManagement::VulnerabilityState::MediumDamage)
|
||||
|| !vec.contains(ProjectDataManagement::VulnerabilityState::HeavyDamage))
|
||||
return false;
|
||||
|
||||
m_injuries = m_dtcPdm->sanitationInjurys();
|
||||
m_injuryKind = m_dtcPdm->sanitationInjuryKinds();
|
||||
m_injuryPlace1 = m_dtcPdm->sanitationInjuryPlace1s();
|
||||
m_injuryPlace2 = m_dtcPdm->sanitationInjuryPlace2s();
|
||||
|
||||
if (m_injuries.count() == 0 || m_injuryKind.count() == 0 || m_injuryPlace1.count() == 0 || m_injuryPlace2.count() == 0)
|
||||
return false;
|
||||
|
||||
createButtonGroups();
|
||||
resetRadioStates();
|
||||
checkRadioStatesBody();
|
||||
|
||||
// I dant want to use mininum size here so I add one first and remove it later
|
||||
//const QString &mediumDamage = toString(ProjectDataManagement::VulnerabilityState::MediumDamage, ProjectDataManagement::VulnerabilityClass::SoldierInjuries);
|
||||
checkState();
|
||||
//m_ui->cbState->addItem(mediumDamage, 0);
|
||||
|
||||
//m_uiRequirements->addRequirement({ m_ui->lblBodypart, [this]() { return (m_bgBodypart->checkedId() > 0); }});
|
||||
//m_uiRequirements->addRequirement({ m_ui->lblInjury, [this]() { return (m_bgInjury->checkedId() > 0); }});
|
||||
//m_uiRequirements->addRequirement({ m_ui->lblSide, [this]() { return ((m_ui->sideLeft->isEnabled() && m_bgSide->checkedId() > 0) || (!m_ui->sideLeft->isEnabled())); }});
|
||||
//m_uiRequirements->addRequirement({ m_ui->lblState, [this]() { return (m_ui->cbState->currentData().toInt() > 0); }});
|
||||
|
||||
//set old data in combo box cbState
|
||||
const DynamicParticipantData &dynData = m_dtc->dynamicParticipantData(m_participantId);
|
||||
setOldData(dynData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ParticipantSetInjuryDialog::~ParticipantSetInjuryDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantSetInjuryDialog::retranslate()
|
||||
{
|
||||
QString id;
|
||||
if (m_eqId > 0)
|
||||
id = QString::number(m_eqId);
|
||||
|
||||
translate(m_ui, tr("Set Injury: %1").arg((id)));
|
||||
}
|
||||
|
||||
|
||||
void ParticipantSetInjuryDialog::createButtonGroups()
|
||||
{
|
||||
|
||||
if (!m_ui->gbBodyPart || !m_ui->gbBodyPart->layout()
|
||||
|| !m_ui->gbInjury || !m_ui->gbInjury->layout()
|
||||
|| !m_ui->gbSide || !m_ui->gbSide->layout())
|
||||
return;
|
||||
|
||||
//Add Injury Kinds
|
||||
QRadioButton *rb;
|
||||
QSpacerItem *item ;
|
||||
|
||||
m_bgInjury = new QButtonGroup(this);
|
||||
for (const auto &injuryKind : qAsConst(m_injuryKind))
|
||||
{
|
||||
rb = new QRadioButton(ProjectDataManagement::trSanitationInjuryKindName(injuryKind.name()), this);
|
||||
m_bgInjury->addButton(rb, injuryKind.id());
|
||||
m_ui->gbInjury->layout()->addWidget(rb);
|
||||
}
|
||||
//Add Spacer at the end
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbInjury->layout()->addItem(item);
|
||||
|
||||
//Now Add Body Parts
|
||||
m_bgBodypart = new QButtonGroup(this);
|
||||
for (const auto &injuryplace1 : qAsConst(m_injuryPlace1))
|
||||
{
|
||||
rb = new QRadioButton(ProjectDataManagement::trSanitationInjuryPlace1Name(injuryplace1.name()), this);
|
||||
m_bgBodypart->addButton(rb, injuryplace1.id());
|
||||
m_ui->gbBodyPart->layout()->addWidget(rb);
|
||||
}
|
||||
// Add Spacer at the end
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbBodyPart->layout()->addItem(item);
|
||||
|
||||
//Now add Sides
|
||||
m_bgSide = new QButtonGroup(this);
|
||||
for (const auto &injuryplace2 : qAsConst(m_injuryPlace2))
|
||||
{
|
||||
rb = new QRadioButton(ProjectDataManagement::trSanitationInjuryPlace2Name(injuryplace2.name()), this);
|
||||
m_bgSide->addButton(rb, injuryplace2.id());
|
||||
m_ui->gbSide->layout()->addWidget(rb);
|
||||
}
|
||||
//Spacer at the end
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbSide->layout()->addItem(item);
|
||||
|
||||
connect(m_bgInjury, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &ParticipantSetInjuryDialog::checkRadioStatesBody);
|
||||
connect(m_bgBodypart, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &ParticipantSetInjuryDialog::checkRadioStatesSides);
|
||||
// connect(m_bgSide, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &ParticipantSetInjuryDialog::checkState);
|
||||
}
|
||||
|
||||
void ParticipantSetInjuryDialog::setOldData(const DynamicParticipantData &data)
|
||||
{
|
||||
if (data.stateHistory().size() == 0)
|
||||
return;
|
||||
|
||||
const StateInformation &lastState = m_dtc->youngestStateInformation(data.stateHistory());
|
||||
//Todo Set last Stuff
|
||||
//uint32_t bits = lastState.vulnerabilityBits();
|
||||
|
||||
int index = m_ui->cbState->findData(lastState.vulnerabilityState().underlying());
|
||||
|
||||
DEBUG_LOG(m_logger) << "Old vulnerability state = " << index;
|
||||
|
||||
if (index > 0)
|
||||
m_ui->cbState->setCurrentIndex(index);
|
||||
|
||||
}
|
||||
|
||||
uint32_t ParticipantSetInjuryDialog::getInjuryBit()
|
||||
{
|
||||
|
||||
// VBA san = ((injury*16 + bodypart) * 4 + side) + 2048
|
||||
int side = m_bgSide->button(1)->isEnabled() ? m_bgSide->checkedId() : 0;
|
||||
|
||||
DEBUG_LOG(m_logger) << "getInjuryBit() -------------- ";
|
||||
DEBUG_LOG(m_logger) << "Injury = " << m_bgInjury->checkedId();
|
||||
DEBUG_LOG(m_logger) << "Body = " << m_bgBodypart->checkedId();
|
||||
DEBUG_LOG(m_logger) << "Side = " << side;
|
||||
|
||||
return (((((m_bgInjury->checkedId() * 16) + m_bgBodypart->checkedId()) * 4) + side) + 2048);
|
||||
|
||||
}
|
||||
|
||||
//slots
|
||||
|
||||
void ParticipantSetInjuryDialog::checkRadioStatesBody()
|
||||
{
|
||||
|
||||
resetRadioStates();
|
||||
bool firstAvailable = true;
|
||||
for (const ProjectDataManagement::SanitationInjury& injury : qAsConst(m_injuries))
|
||||
{
|
||||
if (injury.kind() == m_bgInjury->checkedId())
|
||||
{
|
||||
if (firstAvailable)
|
||||
{
|
||||
m_bgBodypart->button(injury.place1())->setChecked(true);
|
||||
firstAvailable = false;
|
||||
}
|
||||
m_bgBodypart->button(injury.place1())->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
checkRadioStatesSides();
|
||||
|
||||
}
|
||||
|
||||
void ParticipantSetInjuryDialog::checkRadioStatesSides()
|
||||
{
|
||||
|
||||
resetRadioStates(true);
|
||||
|
||||
for (const ProjectDataManagement::SanitationInjury& injury : qAsConst(m_injuries))
|
||||
{
|
||||
if (injury.kind() == m_bgInjury->checkedId() && injury.place1() == m_bgBodypart->checkedId())
|
||||
m_bgSide->button(injury.place2())->setEnabled(true);
|
||||
}
|
||||
if(!m_bgSide->button(1)->isEnabled())
|
||||
m_bgSide->button(0)->setChecked(true);
|
||||
else
|
||||
m_bgSide->button(1)->setChecked(true);
|
||||
|
||||
checkState();
|
||||
|
||||
}
|
||||
|
||||
void ParticipantSetInjuryDialog::checkState()
|
||||
{
|
||||
QSignalBlocker(m_ui->cbState);
|
||||
m_ui->cbState->clear();
|
||||
//Vulnerability
|
||||
//m_ui->cbState->addItem(tr("No Change"), -1);
|
||||
|
||||
if (m_bgBodypart->checkedId() == 0 || m_bgInjury->checkedId() == 0)
|
||||
{
|
||||
m_ui->cbState->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString &lightDamage = tr("Minor"); //toString(ProjectDataManagement::VulnerabilityState::LightDamage, ProjectDataManagement::VulnerabilityClass::SoldierInjuries);
|
||||
const QString &mediumDamage = tr("Middle"); //toString(ProjectDataManagement::VulnerabilityState::MediumDamage, ProjectDataManagement::VulnerabilityClass::SoldierInjuries);
|
||||
const QString &heavyDamage = tr("Serious"); //toString(ProjectDataManagement::VulnerabilityState::HeavyDamage, ProjectDataManagement::VulnerabilityClass::SoldierInjuries);
|
||||
|
||||
for (const ProjectDataManagement::SanitationInjury& injury : qAsConst(m_injuries))
|
||||
{
|
||||
if (injury.kind() == m_bgInjury->checkedId() && injury.place1() == m_bgBodypart->checkedId() && injury.place2() == m_bgSide->checkedId())
|
||||
{
|
||||
|
||||
switch (injury.vbg())
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (m_ui->cbState->findData(ProjectDataManagement::VulnerabilityState_def::LightDamage) < 1)
|
||||
m_ui->cbState->addItem(lightDamage, ProjectDataManagement::VulnerabilityState_def::LightDamage);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (m_ui->cbState->findData(ProjectDataManagement::VulnerabilityState_def::MediumDamage) < 1)
|
||||
m_ui->cbState->addItem(mediumDamage, ProjectDataManagement::VulnerabilityState_def::MediumDamage);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if (m_ui->cbState->findData(ProjectDataManagement::VulnerabilityState_def::HeavyDamage) < 1)
|
||||
m_ui->cbState->addItem(heavyDamage, ProjectDataManagement::VulnerabilityState_def::HeavyDamage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantSetInjuryDialog::resetRadioStates(bool onlySides)
|
||||
{
|
||||
if (!onlySides)
|
||||
{
|
||||
QList<QAbstractButton *> tList = m_bgBodypart->buttons();
|
||||
auto cb = tList.begin();
|
||||
while (cb != tList.end())
|
||||
{
|
||||
auto *cbBody = *cb;
|
||||
cbBody->setEnabled(false);
|
||||
cb++;
|
||||
}
|
||||
//m_ui->bodyNone->setChecked(true);
|
||||
}
|
||||
|
||||
QList<QAbstractButton *> sList = m_bgSide->buttons();
|
||||
auto cbS = sList.begin();
|
||||
while( cbS != sList.end())
|
||||
{
|
||||
auto *cbSide = *cbS;
|
||||
cbSide->setEnabled(false);
|
||||
cbS++;
|
||||
}
|
||||
//m_ui->sideNone->setChecked(true);
|
||||
}
|
||||
|
||||
bool ParticipantSetInjuryDialog::apply()
|
||||
{
|
||||
if (m_ui->cbState->currentData().toInt() <= 0)
|
||||
return false;
|
||||
|
||||
const ProjectDataManagement::VulnerabilityState state = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cbState->currentData().toInt());
|
||||
|
||||
ModifyStateRequest req;
|
||||
req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
req.vulnerabilityState(state);
|
||||
req.participantIds({m_participantId});
|
||||
req.vulnerabilityKind(getInjuryBit());
|
||||
|
||||
DEBUG_LOG(m_logger) << "Saving vulnerability state = " << req.vulnerabilityState();
|
||||
DEBUG_LOG(m_logger) << "Saving vulnerability kind = " << req.vulnerabilityKind();
|
||||
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->modifyStateRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantSetInjury
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2020-05-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
//ProjektDataManagement
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
//DDS
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//Qt
|
||||
#include <QWidget>
|
||||
#include <QButtonGroup>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantSetInjuryDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class ParticipantSetInjuryDialog : public LtsWidgets::LtsDialog
|
||||
, protected ParticipantManagement::Interface::Ftc::ModifyStateReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum Injuries
|
||||
{
|
||||
Hit = 1,
|
||||
Splitter = 2,
|
||||
Explosion = 3,
|
||||
Fracture = 4,
|
||||
Burn = 5,
|
||||
Amputation = 6
|
||||
};
|
||||
|
||||
enum BodyParts
|
||||
{
|
||||
Head = 1,
|
||||
Arm = 2,
|
||||
Leg = 3,
|
||||
Shoulder = 4,
|
||||
Thorax = 5,
|
||||
Abdomen = 6,
|
||||
Torso = 7,
|
||||
Hand = 8,
|
||||
Forearm = 9,
|
||||
Foot = 10,
|
||||
Shank = 11
|
||||
};
|
||||
enum Sides
|
||||
{
|
||||
Left = 1,
|
||||
Right = 2
|
||||
};
|
||||
|
||||
explicit ParticipantSetInjuryDialog(int participantId, QWidget *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtcPdm);
|
||||
|
||||
~ParticipantSetInjuryDialog();
|
||||
|
||||
private:
|
||||
void onModifyStateReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void retranslate() override;
|
||||
|
||||
void createButtonGroups();
|
||||
|
||||
void setOldData(const DynamicParticipantData &data);
|
||||
uint32_t getInjuryBit();
|
||||
|
||||
private slots:
|
||||
void checkRadioStatesBody();
|
||||
void checkRadioStatesSides();
|
||||
void checkState();
|
||||
void resetRadioStates(bool onlySides = false);
|
||||
|
||||
private:
|
||||
bool apply() override final;
|
||||
|
||||
private:
|
||||
int m_participantId;
|
||||
int m_eqId;
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_dtcPdm;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmCbxIfc;
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
QButtonGroup *m_bgInjury;
|
||||
QButtonGroup *m_bgBodypart;
|
||||
QButtonGroup *m_bgSide;
|
||||
Ui::ParticipantSetInjuryDialog *m_ui;
|
||||
QMap<int, ProjectDataManagement::SanitationInjury> m_injuries;
|
||||
QMap<int, ProjectDataManagement::SanitationInjuryKind> m_injuryKind;
|
||||
QMap<int, ProjectDataManagement::SanitationInjuryPlace1> m_injuryPlace1;
|
||||
QMap<int, ProjectDataManagement::SanitationInjuryPlace2> m_injuryPlace2;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantSetInjuryDialog</class>
|
||||
<widget class="QWidget" name="ParticipantSetInjuryDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>465</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbInjury">
|
||||
<property name="title">
|
||||
<string>Injury</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbBodyPart">
|
||||
<property name="title">
|
||||
<string>Body Part</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbSide">
|
||||
<property name="title">
|
||||
<string>Side</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbState">
|
||||
<property name="title">
|
||||
<string>State</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbState"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+215
@@ -0,0 +1,215 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SetSanitationDialog - Send a Sanitation telegram in TAB
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat - 2020-06-20
|
||||
*/
|
||||
|
||||
#include "participant_set_sanitation_dialog.h"
|
||||
#include "ui_participant_set_sanitation_dialog.h"
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ngltranslator/ngltranslator.h>
|
||||
#include <QSpacerItem>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
ParticipantSetSanitationDialog::ParticipantSetSanitationDialog(int participantId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_participantId(participantId)
|
||||
, m_ui(new Ui::ParticipantSetSanitationDialog)
|
||||
, m_logger(getLogger("ParticipantSetSanitationDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_uiRequirements->addRequirement({ m_ui->lbl, [this]()
|
||||
{
|
||||
bool k = false;
|
||||
int val = m_ui->cbQualification->currentData().toInt(&k);
|
||||
if (!val)
|
||||
return false;
|
||||
return (val > 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ParticipantSetSanitationDialog::~ParticipantSetSanitationDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantSetSanitationDialog::retranslate()
|
||||
{
|
||||
QString id;
|
||||
if (m_eqId > 0)
|
||||
id = QString::number(m_eqId);
|
||||
|
||||
translate(m_ui, tr("Medic Treatment: %1").arg((id)));
|
||||
}
|
||||
|
||||
|
||||
bool ParticipantSetSanitationDialog::init(LtsSession::LtsSession *session, const std::shared_ptr<Interface::Dtc> &dtc, const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtcPdm)
|
||||
{
|
||||
if (!session || !dtc || !ftc)
|
||||
return false;
|
||||
|
||||
m_session = session;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtcPdm = dtcPdm;
|
||||
dtcPdm->enableSanitationProcedure(true);
|
||||
dtcPdm->waitForHistoricalDataSanitationProcedure(2000);
|
||||
|
||||
const Participant participant = m_dtc->participant(m_participantId);
|
||||
if (participant.equipmentNumber().is_set())
|
||||
m_eqId = participant.equipmentNumber().get();
|
||||
|
||||
fillCb();
|
||||
connect(m_ui->cbQualification, qOverload<int>(&QComboBox::currentIndexChanged), this, &ParticipantSetSanitationDialog::onQualificationChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantSetSanitationDialog::onQualificationChanged()
|
||||
{
|
||||
int qualification = m_ui->cbQualification->currentData().toInt();
|
||||
for (auto *cbx : m_procedures)
|
||||
{
|
||||
cbx->setEnabled((cbx->property("qualification").toInt() <= qualification));
|
||||
if (!cbx->isEnabled() && cbx->isChecked())
|
||||
cbx->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantSetSanitationDialog::fillCb()
|
||||
{
|
||||
m_ui->cbQualification->blockSignals(true);
|
||||
|
||||
m_ui->cbQualification->clear();
|
||||
//m_ui->cbQualification->addItem(ParticipantManagement::toString(Qualification::NotAssigned), -1);
|
||||
m_ui->cbQualification->addItem(ParticipantManagement::toString(Qualification::FAA), 1);
|
||||
m_ui->cbQualification->addItem(ParticipantManagement::toString(Qualification::FAB), 2);
|
||||
m_ui->cbQualification->addItem(ParticipantManagement::toString(Qualification::SANPers), 3);
|
||||
|
||||
m_procedures.clear();
|
||||
//now get data from Dtc
|
||||
const auto procs = m_dtcPdm->sanitationProcedures();
|
||||
|
||||
for (const auto &proc : procs)
|
||||
{
|
||||
QGroupBox *box = getGroupBox(proc.type());
|
||||
if (!box)
|
||||
continue;
|
||||
QCheckBox *cbx = new QCheckBox(this);
|
||||
//cbx->setText(isGerman ? QString::fromStdString(proc.shortDE()) : QString::fromStdString(proc.shortEN()));
|
||||
cbx->setText(ProjectDataManagement::trSanitationProcedureName(proc.name()));
|
||||
cbx->setProperty("dataCode",proc.dataCode());
|
||||
cbx->setProperty("qualification",proc.minimumQualification());
|
||||
box->layout()->addWidget(cbx);
|
||||
m_procedures.append(cbx);
|
||||
}
|
||||
|
||||
QSpacerItem *item ;
|
||||
if(m_ui->gbA && m_ui->gbA->layout())
|
||||
{
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbA->layout()->addItem(item);
|
||||
}
|
||||
if(m_ui->gbB && m_ui->gbB->layout())
|
||||
{
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbB->layout()->addItem(item);
|
||||
}
|
||||
if(m_ui->gbC && m_ui->gbC->layout())
|
||||
{
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbC->layout()->addItem(item);
|
||||
}
|
||||
if(m_ui->gbD && m_ui->gbD->layout())
|
||||
{
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbD->layout()->addItem(item);
|
||||
}
|
||||
if(m_ui->gbE && m_ui->gbE->layout())
|
||||
{
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbE->layout()->addItem(item);
|
||||
}
|
||||
if(m_ui->gbM && m_ui->gbM->layout())
|
||||
{
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbM->layout()->addItem(item);
|
||||
}
|
||||
if(m_ui->gbX && m_ui->gbX->layout())
|
||||
{
|
||||
item = new QSpacerItem(2,2,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
m_ui->gbX->layout()->addItem(item);
|
||||
}
|
||||
|
||||
onQualificationChanged();
|
||||
m_ui->cbQualification->blockSignals(false);
|
||||
}
|
||||
|
||||
qint64 ParticipantSetSanitationDialog::getProcedures()
|
||||
{
|
||||
qint64 ret = 0;
|
||||
for (const auto &cbx : qAsConst(m_procedures))
|
||||
{
|
||||
if (cbx->isChecked())
|
||||
ret += cbx->property("dataCode").toULongLong();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QGroupBox *ParticipantSetSanitationDialog::getGroupBox(std::string boxName)
|
||||
{
|
||||
if (boxName.size() == 0)
|
||||
return nullptr;
|
||||
switch (boxName.at(0))
|
||||
{
|
||||
case 'x':
|
||||
return m_ui->gbX;
|
||||
case 'A':
|
||||
return m_ui->gbA;
|
||||
case 'B':
|
||||
return m_ui->gbB;
|
||||
case 'C':
|
||||
return m_ui->gbC;
|
||||
case 'D':
|
||||
return m_ui->gbD;
|
||||
case 'E':
|
||||
return m_ui->gbE;
|
||||
case 'M':
|
||||
return m_ui->gbM;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
bool ParticipantSetSanitationDialog::apply()
|
||||
{
|
||||
|
||||
SetSanitationRequest req;
|
||||
req.id(m_participantId);
|
||||
SanitationData sanDat;
|
||||
sanDat.sanitationProceduresTaken(getProcedures());
|
||||
sanDat.qualification(static_cast<Qualification::inner_enum>(m_ui->cbQualification->currentData().toInt()));
|
||||
sanDat.originatorEquipmentNumber(0);
|
||||
req.data(sanDat);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Medic treatment: qualification = " << sanDat.qualification();
|
||||
DEBUG_LOG(m_logger) << "Medic treatment: procedures = " << sanDat.sanitationProceduresTaken();
|
||||
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->setSanitationRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SetSanitationDialog - Send a Sanitation telegram in TAB
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat - 2020-06-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//ProjectDataManagement
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
|
||||
#include <QList>
|
||||
|
||||
class QGroupBox;
|
||||
class QCheckBox;
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantSetSanitationDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class ParticipantSetSanitationDialog : public LtsWidgets::LtsDialog
|
||||
, protected ParticipantManagement::Interface::Ftc::SetSanitationReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantSetSanitationDialog(int participantId, QWidget *parent = nullptr);
|
||||
~ParticipantSetSanitationDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtcPdm);
|
||||
|
||||
private slots:
|
||||
void onQualificationChanged();
|
||||
private:
|
||||
void fillCb();
|
||||
void setCbxName();
|
||||
qint64 getProcedures();
|
||||
void retranslate() override;
|
||||
QGroupBox *getGroupBox(std::string boxName);
|
||||
bool apply() override final;
|
||||
|
||||
void onSetSanitationReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
int m_participantId;
|
||||
int m_eqId{-1};
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_dtcPdm;
|
||||
QList<QCheckBox *> m_procedures;
|
||||
Ui::ParticipantSetSanitationDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantSetSanitationDialog</class>
|
||||
<widget class="QWidget" name="ParticipantSetSanitationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>810</width>
|
||||
<height>526</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="8">
|
||||
<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>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QGroupBox" name="gbQualification">
|
||||
<property name="title">
|
||||
<string>Qualification</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbQualification"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>95</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QGroupBox" name="gbE">
|
||||
<property name="title">
|
||||
<string>Procedures E</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QGroupBox" name="gbD">
|
||||
<property name="title">
|
||||
<string>Procedures D</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QGroupBox" name="gbC">
|
||||
<property name="title">
|
||||
<string>Procedures C</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="gbA">
|
||||
<property name="title">
|
||||
<string>Procedures A</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QGroupBox" name="gbX">
|
||||
<property name="title">
|
||||
<string>Procedures X</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7" rowspan="2">
|
||||
<widget class="QGroupBox" name="gbM">
|
||||
<property name="title">
|
||||
<string>Procedures M</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QGroupBox" name="gbB">
|
||||
<property name="title">
|
||||
<string>Procedures B</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaModel
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Norbert Thoden, NLE, 2020-06-29
|
||||
*/
|
||||
|
||||
#include "participant_shootback_area_model.h"
|
||||
|
||||
#include <LtsUtilsCore/variant_operators.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
|
||||
#include <QApplication> // pixelMetric
|
||||
#include <QBuffer>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
//---------------------------------
|
||||
// AreaModel
|
||||
//---------------------------------
|
||||
AreaModel::AreaModel(QObject *parent)
|
||||
: BaseClass(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Name"),
|
||||
|
||||
// main config
|
||||
tr("Coords")
|
||||
},
|
||||
parent)
|
||||
, m_logger(getLogger("AreaModel"))
|
||||
{}
|
||||
|
||||
|
||||
bool AreaModel::initModel(const TargetInformation &targetInformation)
|
||||
{
|
||||
// insert Model
|
||||
INFO_LOG(m_logger) << "initModel - #AreaModel: " << targetInformation.shootbackAreas().size();
|
||||
|
||||
for (auto singleArea : qAsConst(targetInformation.shootbackAreas()))
|
||||
onShootbackAreaChanged(singleArea, DataModification::eAdded);
|
||||
|
||||
// updateColumnFilter
|
||||
connect(this, &AreaModel::rowsInserted, this, &AreaModel::updateColumnFilter);
|
||||
connect(this, &AreaModel::rowsRemoved, this, &AreaModel::updateColumnFilter);
|
||||
connect(this, &AreaModel::modelReset, this, &AreaModel::updateColumnFilter);
|
||||
// in case of changing value like hitsToKill:
|
||||
connect(this, &AreaModel::dataChanged, this, &AreaModel::updateColumnFilter);
|
||||
updateColumnFilter();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AreaModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole &&
|
||||
orientation == Qt::Horizontal)
|
||||
{
|
||||
// a few QSet<QString> ==>
|
||||
const auto processString = [](const QSet<QString> &usedXYCont) -> QVariant
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
cfc.data.reserve(usedXYCont.size());
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
|
||||
for (const QString &value : usedXYCont)
|
||||
{
|
||||
cfd.data = value;
|
||||
cfd.text = value;
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = true;
|
||||
return cfc.toVariant();
|
||||
};
|
||||
|
||||
if (section == Name)
|
||||
return processString(m_usedNames);
|
||||
}
|
||||
return BaseClass::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
QVariant AreaModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " role=" << role
|
||||
<< " index = " << index.column();
|
||||
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
if (role != Qt::DisplayRole &&
|
||||
role != Qt::DecorationRole &&
|
||||
role != Qt::ToolTipRole &&
|
||||
role != LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
|
||||
return QVariant();
|
||||
|
||||
const ShootbackArea &shootbackArea = m_vecData.at(index.row());
|
||||
|
||||
if (role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
|
||||
{
|
||||
if (index.column() == Name)
|
||||
return QString::fromStdString(shootbackArea.identifier());
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return 0; // shootbackArea.id();
|
||||
case Name:
|
||||
return QString::fromStdString(shootbackArea.identifier());
|
||||
case Coords:
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
} // switch
|
||||
|
||||
QPolygonF poly;
|
||||
|
||||
return QVariant(poly);
|
||||
}
|
||||
|
||||
void AreaModel::onShootbackAreaChanged(const ShootbackArea &data,
|
||||
const DataModification modType)
|
||||
{
|
||||
BaseClass::onDataChanged(data, modType);
|
||||
emit signalAreaNamesChanged();
|
||||
}
|
||||
|
||||
void AreaModel::updateColumnFilter()
|
||||
{
|
||||
m_usedNames.clear();
|
||||
for (const ShootbackArea &item : qAsConst(m_vecData))
|
||||
m_usedNames.insert(QString::fromStdString(item.identifier()));
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// AreaProxyModel
|
||||
// --------------------------------------------------------
|
||||
void AreaProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<AreaModel *>(sourceModel);
|
||||
BaseClass::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool AreaProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
source_left.row() < 0 || source_left.row() >= m_sourceModel->m_vecData.size() ||
|
||||
source_right.row() < 0 || source_right.row() >= m_sourceModel->m_vecData.size()
|
||||
)
|
||||
return BaseClass::lessThan(source_left, source_right);
|
||||
|
||||
const ShootbackArea &left = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const ShootbackArea &right = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
// case AreaModel::Columns::Id:
|
||||
//return left.id() < right.id();
|
||||
case AreaModel::Columns::Name:
|
||||
return left.identifier() < right.identifier();
|
||||
|
||||
// case AreaModel::Columns::Center:
|
||||
// QString compare
|
||||
default:
|
||||
return LtsUtils::lessThan(source_left.data(), source_right.data());
|
||||
}
|
||||
return BaseClass::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaModel
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Norbert Thoden, NLE, 2020-06-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
// --------------------------------------------------------
|
||||
// AreaModel
|
||||
// --------------------------------------------------------
|
||||
class AreaModel final : public LtsWidgets::LtsAbstractTableModel<ShootbackArea>
|
||||
{
|
||||
Q_OBJECT
|
||||
using BaseClass = LtsWidgets::LtsAbstractTableModel<ShootbackArea>;
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
// main config
|
||||
Name,
|
||||
Coords
|
||||
};
|
||||
|
||||
explicit AreaModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const TargetInformation &targetInformation);
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
|
||||
QVariant data(const QModelIndex &, int) const override;
|
||||
|
||||
const QVector<ShootbackArea> &getData() const { return m_vecData; }
|
||||
std::vector<ShootbackArea> getDataStdVector() const { return std::vector<ShootbackArea>(m_vecData.begin(), m_vecData.end()); }
|
||||
|
||||
Q_SIGNALS:
|
||||
void signalAreaNamesChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onShootbackAreaChanged(const ShootbackArea &data,
|
||||
const DataModification modType);
|
||||
void updateColumnFilter();
|
||||
|
||||
private:
|
||||
friend class AreaProxyModel;
|
||||
|
||||
// column filter
|
||||
QSet<QString> m_usedNames;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------
|
||||
// AreaProxyModel
|
||||
// --------------------------------------------------------
|
||||
class AreaProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
using BaseClass = LtsWidgets::LtsColumnFilterProxyModel;
|
||||
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
|
||||
protected:
|
||||
AreaModel *m_sourceModel{nullptr};
|
||||
};
|
||||
|
||||
} //namespace ParticipantManagement
|
||||
Executable
+724
@@ -0,0 +1,724 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantTargetConfigurationDialog (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Norbert Thoden, SLSE, 2022-05-10
|
||||
*/
|
||||
#include "participant_target_config_dialog.h"
|
||||
#include "ui_participant_target_config_dialog.h"
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QTreeView>
|
||||
#include <QDebug>
|
||||
|
||||
// Translations
|
||||
//#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
|
||||
|
||||
const double s_minPoints = 3;
|
||||
const double s_maxPoints = 4;
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
Core::GeoPosition2D convert(const QPointF &coord)
|
||||
{
|
||||
return Core::GeoPosition2D(coord.x(), coord.y()); // lon/lat
|
||||
}
|
||||
|
||||
QPointF convert(const Core::GeoPosition2D &geoPos)
|
||||
{
|
||||
return QPointF(geoPos.lon(), geoPos.lat());
|
||||
}
|
||||
|
||||
|
||||
|
||||
ParticipantTargetConfigurationDialog::ParticipantTargetConfigurationDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ParticipantTargetConfigurationDialog)
|
||||
, m_logger(getLogger("ParticipantTargetConfigurationDialog"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
m_ui->setupUi(this);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
ParticipantTargetConfigurationDialog::~ParticipantTargetConfigurationDialog()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
delete m_ui;
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::retranslate()
|
||||
{
|
||||
const dds::core::optional<int32_t> eqId = m_dtc->participant(m_participantId).equipmentNumber();
|
||||
const QString id = (eqId.is_set() ? QString::number(eqId.get()) : QString());
|
||||
|
||||
translate(m_ui, id, false, tr("Target Configuration"));
|
||||
}
|
||||
|
||||
bool ParticipantTargetConfigurationDialog::apply()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
ModifyTargetInformationRequest req;
|
||||
req.targetInfo(m_targetInformation); // participantId is set at init()
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " update m_targetInformation: " << m_targetInformation;
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->modifyTargetInformationRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
bool ParticipantTargetConfigurationDialog::init(int participantId,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
m_participantId = participantId;
|
||||
if (m_participantId <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " participant invalid, participantId = " << m_participantId;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc; // maybe optional?
|
||||
|
||||
if (!m_dtc || !m_ftc)
|
||||
return false;
|
||||
m_dtc->enableParticipant(true);
|
||||
m_dtc->enableDynamicParticipantData(true);
|
||||
m_dtc->waitForHistoricalDataDynamicParticipantData(2000);
|
||||
|
||||
m_dtc->enableTargetInformation(true);
|
||||
m_dtc->waitForHistoricalDataTargetInformation(2000);
|
||||
|
||||
fillStatusComboBox();
|
||||
fillPrewarningEffectComboBox();
|
||||
fillTakeDownEffectComboBox();
|
||||
|
||||
m_ui->sb_prewarningInterval->setMinimum(0);
|
||||
m_ui->sb_prewarningInterval->setMinimum(10);
|
||||
|
||||
m_ui->sb_takeDownInterval->setMinimum(0);
|
||||
m_ui->sb_takeDownInterval->setMinimum(20);
|
||||
|
||||
// ListView
|
||||
// m_ui->lv_areas->setAlternatingRowColors(true);
|
||||
// m_ui->lv_areas->setDragEnabled(false);
|
||||
// m_ui->lv_areas->setFlow(QListView::Flow::TopToBottom);
|
||||
// m_ui->lv_areas->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||
// m_ui->lv_areas->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
|
||||
|
||||
// LtsDataView
|
||||
|
||||
//
|
||||
// DynamicParticipantData
|
||||
//
|
||||
ParticipantManagement::DynamicParticipantData pdd =
|
||||
m_dtc->dynamicParticipantData(m_participantId);
|
||||
|
||||
// no ppd seems to be valid too:
|
||||
// if (pdd.participantId() != m_participantId)
|
||||
// {
|
||||
// ERROR_LOG(m_logger) << LOGFUNCTION << " participant not found, participantId = " << m_participantId;
|
||||
// return false;
|
||||
// }
|
||||
pdd.participantId(m_participantId);
|
||||
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged,
|
||||
this, &ParticipantTargetConfigurationDialog::onDynamicParticipantDataChanged);
|
||||
onDynamicParticipantDataChanged(pdd, DataModification::eAdded); // update status comboBox
|
||||
|
||||
//
|
||||
// TargetInformation
|
||||
//
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::targetInformationChanged,
|
||||
this, &ParticipantTargetConfigurationDialog::onTargetInformationChanged);
|
||||
|
||||
const std::function<bool(const TargetInformation &data)> cb = [this](const TargetInformation & data) -> bool
|
||||
{
|
||||
if (data.participantId() == m_participantId)
|
||||
{
|
||||
m_targetInformation = data;
|
||||
return true; // break loop
|
||||
}
|
||||
return false;
|
||||
};
|
||||
m_dtc->targetInformations(cb);
|
||||
|
||||
if (m_targetInformation.participantId() > 0)
|
||||
{
|
||||
onTargetInformationChanged(m_targetInformation, DataModification::eAdded); // update status comboBox
|
||||
} else {
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " targetInformation not found for participantId = " << m_participantId
|
||||
<< " - use default.";
|
||||
m_targetInformation.participantId(m_participantId); // bootstrap
|
||||
}
|
||||
|
||||
setupConnections();
|
||||
m_ui->ltsDataView->setModel(&m_areaModel);
|
||||
m_ui->ltsDataView->treeView()->setItemDelegate(new EditNameDelegate(this));
|
||||
|
||||
m_ui->cb_showOnMap->setChecked(true); // at beginning all areas -> previewObjects
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onDynamicParticipantDataChanged(const DynamicParticipantData &dynData, DataModification modType)
|
||||
{
|
||||
if (m_participantId != dynData.participantId())
|
||||
return;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
m_ui->cb_status->setCurrentIndex(-1); // invalid
|
||||
break;
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
const ParticipantManagement::StateInformation &lastState = m_dtc->youngestStateInformation(dynData.stateHistory());
|
||||
const ProjectDataManagement::VulnerabilityState &vulState = lastState.vulnerabilityState();
|
||||
const ProjectDataManagement::VulnerabilityState_def::type vulStateType = vulState.underlying();
|
||||
|
||||
int idx = m_ui->cb_status->findData(vulStateType);
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " cb_status: vulState=" << vulState;
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " cb_status: setCurrentIndex idx=" << idx;
|
||||
m_ui->cb_status->setCurrentIndex(idx);
|
||||
m_ui->cb_status->setEnabled(true);
|
||||
}
|
||||
break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onTargetInformationChanged(const TargetInformation &data, DataModification modType)
|
||||
{
|
||||
if (m_participantId != data.participantId())
|
||||
return;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
m_targetInformation = TargetInformation();
|
||||
m_ui->cb_status->setCurrentIndex(-1); // invalid
|
||||
break;
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " got new targetInformation from dds: " << data;
|
||||
m_targetInformation = data;
|
||||
}
|
||||
break;
|
||||
} // switch
|
||||
|
||||
onDataChanged();
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onStatusChanged()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
m_ui->cb_status->setEnabled(false); // will be enabled by request
|
||||
|
||||
const ProjectDataManagement::VulnerabilityState newParticipantState = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cb_status->currentData().toInt());
|
||||
|
||||
if (newParticipantState == ProjectDataManagement::VulnerabilityState::CombatReady)
|
||||
{
|
||||
InitParticipantRequest req;
|
||||
req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
req.restockCharges(true);
|
||||
req.resetManipulation(true);
|
||||
req.resetVulnerabilityState(true);
|
||||
req.participantIds({m_participantId});
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->initParticipantRequest(req, this);
|
||||
});
|
||||
} else {
|
||||
ModifyStateRequest req;
|
||||
req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
req.vulnerabilityState(newParticipantState);
|
||||
// req.vulnerabilityKind(); ToDo: check
|
||||
req.participantIds({m_participantId});
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->modifyStateRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// const ProjectDataManagement::VulnerabilityState state = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cbStatus->currentData().toInt());
|
||||
// if (m_ui->cbStatus->currentIndex() == 1 ||
|
||||
// m_ui->cbResetGearCharge->isChecked() ||
|
||||
// m_ui->cbResetMedSupplies->isChecked() ||
|
||||
// m_ui->cbResetManipulation->isChecked()) // (1) Ready for action or button checked -> init
|
||||
// {
|
||||
// InitParticipantRequest req;
|
||||
// req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
// req.restockCharges(m_ui->cbResetGearCharge->isChecked());
|
||||
// req.resetManipulation(m_ui->cbResetManipulation->isChecked());
|
||||
// req.resetVulnerabilityState(state == ProjectDataManagement::VulnerabilityState::CombatReady);
|
||||
// req.restockSanitationMaterial(m_ui->cbResetMedSupplies->isChecked());
|
||||
// req.participantIds(participantIds);
|
||||
// m_requestHelper->addRequest([req, this]()
|
||||
// {
|
||||
// return m_ftc->initParticipantRequest(req, this);
|
||||
// });
|
||||
// }
|
||||
// else //set new State
|
||||
// {
|
||||
// // Invalid enum value -1
|
||||
// if (m_ui->cbStatus->currentData().toInt() != -1 || m_ui->cbVitality->currentData().toInt() != 0)
|
||||
// {
|
||||
// ModifyStateRequest req;
|
||||
// req.workstationId(LtsSessionData::LtsSessionData::getInstance()->getWorkstationId());
|
||||
// req.vulnerabilityState(state == ProjectDataManagement::VulnerabilityState::NoChange ? ProjectDataManagement::VulnerabilityState::CombatReady : state);
|
||||
// req.participantIds(participantIds);
|
||||
// req.vitality(m_ui->cbVitality->currentData().toInt());
|
||||
// if(req.vitality() > 0) //if we set the vitality directly send base kind for pvSan
|
||||
// req.vulnerabilityKind(2048);
|
||||
// m_requestHelper->addRequest([req, this]()
|
||||
// {
|
||||
// return m_ftc->modifyStateRequest(req, this);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
|
||||
void ParticipantTargetConfigurationDialog::fillStatusComboBox()
|
||||
{
|
||||
std::list<ProjectDataManagement::VulnerabilityState_def::type> cont;
|
||||
cont = {
|
||||
ProjectDataManagement::VulnerabilityState_def::NoChange, // ToDo
|
||||
ProjectDataManagement::VulnerabilityState_def::CombatReady,
|
||||
ProjectDataManagement::VulnerabilityState_def::CatastrophicKill
|
||||
};
|
||||
|
||||
m_ui->cb_status->clear();
|
||||
for (auto item : qAsConst(cont))
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState st = item;
|
||||
QString str = ProjectDataManagement::toString(st, ProjectDataManagement::VulnerabilityClass_def::VehicleDamages);
|
||||
m_ui->cb_status->addItem(str, static_cast<int>(item));
|
||||
}
|
||||
// m_ui->cb_status->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::fillPrewarningEffectComboBox()
|
||||
{
|
||||
std::list<ProjectDataManagement::VulnerabilityState_def::type> cont;
|
||||
cont = {
|
||||
ProjectDataManagement::VulnerabilityState_def::NoChange, // ToDo
|
||||
ProjectDataManagement::VulnerabilityState_def::MobilityKill,
|
||||
ProjectDataManagement::VulnerabilityState_def::NearMiss,
|
||||
ProjectDataManagement::VulnerabilityState_def::CatastrophicKill
|
||||
};
|
||||
|
||||
m_ui->cb_prewarningEffect->clear();
|
||||
for (auto item : qAsConst(cont))
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState st = item;
|
||||
QString str = ProjectDataManagement::toString(st, ProjectDataManagement::VulnerabilityClass_def::VehicleDamages);
|
||||
m_ui->cb_prewarningEffect->addItem(str, static_cast<int>(item));
|
||||
}
|
||||
m_ui->cb_prewarningEffect->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::fillTakeDownEffectComboBox()
|
||||
{
|
||||
std::list<ProjectDataManagement::VulnerabilityState_def::type> cont;
|
||||
cont = {
|
||||
ProjectDataManagement::VulnerabilityState_def::MobilityKill, // ToDo
|
||||
ProjectDataManagement::VulnerabilityState_def::CatastrophicKill
|
||||
};
|
||||
|
||||
m_ui->cb_takeDownEffect->clear();
|
||||
for (auto item : qAsConst(cont))
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState st = item;
|
||||
QString str = ProjectDataManagement::toString(st, ProjectDataManagement::VulnerabilityClass_def::VehicleDamages);
|
||||
m_ui->cb_takeDownEffect->addItem(str, static_cast<int>(item));
|
||||
}
|
||||
m_ui->cb_takeDownEffect->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::setupConnections()
|
||||
{
|
||||
connect(m_ui->cb_status, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantTargetConfigurationDialog::onStatusChanged);
|
||||
|
||||
|
||||
connect(m_ui->cb_silhouette, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantTargetConfigurationDialog::onGuiChanged);
|
||||
|
||||
connect(m_ui->sb_prewarningInterval, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, &ParticipantTargetConfigurationDialog::onGuiChanged);
|
||||
connect(m_ui->cb_prewarningEffect, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantTargetConfigurationDialog::onGuiChanged);
|
||||
|
||||
connect(m_ui->sb_takeDownInterval, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, &ParticipantTargetConfigurationDialog::onGuiChanged);
|
||||
connect(m_ui->cb_takeDownEffect, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantTargetConfigurationDialog::onGuiChanged);
|
||||
|
||||
// LtsDataView:
|
||||
connect(m_ui->ltsDataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &ParticipantTargetConfigurationDialog::onSelectionChanged);
|
||||
|
||||
// add, edit, remove, showOnMap
|
||||
connect(m_ui->pb_add, &QPushButton::clicked, this, &ParticipantTargetConfigurationDialog::onAddBtnClicked);
|
||||
connect(m_ui->pb_edit, &QPushButton::clicked, this, &ParticipantTargetConfigurationDialog::onEditBtnClicked);
|
||||
connect(m_ui->pb_remove, &QPushButton::clicked, this, &ParticipantTargetConfigurationDialog::onRemoveBtnClicked);
|
||||
connect(m_ui->cb_showOnMap, &QCheckBox::stateChanged, this, &ParticipantTargetConfigurationDialog::onShowOnMapChanged);
|
||||
}
|
||||
|
||||
bool updateValue(int& oldValueRef, int newValue)
|
||||
{
|
||||
bool hasChanged = oldValueRef != newValue;
|
||||
oldValueRef = newValue;
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
bool updateValue(ProjectDataManagement::VulnerabilityState& oldValueRef, ProjectDataManagement::VulnerabilityState_def::type newValue)
|
||||
{
|
||||
bool hasChanged = oldValueRef != newValue;
|
||||
oldValueRef = newValue;
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onGuiChanged()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
// try to recognize, if something really changed:
|
||||
|
||||
bool hasChanged = false;
|
||||
|
||||
// // State:
|
||||
// hasChanged |= updateValue(m_targetInformation.status(), static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cb_status->currentData().toInt()) );
|
||||
// ToDo: Check Silhouette
|
||||
hasChanged |= updateValue(m_targetInformation.silhouette(), m_ui->cb_silhouette->currentData().toInt());
|
||||
|
||||
// Mode:
|
||||
hasChanged |= updateValue(m_targetInformation.prewarningEffect(), static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cb_prewarningEffect->currentData().toInt()) );
|
||||
hasChanged |= updateValue(m_targetInformation.prewarningInterval(), m_ui->sb_prewarningInterval->value());
|
||||
|
||||
hasChanged |= updateValue(m_targetInformation.takedownEffect(), static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cb_takeDownEffect->currentData().toInt()) );
|
||||
hasChanged |= updateValue(m_targetInformation.takedownInterval(), m_ui->sb_takeDownInterval->value());
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " hasChanged=" << hasChanged;
|
||||
|
||||
// Areas
|
||||
const std::vector<ParticipantManagement::ShootbackArea> &modelAreasStdVec = m_areaModel.getDataStdVector();
|
||||
if (modelAreasStdVec != m_targetInformation.shootbackAreas())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " hasChanged=" << hasChanged;
|
||||
hasChanged = true;
|
||||
m_targetInformation.shootbackAreas(modelAreasStdVec);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " slotChangesMade sChanged=" << hasChanged;
|
||||
this->slotChangesMade();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onDataChanged()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START, m_targetInformation=" << m_targetInformation;
|
||||
|
||||
int idx;
|
||||
|
||||
// // State:
|
||||
// idx = m_ui->cb_status->findData(QVariant(m_targetInformation.status().underlying()));
|
||||
// m_ui->cb_status->setCurrentIndex(idx);
|
||||
|
||||
idx = m_ui->cb_silhouette->findData(QVariant(m_targetInformation.silhouette()));
|
||||
m_ui->cb_silhouette->setCurrentIndex(idx);
|
||||
|
||||
// Mode:
|
||||
m_ui->sb_prewarningInterval->setValue(m_targetInformation.prewarningInterval());
|
||||
idx = m_ui->cb_prewarningEffect->findData(QVariant(m_targetInformation.prewarningEffect().underlying()));
|
||||
m_ui->cb_prewarningEffect->setCurrentIndex(idx);
|
||||
|
||||
m_ui->sb_takeDownInterval->setValue(m_targetInformation.takedownInterval());
|
||||
idx = m_ui->cb_takeDownEffect->findData(QVariant(m_targetInformation.takedownEffect().underlying()));
|
||||
m_ui->cb_takeDownEffect->setCurrentIndex(idx);
|
||||
|
||||
// areas:
|
||||
const std::vector<ShootbackArea>& areas = m_targetInformation.shootbackAreas();
|
||||
QVector<ShootbackArea> qVec = QVector<ShootbackArea>(areas.begin(), areas.end());
|
||||
m_areaModel.setData(qVec);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onAddBtnClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
m_rubberbandEditMode = false;
|
||||
m_sitMapGuiIfc->getPolygon(this,
|
||||
SLOT(onPolygonData(QPolygonF)),
|
||||
nullptr,
|
||||
s_minPoints,
|
||||
s_maxPoints);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
QPolygonF areaToPolygon(const ShootbackArea &area)
|
||||
{
|
||||
QPolygonF coordinates;
|
||||
QPointF point;
|
||||
|
||||
point = convert(area.coord1());
|
||||
if (!point.isNull())
|
||||
coordinates.append(point);
|
||||
|
||||
point = convert(area.coord2());
|
||||
if (!point.isNull())
|
||||
coordinates.append(point);
|
||||
|
||||
point = convert(area.coord3());
|
||||
if (!point.isNull())
|
||||
coordinates.append(point);
|
||||
|
||||
point = convert(area.coord4());
|
||||
if (!point.isNull())
|
||||
coordinates.append(point);
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onEditBtnClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
const QModelIndex curIdx = m_ui->ltsDataView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
INFO_LOG(m_logger) << " edit...";
|
||||
|
||||
const ShootbackArea &area = m_areaModel.getRowData(curIdx.row());
|
||||
|
||||
QPolygonF coordinates = areaToPolygon(area);
|
||||
if (coordinates.size() < 3)
|
||||
return;
|
||||
|
||||
m_rubberbandEditMode = true;
|
||||
m_sitMapGuiIfc->getPolygon(this,
|
||||
SLOT(onPolygonData(QPolygonF)),
|
||||
nullptr,
|
||||
s_minPoints,
|
||||
s_maxPoints,
|
||||
-1,
|
||||
-1,
|
||||
coordinates);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onRemoveBtnClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
const QModelIndex curIdx = m_ui->ltsDataView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
INFO_LOG(m_logger) << " remove...";
|
||||
|
||||
m_areaModel.removeRow(curIdx.row());
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onShowOnMapChanged(int)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
const bool bShow = m_ui->cb_showOnMap->isChecked();
|
||||
|
||||
if (bShow)
|
||||
{
|
||||
QVector<QPolygonF> polyVec;
|
||||
const int rowCount = m_areaModel.rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
const ShootbackArea ¤tArea = m_areaModel.getRowData(row);
|
||||
INFO_LOG(m_logger) << " row=" << row << " ; currentArea " << currentArea;
|
||||
const QPolygonF &poly = areaToPolygon(currentArea);
|
||||
polyVec.append(poly);
|
||||
} // for
|
||||
if (!polyVec.isEmpty())
|
||||
m_sitMapGuiIfc->displayPreviewObjects(this, polyVec, true);
|
||||
} else {
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onSelectionChanged()
|
||||
{
|
||||
m_ui->cb_showOnMap->setChecked(false);
|
||||
|
||||
QModelIndexList selectedRows = m_ui->ltsDataView->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_ui->pb_add->setEnabled(true);
|
||||
m_ui->pb_edit->setEnabled(cntSelectedRows == 1);
|
||||
m_ui->pb_remove->setEnabled(cntSelectedRows == 1);
|
||||
|
||||
// display current area on map:
|
||||
const QModelIndex curIdx = m_ui->ltsDataView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
int row = curIdx.row();
|
||||
// qCritical() << " row "<< row;
|
||||
ShootbackArea currentArea = m_areaModel.getRowData(row);
|
||||
INFO_LOG(m_logger) << " currentArea "<< currentArea;
|
||||
m_previewPolygon = areaToPolygon(currentArea);
|
||||
|
||||
// qCritical() << " m_previewPolygon "<< m_previewPolygon;
|
||||
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::onPolygonData(const QPolygonF &poly)
|
||||
{
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
if (poly.size() < 3)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " polygon insufficiant, size=" << poly.size();
|
||||
return;
|
||||
}
|
||||
|
||||
ShootbackArea newArea;
|
||||
// QPointF coord;
|
||||
// coord = poly.at(0);
|
||||
newArea.coord1( convert(poly.at(0)) );
|
||||
newArea.coord2( convert(poly.at(1)) );
|
||||
if (poly.size() > 2)
|
||||
newArea.coord3( convert(poly.at(2)) );
|
||||
if (poly.size() > 3)
|
||||
newArea.coord4( convert(poly.at(3)) );
|
||||
|
||||
if (m_rubberbandEditMode)
|
||||
{
|
||||
const QModelIndex curIdx = m_ui->ltsDataView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
ShootbackArea temp = m_areaModel.getRowData(curIdx.row());
|
||||
newArea.identifier(temp.identifier());
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << "updating newArea = " << newArea;
|
||||
m_areaModel.setRowData(curIdx.row(), newArea);
|
||||
} else {
|
||||
// ADD to overview:
|
||||
int size = m_areaModel.rowCount();
|
||||
newArea.identifier(QString(QStringLiteral("Area_%1")).arg(size).toStdString());
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " adding tempArea = " << newArea;
|
||||
m_areaModel.insertRow(newArea);
|
||||
|
||||
QModelIndex mi = m_areaModel.index(size, 0);
|
||||
//qCritical() << LOGFUNCTION << " mi = " << mi;
|
||||
m_ui->ltsDataView->selectRow(mi);
|
||||
m_ui->ltsDataView->scrollTo(mi);
|
||||
m_ui->ltsDataView->setCurrentIndex(mi);
|
||||
}
|
||||
|
||||
onSelectionChanged(); // which in turn updates previewObject
|
||||
onGuiChanged();
|
||||
}
|
||||
|
||||
void ParticipantTargetConfigurationDialog::showPreviewObject()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (!m_sitMapGuiIfc || m_previewPolygon.isEmpty())
|
||||
return;
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Class EditNameDelegate
|
||||
//-----------------------------------------------
|
||||
EditNameDelegate::EditNameDelegate(QWidget *parent)
|
||||
: QItemDelegate(parent)
|
||||
, m_logger(getLogger("EditNameDelegate"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
QWidget *EditNameDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
FATAL_LOG(m_logger) << LOGFUNCTION
|
||||
<< " rox/column: " << index.row() << "/" << index.column() ;
|
||||
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(index)
|
||||
QLineEdit *le = new QLineEdit(parent);
|
||||
|
||||
le->setMaxLength(10);
|
||||
return le;
|
||||
}
|
||||
|
||||
void EditNameDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
FATAL_LOG(m_logger) << LOGFUNCTION << " XXXXXXXXXXXXX";
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>(editor);
|
||||
if (!le)
|
||||
return;
|
||||
|
||||
QVariant v = index.data(Qt::EditRole);
|
||||
le->setText(v.toString());
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION
|
||||
<< " rox/column: " << index.row() << "/" << index.column()
|
||||
<< " Input: " << v.toString();
|
||||
}
|
||||
|
||||
void EditNameDelegate::setModelData(QWidget *editor,
|
||||
QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>(editor);
|
||||
if (!le)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION
|
||||
<< " rox/column: " << index.row() << "/" << index.column()
|
||||
<< " setData... Input: " << le->text();
|
||||
|
||||
model->setData(index, le->text(), Qt::EditRole);
|
||||
|
||||
} // end of setModelData()
|
||||
|
||||
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - ParticipantTargetConfigurationDialog (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Norbert Thoden, SLSE, 2022-05-10
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
//ParticipantManagement
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include "participant_shootback_area_model.h"
|
||||
|
||||
#include <QItemDelegate>
|
||||
|
||||
namespace Ui {
|
||||
class ParticipantTargetConfigurationDialog;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// ParticipantTargetConfigurationDialog
|
||||
// --------------------------------------------------------
|
||||
class ParticipantTargetConfigurationDialog final : public LtsWidgets::LtsDialog
|
||||
, protected ParticipantManagement::Interface::Ftc::InitParticipantReplyHandler
|
||||
, protected ParticipantManagement::Interface::Ftc::ModifyStateReplyHandler
|
||||
, protected ParticipantManagement::Interface::Ftc::ModifyTargetInformationReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantTargetConfigurationDialog(QWidget *parent = nullptr);
|
||||
~ParticipantTargetConfigurationDialog();
|
||||
|
||||
bool init(int participantId,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onDynamicParticipantDataChanged(const ParticipantManagement::DynamicParticipantData &dynData, DataModification modType);
|
||||
void onTargetInformationChanged(const TargetInformation &data, DataModification modType);
|
||||
void onStatusChanged();
|
||||
void onGuiChanged(); // -> update m_targetInformation
|
||||
void onDataChanged(); // -> update GUI
|
||||
|
||||
void onAddBtnClicked();
|
||||
void onEditBtnClicked();
|
||||
void onRemoveBtnClicked();
|
||||
void onShowOnMapChanged(int);
|
||||
|
||||
// sitMap-related slots:
|
||||
void onPolygonData(const QPolygonF &poly);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
void onInitParticipantReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onModifyStateReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onModifyTargetInformationReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
|
||||
void fillStatusComboBox();
|
||||
void fillPrewarningEffectComboBox();
|
||||
void fillTakeDownEffectComboBox();
|
||||
|
||||
void setupConnections();
|
||||
void onSelectionChanged();
|
||||
void showPreviewObject();
|
||||
|
||||
int m_participantId{-1};
|
||||
TargetInformation m_targetInformation;
|
||||
AreaModel m_areaModel;
|
||||
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper{nullptr};
|
||||
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
bool m_rubberbandEditMode{false};
|
||||
QPolygonF m_previewPolygon;
|
||||
|
||||
Ui::ParticipantTargetConfigurationDialog *m_ui{nullptr};
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
class EditNameDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditNameDelegate(QWidget *parent = nullptr);
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override ;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const override;
|
||||
private:
|
||||
LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
Executable
+200
@@ -0,0 +1,200 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantTargetConfigurationDialog</class>
|
||||
<widget class="QWidget" name="ParticipantTargetConfigurationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>965</width>
|
||||
<height>380</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Player History </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QLabel" name="lb_shotbackAreas">
|
||||
<property name="text">
|
||||
<string>Shootback Area</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lb_status">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cb_status"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lb_silhouette">
|
||||
<property name="text">
|
||||
<string>Silhouette:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cb_silhouette"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lb_status_3">
|
||||
<property name="text">
|
||||
<string>Silhouette-Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lb_prewarningInterval">
|
||||
<property name="text">
|
||||
<string>Prewarning Interval [s]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="sb_prewarningInterval"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lb_prewarningEffect">
|
||||
<property name="text">
|
||||
<string>Prewarning Effect:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cb_prewarningEffect"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lb_takeDownInterval">
|
||||
<property name="text">
|
||||
<string>Take Down Interval [s]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="sb_takeDownInterval"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lb_takeDownEffect">
|
||||
<property name="text">
|
||||
<string>Take Down Effect:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cb_takeDownEffect"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2" rowspan="2" colspan="4">
|
||||
<widget class="LtsDataView::LtsDataView" name="ltsDataView" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" rowspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>151</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="pb_add">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QPushButton" name="pb_edit">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="pb_remove">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>273</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="cb_showOnMap">
|
||||
<property name="text">
|
||||
<string>Show on Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Dialog for mounted participants table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Dassow Philipp, SLEA, 2017-08-30
|
||||
*/
|
||||
|
||||
#include "participants_mounted_table_dialog.h"
|
||||
#include "ui_participants_mounted_table_dialog.h"
|
||||
|
||||
namespace ParticipantManagement {
|
||||
|
||||
ParticipantsMountedTableDialog::ParticipantsMountedTableDialog(int32_t carrierId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_carrierId(carrierId)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmGuiIfc(nullptr)
|
||||
, m_mountedTableModel(nullptr)
|
||||
, m_ui(new Ui::ParticipantsMountedTableDialog)
|
||||
, m_logger(getLogger("ParticipantsMountedTableDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
ParticipantsMountedTableDialog::~ParticipantsMountedTableDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool ParticipantsMountedTableDialog::init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmGuiIfc = ppmGuiIfc;
|
||||
|
||||
m_mountedTableModel = new ParticipantsMountedTableModel(this);
|
||||
if (!m_mountedTableModel->initModel(m_carrierId, m_dtc))
|
||||
return false;
|
||||
m_ui->tvMountedParticipants->setModel(m_mountedTableModel);
|
||||
|
||||
connect(m_ui->tvMountedParticipants, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this,
|
||||
&ParticipantsMountedTableDialog::onShowTlnInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantsMountedTableDialog::onShowTlnInfo()
|
||||
{
|
||||
if (!m_ppmGuiIfc)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "onDoubleClick --> showTlnInfo";
|
||||
const QModelIndex idx = m_ui->tvMountedParticipants->currentIndex();
|
||||
const int id = m_mountedTableModel->getRowData(idx.row()).id();
|
||||
m_ppmGuiIfc->showParticipantInfoWindow(id);
|
||||
}
|
||||
|
||||
void ParticipantsMountedTableDialog::retranslate()
|
||||
{
|
||||
const dds::core::optional<int32_t> eqId = m_dtc->participant(m_carrierId).equipmentNumber();
|
||||
const QString id = (eqId.is_set() ? QString::number(eqId.get()) : QString());
|
||||
|
||||
translate(m_ui, id, false, tr("participants on vehicle")); // will be 'Show participants on vehicle: 4711'
|
||||
}
|
||||
}
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Dialog for mounted participants table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Dassow Philipp, SLEA, 2017-08-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "participants_mounted_table_model.h"
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantsMountedTableDialog;
|
||||
}
|
||||
namespace ParticipantManagement {
|
||||
|
||||
class ParticipantsMountedTableDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ParticipantsMountedTableDialog(int32_t carrierId,
|
||||
QWidget *parent = nullptr);
|
||||
~ParticipantsMountedTableDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc);
|
||||
|
||||
private slots:
|
||||
void onShowTlnInfo();
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
int32_t m_carrierId;
|
||||
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ForeignParticipantInfoGuiInterface> m_ppmGuiIfc;
|
||||
ParticipantsMountedTableModel *m_mountedTableModel;
|
||||
|
||||
Ui::ParticipantsMountedTableDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantsMountedTableDialog</class>
|
||||
<widget class="QWidget" name="ParticipantsMountedTableDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>226</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="LtsDataView::LtsDataView" name="tvMountedParticipants"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for mounted participants table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Dassow Philipp, SLEA, 2017-08-29
|
||||
*/
|
||||
|
||||
#include "participants_mounted_table_model.h"
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
|
||||
namespace ParticipantManagement {
|
||||
ParticipantsMountedTableModel::ParticipantsMountedTableModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<Participant>({tr("Equipment Number"),
|
||||
tr("Party"),
|
||||
tr("Designator"),
|
||||
tr("Tact. Identifier")}, parent)
|
||||
, m_carrierId(0)
|
||||
, m_dtc(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool ParticipantsMountedTableModel::initModel(int32_t carrierId,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc)
|
||||
{
|
||||
m_carrierId = carrierId;
|
||||
m_dtc = dtc;
|
||||
if (!m_dtc || !m_carrierId)
|
||||
return false;
|
||||
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
this, &ParticipantsMountedTableModel::onPositionChanged,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
reInitModel();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantsMountedTableModel::reInitModel()
|
||||
{
|
||||
clear();
|
||||
|
||||
ParticipantPosition pos = m_dtc->participantPosition(m_carrierId);
|
||||
|
||||
if (pos.mountedParticipants().is_set())
|
||||
for (size_t idx = 0; idx < pos.mountedParticipants().get().size(); ++idx)
|
||||
insertRow(m_dtc->participant(pos.mountedParticipants().get().at(idx)));
|
||||
}
|
||||
|
||||
QVariant ParticipantsMountedTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const Participant &participant = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return participant.equipmentNumber().is_set()?participant.equipmentNumber().get():0;
|
||||
case 1:
|
||||
return ParticipantManagement::trPartyName(m_dtc->party(participant.partyId()).name());
|
||||
case 2:
|
||||
return QString::fromStdString(participant.designator());
|
||||
case 3:
|
||||
return QString::fromStdString(participant.tacticalIdentifier());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ParticipantsMountedTableModel::onPositionChanged(const ParticipantPosition &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eRemoved)
|
||||
if (data.participantId() == m_carrierId)
|
||||
reInitModel();
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for mounted participants table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Dassow Philipp, SLEA, 2017-08-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
namespace ParticipantManagement {
|
||||
|
||||
class ParticipantsMountedTableModel : public LtsWidgets::LtsAbstractTableModel<Participant>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ParticipantsMountedTableModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(int32_t carrierId, const std::shared_ptr<Interface::Dtc> &dtc);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPositionChanged(const ParticipantPosition &data, DataModification modType);
|
||||
private:
|
||||
void reInitModel();
|
||||
|
||||
private:
|
||||
int32_t m_carrierId;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user