Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+113
-137
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_config_alarm_model.h"
|
||||
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
@@ -9,156 +9,132 @@
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
ConfigAlarmModel::ConfigAlarmModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>(
|
||||
ConfigAlarmModel::ConfigAlarmModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>(
|
||||
{tr("Id"), tr("Equip. No."), tr("Designator"), tr("Tact. Identifier"), tr("Vulnerability State"),
|
||||
tr("Event Type"), tr("Message Window"), tr("Set Marker")},
|
||||
parent),
|
||||
m_dtc(nullptr), m_ppmDtc(nullptr), m_alarmHistoryModel(nullptr), m_global(false)
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Equip. No."),
|
||||
tr("Designator"),
|
||||
tr("Tact. Identifier"),
|
||||
tr("Vulnerability State"),
|
||||
tr("Event Type"),
|
||||
tr("Message Window"),
|
||||
tr("Set Marker")
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_global(false)
|
||||
{}
|
||||
|
||||
|
||||
bool ConfigAlarmModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel,
|
||||
bool global)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
m_global = global;
|
||||
|
||||
|
||||
const QMap<qint32, AlarmManagement::AlarmConfig> alarmConfigs = m_dtc->alarmConfigs();
|
||||
INFO_LOG(m_logger) << "initModel - #AlarmConfig: " << alarmConfigs.size();
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::alarmConfigChanged,
|
||||
this, &ConfigAlarmModel::onAlarmConfigChanged);
|
||||
|
||||
m_dtc->enableAlarmConfig();
|
||||
auto cb = [this] (const AlarmManagement::AlarmConfig &d)
|
||||
{
|
||||
onAlarmConfigChanged(d, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->alarmConfigs(cb);
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant ConfigAlarmModel::data(const QModelIndex &index, int role) const
|
||||
bool ConfigAlarmModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
AlarmHistoryModel* alarmHistoryModel, bool global)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AlarmManagementModel::data";
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
m_global = global;
|
||||
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
const QMap<qint32, AlarmManagement::AlarmConfig> alarmConfigs = m_dtc->alarmConfigs();
|
||||
INFO_LOG(m_logger) << "initModel - #AlarmConfig: " << alarmConfigs.size();
|
||||
|
||||
const AlarmManagement::AlarmConfig &alarmConfig = m_vecData.at(index.row());
|
||||
if (alarmConfig.global() != m_global)
|
||||
return QVariant();
|
||||
connect(m_dtc.get(), &Interface::Dtc::alarmConfigChanged, this, &ConfigAlarmModel::onAlarmConfigChanged);
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return alarmConfig.id();
|
||||
case EquipmentNumber:
|
||||
{
|
||||
const int equipmentNumber = m_alarmHistoryModel->participantId2EquipNo(alarmConfig.participantId());
|
||||
if (equipmentNumber == 0)
|
||||
return tr("All");
|
||||
return equipmentNumber;
|
||||
}
|
||||
case Designator:
|
||||
return m_alarmHistoryModel->getDesignator(alarmConfig.participantId());
|
||||
case TactIdentifier:
|
||||
return m_alarmHistoryModel->getTactIdentifier(alarmConfig.participantId());
|
||||
case VulnerabilityState:
|
||||
{
|
||||
QString vulnerabilityState = tr("All Types");
|
||||
if (alarmConfig.vulnerabilityState()>=0){
|
||||
ParticipantManagement::TypeClass typeClass =
|
||||
m_ppmDtc->type(m_ppmDtc->participant(alarmConfig.participantId()).typeId()).typeClass();
|
||||
|
||||
const ProjectDataManagement::VulnerabilityClass vc = typeClass == ParticipantManagement::TypeClass::Human ?
|
||||
ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries :
|
||||
ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
ProjectDataManagement::VulnerabilityState vs = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarmConfig.vulnerabilityState());
|
||||
vulnerabilityState = ProjectDataManagement::toString(vs, vc);
|
||||
}
|
||||
return vulnerabilityState;
|
||||
}
|
||||
|
||||
case EventType:
|
||||
return ProjectDataManagement::toString(alarmConfig.eventTypeId());
|
||||
case MessageWindow:
|
||||
return alarmConfig.messageWindow() ? tr("Yes") : tr("No");
|
||||
case SetMarker:
|
||||
return alarmConfig.setMarker() ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
m_dtc->enableAlarmConfig();
|
||||
auto cb = [this](const AlarmManagement::AlarmConfig& d) { onAlarmConfigChanged(d, DataModification::eAdded); };
|
||||
m_dtc->alarmConfigs(cb);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ConfigAlarmModel::onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data,
|
||||
const DataModification modType)
|
||||
QVariant ConfigAlarmModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
const int id = data.id();
|
||||
if (data.global() != m_global)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "AlarmManagementModel::data";
|
||||
|
||||
int row = findRowForId(id);
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const int eventTypeId = data.eventTypeId().underlying();
|
||||
const bool messageWindow = data.messageWindow();
|
||||
const bool setMarker = data.setMarker();
|
||||
DEBUG_LOG(m_logger) << "onAlarmConfigChanged: " << eventTypeId << " messageWindow=" << messageWindow
|
||||
<< "setMarker"<<setMarker;
|
||||
const AlarmManagement::AlarmConfig& alarmConfig = m_vecData.at(index.row());
|
||||
if (alarmConfig.global() != m_global)
|
||||
return QVariant();
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "AlarmConfig was removed: " << id;
|
||||
AlarmManagement::AlarmConfig data1 = data;
|
||||
data1.messageWindow(false);
|
||||
data1.setMarker(false);
|
||||
setRowData(row, data1);
|
||||
removeRow(row);
|
||||
return;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eModified: ";
|
||||
if (row < 0)
|
||||
switch (index.column())
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
if (m_alarmHistoryModel->participantId2EquipNo(data.participantId()) > 0)
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DataModification::eAdded";
|
||||
insertRow(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Id:
|
||||
return alarmConfig.id();
|
||||
case EquipmentNumber: {
|
||||
const int equipmentNumber = m_alarmHistoryModel->participantId2EquipNo(alarmConfig.participantId());
|
||||
if (equipmentNumber == 0)
|
||||
return tr("All");
|
||||
return equipmentNumber;
|
||||
}
|
||||
case Designator:
|
||||
return m_alarmHistoryModel->getDesignator(alarmConfig.participantId());
|
||||
case TactIdentifier:
|
||||
return m_alarmHistoryModel->getTactIdentifier(alarmConfig.participantId());
|
||||
case VulnerabilityState: {
|
||||
QString vulnerabilityState = tr("All Types");
|
||||
if (alarmConfig.vulnerabilityState() >= 0)
|
||||
{
|
||||
ParticipantManagement::TypeClass typeClass =
|
||||
m_ppmDtc->type(m_ppmDtc->participant(alarmConfig.participantId()).typeId()).typeClass();
|
||||
|
||||
const ProjectDataManagement::VulnerabilityClass vc =
|
||||
typeClass == ParticipantManagement::TypeClass::Human
|
||||
? ProjectDataManagement::VulnerabilityClass_def::SoldierInjuries
|
||||
: ProjectDataManagement::VulnerabilityClass_def::VehicleDamages;
|
||||
ProjectDataManagement::VulnerabilityState vs =
|
||||
static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarmConfig.vulnerabilityState());
|
||||
vulnerabilityState = ProjectDataManagement::toString(vs, vc);
|
||||
}
|
||||
return vulnerabilityState;
|
||||
}
|
||||
|
||||
case EventType:
|
||||
return ProjectDataManagement::toString(alarmConfig.eventTypeId());
|
||||
case MessageWindow:
|
||||
return alarmConfig.messageWindow() ? tr("Yes") : tr("No");
|
||||
case SetMarker:
|
||||
return alarmConfig.setMarker() ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
}
|
||||
void ConfigAlarmModel::onAlarmConfigChanged(const AlarmManagement::AlarmConfig& data, const DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
if (data.global() != m_global)
|
||||
return;
|
||||
|
||||
int row = findRowForId(id);
|
||||
|
||||
const int eventTypeId = data.eventTypeId().underlying();
|
||||
const bool messageWindow = data.messageWindow();
|
||||
const bool setMarker = data.setMarker();
|
||||
DEBUG_LOG(m_logger) << "onAlarmConfigChanged: " << eventTypeId << " messageWindow=" << messageWindow << "setMarker"
|
||||
<< setMarker;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved: {
|
||||
|
||||
DEBUG_LOG(m_logger) << "AlarmConfig was removed: " << id;
|
||||
AlarmManagement::AlarmConfig data1 = data;
|
||||
data1.messageWindow(false);
|
||||
data1.setMarker(false);
|
||||
setRowData(row, data1);
|
||||
removeRow(row);
|
||||
return;
|
||||
}
|
||||
case DataModification::eModified: {
|
||||
DEBUG_LOG(m_logger) << "DataModification::eModified: ";
|
||||
if (row < 0)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
if (m_alarmHistoryModel->participantId2EquipNo(data.participantId()) > 0)
|
||||
setRowData(row, data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eAdded: {
|
||||
DEBUG_LOG(m_logger) << "DataModification::eAdded";
|
||||
insertRow(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+30
-35
@@ -1,54 +1,49 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "alm_history_alarm_model.h"
|
||||
#include "almcommon_export.h"
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include "alm_history_alarm_model.h"
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class ALMCOMMON_EXPORT ConfigAlarmModel final : public LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlarmConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
EquipmentNumber,
|
||||
Designator,
|
||||
TactIdentifier,
|
||||
VulnerabilityState,
|
||||
EventType,
|
||||
MessageWindow,
|
||||
SetMarker
|
||||
};
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns {
|
||||
Id,
|
||||
EquipmentNumber,
|
||||
Designator,
|
||||
TactIdentifier,
|
||||
VulnerabilityState,
|
||||
EventType,
|
||||
MessageWindow,
|
||||
SetMarker
|
||||
};
|
||||
|
||||
explicit ConfigAlarmModel(QObject *parent = nullptr);
|
||||
explicit ConfigAlarmModel(QObject* parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel,
|
||||
bool global);
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
AlarmHistoryModel* alarmHistoryModel, bool global);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private slots:
|
||||
void onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data,
|
||||
const DataModification modType);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
AlarmHistoryModel *m_alarmHistoryModel;
|
||||
bool m_global;
|
||||
private slots:
|
||||
void onAlarmConfigChanged(const AlarmManagement::AlarmConfig& data, const DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
AlarmHistoryModel* m_alarmHistoryModel;
|
||||
bool m_global;
|
||||
};
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+226
-262
@@ -1,318 +1,282 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_history_alarm_model.h"
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AlarmManagement/alm_translation.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
AlarmHistoryModel::AlarmHistoryModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<NotificationEx>(
|
||||
AlarmHistoryModel::AlarmHistoryModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<NotificationEx>(
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Date"),
|
||||
tr("Incident"),
|
||||
tr("Equip. No."),
|
||||
tr("Hierarchie"),
|
||||
tr("Participant Id"),
|
||||
tr("Position"),
|
||||
tr("Aes Id"),
|
||||
tr("Aes Name"),
|
||||
},
|
||||
parent),
|
||||
m_dtc(nullptr), m_ppmDtc(nullptr)
|
||||
{
|
||||
tr("Id"),
|
||||
tr("Date"),
|
||||
tr("Incident"),
|
||||
tr("Equip. No."),
|
||||
tr("Hierarchie"),
|
||||
tr("Participant Id"),
|
||||
tr("Position"),
|
||||
tr("Aes Id"),
|
||||
tr("Aes Name"),
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool AlarmHistoryModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_aesDtc = aesDtc;
|
||||
|
||||
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::notificationChanged,
|
||||
this, &AlarmHistoryModel::onNotificationChanged);
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &AlarmHistoryModel::onParticipantChanged);
|
||||
|
||||
m_ppmDtc->enableParticipant();
|
||||
m_dtc->enableNotification();
|
||||
|
||||
|
||||
const auto cbParticipants = [this](const ParticipantManagement::Participant & participant)
|
||||
{
|
||||
onParticipantChanged(participant, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->participants(cbParticipants);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::nContaminationChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::bCContaminationChanged,
|
||||
this, &AlarmHistoryModel::onBCContaminationChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::functionalAreaChanged,
|
||||
this, &AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::boobyTrapChanged,
|
||||
this, &AlarmHistoryModel::onBoobyTrapChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::offRouteMineChanged,
|
||||
this, &AlarmHistoryModel::onOffRouteMineChanged);
|
||||
|
||||
|
||||
auto cbAesItem = [this](const AreaEffectSimulation::AesItem & item)
|
||||
{
|
||||
onAesItemChanged(item, DataModification::eAdded);
|
||||
};
|
||||
m_aesDtc->borderlines(cbAesItem);
|
||||
m_aesDtc->dangerAreas(cbAesItem);
|
||||
m_aesDtc->nContaminations(cbAesItem);
|
||||
m_aesDtc->mineAreas(cbAesItem);
|
||||
m_aesDtc->functionalAreas(cbAesItem);
|
||||
m_aesDtc->boobyTraps(cbAesItem);
|
||||
m_aesDtc->offRouteMines(cbAesItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant AlarmHistoryModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
if ((role != Qt::DisplayRole) && (role != Qt::UserRole) && (role != Qt::BackgroundRole))
|
||||
return QVariant();
|
||||
|
||||
const NotificationEx ¬ificationEx = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (notificationEx.eventType() == ProjectDataManagement::EventType_def::EmergencyCall)
|
||||
return QColor(Qt::red);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return notificationEx.id();
|
||||
case Date:
|
||||
return QDateTime::fromMSecsSinceEpoch(notificationEx.time());
|
||||
case EquipmentNumber:
|
||||
if (notificationEx.equipmentNumber)
|
||||
return notificationEx.equipmentNumber;
|
||||
break;
|
||||
case Incident:
|
||||
return ProjectDataManagement::toString(notificationEx.eventTypeId);
|
||||
case Hierarchie:
|
||||
return m_ppmDtc->hierarchyFromParticipant(notificationEx.participantId);
|
||||
case ParticipantId:
|
||||
return notificationEx.participantId;
|
||||
case Position:
|
||||
if (role == Qt::DisplayRole)
|
||||
return LtsCoordTrans::mgrsFromGeographic(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
else if (role == Qt::UserRole)
|
||||
return QPointF(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
break;
|
||||
case AesId:
|
||||
return notificationEx.aesId;
|
||||
case AesName:
|
||||
|
||||
return m_aesNameMap.value(notificationEx.aesId, tr("-"));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
bool AlarmHistoryModel::isFiltered(const NotificationEx &data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.operatorId() == 0)
|
||||
return false;
|
||||
return data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onNotificationChanged(const AlarmManagement::Notification &data,
|
||||
const DataModification modType)
|
||||
bool AlarmHistoryModel::initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
m_dtc = dtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_aesDtc = aesDtc;
|
||||
|
||||
NotificationEx notification(data);
|
||||
const QByteArray properties = QByteArray::fromRawData(data.properties().c_str(), data.properties().size());
|
||||
const QJsonDocument propertieJsonDoc = QJsonDocument::fromJson(properties);
|
||||
const QJsonObject propertieJsonObj = propertieJsonDoc.object();
|
||||
connect(m_dtc.get(), &Interface::Dtc::notificationChanged, this, &AlarmHistoryModel::onNotificationChanged);
|
||||
|
||||
notification.equipmentNumber = data.equipmentNumber();
|
||||
if (data.participantId().is_set())
|
||||
notification.participantId = data.participantId().get();
|
||||
notification.eventTypeId = data.eventType();
|
||||
if (data.aesId().is_set())
|
||||
notification.aesId = data.aesId().get();
|
||||
const int global = propertieJsonObj[QStringLiteral("Global")].toInt();
|
||||
const int friendlyFire = propertieJsonObj[QStringLiteral("FriendlyFire")].toInt();
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged, this,
|
||||
&AlarmHistoryModel::onParticipantChanged);
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO
|
||||
<< " notification:" << data
|
||||
<< ", Global: " << global
|
||||
<< ", FriendlyFire: " << friendlyFire;
|
||||
m_ppmDtc->enableParticipant();
|
||||
m_dtc->enableNotification();
|
||||
|
||||
onDataChanged(notification, modType);
|
||||
}
|
||||
const auto cbParticipants = [this](const ParticipantManagement::Participant& participant) {
|
||||
onParticipantChanged(participant, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->participants(cbParticipants);
|
||||
|
||||
void AlarmHistoryModel::onParticipantChanged(const ParticipantManagement::Participant &participant,
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::nContaminationChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::bCContaminationChanged, this,
|
||||
&AlarmHistoryModel::onBCContaminationChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::functionalAreaChanged, this,
|
||||
&AlarmHistoryModel::onAesItemChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::boobyTrapChanged, this,
|
||||
&AlarmHistoryModel::onBoobyTrapChanged);
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::offRouteMineChanged, this,
|
||||
&AlarmHistoryModel::onOffRouteMineChanged);
|
||||
|
||||
auto cbAesItem = [this](const AreaEffectSimulation::AesItem& item) {
|
||||
onAesItemChanged(item, DataModification::eAdded);
|
||||
};
|
||||
m_aesDtc->borderlines(cbAesItem);
|
||||
m_aesDtc->dangerAreas(cbAesItem);
|
||||
m_aesDtc->nContaminations(cbAesItem);
|
||||
m_aesDtc->mineAreas(cbAesItem);
|
||||
m_aesDtc->functionalAreas(cbAesItem);
|
||||
m_aesDtc->boobyTraps(cbAesItem);
|
||||
m_aesDtc->offRouteMines(cbAesItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AlarmHistoryModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
if ((role != Qt::DisplayRole) && (role != Qt::UserRole) && (role != Qt::BackgroundRole))
|
||||
return QVariant();
|
||||
|
||||
const NotificationEx& notificationEx = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (notificationEx.eventType() == ProjectDataManagement::EventType_def::EmergencyCall)
|
||||
return QColor(Qt::red);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return notificationEx.id();
|
||||
case Date:
|
||||
return QDateTime::fromMSecsSinceEpoch(notificationEx.time());
|
||||
case EquipmentNumber:
|
||||
if (notificationEx.equipmentNumber)
|
||||
return notificationEx.equipmentNumber;
|
||||
break;
|
||||
case Incident:
|
||||
return ProjectDataManagement::toString(notificationEx.eventTypeId);
|
||||
case Hierarchie:
|
||||
return m_ppmDtc->hierarchyFromParticipant(notificationEx.participantId);
|
||||
case ParticipantId:
|
||||
return notificationEx.participantId;
|
||||
case Position:
|
||||
if (role == Qt::DisplayRole)
|
||||
return LtsCoordTrans::mgrsFromGeographic(notificationEx.position().lon(),
|
||||
notificationEx.position().lat());
|
||||
else if (role == Qt::UserRole)
|
||||
return QPointF(notificationEx.position().lon(), notificationEx.position().lat());
|
||||
break;
|
||||
case AesId:
|
||||
return notificationEx.aesId;
|
||||
case AesName:
|
||||
|
||||
return m_aesNameMap.value(notificationEx.aesId, tr("-"));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool AlarmHistoryModel::isFiltered(const NotificationEx& data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.operatorId() == 0)
|
||||
return false;
|
||||
return data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onNotificationChanged(const AlarmManagement::Notification& data, const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
NotificationEx notification(data);
|
||||
const QByteArray properties = QByteArray::fromRawData(data.properties().c_str(), data.properties().size());
|
||||
const QJsonDocument propertieJsonDoc = QJsonDocument::fromJson(properties);
|
||||
const QJsonObject propertieJsonObj = propertieJsonDoc.object();
|
||||
|
||||
notification.equipmentNumber = data.equipmentNumber();
|
||||
if (data.participantId().is_set())
|
||||
notification.participantId = data.participantId().get();
|
||||
notification.eventTypeId = data.eventType();
|
||||
if (data.aesId().is_set())
|
||||
notification.aesId = data.aesId().get();
|
||||
const int global = propertieJsonObj[QStringLiteral("Global")].toInt();
|
||||
const int friendlyFire = propertieJsonObj[QStringLiteral("FriendlyFire")].toInt();
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " notification:" << data << ", Global: " << global
|
||||
<< ", FriendlyFire: " << friendlyFire;
|
||||
|
||||
onDataChanged(notification, modType);
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onParticipantChanged(const ParticipantManagement::Participant& participant,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString designator = QString::fromStdString(participant.designator());
|
||||
m_idDesignatorMap.insert(participant.id(), designator);
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString designator = QString::fromStdString(participant.designator());
|
||||
m_idDesignatorMap.insert(participant.id(), designator);
|
||||
|
||||
const int equipNo = participant.equipmentNumber().is_set() ? participant.equipmentNumber().get() : 0;
|
||||
m_partId2EquipNoMap.insert(participant.id(), equipNo);
|
||||
const int equipNo = participant.equipmentNumber().is_set() ? participant.equipmentNumber().get() : 0;
|
||||
m_partId2EquipNoMap.insert(participant.id(), equipNo);
|
||||
|
||||
QString tacticalIdentifier = QString::fromStdString(participant.tacticalIdentifier());
|
||||
m_idTactIdentifierMap.insert(participant.id(), tacticalIdentifier);
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " id=" << participant.id()
|
||||
<< " designator=" << designator
|
||||
<< " tacticalIdentifier=" << tacticalIdentifier;
|
||||
}
|
||||
QString tacticalIdentifier = QString::fromStdString(participant.tacticalIdentifier());
|
||||
m_idTactIdentifierMap.insert(participant.id(), tacticalIdentifier);
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " id=" << participant.id() << " designator=" << designator
|
||||
<< " tacticalIdentifier=" << tacticalIdentifier;
|
||||
}
|
||||
|
||||
int AlarmHistoryModel::participantId2EquipNo(const int participantId) const
|
||||
{
|
||||
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
||||
INFO_LOG(m_logger) << "participantId2EquipNo participantId=" << participantId
|
||||
<< " EquipmentNumber=" << ret;
|
||||
return ret;
|
||||
}
|
||||
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
||||
INFO_LOG(m_logger) << "participantId2EquipNo participantId=" << participantId << " EquipmentNumber=" << ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString AlarmHistoryModel::getDesignator(const int participantId) const
|
||||
{
|
||||
QString designator = m_idDesignatorMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idDesignatorMap.value(participantId)=" << designator;
|
||||
QString designator = m_idDesignatorMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idDesignatorMap.value(participantId)=" << designator;
|
||||
|
||||
return designator;
|
||||
return designator;
|
||||
}
|
||||
|
||||
QString AlarmHistoryModel::getTactIdentifier(const int participantId) const
|
||||
{
|
||||
QString tactIdentifier = m_idTactIdentifierMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idTactIdentifierMap.value(participantId)=" << tactIdentifier;
|
||||
QString tactIdentifier = m_idTactIdentifierMap.value(participantId);
|
||||
DEBUG_LOG(m_logger) << "m_idTactIdentifierMap.value(participantId)=" << tactIdentifier;
|
||||
|
||||
return tactIdentifier;
|
||||
return tactIdentifier;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onBCContaminationChanged(const AreaEffectSimulation::BCContamination& data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "onBCContaminationChanged: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "onBCContaminationChanged: " << data << " Name=" << name << " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap& data, const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "BoobyTrap: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "BoobyTrap: " << data << " Name=" << name << " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine& data,
|
||||
const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "OffRouteMine: " << data
|
||||
<< " Name=" << name
|
||||
<< " id=" << id;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
int id = data.id();
|
||||
QString name = QString::fromStdString(data.name());
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "OffRouteMine: " << data << " Name=" << name << " id=" << id;
|
||||
}
|
||||
|
||||
void AlarmHistoryModel::onAesItemChanged(const AreaEffectSimulation::AesItem &item,
|
||||
const DataModification modType)
|
||||
void AlarmHistoryModel::onAesItemChanged(const AreaEffectSimulation::AesItem& item, const DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString name = QString::fromStdString(item.name());
|
||||
int id = item.id();
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "AreaEffectSimulation::AesItem onAesItemChanged: " << item
|
||||
<< " Name=" << name
|
||||
<< " id=" << item.id();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AlarmHistoryProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<AlarmHistoryModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
QString name = QString::fromStdString(item.name());
|
||||
int id = item.id();
|
||||
m_aesNameMap[id] = name;
|
||||
DEBUG_LOG(m_logger) << "AreaEffectSimulation::AesItem onAesItemChanged: " << item << " Name=" << name
|
||||
<< " id=" << item.id();
|
||||
}
|
||||
|
||||
bool AlarmHistoryProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
void AlarmHistoryProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
m_sourceModel = qobject_cast<AlarmHistoryModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool AlarmHistoryProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
|
||||
{
|
||||
if (!m_sourceModel || source_left.column() != source_right.column() || !source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto& dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AlarmHistoryModel::Date:
|
||||
return dataLeft.time() < dataRight.time();
|
||||
|
||||
case AlarmHistoryModel::Id:
|
||||
case AlarmHistoryModel::Incident:
|
||||
case AlarmHistoryModel::EquipmentNumber:
|
||||
case AlarmHistoryModel::Hierarchie:
|
||||
case AlarmHistoryModel::ParticipantId:
|
||||
case AlarmHistoryModel::Position:
|
||||
case AlarmHistoryModel::AesId:
|
||||
case AlarmHistoryModel::AesName:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AlarmHistoryModel::Date:
|
||||
return dataLeft.time() < dataRight.time();
|
||||
|
||||
case AlarmHistoryModel::Id:
|
||||
case AlarmHistoryModel::Incident:
|
||||
case AlarmHistoryModel::EquipmentNumber:
|
||||
case AlarmHistoryModel::Hierarchie:
|
||||
case AlarmHistoryModel::ParticipantId:
|
||||
case AlarmHistoryModel::Position:
|
||||
case AlarmHistoryModel::AesId:
|
||||
case AlarmHistoryModel::AesName:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+52
-75
@@ -1,107 +1,84 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "almcommon_export.h"
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct NotificationEx : public AlarmManagement::Notification
|
||||
{
|
||||
int equipmentNumber = 0;
|
||||
int participantId = 0;
|
||||
int aesId = 0;
|
||||
ProjectDataManagement::EventType eventTypeId = ProjectDataManagement::EventType::Unknown;
|
||||
int equipmentNumber = 0;
|
||||
int participantId = 0;
|
||||
int aesId = 0;
|
||||
ProjectDataManagement::EventType eventTypeId = ProjectDataManagement::EventType::Unknown;
|
||||
|
||||
NotificationEx() = default;
|
||||
explicit NotificationEx(const AlarmManagement::Notification &n)
|
||||
: AlarmManagement::Notification(n)
|
||||
{}
|
||||
NotificationEx() = default;
|
||||
|
||||
explicit NotificationEx(const AlarmManagement::Notification& n) : AlarmManagement::Notification(n) {}
|
||||
};
|
||||
|
||||
class ALMCOMMON_EXPORT AlarmHistoryModel final : public LtsWidgets::LtsAbstractTableModel<NotificationEx>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns { Id, Date, Incident, EquipmentNumber, Hierarchie, ParticipantId, Position, AesId, AesName };
|
||||
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Date,
|
||||
Incident,
|
||||
EquipmentNumber,
|
||||
Hierarchie,
|
||||
ParticipantId,
|
||||
Position,
|
||||
AesId,
|
||||
AesName
|
||||
};
|
||||
explicit AlarmHistoryModel(QObject* parent = nullptr);
|
||||
|
||||
explicit AlarmHistoryModel(QObject *parent = nullptr);
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc);
|
||||
|
||||
bool initModel(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
int participantId2EquipNo(const int participantId) const;
|
||||
QString getDesignator(const int participantId) const;
|
||||
QString getTactIdentifier(const int participantId) const;
|
||||
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool isFiltered(const NotificationEx& data, DataModification modType) const override;
|
||||
private slots:
|
||||
void onNotificationChanged(const AlarmManagement::Notification& data, const DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant& participant, const DataModification modType);
|
||||
void onAesItemChanged(const AreaEffectSimulation::AesItem& item, const DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination& data, const DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap& data, const DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine& data, const DataModification modType);
|
||||
|
||||
int participantId2EquipNo(const int participantId) const;
|
||||
QString getDesignator(const int participantId) const;
|
||||
QString getTactIdentifier(const int participantId) const;
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
|
||||
protected:
|
||||
QMap<int, int> m_partId2EquipNoMap;
|
||||
QHash<int, QString> m_idDesignatorMap;
|
||||
QHash<int, QString> m_idTactIdentifierMap;
|
||||
QHash<int, QString> m_aesNameMap;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool isFiltered(const NotificationEx &data, DataModification modType) const override;
|
||||
private slots:
|
||||
void onNotificationChanged(const AlarmManagement::Notification &data,
|
||||
const DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &participant,
|
||||
const DataModification modType);
|
||||
void onAesItemChanged(const AreaEffectSimulation::AesItem &item,
|
||||
const DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data,
|
||||
const DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data,
|
||||
const DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data,
|
||||
const DataModification modType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
|
||||
QMap<int, int> m_partId2EquipNoMap;
|
||||
QHash<int, QString> m_idDesignatorMap;
|
||||
QHash<int, QString> m_idTactIdentifierMap;
|
||||
QHash<int, QString> m_aesNameMap;
|
||||
|
||||
friend class AlarmHistoryProxyModel;
|
||||
friend class AlarmHistoryProxyModel;
|
||||
};
|
||||
|
||||
class ALMCOMMON_EXPORT AlarmHistoryProxyModel 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:
|
||||
AlarmHistoryModel *m_sourceModel = nullptr;
|
||||
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:
|
||||
AlarmHistoryModel* m_sourceModel = nullptr;
|
||||
};
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+225
-249
@@ -1,311 +1,287 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_dialog.h"
|
||||
#include <utility>
|
||||
#include "ui_alm_dialog.h"
|
||||
|
||||
#include "alm_history.h"
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_config_alarm_model.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include "ui_alm_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_config_alarm_model.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
AlarmDialog::AlarmDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_configAlarmModel(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_ui(new Ui::AlarmDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_operatorId(-1)
|
||||
AlarmDialog::AlarmDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_configAlarmModel(nullptr),
|
||||
m_dtc(nullptr), m_ftc(nullptr), m_ui(new Ui::AlarmDialog), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_operatorId(-1)
|
||||
{
|
||||
AlarmCheckBox alarmCheckBox;
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
AlarmCheckBox alarmCheckBox;
|
||||
LtsUtils::ProjectSettings* ps = LtsUtils::ProjectSettings::getInstance();
|
||||
|
||||
const bool enableNuclearContaminations = ps->value(QLatin1String("aes"),
|
||||
QLatin1String("enableNuclearContaminations")).toBool();
|
||||
const bool enableDangerAreas = ps->value(QLatin1String("aes"),
|
||||
QLatin1String("enableDangerAreas")).toBool();
|
||||
const bool enableMineAreas = ps->value(QLatin1String("aes"),
|
||||
QLatin1String("enableMineAreas")).toBool();
|
||||
const bool enableNuclearContaminations =
|
||||
ps->value(QLatin1String("aes"), QLatin1String("enableNuclearContaminations")).toBool();
|
||||
const bool enableDangerAreas = ps->value(QLatin1String("aes"), QLatin1String("enableDangerAreas")).toBool();
|
||||
const bool enableMineAreas = ps->value(QLatin1String("aes"), QLatin1String("enableMineAreas")).toBool();
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->lblNAgentEntry->hide();
|
||||
m_ui->cbxNMarker->hide();
|
||||
m_ui->cbxNMessage->hide();
|
||||
}
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->lblNAgentEntry->hide();
|
||||
m_ui->cbxNMarker->hide();
|
||||
m_ui->cbxNMessage->hide();
|
||||
}
|
||||
|
||||
if (!enableDangerAreas)
|
||||
{
|
||||
m_ui->lblDangerAreaEntry->hide();
|
||||
m_ui->cbxDanerAreaMarker->hide();
|
||||
m_ui->cbxDangerAreaMessage->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->lblMineAreaEntry->hide();
|
||||
m_ui->cbxMineAreaEntryMarker->hide();
|
||||
m_ui->cbxMineAreaEntryMessage->hide();
|
||||
m_ui->lblMineAreaHit->hide();
|
||||
m_ui->cbxMineAreaHitMarker->hide();
|
||||
m_ui->cbxMineAreaHitMessage->hide();
|
||||
}
|
||||
if (!enableDangerAreas)
|
||||
{
|
||||
m_ui->lblDangerAreaEntry->hide();
|
||||
m_ui->cbxDanerAreaMarker->hide();
|
||||
m_ui->cbxDangerAreaMessage->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->lblMineAreaEntry->hide();
|
||||
m_ui->cbxMineAreaEntryMarker->hide();
|
||||
m_ui->cbxMineAreaEntryMessage->hide();
|
||||
m_ui->lblMineAreaHit->hide();
|
||||
m_ui->cbxMineAreaHitMarker->hide();
|
||||
m_ui->cbxMineAreaHitMessage->hide();
|
||||
}
|
||||
|
||||
alarmCheckBox.name = QLatin1String("NuclearAgentEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxNMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxNMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterNuclear;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("NuclearAgentEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxNMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxNMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterNuclear;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("DangerAreasEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDanerAreaMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDangerAreaMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterDangerArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("DangerAreasEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDanerAreaMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDangerAreaMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterDangerArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("MineAreaEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaEntryMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaEntryMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterMineArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("MineAreaEntry");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaEntryMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaEntryMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::EnterMineArea;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("MineAreaHit");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaHitMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaHitMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitMine;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("MineAreaHit");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxMineAreaHitMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxMineAreaHitMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitMine;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("DirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::Hit;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("DirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxDirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxDirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::Hit;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("IndirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxIndirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxIndirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitEffectSimulation;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("IndirectFire");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxIndirectFireMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxIndirectFireMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::HitEffectSimulation;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("CrossLocalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxLocalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxLocalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossLocalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("CrossLocalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxLocalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxLocalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossLocalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("CrossGlobalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxGlobalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxGlobalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossGlobalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("CrossGlobalBorderlines");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxGlobalBorderMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxGlobalBorderMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::CrossGlobalBorderline;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
alarmCheckBox.name = QLatin1String("AirSupport");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxAirSupportMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxAirSupportMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::AirSupport;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
alarmCheckBox.name = QLatin1String("AirSupport");
|
||||
alarmCheckBox.checkboxMarker = m_ui->cbxAirSupportMarker;
|
||||
alarmCheckBox.checkboxWindow = m_ui->cbxAirSupportMessage;
|
||||
alarmCheckBox.eventTypeId = ProjectDataManagement::EventType::AirSupport;
|
||||
m_checkBoxes.append(alarmCheckBox);
|
||||
|
||||
setOnlineHelpFilename(QLatin1String("Situation-Configure_Global_Alarms"));
|
||||
setOnlineHelpFilename(QLatin1String("Situation-Configure_Global_Alarms"));
|
||||
}
|
||||
|
||||
AlarmDialog::~AlarmDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AlarmDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
AlarmHistoryModel *alarmHistoryModel)
|
||||
bool AlarmDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
AlarmHistoryModel* alarmHistoryModel)
|
||||
{
|
||||
if (!ftc)
|
||||
return false;
|
||||
if (!dtc)
|
||||
return false;
|
||||
if (!ppmDtc)
|
||||
return false;
|
||||
if (!ftc)
|
||||
return false;
|
||||
if (!dtc)
|
||||
return false;
|
||||
if (!ppmDtc)
|
||||
return false;
|
||||
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::alarmConfigChanged,
|
||||
this, &AlarmDialog::onAlarmConfigChanged);
|
||||
m_dtc->enableAlarmConfig();
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::alarmConfigChanged, this,
|
||||
&AlarmDialog::onAlarmConfigChanged);
|
||||
m_dtc->enableAlarmConfig();
|
||||
|
||||
auto cbConfig = [this](const AlarmManagement::AlarmConfig & c)
|
||||
{
|
||||
onAlarmConfigChanged(c, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->alarmConfigs(cbConfig);
|
||||
auto cbConfig = [this](const AlarmManagement::AlarmConfig& c) {
|
||||
onAlarmConfigChanged(c, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->alarmConfigs(cbConfig);
|
||||
|
||||
delete m_configAlarmModel;
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
bool global = true;
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, alarmHistoryModel, global);
|
||||
delete m_configAlarmModel;
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
bool global = true;
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, alarmHistoryModel, global);
|
||||
|
||||
INFO_LOG(m_logger) << "AlarmDialog::init";
|
||||
return true;
|
||||
INFO_LOG(m_logger) << "AlarmDialog::init";
|
||||
return true;
|
||||
}
|
||||
|
||||
void AlarmDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Configure Global Alarms"));
|
||||
translate(m_ui, tr("Configure Global Alarms"));
|
||||
}
|
||||
|
||||
void AlarmDialog::onAlarmConfigChanged(const AlarmManagement::AlarmConfig &data, DataModification modType)
|
||||
void AlarmDialog::onAlarmConfigChanged(const AlarmManagement::AlarmConfig& data, DataModification modType)
|
||||
{
|
||||
bool setMarker = data.setMarker();
|
||||
bool messageWindow = data.messageWindow();
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
bool setMarker = data.setMarker();
|
||||
bool messageWindow = data.messageWindow();
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfigChanged "
|
||||
<< " id=" << data.id()
|
||||
<< " operatorId=" << data.operatorId()
|
||||
<< " m_operatorId=" << m_operatorId
|
||||
<< " participantId=" << data.participantId()
|
||||
<< " eventTypeId=" << data.eventTypeId()
|
||||
<< " messageWindow=" << messageWindow
|
||||
<< " setMarker=" << setMarker;
|
||||
if (data.global() == false)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfigChanged "
|
||||
<< " id=" << data.id() << " operatorId=" << data.operatorId()
|
||||
<< " m_operatorId=" << m_operatorId << " participantId=" << data.participantId()
|
||||
<< " eventTypeId=" << data.eventTypeId() << " messageWindow=" << messageWindow
|
||||
<< " setMarker=" << setMarker;
|
||||
if (data.global() == false)
|
||||
return;
|
||||
|
||||
if (data.operatorId() == m_operatorId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfig zuweisen ";
|
||||
switch (data.eventTypeId().underlying())
|
||||
if (data.operatorId() == m_operatorId)
|
||||
{
|
||||
case ProjectDataManagement::EventType_def::EnterNuclear:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EnterNuclear zuweisen ";
|
||||
m_ui->cbxNMarker->setChecked(setMarker);
|
||||
m_ui->cbxNMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterDangerArea:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EnterDangerArea zuweisen ";
|
||||
m_ui->cbxDanerAreaMarker->setChecked(setMarker);
|
||||
m_ui->cbxDangerAreaMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterMineArea:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EnterMineArea zuweisen ";
|
||||
m_ui->cbxMineAreaEntryMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaEntryMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMineAreaHitMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaHitMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "************** onAlarmConfig zuweisen ";
|
||||
switch (data.eventTypeId().underlying())
|
||||
{
|
||||
case ProjectDataManagement::EventType_def::EnterNuclear: {
|
||||
DEBUG_LOG(m_logger) << "EnterNuclear zuweisen ";
|
||||
m_ui->cbxNMarker->setChecked(setMarker);
|
||||
m_ui->cbxNMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterDangerArea: {
|
||||
DEBUG_LOG(m_logger) << "EnterDangerArea zuweisen ";
|
||||
m_ui->cbxDanerAreaMarker->setChecked(setMarker);
|
||||
m_ui->cbxDangerAreaMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::EnterMineArea: {
|
||||
DEBUG_LOG(m_logger) << "EnterMineArea zuweisen ";
|
||||
m_ui->cbxMineAreaEntryMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaEntryMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine: {
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMineAreaHitMarker->setChecked(setMarker);
|
||||
m_ui->cbxMineAreaHitMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::EventType_def::Hit:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxDirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitEffectSimulation zuweisen ";
|
||||
m_ui->cbxIndirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxIndirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::Hit: {
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxDirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation: {
|
||||
DEBUG_LOG(m_logger) << "HitEffectSimulation zuweisen ";
|
||||
m_ui->cbxIndirectFireMarker->setChecked(setMarker);
|
||||
m_ui->cbxIndirectFireMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxLocalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxLocalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxGlobalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport: {
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupportMarker->setChecked(setMarker);
|
||||
m_ui->cbxAirSupportMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderMarker->setChecked(setMarker);
|
||||
m_ui->cbxGlobalBorderMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupportMarker->setChecked(setMarker);
|
||||
m_ui->cbxAirSupportMessage->setChecked(messageWindow);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> AlarmDialog::getCheckedValues() const
|
||||
{
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
std::vector<AlarmManagement::AlarmAction> ret;
|
||||
ret.clear();
|
||||
ret.reserve(m_checkBoxes.size());
|
||||
for (const AlarmCheckBox &item : std::as_const(m_checkBoxes))
|
||||
{
|
||||
alarmActionDds.eventTypeId(item.eventTypeId);
|
||||
if (item.checkboxMarker->isChecked())
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
std::vector<AlarmManagement::AlarmAction> ret;
|
||||
ret.clear();
|
||||
ret.reserve(m_checkBoxes.size());
|
||||
for (const AlarmCheckBox& item : std::as_const(m_checkBoxes))
|
||||
{
|
||||
alarmActionDds.setMarker(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = true";
|
||||
alarmActionDds.eventTypeId(item.eventTypeId);
|
||||
if (item.checkboxMarker->isChecked())
|
||||
{
|
||||
alarmActionDds.setMarker(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = true";
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.setMarker(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = false";
|
||||
}
|
||||
if (item.checkboxWindow->isChecked())
|
||||
{
|
||||
alarmActionDds.messageWindow(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = true";
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.messageWindow(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = false";
|
||||
}
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
ret.push_back(alarmActionDds);
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.setMarker(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " setMarker = false";
|
||||
}
|
||||
if (item.checkboxWindow->isChecked())
|
||||
{
|
||||
alarmActionDds.messageWindow(true);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = true";
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmActionDds.messageWindow(false);
|
||||
DEBUG_LOG(m_logger) << item.name << " messageWindow = false";
|
||||
}
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
ret.push_back(alarmActionDds);
|
||||
}
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AlarmDialog::apply()
|
||||
{
|
||||
std::vector<int32_t> participantIds;
|
||||
participantIds.push_back(0);
|
||||
bool globalEvent = true;
|
||||
bool remove = false;
|
||||
const ConfigureAlarmsRequest req(getCheckedValues(), m_operatorId, participantIds, globalEvent, remove);
|
||||
std::vector<int32_t> participantIds;
|
||||
participantIds.push_back(0);
|
||||
bool globalEvent = true;
|
||||
bool remove = false;
|
||||
const ConfigureAlarmsRequest req(getCheckedValues(), m_operatorId, participantIds, globalEvent, remove);
|
||||
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->configureAlarmsRequest(req, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
return m_requestHelper->startSingleRequest([req, this]() { return m_ftc->configureAlarmsRequest(req, this); });
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+85
-106
@@ -1,163 +1,142 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_history.h"
|
||||
|
||||
#include "ui_alm_history.h"
|
||||
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
AlarmView::AlarmView(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::AlarmView)
|
||||
AlarmView::AlarmView(LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_alarmHistoryModel(nullptr),
|
||||
m_dtc(nullptr), m_sitMapGuiIfc(nullptr), m_session(session), m_ui(new Ui::AlarmView)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --- AlarmView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " --- AlarmView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &AlarmView::onSelectionChanged);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &AlarmView::onSelectionChanged);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &AlarmView::onShowAlarm);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &AlarmView::onShowAlarm);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print,
|
||||
this, &AlarmView::onPrint);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AlarmView::onRemoveAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &AlarmView::onPrint);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AlarmView::onCenterAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AlarmView::onRemoveAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Alarm_History"));
|
||||
|
||||
}
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AlarmView::onCenterAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Alarm_History"));
|
||||
}
|
||||
|
||||
AlarmView::~AlarmView()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- AlarmView Destruktor() ";
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "--- AlarmView Destruktor() ";
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void AlarmView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Alarm History"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Center Map"));
|
||||
translate(m_ui, tr("Alarm History"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Center Map"));
|
||||
}
|
||||
|
||||
bool AlarmView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
AlarmHistoryModel *alarmHistoryModel)
|
||||
bool AlarmView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc, AlarmHistoryModel* alarmHistoryModel)
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc)
|
||||
return false;
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- AlarmView::init ";
|
||||
m_proxyModel = new AlarmHistoryProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_alarmHistoryModel);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
m_dtc = dtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- AlarmView::init ";
|
||||
m_proxyModel = new AlarmHistoryProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_alarmHistoryModel);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::Id);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::ParticipantId);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::AesId);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::Id);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::ParticipantId);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::AesId);
|
||||
#endif
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AlarmView::onSelectionChanged()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows > 0);
|
||||
}
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows > 0);
|
||||
}
|
||||
|
||||
void AlarmView::onShowAlarm()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- onShowMAlarm() ";
|
||||
}
|
||||
|
||||
|
||||
INFO_LOG(m_logger) << "--- onShowMAlarm() ";
|
||||
}
|
||||
|
||||
void AlarmView::onRemoveAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm selectedRows.size"
|
||||
<< m_ui->widget->selectedRows().size();
|
||||
|
||||
const QModelIndexList idxList = m_ui->widget->selectedRows();
|
||||
QVector<int> rowsToRemove;
|
||||
rowsToRemove.reserve(idxList.size());
|
||||
for (const auto &idx : idxList)
|
||||
rowsToRemove.push_back(idx.row());
|
||||
std::sort(rowsToRemove.begin(), rowsToRemove.end(), std::greater<int>());
|
||||
for (int i = 0; i < rowsToRemove.length(); i++)
|
||||
m_alarmHistoryModel->removeRow(rowsToRemove.at(i));
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm selectedRows.size" << m_ui->widget->selectedRows().size();
|
||||
|
||||
const QModelIndexList idxList = m_ui->widget->selectedRows();
|
||||
QVector<int> rowsToRemove;
|
||||
rowsToRemove.reserve(idxList.size());
|
||||
for (const auto& idx : idxList)
|
||||
rowsToRemove.push_back(idx.row());
|
||||
std::sort(rowsToRemove.begin(), rowsToRemove.end(), std::greater<int>());
|
||||
for (int i = 0; i < rowsToRemove.length(); i++)
|
||||
m_alarmHistoryModel->removeRow(rowsToRemove.at(i));
|
||||
}
|
||||
|
||||
void AlarmView::onCenterAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onCenterAlarm";
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
const QModelIndexList indexList = m_ui->widget->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
const QModelIndex &index = indexList.first();
|
||||
DEBUG_LOG(m_logger) << "onCenterAlarm";
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
const QModelIndexList indexList = m_ui->widget->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
const QModelIndex& index = indexList.first();
|
||||
|
||||
const QModelIndex indexPosi = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::Position, index.parent());
|
||||
const QPointF &position = indexPosi.data(Qt::UserRole).toPointF();
|
||||
const QModelIndex indexPosi = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::Position, index.parent());
|
||||
const QPointF& position = indexPosi.data(Qt::UserRole).toPointF();
|
||||
|
||||
if (!position.isNull())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " position=" << position.x() << " - " << position.y();
|
||||
m_sitMapGuiIfc->setCenterPoint(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QModelIndex &indexParticipantId = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::ParticipantId, index.parent());
|
||||
const int participantId = indexParticipantId.data().toInt();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " participantId=" << participantId;
|
||||
m_sitMapGuiIfc->centerMapToParticipant(participantId);
|
||||
}
|
||||
}
|
||||
if (!position.isNull())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " position=" << position.x() << " - " << position.y();
|
||||
m_sitMapGuiIfc->setCenterPoint(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QModelIndex& indexParticipantId =
|
||||
m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::ParticipantId, index.parent());
|
||||
const int participantId = indexParticipantId.data().toInt();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " participantId=" << participantId;
|
||||
m_sitMapGuiIfc->centerMapToParticipant(participantId);
|
||||
}
|
||||
}
|
||||
|
||||
void AlarmView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void AlarmView::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+24
-26
@@ -1,18 +1,18 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AlarmView;
|
||||
}
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
class AlarmHistoryModel;
|
||||
@@ -20,33 +20,31 @@ class AlarmHistoryProxyModel;
|
||||
|
||||
class AlarmView final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlarmView(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~AlarmView();
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
AlarmHistoryModel *alarmHistoryModel);
|
||||
public:
|
||||
explicit AlarmView(LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~AlarmView();
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc, AlarmHistoryModel* alarmHistoryModel);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onCenterAlarm();
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onCenterAlarm();
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
private:
|
||||
AlarmHistoryModel* m_alarmHistoryModel;
|
||||
AlarmHistoryProxyModel* m_proxyModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
private:
|
||||
AlarmHistoryModel *m_alarmHistoryModel;
|
||||
AlarmHistoryProxyModel *m_proxyModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::AlarmView *m_ui;
|
||||
LtsSession::LtsSession* m_session;
|
||||
Ui::AlarmView* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+240
-254
@@ -1,320 +1,306 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "alm_config_participant_dialog.h"
|
||||
|
||||
#include "ui_alm_config_participant_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <ParticipantManagement/Gui/Common/participant_vulnerability_types.h>
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
ConfigParticipantsDialog::ConfigParticipantsDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::ConfigParticipantsDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_typeClass(ParticipantManagement::TypeClass::Human)
|
||||
, m_logger(AlarmManagement::getLogger("ConfigParticipantsDialog"))
|
||||
ConfigParticipantsDialog::ConfigParticipantsDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel),
|
||||
m_ui(new Ui::ConfigParticipantsDialog), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_typeClass(ParticipantManagement::TypeClass::Human),
|
||||
m_logger(AlarmManagement::getLogger("ConfigParticipantsDialog"))
|
||||
{
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
LtsUtils::ProjectSettings* ps = LtsUtils::ProjectSettings::getInstance();
|
||||
|
||||
const bool enableNuclearContaminations = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableNuclearContaminations")).toBool();
|
||||
const bool enableMineAreas = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableMineAreas")).toBool();
|
||||
m_ui->setupUi(this);
|
||||
const bool enableNuclearContaminations =
|
||||
ps->value(QStringLiteral("aes"), QStringLiteral("enableNuclearContaminations")).toBool();
|
||||
const bool enableMineAreas = ps->value(QStringLiteral("aes"), QStringLiteral("enableMineAreas")).toBool();
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->cbxNbcAgent->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->cbxMines->hide();
|
||||
m_ui->cbxIndirectFire->hide();
|
||||
}
|
||||
if (!enableNuclearContaminations)
|
||||
{
|
||||
m_ui->cbxNbcAgent->hide();
|
||||
}
|
||||
if (!enableMineAreas)
|
||||
{
|
||||
m_ui->cbxMines->hide();
|
||||
m_ui->cbxIndirectFire->hide();
|
||||
}
|
||||
|
||||
#ifdef ETS_MODE
|
||||
|
||||
m_ui->cbxFriendlyFire->hide();
|
||||
m_ui->cbStatusFriendly->hide();
|
||||
|
||||
m_ui->cbxFriendlyFire->hide();
|
||||
m_ui->cbStatusFriendly->hide();
|
||||
#endif
|
||||
|
||||
setNoTopicLock();
|
||||
setNoTopicLock();
|
||||
}
|
||||
|
||||
ConfigParticipantsDialog::~ConfigParticipantsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ConfigParticipantsDialog::retranslate()
|
||||
{
|
||||
if (!m_participantData.equipmentNumber().is_set())
|
||||
{
|
||||
QString hierarchy = m_ppmDtc->hierarchyFromParticipant(m_participantData.id());
|
||||
translate(m_ui, m_participantData, hierarchy, tr("Participant Alarm"));
|
||||
}
|
||||
else
|
||||
translate(m_ui, m_participantData, QString::number(m_participantData.equipmentNumber().get()), tr("Participant Alarm"));
|
||||
if (!m_participantData.equipmentNumber().is_set())
|
||||
{
|
||||
QString hierarchy = m_ppmDtc->hierarchyFromParticipant(m_participantData.id());
|
||||
translate(m_ui, m_participantData, hierarchy, tr("Participant Alarm"));
|
||||
}
|
||||
else
|
||||
translate(m_ui, m_participantData, QString::number(m_participantData.equipmentNumber().get()),
|
||||
tr("Participant Alarm"));
|
||||
|
||||
m_uiRequirements->clear();
|
||||
m_uiRequirements->addRequirement( { m_ui->lbReaction, [this]() { return m_ui->cbxSetMarker->isChecked() || m_ui->cbxMessageWindow->isChecked(); }, tr("Select at least one reaction") });
|
||||
m_uiRequirements->clear();
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lbReaction, [this]() { return m_ui->cbxSetMarker->isChecked() || m_ui->cbxMessageWindow->isChecked(); },
|
||||
tr("Select at least one reaction")});
|
||||
}
|
||||
|
||||
bool ConfigParticipantsDialog::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const ParticipantManagement::ParticipantData &participantData,
|
||||
const std::vector<int> &participantVector,
|
||||
const std::vector<int> &equipmentVector)
|
||||
bool ConfigParticipantsDialog::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const ParticipantManagement::ParticipantData& participantData,
|
||||
const std::vector<int>& participantVector, const std::vector<int>& equipmentVector)
|
||||
{
|
||||
if (!ppmDtc || !almDtc || !almFtc)
|
||||
return false;
|
||||
if (!ppmDtc || !almDtc || !almFtc)
|
||||
return false;
|
||||
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_almDtc = almDtc;
|
||||
m_participantVector = participantVector;
|
||||
m_participantData = participantData;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_almDtc = almDtc;
|
||||
m_participantVector = participantVector;
|
||||
m_participantData = participantData;
|
||||
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
m_ui->lbHierarchy->setText(m_ppmDtc->hierarchyFromParticipant(m_participantData.id()));
|
||||
m_ui->lbHierarchy->setText(m_ppmDtc->hierarchyFromParticipant(m_participantData.id()));
|
||||
|
||||
QString equipmentNumbersStr;
|
||||
if (participantData.equipmentNumber().is_set())
|
||||
{
|
||||
equipmentNumbersStr.append(QString::number(participantData.equipmentNumber().get()));
|
||||
equipmentNumbersStr.append(QStringLiteral(": "));
|
||||
}
|
||||
QString equipmentNumbersStr;
|
||||
if (participantData.equipmentNumber().is_set())
|
||||
{
|
||||
equipmentNumbersStr.append(QString::number(participantData.equipmentNumber().get()));
|
||||
equipmentNumbersStr.append(QStringLiteral(": "));
|
||||
}
|
||||
|
||||
for (const int equipNo : equipmentVector)
|
||||
equipmentNumbersStr += QString::number(equipNo) + QStringLiteral(", ");
|
||||
equipmentNumbersStr.chop(2);
|
||||
for (const int equipNo : equipmentVector)
|
||||
equipmentNumbersStr += QString::number(equipNo) + QStringLiteral(", ");
|
||||
equipmentNumbersStr.chop(2);
|
||||
|
||||
m_ui->equipmentNoContent->setText(equipmentNumbersStr);
|
||||
m_ui->equipmentNoContent->setText(equipmentNumbersStr);
|
||||
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << participantData.id();
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << participantData.id();
|
||||
|
||||
m_typeClass = ppmDtc->type(participantData.typeId()).typeClass();
|
||||
DEBUG_LOG(m_logger) << "m_typeClass=" << m_typeClass << " TypeId=" << participantData.typeId();
|
||||
fillCbx();
|
||||
m_typeClass = ppmDtc->type(participantData.typeId()).typeClass();
|
||||
DEBUG_LOG(m_logger) << "m_typeClass=" << m_typeClass << " TypeId=" << participantData.typeId();
|
||||
fillCbx();
|
||||
|
||||
m_almDtc->alarmConfigs([this](const AlarmManagement::AlarmConfig &alarm) { setAlaramData(alarm); });
|
||||
return true;
|
||||
m_almDtc->alarmConfigs([this](const AlarmManagement::AlarmConfig& alarm) { setAlaramData(alarm); });
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigParticipantsDialog::setAlaramData(const AlarmManagement::AlarmConfig &alarm)
|
||||
void ConfigParticipantsDialog::setAlaramData(const AlarmManagement::AlarmConfig& alarm)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setAlaramData:" << alarm;
|
||||
if (alarm.operatorId() != m_operatorId ||
|
||||
alarm.participantId() != m_participantData.id() ||
|
||||
alarm.global())
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "setAlaramData:" << alarm;
|
||||
if (alarm.operatorId() != m_operatorId || alarm.participantId() != m_participantData.id() || alarm.global())
|
||||
return;
|
||||
|
||||
switch (alarm.eventTypeId().underlying())
|
||||
{
|
||||
case ProjectDataManagement::EventType_def::Hit:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
switch (alarm.eventTypeId().underlying())
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusDirect->setCurrentIndex(index);
|
||||
case ProjectDataManagement::EventType_def::Hit: {
|
||||
DEBUG_LOG(m_logger) << "Hit zuweisen ";
|
||||
m_ui->cbxDirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState =
|
||||
static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusDirect->setCurrentIndex(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation: {
|
||||
DEBUG_LOG(m_logger) << "HitIndirect zuweisen ";
|
||||
m_ui->cbxIndirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport: {
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupport->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine: {
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMines->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitB:
|
||||
case ProjectDataManagement::EventType_def::HitN:
|
||||
case ProjectDataManagement::EventType_def::HitC: {
|
||||
DEBUG_LOG(m_logger) << "Hit N/B/C zuweisen ";
|
||||
m_ui->cbxNbcAgent->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::FriendlyFire: {
|
||||
DEBUG_LOG(m_logger) << "FriendlyFire zuweisen ";
|
||||
m_ui->cbxFriendlyFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState =
|
||||
static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusFriendly->setCurrentIndex(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::Manipulation: {
|
||||
DEBUG_LOG(m_logger) << "Manipulation zuweisen ";
|
||||
m_ui->cbxManipulation->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline: {
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitEffectSimulation:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitIndirect zuweisen ";
|
||||
m_ui->cbxIndirectFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::AirSupport:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AirSupport zuweisen ";
|
||||
m_ui->cbxAirSupport->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitMine:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HitMine zuweisen ";
|
||||
m_ui->cbxMines->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::HitB:
|
||||
case ProjectDataManagement::EventType_def::HitN:
|
||||
case ProjectDataManagement::EventType_def::HitC:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Hit N/B/C zuweisen ";
|
||||
m_ui->cbxNbcAgent->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::FriendlyFire:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "FriendlyFire zuweisen ";
|
||||
m_ui->cbxFriendlyFire->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
if (alarm.vulnerabilityState() >= 0)
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulState = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(alarm.vulnerabilityState());
|
||||
int index = m_ui->cbStatusDirect->findData(QVariant(vulState.underlying()));
|
||||
m_ui->cbStatusFriendly->setCurrentIndex(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::Manipulation:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Manipulation zuweisen ";
|
||||
m_ui->cbxManipulation->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossGlobalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossGlobalBorderline zuweisen ";
|
||||
m_ui->cbxGlobalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::EventType_def::CrossLocalBorderline:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CrossLocalBorderline zuweisen ";
|
||||
m_ui->cbxLocalBorderLine->setChecked(true);
|
||||
m_ui->cbxSetMarker->setChecked(alarm.setMarker());
|
||||
m_ui->cbxMessageWindow->setChecked(alarm.messageWindow());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to set with Operator App!!!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> ConfigParticipantsDialog::getCheckedValues() const
|
||||
{
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
DEBUG_LOG(m_logger) << "getCheckedValues";
|
||||
AlarmManagement::AlarmAction alarmActionDds;
|
||||
DEBUG_LOG(m_logger) << "getCheckedValues";
|
||||
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
|
||||
alarmActionDds.setMarker(m_ui->cbxSetMarker->isChecked());
|
||||
alarmActionDds.messageWindow(m_ui->cbxMessageWindow->isChecked());
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
alarmActionDds.setMarker(m_ui->cbxSetMarker->isChecked());
|
||||
alarmActionDds.messageWindow(m_ui->cbxMessageWindow->isChecked());
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
{
|
||||
if (m_ui->cbxDirectFire->isChecked())
|
||||
if (alarmActionDds.setMarker() || alarmActionDds.messageWindow())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Hit);
|
||||
int statusDirect = -1;
|
||||
if (m_ui->cbStatusDirect->currentIndex() > 0)
|
||||
statusDirect = m_ui->cbStatusDirect->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusDirect);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
if (m_ui->cbxDirectFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Hit);
|
||||
int statusDirect = -1;
|
||||
if (m_ui->cbStatusDirect->currentIndex() > 0)
|
||||
statusDirect = m_ui->cbStatusDirect->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusDirect);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxFriendlyFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::FriendlyFire);
|
||||
int statusFriendly = -1;
|
||||
if (m_ui->cbStatusFriendly->currentIndex() > 0)
|
||||
statusFriendly = m_ui->cbStatusFriendly->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusFriendly);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
if (m_ui->cbxIndirectFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitEffectSimulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxAirSupport->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::AirSupport);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxMines->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitMine);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxNbcAgent->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitN);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitB);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitC);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxManipulation->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Manipulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxGlobalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossGlobalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxLocalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossLocalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
}
|
||||
if (m_ui->cbxFriendlyFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::FriendlyFire);
|
||||
int statusFriendly = -1;
|
||||
if (m_ui->cbStatusFriendly->currentIndex() > 0)
|
||||
statusFriendly = m_ui->cbStatusFriendly->currentData().toInt();
|
||||
alarmActionDds.vulnerabilityState(statusFriendly);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
alarmActionDds.vulnerabilityState(-1);
|
||||
if (m_ui->cbxIndirectFire->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitEffectSimulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxAirSupport->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::AirSupport);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxMines->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitMine);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxNbcAgent->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitN);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitB);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::HitC);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxManipulation->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::Manipulation);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxGlobalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossGlobalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
if (m_ui->cbxLocalBorderLine->isChecked())
|
||||
{
|
||||
alarmActionDds.eventTypeId(ProjectDataManagement::EventType_def::CrossLocalBorderline);
|
||||
alarmsDds.push_back(alarmActionDds);
|
||||
}
|
||||
}
|
||||
return alarmsDds;
|
||||
return alarmsDds;
|
||||
}
|
||||
|
||||
bool ConfigParticipantsDialog::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "apply";
|
||||
AlarmManagement::ConfigureAlarmsRequest req;
|
||||
req.participantIds(m_participantVector);
|
||||
req.alarms(getCheckedValues());
|
||||
req.operatorId(m_operatorId);
|
||||
req.global(false);
|
||||
req.remove(false);
|
||||
DEBUG_LOG(m_logger) << "apply";
|
||||
AlarmManagement::ConfigureAlarmsRequest req;
|
||||
req.participantIds(m_participantVector);
|
||||
req.alarms(getCheckedValues());
|
||||
req.operatorId(m_operatorId);
|
||||
req.global(false);
|
||||
req.remove(false);
|
||||
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_almFtc->configureAlarmsRequest(req, this);
|
||||
});
|
||||
return m_requestHelper->startSingleRequest([req, this]() { return m_almFtc->configureAlarmsRequest(req, this); });
|
||||
}
|
||||
|
||||
void ConfigParticipantsDialog::fillCbx()
|
||||
{
|
||||
m_ui->cbStatusDirect->clear();
|
||||
m_ui->cbStatusFriendly->clear();
|
||||
|
||||
m_ui->cbStatusDirect->addItem(tr("All Types"), -1);
|
||||
m_ui->cbStatusFriendly->addItem(tr("All Types"), -1);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusDirect, m_typeClass);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusFriendly, m_typeClass);
|
||||
m_ui->cbStatusDirect->removeItem(m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
m_ui->cbStatusFriendly->removeItem(m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
m_ui->cbStatusDirect->clear();
|
||||
m_ui->cbStatusFriendly->clear();
|
||||
|
||||
m_ui->cbStatusDirect->addItem(tr("All Types"), -1);
|
||||
m_ui->cbStatusFriendly->addItem(tr("All Types"), -1);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusDirect, m_typeClass);
|
||||
ParticipantManagement::insertVulnerabilityStates(m_ui->cbStatusFriendly, m_typeClass);
|
||||
m_ui->cbStatusDirect->removeItem(
|
||||
m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
m_ui->cbStatusFriendly->removeItem(
|
||||
m_ui->cbStatusDirect->findData(ProjectDataManagement::VulnerabilityState::TemporarySeverance));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+37
-36
@@ -1,15 +1,14 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <memory>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <AlarmManagement/logger.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -18,43 +17,45 @@ class ConfigParticipantsDialog;
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
class ConfigParticipantsDialog : public LtsWidgets::LtsDialog
|
||||
, protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
class ConfigParticipantsDialog : public LtsWidgets::LtsDialog,
|
||||
protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigParticipantsDialog(QWidget *parent = nullptr);
|
||||
~ConfigParticipantsDialog();
|
||||
public:
|
||||
explicit ConfigParticipantsDialog(QWidget* parent = nullptr);
|
||||
~ConfigParticipantsDialog();
|
||||
|
||||
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const ParticipantManagement::ParticipantData &participantData,
|
||||
const std::vector<int> &participantVector,
|
||||
const std::vector<int> &equipmentVector);
|
||||
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const ParticipantManagement::ParticipantData& participantData, const std::vector<int>& participantVector,
|
||||
const std::vector<int>& equipmentVector);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
std::vector<AlarmManagement::AlarmAction> getCheckedValues() const;
|
||||
void fillCbx();
|
||||
void setAlaramData(const AlarmManagement::AlarmConfig &alarm);
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
std::vector<AlarmManagement::AlarmAction> getCheckedValues() const;
|
||||
void fillCbx();
|
||||
void setAlaramData(const AlarmManagement::AlarmConfig& alarm);
|
||||
|
||||
private:
|
||||
Ui::ConfigParticipantsDialog *m_ui;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
int m_operatorId;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
ParticipantManagement::TypeClass m_typeClass;
|
||||
ParticipantManagement::ParticipantData m_participantData;
|
||||
private:
|
||||
Ui::ConfigParticipantsDialog* m_ui;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
int m_operatorId;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
ParticipantManagement::TypeClass m_typeClass;
|
||||
ParticipantManagement::ParticipantData m_participantData;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+127
-150
@@ -1,228 +1,205 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "alm_participant_dialog.h"
|
||||
#include "ui_alm_participant_dialog.h"
|
||||
|
||||
#include "alm_config_participant_dialog.h"
|
||||
#include "alm_participant_model.h"
|
||||
#include "ui_alm_participant_dialog.h"
|
||||
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
int ParticipantsDialog::s_preselectedParty = -1;
|
||||
|
||||
ParticipantsDialog::ParticipantsDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent)
|
||||
, m_session(nullptr)
|
||||
, m_almDtc(nullptr)
|
||||
, m_almFtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_participantModel(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_ui(new Ui::ParticipantsDialog)
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantsDialog"))
|
||||
ParticipantsDialog::ParticipantsDialog(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent), m_session(nullptr), m_almDtc(nullptr), m_almFtc(nullptr), m_ppmDtc(nullptr),
|
||||
m_participantModel(nullptr), m_requestHelper(new LtsUtils::RequestHelper(this)), m_menuGroup(menuGroup),
|
||||
m_ui(new Ui::ParticipantsDialog), m_logger(AlarmManagement::getLogger("ParticipantsDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ParticipantsDialog::onAddButtonClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantsDialog::onPrint);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ParticipantsDialog::onAddButtonClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantsDialog::onPrint);
|
||||
|
||||
m_ui->cbAllParticipants->setVisible(false);
|
||||
m_ui->cbAllParticipants->setVisible(false);
|
||||
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Participant_Alarms"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Participant_Alarms"));
|
||||
}
|
||||
|
||||
ParticipantsDialog::~ParticipantsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantsDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Assign Participant Alarms"));
|
||||
translate(m_ui, tr("Assign Participant Alarms"));
|
||||
}
|
||||
|
||||
bool ParticipantsDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc)
|
||||
bool ParticipantsDialog::init(LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface>& ppmGuiCbxIfc)
|
||||
{
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almDtc = almDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_session = session;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almDtc = almDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_session = session;
|
||||
|
||||
if (m_ppmDtc == nullptr ||
|
||||
!ppmDtc->enableDynamicParticipantData() ||
|
||||
!ppmDtc->enableParticipant())
|
||||
return false;
|
||||
if (m_ppmDtc == nullptr || !ppmDtc->enableDynamicParticipantData() || !ppmDtc->enableParticipant())
|
||||
return false;
|
||||
|
||||
if (m_almFtc == nullptr ||
|
||||
!almFtc->enableConfigureAlarms())
|
||||
return false;
|
||||
if (m_almFtc == nullptr || !almFtc->enableConfigureAlarms())
|
||||
return false;
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
m_participantModel = new ParticipantAlarms::ParticipantAlarmModel(this,
|
||||
m_ppmDtc,
|
||||
asbIfc);
|
||||
m_participantProxyModel = new ParticipantManagement::ParticipantTreeFilterProxyModel(this);
|
||||
m_participantProxyModel->setSourceModel(m_participantModel);
|
||||
m_participantProxyModel->setRecursiveFilteringEnabled(true);
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
m_participantModel = new ParticipantAlarms::ParticipantAlarmModel(this, m_ppmDtc, asbIfc);
|
||||
m_participantProxyModel = new ParticipantManagement::ParticipantTreeFilterProxyModel(this);
|
||||
m_participantProxyModel->setSourceModel(m_participantModel);
|
||||
m_participantProxyModel->setRecursiveFilteringEnabled(true);
|
||||
|
||||
m_ui->dvParticipants->setModel(m_participantProxyModel);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantsDialog::onCbPartyChanged);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked,
|
||||
m_ui->dvParticipants, &LtsDataView::LtsDataView::setDisabled);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ParticipantsDialog::onSelectionChanged);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ParticipantsDialog::onDoubleClicked);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked,
|
||||
this, [this](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
else
|
||||
m_ui->dvParticipants->treeView()->clearSelection();
|
||||
});
|
||||
m_ui->dvParticipants->setModel(m_participantProxyModel);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ParticipantsDialog::onCbPartyChanged);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked, m_ui->dvParticipants, &LtsDataView::LtsDataView::setDisabled);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::selectionChanged, this,
|
||||
&ParticipantsDialog::onSelectionChanged);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&ParticipantsDialog::onDoubleClicked);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked, this, [this](bool checked) {
|
||||
if (checked)
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
else
|
||||
m_ui->dvParticipants->treeView()->clearSelection();
|
||||
});
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
onCbPartyChanged();
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
onCbPartyChanged();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onSelectionChanged()
|
||||
{
|
||||
bool configureAlarms = false;
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged";
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
bool configureAlarms = false;
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged";
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
{
|
||||
const ParticipantManagement::ParticipantData data(m_participantModel->getParticipantData(index));
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_ppmDtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
configureAlarms = true;
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected row =" << index.row() << " column=" << index.column();
|
||||
|
||||
}
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, configureAlarms);
|
||||
for (const QModelIndex& index : currentlySelectedParticipants)
|
||||
{
|
||||
const ParticipantManagement::ParticipantData data(m_participantModel->getParticipantData(index));
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_ppmDtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
configureAlarms = true;
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected row =" << index.row() << " column=" << index.column();
|
||||
}
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, configureAlarms);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onCbPartyChanged()
|
||||
{
|
||||
const int curPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = curPartyId;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_participantModel->onReinitModel(curPartyId);
|
||||
m_ui->dvParticipants->expandAll();
|
||||
if (m_ui->cbAllParticipants->isChecked())
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
m_ui->dvParticipants->resizeHeadersByContent();
|
||||
const int curPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = curPartyId;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_participantModel->onReinitModel(curPartyId);
|
||||
m_ui->dvParticipants->expandAll();
|
||||
if (m_ui->cbAllParticipants->isChecked())
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
m_ui->dvParticipants->resizeHeadersByContent();
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onAddButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onAddButtonClicked";
|
||||
|
||||
m_participantVector.clear();
|
||||
m_equipmentVector.clear();
|
||||
if (!m_ui->cbAllParticipants->isChecked())
|
||||
{
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
DEBUG_LOG(m_logger) << "onAddButtonClicked";
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
m_participantVector.clear();
|
||||
m_equipmentVector.clear();
|
||||
if (!m_ui->cbAllParticipants->isChecked())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected: " << index.row() << " column=" << index.column();
|
||||
setChildrenSelected(index);
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
|
||||
for (const QModelIndex& index : currentlySelectedParticipants)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected: " << index.row() << " column=" << index.column();
|
||||
setChildrenSelected(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex participantIndex = m_ui->dvParticipants->currentIndex();
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(participantIndex);
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
QModelIndex participantIndex = m_ui->dvParticipants->currentIndex();
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(participantIndex);
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
|
||||
const auto partData = m_participantModel->getParticipantData(participantIndex);
|
||||
addDialog(LtsWidgets::initDialog(new ConfigParticipantsDialog(this),
|
||||
m_ppmDtc, m_almDtc, m_almFtc, partData, m_participantVector, m_equipmentVector),
|
||||
m_menuGroup, QStringLiteral("ConfigAlarms%1").arg(partData.id()));
|
||||
const auto partData = m_participantModel->getParticipantData(participantIndex);
|
||||
addDialog(LtsWidgets::initDialog(new ConfigParticipantsDialog(this), m_ppmDtc, m_almDtc, m_almFtc, partData,
|
||||
m_participantVector, m_equipmentVector),
|
||||
m_menuGroup, QStringLiteral("ConfigAlarms%1").arg(partData.id()));
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvParticipants->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvParticipants->treeView());
|
||||
}
|
||||
|
||||
void ParticipantsDialog::setChildrenSelected(const QModelIndex &parent)
|
||||
void ParticipantsDialog::setChildrenSelected(const QModelIndex& parent)
|
||||
{
|
||||
if (!(parent.isValid() &&
|
||||
m_participantModel->hasChildren(parent)))
|
||||
return;
|
||||
if (!(parent.isValid() && m_participantModel->hasChildren(parent)))
|
||||
return;
|
||||
|
||||
const int rc = m_participantModel->rowCount(parent);
|
||||
for (int currentRow = 0; currentRow < rc; ++currentRow)
|
||||
{
|
||||
QModelIndex childIndex = m_participantModel->index(currentRow, 0, parent);
|
||||
|
||||
if (m_participantModel->hasChildren(childIndex))
|
||||
setChildrenSelected(childIndex);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Setting row "
|
||||
<< childIndex.row()
|
||||
<< " selected";
|
||||
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(childIndex);
|
||||
DEBUG_LOG(m_logger) << "append participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
if (data.equipmentNumber().is_set())
|
||||
const int rc = m_participantModel->rowCount(parent);
|
||||
for (int currentRow = 0; currentRow < rc; ++currentRow)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "append equipmentNumber = " << data.equipmentNumber().get();
|
||||
m_equipmentVector.push_back(data.equipmentNumber().get());
|
||||
}
|
||||
QModelIndex childIndex = m_participantModel->index(currentRow, 0, parent);
|
||||
|
||||
m_ui->dvParticipants->selectionModel()->select(m_participantProxyModel->mapFromSource(childIndex), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
if (m_participantModel->hasChildren(childIndex))
|
||||
setChildrenSelected(childIndex);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Setting row " << childIndex.row() << " selected";
|
||||
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(childIndex);
|
||||
DEBUG_LOG(m_logger) << "append participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
if (data.equipmentNumber().is_set())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "append equipmentNumber = " << data.equipmentNumber().get();
|
||||
m_equipmentVector.push_back(data.equipmentNumber().get());
|
||||
}
|
||||
|
||||
m_ui->dvParticipants->selectionModel()->select(m_participantProxyModel->mapFromSource(childIndex),
|
||||
QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantsDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dvParticipants->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dvParticipants->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject)
|
||||
void ParticipantsDialog::onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onConfigureAlarmsReply" << replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
DEBUG_LOG(m_logger) << "onConfigureAlarmsReply" << replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onDoubleClicked()
|
||||
{
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "onDoubleClicked";
|
||||
onAddButtonClicked();
|
||||
DEBUG_LOG(m_logger) << "onDoubleClicked";
|
||||
onAddButtonClicked();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+42
-45
@@ -1,18 +1,17 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "alm_participant_model.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <memory>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm.hpp>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <Services/AlarmManagement/alm.hpp>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -23,56 +22,54 @@ namespace ParticipantManagement
|
||||
{
|
||||
class ParticipantTreeFilterProxyModel;
|
||||
class ForeignGuiComboboxInterface;
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
class TypeModel;
|
||||
|
||||
class ParticipantsDialog : public LtsWidgets::LtsDialog
|
||||
, protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
class ParticipantsDialog : public LtsWidgets::LtsDialog,
|
||||
protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantsDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~ParticipantsDialog();
|
||||
public:
|
||||
explicit ParticipantsDialog(const QString& menuGroup, QWidget* parent = nullptr);
|
||||
~ParticipantsDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface>& ppmGuiCbxIfc);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
private slots:
|
||||
void onAddButtonClicked();
|
||||
void onPrint();
|
||||
void onCbPartyChanged();
|
||||
void onDoubleClicked();
|
||||
void onSelectionChanged();
|
||||
|
||||
private slots:
|
||||
void onAddButtonClicked();
|
||||
void onPrint();
|
||||
void onCbPartyChanged();
|
||||
void onDoubleClicked();
|
||||
void onSelectionChanged();
|
||||
private:
|
||||
void retranslate() override;
|
||||
void setChildrenSelected(const QModelIndex& parent);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void setChildrenSelected(const QModelIndex &parent);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ParticipantAlarmModel *m_participantModel;
|
||||
ParticipantManagement::ParticipantTreeFilterProxyModel *m_participantProxyModel;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
std::vector<int> m_equipmentVector;
|
||||
QString m_menuGroup;
|
||||
static int s_preselectedParty;
|
||||
Ui::ParticipantsDialog *m_ui;
|
||||
private:
|
||||
LtsSession::LtsSession* m_session;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_almDtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ParticipantAlarmModel* m_participantModel;
|
||||
ParticipantManagement::ParticipantTreeFilterProxyModel* m_participantProxyModel;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
std::vector<int> m_participantVector;
|
||||
std::vector<int> m_equipmentVector;
|
||||
QString m_menuGroup;
|
||||
static int s_preselectedParty;
|
||||
Ui::ParticipantsDialog* m_ui;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+39
-44
@@ -1,73 +1,68 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_participant_model.h"
|
||||
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
|
||||
ParticipantAlarmModel::ParticipantAlarmModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc)
|
||||
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc)
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantAlarmModel"))
|
||||
ParticipantAlarmModel::ParticipantAlarmModel(QObject* parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface>& asbIfc)
|
||||
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc),
|
||||
m_logger(AlarmManagement::getLogger("ParticipantAlarmModel"))
|
||||
{
|
||||
m_titles += tr("Alarm Assignable");
|
||||
m_titles += tr("Alarm Assignable");
|
||||
|
||||
DEBUG_LOG(m_logger) << "ParticipantAlarmModel::ParticipantAlarmModel";
|
||||
DEBUG_LOG(m_logger) << "ParticipantAlarmModel::ParticipantAlarmModel";
|
||||
}
|
||||
|
||||
QVariant ParticipantAlarmModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ParticipantAlarmModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
|
||||
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
||||
{
|
||||
bool bIsSimulated = false;
|
||||
if (!isSelectableByAlarm(index, &bIsSimulated))
|
||||
return QVariant();
|
||||
return !bIsSimulated ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
||||
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
||||
{
|
||||
bool bIsSimulated = false;
|
||||
if (!isSelectableByAlarm(index, &bIsSimulated))
|
||||
return QVariant();
|
||||
return !bIsSimulated ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
||||
}
|
||||
|
||||
void ParticipantAlarmModel::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
void ParticipantAlarmModel::onParticipantChanged(const ParticipantManagement::Participant& data,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.partyId() != partyId())
|
||||
return;
|
||||
Q_UNUSED(modType);
|
||||
if (data.partyId() != partyId())
|
||||
return;
|
||||
|
||||
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
||||
onReinitModel(partyId());
|
||||
emit newData();
|
||||
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
||||
onReinitModel(partyId());
|
||||
emit newData();
|
||||
}
|
||||
|
||||
bool ParticipantAlarmModel::isSelectableByAlarm(const QModelIndex &index, bool *bIsSimulated) const
|
||||
bool ParticipantAlarmModel::isSelectableByAlarm(const QModelIndex& index, bool* bIsSimulated) const
|
||||
{
|
||||
bool isSimulatable = false;
|
||||
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
||||
bool isSimulatable = false;
|
||||
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
||||
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
isSimulatable = true;
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
isSimulatable = true;
|
||||
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id()
|
||||
<< " isSimulated:" << data.isSimulated()
|
||||
<< " equipmentNo:" << data.equipmentNumber()
|
||||
<< " typeId=" << data.typeId()
|
||||
<< " modId=" << data.modId()
|
||||
<< " typeClass=" << m_dtc->type(data.typeId()).typeClass()
|
||||
<< " isSimulatable=" << isSimulatable;
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id() << " isSimulated:" << data.isSimulated()
|
||||
<< " equipmentNo:" << data.equipmentNumber() << " typeId=" << data.typeId()
|
||||
<< " modId=" << data.modId() << " typeClass=" << m_dtc->type(data.typeId()).typeClass()
|
||||
<< " isSimulatable=" << isSimulatable;
|
||||
|
||||
if (bIsSimulated)
|
||||
*bIsSimulated = data.isSimulated();
|
||||
if (bIsSimulated)
|
||||
*bIsSimulated = data.isSimulated();
|
||||
|
||||
return isSimulatable;
|
||||
return isSimulatable;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+12
-15
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
@@ -9,21 +8,19 @@ namespace ParticipantAlarms
|
||||
{
|
||||
class ParticipantAlarmModel final : public ParticipantManagement::ParticipantEditModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticipantAlarmModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc);
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticipantAlarmModel(QObject* parent, const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface>& asbIfc);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
signals:
|
||||
void newData();
|
||||
signals:
|
||||
void newData();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
bool isSelectableByAlarm(const QModelIndex &index, bool *bIsSimulated = nullptr) const;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onParticipantChanged(const ParticipantManagement::Participant& data, DataModification modType);
|
||||
bool isSelectableByAlarm(const QModelIndex& index, bool* bIsSimulated = nullptr) const;
|
||||
};
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+83
-100
@@ -1,150 +1,133 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_participant_show_config.h"
|
||||
|
||||
#include "ui_alm_participant_show_config.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
|
||||
ParticipantShowConfigView::ParticipantShowConfigView(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_configAlarmModel(nullptr)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_almFtc(nullptr)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::ParticipantShowConfigView)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantShowConfigView"))
|
||||
ParticipantShowConfigView::ParticipantShowConfigView(LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_configAlarmModel(nullptr),
|
||||
m_alarmHistoryModel(nullptr), m_dtc(nullptr), m_almFtc(nullptr), m_session(session),
|
||||
m_ui(new Ui::ParticipantShowConfigView), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_logger(AlarmManagement::getLogger("ParticipantShowConfigView"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &ParticipantShowConfigView::onSelectionChanged);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&ParticipantShowConfigView::onSelectionChanged);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ParticipantShowConfigView::onShowAlarm);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&ParticipantShowConfigView::onShowAlarm);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ParticipantShowConfigView::onRemoveAlarm);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantShowConfigView::onPrint);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_Config_Participant_Alarms"));
|
||||
|
||||
}
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ParticipantShowConfigView::onRemoveAlarm);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantShowConfigView::onPrint);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_Config_Participant_Alarms"));
|
||||
}
|
||||
|
||||
ParticipantShowConfigView::~ParticipantShowConfigView()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- ParticipantShowConfigView Destruktor() ";
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "--- ParticipantShowConfigView Destruktor() ";
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Show Config Participant Alarms"));
|
||||
translate(m_ui, tr("Show Config Participant Alarms"));
|
||||
}
|
||||
|
||||
bool ParticipantShowConfigView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
|
||||
bool ParticipantShowConfigView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc)
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc || !ftc)
|
||||
return false;
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc || !ftc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_almFtc = ftc;
|
||||
m_alarmHistoryModel = new AlarmManagement::AlarmHistoryModel(this);
|
||||
m_alarmHistoryModel->initModel(dtc, ppmDtc, aesDtc);
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView::init ";
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, m_alarmHistoryModel, false);
|
||||
m_ui->widget->setModel(m_configAlarmModel);
|
||||
return true;
|
||||
}
|
||||
m_dtc = dtc;
|
||||
m_almFtc = ftc;
|
||||
m_alarmHistoryModel = new AlarmManagement::AlarmHistoryModel(this);
|
||||
m_alarmHistoryModel->initModel(dtc, ppmDtc, aesDtc);
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- ParticipantShowConfigView::init ";
|
||||
m_configAlarmModel = new AlarmManagement::ConfigAlarmModel(this);
|
||||
m_configAlarmModel->initModel(m_dtc, ppmDtc, m_alarmHistoryModel, false);
|
||||
m_ui->widget->setModel(m_configAlarmModel);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onSelectionChanged()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, cntSelectedRows == 1);
|
||||
}
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, cntSelectedRows == 1);
|
||||
}
|
||||
|
||||
|
||||
void ParticipantShowConfigView::onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject)
|
||||
void ParticipantShowConfigView::onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger)<<"onConfigureAlarmsReply"<<replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "onConfigureAlarmsReply" << replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onShowAlarm()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- onShowAlarm() ";
|
||||
}
|
||||
|
||||
|
||||
INFO_LOG(m_logger) << "--- onShowAlarm() ";
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onRemoveAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm"
|
||||
<< " id = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).id()
|
||||
<< " eventTypeId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).eventTypeId()
|
||||
<< " operatorId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).operatorId()
|
||||
<< " participantId = "<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).participantId();
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm"
|
||||
<< " id = " << m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).id()
|
||||
<< " eventTypeId = "
|
||||
<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).eventTypeId()
|
||||
<< " operatorId = "
|
||||
<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).operatorId()
|
||||
<< " participantId = "
|
||||
<< m_configAlarmModel->getRowData(m_ui->widget->currentIndex().row()).participantId();
|
||||
|
||||
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
const AlarmManagement::AlarmConfig &rowdata = m_configAlarmModel->getRowData(curIdx.row());
|
||||
int operatorId = rowdata.operatorId();
|
||||
std::vector<int32_t> ddsParticipantIds;
|
||||
ddsParticipantIds.push_back(rowdata.participantId());
|
||||
bool globalEvent = true;
|
||||
bool remove = true;
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
alarmsDds.resize(1);
|
||||
alarmsDds[0].setMarker(false);
|
||||
alarmsDds[0].messageWindow(false);
|
||||
alarmsDds[0].eventTypeId(rowdata.eventTypeId());
|
||||
AlarmManagement::ConfigureAlarmsRequest request(alarmsDds, operatorId, ddsParticipantIds, globalEvent, remove);
|
||||
|
||||
m_requestHelper->startSingleRequest([request, this]()
|
||||
{
|
||||
return m_almFtc->configureAlarmsRequest(request, this);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
const AlarmManagement::AlarmConfig& rowdata = m_configAlarmModel->getRowData(curIdx.row());
|
||||
int operatorId = rowdata.operatorId();
|
||||
std::vector<int32_t> ddsParticipantIds;
|
||||
ddsParticipantIds.push_back(rowdata.participantId());
|
||||
bool globalEvent = true;
|
||||
bool remove = true;
|
||||
std::vector<AlarmManagement::AlarmAction> alarmsDds;
|
||||
alarmsDds.resize(1);
|
||||
alarmsDds[0].setMarker(false);
|
||||
alarmsDds[0].messageWindow(false);
|
||||
alarmsDds[0].eventTypeId(rowdata.eventTypeId());
|
||||
AlarmManagement::ConfigureAlarmsRequest request(alarmsDds, operatorId, ddsParticipantIds, globalEvent, remove);
|
||||
|
||||
m_requestHelper->startSingleRequest([request, this]() {
|
||||
return m_almFtc->configureAlarmsRequest(request, this);
|
||||
});
|
||||
}
|
||||
|
||||
void ParticipantShowConfigView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+36
-38
@@ -1,65 +1,63 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_config_alarm_model.h>
|
||||
#include <Services/AlarmManagement/alm_dtc.h>
|
||||
#include <Services/AlarmManagement/alm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantShowConfigView;
|
||||
}
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
|
||||
class ParticipantShowConfigView : public LtsWidgets::LtsDialog
|
||||
, protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
class ParticipantShowConfigView : public LtsWidgets::LtsDialog,
|
||||
protected AlarmManagement::Interface::Ftc::ConfigureAlarmsReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantShowConfigView(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~ParticipantShowConfigView();
|
||||
public:
|
||||
explicit ParticipantShowConfigView(LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~ParticipantShowConfigView();
|
||||
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc);
|
||||
bool init(const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc>& aesDtc);
|
||||
|
||||
private Q_SLOTS:
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onPrint();
|
||||
|
||||
private Q_SLOTS:
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowAlarm();
|
||||
void onRemoveAlarm();
|
||||
void onPrint();
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
protected:
|
||||
private:
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
private:
|
||||
AlarmManagement::ConfigAlarmModel* m_configAlarmModel;
|
||||
AlarmManagement::AlarmHistoryModel* m_alarmHistoryModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
|
||||
private:
|
||||
void tableColumnOrganiserSetting() override;
|
||||
LtsSession::LtsSession* m_session;
|
||||
Ui::ParticipantShowConfigView* m_ui;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
private:
|
||||
AlarmManagement::ConfigAlarmModel *m_configAlarmModel;
|
||||
AlarmManagement::AlarmHistoryModel *m_alarmHistoryModel;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AlarmManagement::Interface::Ftc> m_almFtc;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::ParticipantShowConfigView *m_ui;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
AlarmManagement::
|
||||
AlarmManagement::
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ParticipantAlarms
|
||||
Executable → Regular
+143
-175
@@ -1,264 +1,232 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_emergency_call_dialog.h"
|
||||
#include "ui_alm_emergency_call_dialog.h"
|
||||
|
||||
#include "AlarmManagement/Gui/EmergencyCalls/alm_emergency_call_model.h"
|
||||
#include <Services/AlarmManagement/alm_operator_rights.h>
|
||||
#include "ui_alm_emergency_call_dialog.h"
|
||||
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include <Services/AlarmManagement/alm_operator_rights.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
|
||||
EmergencyCallDialog::EmergencyCallDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::EmergencyCallDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
EmergencyCallDialog::EmergencyCallDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_session(nullptr), m_ui(new Ui::EmergencyCallDialog), m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
void EmergencyCallDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Emergency Call "));
|
||||
translate(m_ui, tr("Emergency Call "));
|
||||
}
|
||||
|
||||
bool EmergencyCallDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
LtsSession::LtsSession *session)
|
||||
bool EmergencyCallDialog::init(const std::shared_ptr<AlarmManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc,
|
||||
LtsSession::LtsSession* session)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START ";
|
||||
if (!ftc || !dtc || !session){
|
||||
ERROR_LOG(m_logger)<<" init Emergency call dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START ";
|
||||
if (!ftc || !dtc || !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " init Emergency call dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_session = session;
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_session = session;
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
|
||||
delete m_model;
|
||||
m_model = new AlarmManagement::EmergencyCallModel(this);
|
||||
m_model->initModel(m_dtc, opmDtc);
|
||||
|
||||
delete m_model;
|
||||
m_model = new AlarmManagement::EmergencyCallModel(this);
|
||||
m_model->initModel(m_dtc, opmDtc);
|
||||
m_proxyModel = new EmergencyCallProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->emergencyCallView->setModel(m_proxyModel);
|
||||
m_proxyModel->hideByExerciseStopped(m_session->exerciseState() != LtsWidgets::ExcState::eStarted &&
|
||||
m_session->exerciseState() != LtsWidgets::ExcState::ePaused);
|
||||
m_ui->emergencyCallView->setSortingEnabled(true);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::SAMPLE_TIME, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::POSITION, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::DELETED_TIMESTAMP, 300);
|
||||
|
||||
m_proxyModel = new EmergencyCallProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->emergencyCallView->setModel(m_proxyModel);
|
||||
m_proxyModel->hideByExerciseStopped(m_session->exerciseState()!=LtsWidgets::ExcState::eStarted &&
|
||||
m_session->exerciseState() != LtsWidgets::ExcState::ePaused);
|
||||
m_ui->emergencyCallView->setSortingEnabled(true);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::SAMPLE_TIME, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::POSITION, 300);
|
||||
m_ui->emergencyCallView->resizeSection(EmergencyCallModel::Columns::DELETED_TIMESTAMP, 300);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Acknowledge"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Center"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Acknowledge"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Center"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &EmergencyCallDialog::onEditBtCliked);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &EmergencyCallDialog::onEditBtCliked);
|
||||
const bool& hasOperatorRightEmergencyCall =
|
||||
LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(hasOperatorRightEmergencyCall);
|
||||
|
||||
const bool &hasOperatorRightEmergencyCall = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(hasOperatorRightEmergencyCall);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &EmergencyCallDialog::onFindEmergencyOnMap);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &EmergencyCallDialog::onFindEmergencyOnMap);
|
||||
QCheckBox* cbExpired = new QCheckBox(tr("Show expired"), m_ui->emergencyCallView);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->emergencyCallView->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &EmergencyCallDialog::onSetShowExpired);
|
||||
|
||||
|
||||
|
||||
QCheckBox *cbExpired = new QCheckBox(tr("Show expired"), m_ui->emergencyCallView);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->emergencyCallView->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &EmergencyCallDialog::onSetShowExpired);
|
||||
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::signalSelectionChanged, this, &EmergencyCallDialog::enaDisa);
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::doubleClicked, this, &EmergencyCallDialog::onEmergencyIndexDoubleClicked);
|
||||
enaDisa();
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&EmergencyCallDialog::enaDisa);
|
||||
connect(m_ui->emergencyCallView, &LtsDataView::LtsDataView::doubleClicked, this,
|
||||
&EmergencyCallDialog::onEmergencyIndexDoubleClicked);
|
||||
enaDisa();
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::ID);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::SAMPLE_TIME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::NAME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::EXPIRED);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::ID);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::SAMPLE_TIME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::NAME);
|
||||
m_ui->emergencyCallView->hideColumn(EmergencyCallModel::EXPIRED);
|
||||
#endif
|
||||
|
||||
INFO_LOG(m_logger) << "EmergencyCallDialog::init done";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
INFO_LOG(m_logger) << "EmergencyCallDialog::init done";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::enaDisa()
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
|
||||
if (!sos.expired())
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
if (!sos.expired())
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AlmEmergencyCall EmergencyCallDialog::getSelectedSOS()
|
||||
{
|
||||
QModelIndexList indexList = m_ui->emergencyCallView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return {};
|
||||
QModelIndexList indexList = m_ui->emergencyCallView->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return {};
|
||||
|
||||
return m_model->getRowData(indexList.front().row());
|
||||
return m_model->getRowData(indexList.front().row());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::setAcknowledgeUi()
|
||||
{
|
||||
LtsWidgets::LtsFramelessDialog *popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout *lay = new QVBoxLayout(popup);
|
||||
QLineEdit *le = new QLineEdit(popup);
|
||||
QLabel *lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
LtsWidgets::LtsFramelessDialog* popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox* btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout* lay = new QVBoxLayout(popup);
|
||||
QLineEdit* le = new QLineEdit(popup);
|
||||
QLabel* lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup,
|
||||
&LtsWidgets::LtsFramelessDialog::accept);
|
||||
|
||||
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString &text)
|
||||
{
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]()
|
||||
{
|
||||
sendAcknowledgeEmergency(le->text());
|
||||
popup->accept();
|
||||
});
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString& text) {
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]() {
|
||||
sendAcknowledgeEmergency(le->text());
|
||||
popup->accept();
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onEditBtCliked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
setAcknowledgeUi();
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
setAcknowledgeUi();
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onSetShowExpired(bool show)
|
||||
{
|
||||
if (m_proxyModel)
|
||||
m_proxyModel->setShowExpired(show);
|
||||
if (m_proxyModel)
|
||||
m_proxyModel->setShowExpired(show);
|
||||
|
||||
|
||||
if (!m_updateSOSGuard)
|
||||
m_updateSOSGuard = QSharedPointer<UpdateSOSGuard>(new UpdateSOSGuard(m_sitMapGuiIfc));
|
||||
m_updateSOSGuard->showExpiredSOS(show);
|
||||
if (!m_updateSOSGuard)
|
||||
m_updateSOSGuard = QSharedPointer<UpdateSOSGuard>(new UpdateSOSGuard(m_sitMapGuiIfc));
|
||||
m_updateSOSGuard->showExpiredSOS(show);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onFindEmergencyOnMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0)
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(sos.position().lon(), sos.position().lat()));
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(sos.position().lon(), sos.position().lat()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::onEmergencyIndexDoubleClicked(const QModelIndex &index)
|
||||
void EmergencyCallDialog::onEmergencyIndexDoubleClicked(const QModelIndex& index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
emit openInfoDlg(getSelectedSOS().id());
|
||||
Q_UNUSED(index)
|
||||
emit openInfoDlg(getSelectedSOS().id());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallDialog::sendAcknowledgeEmergency(const QString &comment)
|
||||
void EmergencyCallDialog::sendAcknowledgeEmergency(const QString& comment)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
const AlmEmergencyCall &sos = getSelectedSOS();
|
||||
if (sos.id() <= 0 || sos.expired())
|
||||
return;
|
||||
const AlmEmergencyCall& sos = getSelectedSOS();
|
||||
if (sos.id() <= 0 || sos.expired())
|
||||
return;
|
||||
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(sos.id());
|
||||
request.issi(sos.issi());
|
||||
request.name(sos.name());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(sos.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->emergencyCallAcknowledgeRequest(request, this);
|
||||
});
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(sos.id());
|
||||
request.issi(sos.issi());
|
||||
request.name(sos.name());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(sos.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_ftc->emergencyCallAcknowledgeRequest(request, this); });
|
||||
|
||||
enaDisa();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
enaDisa();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void EmergencyCallDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->emergencyCallView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->emergencyCallView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
EmergencyCallDialog::~EmergencyCallDialog()
|
||||
{
|
||||
|
||||
|
||||
|
||||
delete m_ui;
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+141
-163
@@ -1,242 +1,220 @@
|
||||
|
||||
|
||||
|
||||
#include "alm_emergency_call_info_dialog.h"
|
||||
|
||||
#include "ui_alm_emergency_call_info_dialog.h"
|
||||
|
||||
#include <AlarmManagement/alm_operator_rights.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <AlarmManagement/alm_operator_rights.h>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
QImage renderEmergencySymbol(bool expired = false)
|
||||
{
|
||||
int size = 64;
|
||||
QImage image(size, size, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
int size = 64;
|
||||
QImage image(size, size, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QPen pen(Qt::white);
|
||||
pen.setWidth(3);
|
||||
painter.setPen(pen);
|
||||
QPen pen(Qt::white);
|
||||
pen.setWidth(3);
|
||||
painter.setPen(pen);
|
||||
|
||||
painter.setBrush( expired ? QBrush(Qt::gray) : QBrush(Qt::red));
|
||||
painter.drawEllipse(QPointF(image.rect().center()),
|
||||
image.rect().width() * 0.45,
|
||||
image.rect().height() * 0.45);
|
||||
painter.setBrush(expired ? QBrush(Qt::gray) : QBrush(Qt::red));
|
||||
painter.drawEllipse(QPointF(image.rect().center()), image.rect().width() * 0.45, image.rect().height() * 0.45);
|
||||
|
||||
painter.setPen(QPen(Qt::white));
|
||||
painter.setPen(QPen(Qt::white));
|
||||
|
||||
QFont font = painter.font();
|
||||
font.setBold(true);
|
||||
font.setPixelSize(26);
|
||||
painter.setFont(font);
|
||||
QFont font = painter.font();
|
||||
font.setBold(true);
|
||||
font.setPixelSize(26);
|
||||
painter.setFont(font);
|
||||
|
||||
QPointF pos(image.width() * 0.125,
|
||||
image.height() * 0.625);
|
||||
QPointF pos(image.width() * 0.125, image.height() * 0.625);
|
||||
|
||||
painter.drawText(pos, QLatin1String("SOS"));
|
||||
painter.drawText(pos, QLatin1String("SOS"));
|
||||
|
||||
return image;
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EmergencyCallInfoDialog::EmergencyCallInfoDialog(int entryId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::EmergencyCallInfoDialog)
|
||||
EmergencyCallInfoDialog::EmergencyCallInfoDialog(int entryId, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::EmergencyCallInfoDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_emergency.id(entryId);
|
||||
m_ui->setupUi(this);
|
||||
m_emergency.id(entryId);
|
||||
}
|
||||
|
||||
EmergencyCallInfoDialog::~EmergencyCallInfoDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EmergencyCallInfoDialog::init(const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>&opmDtc)
|
||||
bool EmergencyCallInfoDialog::init(const std::shared_ptr<Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger)<<" init Emergency call Info dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " init Emergency call Info dialog failed !!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
m_dtc->enableAlmEmergencyCall();
|
||||
m_ftc->enableEmergencyCallAcknowledge();
|
||||
|
||||
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
setUiValues();
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
setUiValues();
|
||||
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::almEmergencyCallChanged, this, &EmergencyCallInfoDialog::onEmergencyCallChanged );
|
||||
connect(m_ui->pbAckEmergency, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onPbAckEmergencyClicked );
|
||||
connect(m_ui->pbEmergencyCallFindOnMap, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onFindEmergencyOnMap);
|
||||
connect(m_dtc.get(), &AlarmManagement::Interface::Dtc::almEmergencyCallChanged, this,
|
||||
&EmergencyCallInfoDialog::onEmergencyCallChanged);
|
||||
connect(m_ui->pbAckEmergency, &QPushButton::clicked, this, &EmergencyCallInfoDialog::onPbAckEmergencyClicked);
|
||||
connect(m_ui->pbEmergencyCallFindOnMap, &QPushButton::clicked, this,
|
||||
&EmergencyCallInfoDialog::onFindEmergencyOnMap);
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString EmergencyCallInfoDialog::emergencyIdentifier() const
|
||||
{
|
||||
return QStringLiteral("emergency_") + QString::number(m_emergency.id());
|
||||
return QStringLiteral("emergency_") + QString::number(m_emergency.id());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EmergencyCallInfoDialog::setUiValues()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!m_dtc || !m_ftc || m_emergency.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger)<<" >> unabled to init EmergencyCallInfoDialog";
|
||||
return false;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (!m_dtc || !m_ftc || m_emergency.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " >> unabled to init EmergencyCallInfoDialog";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->lblEquipNr->setText(QString::number(m_emergency.issi()));
|
||||
m_ui->lblIncomingTime->setText(DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.incomingTime())));
|
||||
m_ui->lblStatus->setText(m_emergency.expired() ? DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.deleted())) : QStringLiteral("--"));
|
||||
m_ui->lblComment->setText(QString::fromStdString(m_emergency.comment()));
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(m_emergency.position().lon(), m_emergency.position().lat());
|
||||
m_ui->lblPosition->setText(mgrs);
|
||||
m_ui->lblEquipNr->setText(QString::number(m_emergency.issi()));
|
||||
m_ui->lblIncomingTime->setText(DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.incomingTime())));
|
||||
m_ui->lblStatus->setText(m_emergency.expired()
|
||||
? DTG::toString(QDateTime::fromMSecsSinceEpoch(m_emergency.deleted()))
|
||||
: QStringLiteral("--"));
|
||||
m_ui->lblComment->setText(QString::fromStdString(m_emergency.comment()));
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(m_emergency.position().lon(), m_emergency.position().lat());
|
||||
m_ui->lblPosition->setText(mgrs);
|
||||
|
||||
|
||||
const bool &hasOperatorRightEmergencyCall = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_ui->pbAckEmergency->setIcon(QIcon(QStringLiteral("icon:edit.svg")));
|
||||
m_ui->pbAckEmergency->setEnabled(m_emergency.expired() ? false : true);
|
||||
m_ui->pbAckEmergency->setVisible(hasOperatorRightEmergencyCall);
|
||||
const bool& hasOperatorRightEmergencyCall =
|
||||
LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::EmergencyCall);
|
||||
m_ui->pbAckEmergency->setIcon(QIcon(QStringLiteral("icon:edit.svg")));
|
||||
m_ui->pbAckEmergency->setEnabled(m_emergency.expired() ? false : true);
|
||||
m_ui->pbAckEmergency->setVisible(hasOperatorRightEmergencyCall);
|
||||
|
||||
|
||||
QPixmap iconPixmap = QPixmap::fromImage(renderEmergencySymbol(m_emergency.expired()));
|
||||
m_ui->lblIcon->setPixmap(iconPixmap);
|
||||
QPixmap iconPixmap = QPixmap::fromImage(renderEmergencySymbol(m_emergency.expired()));
|
||||
m_ui->lblIcon->setPixmap(iconPixmap);
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallInfoDialog::onEmergencyCallChanged(AlarmManagement::AlmEmergencyCall data, DataModification modType)
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (data.id() != m_emergency.id() || data.id() == 0)
|
||||
return;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
if (data.id() != m_emergency.id() || data.id() == 0)
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_ui->pbAckEmergency->setEnabled(false);
|
||||
m_ui->pbEmergencyCallFindOnMap->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
m_emergency = data;
|
||||
setUiValues();
|
||||
}
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_ui->pbAckEmergency->setEnabled(false);
|
||||
m_ui->pbEmergencyCallFindOnMap->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
m_emergency = data;
|
||||
setUiValues();
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallInfoDialog::onFindEmergencyOnMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc || m_emergency.id() <= 0)
|
||||
return;
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(m_emergency.position().lon(), m_emergency.position().lat()));
|
||||
if (!m_sitMapGuiIfc || m_emergency.id() <= 0)
|
||||
return;
|
||||
m_sitMapGuiIfc->setCenterPoint(QPointF(m_emergency.position().lon(), m_emergency.position().lat()));
|
||||
}
|
||||
|
||||
void EmergencyCallInfoDialog::onPbAckEmergencyClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
|
||||
LtsWidgets::LtsFramelessDialog *popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout *lay = new QVBoxLayout(popup);
|
||||
QLineEdit *le = new QLineEdit(popup);
|
||||
QLabel *lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
LtsWidgets::LtsFramelessDialog* popup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
LtsWidgets::LtsDialogButtonBox* btnBox = new LtsWidgets::LtsDialogButtonBox(popup);
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(false);
|
||||
QVBoxLayout* lay = new QVBoxLayout(popup);
|
||||
QLineEdit* le = new QLineEdit(popup);
|
||||
QLabel* lblTxt = new QLabel(tr("Acknowledged by:"), popup);
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup, &LtsWidgets::LtsFramelessDialog::accept);
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, popup,
|
||||
&LtsWidgets::LtsFramelessDialog::accept);
|
||||
|
||||
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString &text)
|
||||
{
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
connect(le, &QLineEdit::textChanged, this, [btnBox](const QString& text) {
|
||||
const int textMinSize = 5;
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(text.trimmed().size() >= textMinSize);
|
||||
});
|
||||
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]()
|
||||
{
|
||||
const QString c = le->text().trimmed();
|
||||
sendAcknowledgeEmergencyCallRequest(c);
|
||||
popup->accept();
|
||||
});
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, [this, le, popup]() {
|
||||
const QString c = le->text().trimmed();
|
||||
sendAcknowledgeEmergencyCallRequest(c);
|
||||
popup->accept();
|
||||
});
|
||||
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
lay->addWidget(lblTxt);
|
||||
lay->addWidget(le);
|
||||
lay->addWidget(btnBox);
|
||||
popup->setLayout(lay);
|
||||
popup->setMinimumWidth(350);
|
||||
popup->show();
|
||||
le->setFocus();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EmergencyCallInfoDialog::sendAcknowledgeEmergencyCallRequest(const QString &comment)
|
||||
void EmergencyCallInfoDialog::sendAcknowledgeEmergencyCallRequest(const QString& comment)
|
||||
{
|
||||
if (m_emergency.id() <= 0)
|
||||
return ;
|
||||
if (m_emergency.id() <= 0)
|
||||
return;
|
||||
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(m_emergency.id());
|
||||
request.name(m_emergency.name());
|
||||
request.issi(m_emergency.issi());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(m_emergency.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
bool ret = m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->emergencyCallAcknowledgeRequest(request, this);
|
||||
});
|
||||
EmergencyCallAcknowledgeRequest request;
|
||||
request.id(m_emergency.id());
|
||||
request.name(m_emergency.name());
|
||||
request.issi(m_emergency.issi());
|
||||
request.timestamp(QDateTime::currentMSecsSinceEpoch());
|
||||
request.incomingTime(m_emergency.incomingTime());
|
||||
request.expired(true);
|
||||
request.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
request.comment(comment.toStdString());
|
||||
bool ret = m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_ftc->emergencyCallAcknowledgeRequest(request, this); });
|
||||
|
||||
if (ret)
|
||||
setUiValues();
|
||||
if (ret)
|
||||
setUiValues();
|
||||
}
|
||||
|
||||
void EmergencyCallInfoDialog::retranslate()
|
||||
{
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
const QString lbName = tr("SOS_%1").arg(m_emergency.issi());
|
||||
translate(m_ui, lbName);
|
||||
m_emergency = m_dtc->almEmergencyCall(m_emergency.id());
|
||||
const QString lbName = tr("SOS_%1").arg(m_emergency.issi());
|
||||
translate(m_ui, lbName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AlarmManagement
|
||||
Executable → Regular
+52
-53
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AlarmManagement/alm_dtc.h>
|
||||
@@ -8,7 +7,6 @@
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace AlarmManagement
|
||||
@@ -16,67 +14,68 @@ namespace AlarmManagement
|
||||
|
||||
class EmergencyCallModel : public LtsWidgets::LtsAbstractTableModel<AlarmManagement::AlmEmergencyCall>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ID,
|
||||
SAMPLE_TIME,
|
||||
INCOMING_TIME,
|
||||
NAME,
|
||||
ISSI,
|
||||
POSITION,
|
||||
EXPIRED,
|
||||
OPERATION_ID,
|
||||
DELETED_TIMESTAMP,
|
||||
COMMENT
|
||||
};
|
||||
explicit EmergencyCallModel(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns {
|
||||
ID,
|
||||
SAMPLE_TIME,
|
||||
INCOMING_TIME,
|
||||
NAME,
|
||||
ISSI,
|
||||
POSITION,
|
||||
EXPIRED,
|
||||
OPERATION_ID,
|
||||
DELETED_TIMESTAMP,
|
||||
COMMENT
|
||||
};
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
|
||||
explicit EmergencyCallModel(QObject* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void onAlarmEmergencyCallChanged(const AlarmManagement::AlmEmergencyCall &data, const DataModification modType);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
friend class EmergencyCallProxyModel;
|
||||
QVariant data(const QModelIndex& index, int role) const override final;
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc);
|
||||
|
||||
private slots:
|
||||
void onAlarmEmergencyCallChanged(const AlarmManagement::AlmEmergencyCall& data, const DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AlarmManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
friend class EmergencyCallProxyModel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class EmergencyCallProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
bool showExpired() const { return m_showExpired; }
|
||||
bool exerciseStopped()const {return m_hideByExerciseStopped;}
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
void hideByExerciseStopped(bool show);
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
public slots:
|
||||
void setShowExpired(bool show);
|
||||
bool showExpired() const
|
||||
{
|
||||
return m_showExpired;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override final;
|
||||
bool exerciseStopped() const
|
||||
{
|
||||
return m_hideByExerciseStopped;
|
||||
}
|
||||
|
||||
private:
|
||||
bool checkFilter(int source_row) const;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
void hideByExerciseStopped(bool show);
|
||||
|
||||
private:
|
||||
bool m_showExpired{false};
|
||||
bool m_hideByExerciseStopped{false};
|
||||
EmergencyCallModel *m_sourceModel{nullptr};
|
||||
public slots:
|
||||
void setShowExpired(bool show);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override final;
|
||||
|
||||
private:
|
||||
bool checkFilter(int source_row) const;
|
||||
|
||||
private:
|
||||
bool m_showExpired{false};
|
||||
bool m_hideByExerciseStopped{false};
|
||||
EmergencyCallModel* m_sourceModel{nullptr};
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace AlarmManagement
|
||||
Reference in new issue
Block a user