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
+259
-275
@@ -1,347 +1,331 @@
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <ChargeEffect/aes_charge_effect_edit.h>
|
||||
#include <ChargeEffect/aes_charge_effect_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/NContamination/aes_ncontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Explosion/aes_explosion_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineArea/aes_mine_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineCorridor/aes_mine_corridor_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/GasPipe/aes_gas_pipe_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/DangerArea/aes_danger_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Borderline/aes_borderline_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/FunctionalArea/aes_functional_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineSingleVirtual/aes_mine_single_virtual_gui_plugin_interface.h>
|
||||
#include "aes_charge_effect_item_info.h"
|
||||
|
||||
#include "aes_translation.h"
|
||||
#include "aes_charge_effect_item_info.h"
|
||||
#include "ui_aes_charge_effect_item_info.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ChargeEffect/aes_charge_effect_edit.h>
|
||||
#include <ChargeEffect/aes_charge_effect_gui_plugin_interface.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Borderline/aes_borderline_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/DangerArea/aes_danger_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Explosion/aes_explosion_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/FunctionalArea/aes_functional_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/GasPipe/aes_gas_pipe_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineArea/aes_mine_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineCorridor/aes_mine_corridor_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineSingleVirtual/aes_mine_single_virtual_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/NContamination/aes_ncontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesChargeEffectItemInfo::AesChargeEffectItemInfo(int chargeEffectId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(nullptr)
|
||||
, m_ChargeEffectId(chargeEffectId)
|
||||
, m_ui(new Ui::AesChargeEffectItemInfo)
|
||||
AesChargeEffectItemInfo::AesChargeEffectItemInfo(int chargeEffectId, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_session(nullptr),
|
||||
m_ChargeEffectId(chargeEffectId), m_ui(new Ui::AesChargeEffectItemInfo)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->lblChargeEffectId->setText(QString::number(m_ChargeEffectId));
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onFindOnMap);
|
||||
connect(m_ui->pbDetails, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onShowDetails);
|
||||
m_ui->lblChargeEffectId->setText(QString::number(m_ChargeEffectId));
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onFindOnMap);
|
||||
connect(m_ui->pbDetails, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onShowDetails);
|
||||
}
|
||||
|
||||
AesChargeEffectItemInfo::~AesChargeEffectItemInfo()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AesChargeEffectItemInfo::init(LtsSession::LtsSession *session)
|
||||
bool AesChargeEffectItemInfo::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
return false;
|
||||
}
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get aesDtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_aesDtc->isAesItemViewEnabled())
|
||||
m_aesDtc->enableAesItemView();
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get aesDtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_aesDtc->isAesItemViewEnabled())
|
||||
m_aesDtc->enableAesItemView();
|
||||
|
||||
if (!m_pdmDtc->isChargeTypeEnabled())
|
||||
m_pdmDtc->enableChargeType();
|
||||
if (!m_pdmDtc->isChargeTypeEnabled())
|
||||
m_pdmDtc->enableChargeType();
|
||||
|
||||
const ChargeEffect data = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
|
||||
m_ui->lblPosition->hide();
|
||||
|
||||
const ChargeEffect data = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
|
||||
m_ui->lblPosition->hide();
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lbxChargeEffectId->hide();
|
||||
m_ui->lblChargeEffectId->hide();
|
||||
m_ui->lbxChargeTypeId->hide();
|
||||
m_ui->lblChargeTypeId->hide();
|
||||
m_ui->lbxOriginatorId->hide();
|
||||
m_ui->lblOriginatorId->hide();
|
||||
m_ui->lbxOriginatorType->hide();
|
||||
m_ui->lblOriginatorType->hide();
|
||||
m_ui->lbxChargeEffectId->hide();
|
||||
m_ui->lblChargeEffectId->hide();
|
||||
m_ui->lbxChargeTypeId->hide();
|
||||
m_ui->lblChargeTypeId->hide();
|
||||
m_ui->lbxOriginatorId->hide();
|
||||
m_ui->lblOriginatorId->hide();
|
||||
m_ui->lbxOriginatorType->hide();
|
||||
m_ui->lblOriginatorType->hide();
|
||||
#endif
|
||||
|
||||
m_ui->lblOriginatorId->setText(QString::number(data.originatorId()));
|
||||
m_ui->lblOriginatorType->setText(QString::number(data.originatorTypeId().underlying()));
|
||||
m_ui->lblOriginatorId->setText(QString::number(data.originatorId()));
|
||||
m_ui->lblOriginatorType->setText(QString::number(data.originatorTypeId().underlying()));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Charge_Effect"));
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Charge_Effect"));
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::chargeEffectChanged, this,
|
||||
&AesChargeEffectItemInfo::onChargeEffectChanged);
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::chargeEffectChanged,
|
||||
this, &AesChargeEffectItemInfo::onChargeEffectChanged);
|
||||
handleChargeEffect(data);
|
||||
|
||||
handleChargeEffect(data);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::retranslate()
|
||||
{
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
translate(m_ui, tr("ChargeEffect: \"%1\"").arg(QString::fromStdString(item.name()), 1, QLatin1Char('?')));
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onFindOnMap() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onFindOnMap() aesId: "<<m_ChargeEffectId;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToChargeEffectObject(m_ChargeEffectId);
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << "getForeignGuiInterface<SituationMap::ForeignGuiInterface> failed!";
|
||||
DEBUG_LOG(m_logger) << "onFindOnMap() aesId: " << m_ChargeEffectId;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToChargeEffectObject(m_ChargeEffectId);
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << "getForeignGuiInterface<SituationMap::ForeignGuiInterface> failed!";
|
||||
}
|
||||
|
||||
template <typename InterfaceType>
|
||||
bool AesChargeEffectItemInfo::tryShowStandardEditDialog(const AesItemView& aiv)
|
||||
template <typename InterfaceType> bool AesChargeEffectItemInfo::tryShowStandardEditDialog(const AesItemView& aiv)
|
||||
{
|
||||
std::shared_ptr<InterfaceType> ifc;
|
||||
if (m_session->getForeignGuiInterface<InterfaceType>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(aiv.aesItemId(), this);
|
||||
if (dialog)
|
||||
std::shared_ptr<InterfaceType> ifc;
|
||||
if (m_session->getForeignGuiInterface<InterfaceType>(ifc))
|
||||
{
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(aiv.aesItemId(), this);
|
||||
if (dialog)
|
||||
{
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface failed for specific AES interface!";
|
||||
return false;
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface failed for specific AES interface!";
|
||||
return false;
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onShowDetails()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
|
||||
if (item.originatorTypeId() == ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation)
|
||||
{
|
||||
AesItemView aiv;
|
||||
m_aesDtc->aesItemViewFromEntityId(item.originatorId(), AreaEffectSimulation::AesType::AtUnknown, aiv);
|
||||
DEBUG_LOG(m_logger) << "aiv.id():" << aiv.id() << ", aesType: " << aiv.aesTypeId();
|
||||
if (item.originatorTypeId() == ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation)
|
||||
{
|
||||
AesItemView aiv;
|
||||
m_aesDtc->aesItemViewFromEntityId(item.originatorId(), AreaEffectSimulation::AesType::AtUnknown, aiv);
|
||||
DEBUG_LOG(m_logger) << "aiv.id():" << aiv.id() << ", aesType: " << aiv.aesTypeId();
|
||||
|
||||
|
||||
auto registerDialog = [this](AreaEffectSimulation::BaseEdit* dialog) {
|
||||
if (dialog) {
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
};
|
||||
auto registerDialog = [this](AreaEffectSimulation::BaseEdit* dialog) {
|
||||
if (dialog)
|
||||
{
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
};
|
||||
|
||||
switch(aiv.aesTypeId().underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesType::AtNContamination:
|
||||
{
|
||||
tryShowStandardEditDialog<AesNContamination::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtMineArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesMineArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtMineCorridor:
|
||||
{
|
||||
tryShowStandardEditDialog<AesMineCorridor::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtGasPipe:
|
||||
{
|
||||
tryShowStandardEditDialog<AesGasPipe::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtDangerArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesDangerArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBorderline:
|
||||
{
|
||||
tryShowStandardEditDialog<AesBorderline::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtFunctionalArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesFunctionalArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtBCContamination:
|
||||
{
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
if (gearClass == ProjectDataManagement::GearClass_def::Biological)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), false, this));
|
||||
else if (gearClass == ProjectDataManagement::GearClass_def::Chemical)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), true, this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesBCContamination::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrap:
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrapSecondary:
|
||||
{
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showBoobyTrapEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMine:
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMineSecondary:
|
||||
{
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showOffRouteMineEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingle:
|
||||
case AreaEffectSimulation::AesType::AtExplosionArea:
|
||||
{
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const bool isExplosionSingle = (aiv.aesTypeId().underlying() == AreaEffectSimulation::AesType::AtExplosionSingle);
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
|
||||
for (auto gc : { ProjectDataManagement::GearClass::Artillery, ProjectDataManagement::GearClass::Mortar, ProjectDataManagement::GearClass::AirSupport })
|
||||
switch (aiv.aesTypeId().underlying())
|
||||
{
|
||||
if (gc == ProjectDataManagement::GearClass::AirSupport && !isExplosionSingle) continue;
|
||||
case AreaEffectSimulation::AesType::AtNContamination: {
|
||||
tryShowStandardEditDialog<AesNContamination::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtMineArea: {
|
||||
tryShowStandardEditDialog<AesMineArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
if (gearClass == gc)
|
||||
{
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), isExplosionSingle, false, gc, this));
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtMineCorridor: {
|
||||
tryShowStandardEditDialog<AesMineCorridor::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtGasPipe: {
|
||||
tryShowStandardEditDialog<AesGasPipe::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtDangerArea: {
|
||||
tryShowStandardEditDialog<AesDangerArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBorderline: {
|
||||
tryShowStandardEditDialog<AesBorderline::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtFunctionalArea: {
|
||||
tryShowStandardEditDialog<AesFunctionalArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtBCContamination: {
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
if (gearClass == ProjectDataManagement::GearClass_def::Biological)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), false, this));
|
||||
else if (gearClass == ProjectDataManagement::GearClass_def::Chemical)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), true, this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesBCContamination::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrap:
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrapSecondary: {
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showBoobyTrapEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMine:
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMineSecondary: {
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showOffRouteMineEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingle:
|
||||
case AreaEffectSimulation::AesType::AtExplosionArea: {
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const bool isExplosionSingle =
|
||||
(aiv.aesTypeId().underlying() == AreaEffectSimulation::AesType::AtExplosionSingle);
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
|
||||
for (auto gc :
|
||||
{ProjectDataManagement::GearClass::Artillery, ProjectDataManagement::GearClass::Mortar,
|
||||
ProjectDataManagement::GearClass::AirSupport})
|
||||
{
|
||||
if (gc == ProjectDataManagement::GearClass::AirSupport && !isExplosionSingle)
|
||||
continue;
|
||||
|
||||
if (gearClass == gc)
|
||||
{
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), isExplosionSingle, false, gc, this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtExplosionCluster:
|
||||
case AreaEffectSimulation::AesType::AtEffectCluster: {
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
|
||||
AesItem ai;
|
||||
m_aesDtc->aesItemFromId(aiv.aesItemId(), ai);
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), ai.effectSourceId(), this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger)
|
||||
<< Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtAirSupportImpact:
|
||||
case AreaEffectSimulation::AesType::AtDusSingleMine:
|
||||
case AreaEffectSimulation::AesType::AtExplosionAreaSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtMineAreaSingleMines:
|
||||
case AreaEffectSimulation::AesType::AtReconArea:
|
||||
case AreaEffectSimulation::AesType::AtTechnicalArea:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentral:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentralTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleTrajectory:
|
||||
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
case AreaEffectSimulation::AesType::AtUnknown:
|
||||
Q_ASSERT(false);
|
||||
WARNING_LOG(m_logger) << "Unknown AesType found for aesEntityId: " << aiv.aesTypeId();
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "Couldn't find AesItem to ChargeEffect (any more). Hiding the button";
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtExplosionCluster:
|
||||
case AreaEffectSimulation::AesType::AtEffectCluster:
|
||||
{
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
|
||||
AesItem ai;
|
||||
m_aesDtc->aesItemFromId(aiv.aesItemId(), ai);
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), ai.effectSourceId(), this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtAirSupportImpact:
|
||||
case AreaEffectSimulation::AesType::AtDusSingleMine:
|
||||
case AreaEffectSimulation::AesType::AtExplosionAreaSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtMineAreaSingleMines:
|
||||
case AreaEffectSimulation::AesType::AtReconArea:
|
||||
case AreaEffectSimulation::AesType::AtTechnicalArea:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentral:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentralTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleTrajectory:
|
||||
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
case AreaEffectSimulation::AesType::AtUnknown:
|
||||
Q_ASSERT(false);
|
||||
WARNING_LOG(m_logger) << "Unknown AesType found for aesEntityId: " << aiv.aesTypeId();
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "Couldn't find AesItem to ChargeEffect (any more). Hiding the button";
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<AesChargeEffect::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesChargeEffect::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(m_ChargeEffectId, this);
|
||||
if (dialog)
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface ChargeEffect failed!";
|
||||
}
|
||||
{
|
||||
std::shared_ptr<AesChargeEffect::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesChargeEffect::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(m_ChargeEffectId, this);
|
||||
if (dialog)
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " getForeignGuiInterface ChargeEffect failed!";
|
||||
}
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onChargeEffectChanged(const ChargeEffect &data, DataModification modType)
|
||||
void AesChargeEffectItemInfo::onChargeEffectChanged(const ChargeEffect& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " [onChargeEffectChanged] id: " << data.id();
|
||||
if (data.id() == m_ChargeEffectId && modType != DataModification::eRemoved)
|
||||
handleChargeEffect(data);
|
||||
DEBUG_LOG(m_logger) << " [onChargeEffectChanged] id: " << data.id();
|
||||
if (data.id() == m_ChargeEffectId && modType != DataModification::eRemoved)
|
||||
handleChargeEffect(data);
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::handleChargeEffect(const ChargeEffect &data)
|
||||
void AesChargeEffectItemInfo::handleChargeEffect(const ChargeEffect& data)
|
||||
{
|
||||
|
||||
m_ui->lblChargeEffectName->setText(QString::fromStdString(data.name()));
|
||||
|
||||
|
||||
m_ui->lblEffectStart->setText(DTG::toStringMSec(data.effectStart()));
|
||||
|
||||
m_ui->lblChargeEffectName->setText(QString::fromStdString(data.name()));
|
||||
|
||||
m_ui->lblEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
m_ui->lbxEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
m_ui->lblEffectStart->setText(DTG::toStringMSec(data.effectStart()));
|
||||
|
||||
m_ui->lblEffectDuration->setText(LtsWidgets::readableDuration(data.effectDuration()));
|
||||
m_ui->lblEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
m_ui->lbxEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
|
||||
|
||||
AreaEffectSimulation::AesEffectState st = data.state();
|
||||
m_ui->lblStatus->setText(AreaEffectSimulation::toString(st));
|
||||
m_ui->lblEffectDuration->setText(LtsWidgets::readableDuration(data.effectDuration()));
|
||||
|
||||
|
||||
m_ui->lblChargeTypeId->setText(QString::number(data.chargeTypeId()));
|
||||
AreaEffectSimulation::AesEffectState st = data.state();
|
||||
m_ui->lblStatus->setText(AreaEffectSimulation::toString(st));
|
||||
|
||||
|
||||
m_ui->lblChargeType->setText(m_pdmDtc->trChargeTypeShortName(data.chargeTypeId()));
|
||||
m_ui->lblChargeType->setToolTip(m_pdmDtc->trChargeTypeName(data.chargeTypeId()));
|
||||
m_ui->lblChargeTypeId->setText(QString::number(data.chargeTypeId()));
|
||||
|
||||
|
||||
m_ui->lblPosition->show();
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(data.position().lon(), data.position().lat());
|
||||
m_ui->lblPosition->setText(tr("Position: %1").arg(mgrs));
|
||||
m_ui->lblChargeType->setText(m_pdmDtc->trChargeTypeShortName(data.chargeTypeId()));
|
||||
m_ui->lblChargeType->setToolTip(m_pdmDtc->trChargeTypeName(data.chargeTypeId()));
|
||||
|
||||
m_ui->lblPosition->show();
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(data.position().lon(), data.position().lat());
|
||||
m_ui->lblPosition->setText(tr("Position: %1").arg(mgrs));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+96
-106
@@ -1,160 +1,150 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_danger_area_aes_item_info.h"
|
||||
#include <utility>
|
||||
|
||||
#include "ui_aes_danger_area_aes_item_info.h"
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
#include <BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
DangerAreaAesItemInfo::DangerAreaAesItemInfo(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::DangerAreaAesItemInfo)
|
||||
, m_aesItemId(-1)
|
||||
DangerAreaAesItemInfo::DangerAreaAesItemInfo(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_dtc(nullptr), m_session(nullptr),
|
||||
m_ui(new Ui::DangerAreaAesItemInfo), m_aesItemId(-1)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
DangerAreaAesItemInfo::~DangerAreaAesItemInfo()
|
||||
{
|
||||
for (const auto &item : std::as_const(m_aesItems))
|
||||
delete item.item;
|
||||
delete m_ui;
|
||||
for (const auto& item : std::as_const(m_aesItems))
|
||||
delete item.item;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::retranslate()
|
||||
{
|
||||
|
||||
std::unique_ptr<AesItem> item(new BCContamination(m_dtc->bCContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->bCContamination(m_aesItemId), tr("B/C-Contamination"));
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<AesItem> item(new BCContamination(m_dtc->bCContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->bCContamination(m_aesItemId), tr("B/C-Contamination"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new NContamination(m_dtc->nContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->nContamination(m_aesItemId), tr("N-Contamination"));
|
||||
return;
|
||||
}
|
||||
item.reset(new NContamination(m_dtc->nContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->nContamination(m_aesItemId), tr("N-Contamination"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new ExplosionArea(m_dtc->explosionArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionArea(m_aesItemId), tr("Explosion Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new ExplosionArea(m_dtc->explosionArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionArea(m_aesItemId), tr("Explosion Area"));
|
||||
return;
|
||||
}
|
||||
item.reset(new ExplosionSingle(m_dtc->explosionSingle(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionSingle(m_aesItemId), tr("Single Explosion"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new MineArea(m_dtc->mineArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->mineArea(m_aesItemId), tr("Mine Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new ExplosionSingle(m_dtc->explosionSingle(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionSingle(m_aesItemId), tr("Single Explosion"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
item.reset(new MineArea(m_dtc->mineArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->mineArea(m_aesItemId), tr("Mine Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
translate(m_ui, tr("Unknown Aes Type"));
|
||||
translate(m_ui, tr("Unknown Aes Type"));
|
||||
}
|
||||
|
||||
bool DangerAreaAesItemInfo::init(const QSet<int> &dangerAreaIds, const QSet<int> &aesItemIds, LtsSession::LtsSession *session)
|
||||
bool DangerAreaAesItemInfo::init(const QSet<int>& dangerAreaIds, const QSet<int>& aesItemIds,
|
||||
LtsSession::LtsSession* session)
|
||||
{
|
||||
if (!init(session))
|
||||
return false;
|
||||
if (!init(session))
|
||||
return false;
|
||||
|
||||
for (int dangerAreaId : dangerAreaIds)
|
||||
m_dangerAreas.insert(dangerAreaId, m_dtc->dangerArea(dangerAreaId));
|
||||
for (int aesItemId : aesItemIds)
|
||||
insertAesItem(aesItemId);
|
||||
for (int dangerAreaId : dangerAreaIds)
|
||||
m_dangerAreas.insert(dangerAreaId, m_dtc->dangerArea(dangerAreaId));
|
||||
for (int aesItemId : aesItemIds)
|
||||
insertAesItem(aesItemId);
|
||||
|
||||
m_aesItemId = aesItemIds.empty() ? -1 : *aesItemIds.begin();
|
||||
setText();
|
||||
return true;
|
||||
m_aesItemId = aesItemIds.empty() ? -1 : *aesItemIds.begin();
|
||||
setText();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DangerAreaAesItemInfo::init(LtsSession::LtsSession *session)
|
||||
bool DangerAreaAesItemInfo::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session && session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session && !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "No Session available!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session)
|
||||
m_session = session;
|
||||
if (m_session && session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session && !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "No Session available!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session)
|
||||
m_session = session;
|
||||
|
||||
if(!m_dtc.get())
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_dtc.get())
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
|
||||
setText();
|
||||
return true;
|
||||
setText();
|
||||
return true;
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::insertAesItem(int aesItemId)
|
||||
{
|
||||
AesItem *item;
|
||||
item = new BCContamination(m_dtc->bCContamination(aesItemId));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
m_aesItems.insert(aesItemId, AesStruct(AesType::AtBCContamination, item));
|
||||
return;
|
||||
}
|
||||
delete item;
|
||||
AesItem* item;
|
||||
item = new BCContamination(m_dtc->bCContamination(aesItemId));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
m_aesItems.insert(aesItemId, AesStruct(AesType::AtBCContamination, item));
|
||||
return;
|
||||
}
|
||||
delete item;
|
||||
|
||||
WARNING_LOG(m_logger) << "AesItem with id " << aesItemId << " is not of any known type!";
|
||||
WARNING_LOG(m_logger) << "AesItem with id " << aesItemId << " is not of any known type!";
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::setText()
|
||||
{
|
||||
for (const DangerArea &dangerArea : std::as_const(m_dangerAreas))
|
||||
aesItemInfo(&dangerArea);
|
||||
for (const DangerArea& dangerArea : std::as_const(m_dangerAreas))
|
||||
aesItemInfo(&dangerArea);
|
||||
|
||||
|
||||
for(const AesStruct &aesStruct : std::as_const(m_aesItems))
|
||||
{
|
||||
if(aesStruct.item->effectStateId() == AreaEffectSimulation::AesEffectState::EsActivated)
|
||||
aesItemInfo(aesStruct.item);
|
||||
}
|
||||
for (const AesStruct& aesStruct : std::as_const(m_aesItems))
|
||||
{
|
||||
if (aesStruct.item->effectStateId() == AreaEffectSimulation::AesEffectState::EsActivated)
|
||||
aesItemInfo(aesStruct.item);
|
||||
}
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::aesItemInfo(const AesItem *item)
|
||||
void DangerAreaAesItemInfo::aesItemInfo(const AesItem* item)
|
||||
{
|
||||
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> guiInterface;
|
||||
if (!m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(guiInterface) || !guiInterface)
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsDialog *info = guiInterface->showInfoWindow(item);
|
||||
m_ui->mainLayout->addWidget(info);
|
||||
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> guiInterface;
|
||||
if (!m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(guiInterface) || !guiInterface)
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsDialog* info = guiInterface->showInfoWindow(item);
|
||||
m_ui->mainLayout->addWidget(info);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+1207
-1285
File diff suppressed because it is too large.
Load diff
Executable → Regular
+93
-102
@@ -1,131 +1,122 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class AesInfoDialog;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class AesInfoDialog : public LtsWidgets::LtsDialog
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineResetReplyHandler
|
||||
class AesInfoDialog : public LtsWidgets::LtsDialog,
|
||||
protected AreaEffectSimulation::Interface::Ftc::MineResetReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AesInfoDialog(int aesEntityId, AreaEffectSimulation::AesType aesType, QWidget *parent = nullptr);
|
||||
~AesInfoDialog();
|
||||
public:
|
||||
explicit AesInfoDialog(int aesEntityId, AreaEffectSimulation::AesType aesType, QWidget* parent = nullptr);
|
||||
~AesInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc>& pdmDtc);
|
||||
|
||||
void onMineResetReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onMineResetReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
void handleNContamination(const AesItemView &aesItemView);
|
||||
void handleNContamination(const AreaEffectSimulation::NContamination &data);
|
||||
void handleBCContamination(const AesItemView &aesItemView);
|
||||
void handleBCContamination(const AreaEffectSimulation::BCContamination &data);
|
||||
void handleExplosionArea(const AesItemView &aesItemView);
|
||||
void handleExplosionArea(const AreaEffectSimulation::ExplosionArea &data);
|
||||
void handleExplosionSingle(const AesItemView &aesItemView);
|
||||
void handleExplosionSingle(const AreaEffectSimulation::ExplosionSingle &data);
|
||||
void handleMineArea(const AesItemView &aesItemView);
|
||||
void handleMineArea(const AreaEffectSimulation::MineArea &data);
|
||||
void handleMineCorridor(const AesItemView &aesItemView);
|
||||
void handleMineCorridor(const AreaEffectSimulation::MineCorridor &data);
|
||||
void handleBoobyTrap(const AesItemView &aesItemView);
|
||||
void handleBoobyTrap(const AreaEffectSimulation::BoobyTrap &data);
|
||||
void handleOffRouteMine(const AesItemView &aesItemView);
|
||||
void handleOffRouteMine(const AreaEffectSimulation::OffRouteMine &data);
|
||||
void handleGasPipe(const AesItemView &aesItemView);
|
||||
void handleGasPipe(const AreaEffectSimulation::GasPipe &data);
|
||||
void handleDangerArea(const AesItemView &aesItemView);
|
||||
void handleDangerArea(const AreaEffectSimulation::DangerArea &data);
|
||||
void handleBorderline(const AesItemView &aesItemView);
|
||||
void handleBorderline(const AreaEffectSimulation::Borderline &data);
|
||||
void handleFunctionalArea(const AesItemView &aesItemView);
|
||||
void handleFunctionalArea(const AreaEffectSimulation::FunctionalArea &data);
|
||||
void handleAirSupportImpact(const AesItemView &aesItemView);
|
||||
void handleAirSupportImpact(const AreaEffectSimulation::AirSupportImpact &data);
|
||||
void handleMineAraeSingleMine();
|
||||
void handleMineAraeSingleMine(const Core::GeoPosition2D &position, const DusMine &mine);
|
||||
void handleSingleDusMine();
|
||||
void handleExplosionCluster(const AesItemView &aesItemView);
|
||||
void handleExplosionCluster(const AreaEffectSimulation::ExplosionCluster &data);
|
||||
void handleEffectCluster(const AesItemView &aesItemView);
|
||||
void handleEffectCluster(const AreaEffectSimulation::EffectCluster &data);
|
||||
void handleNContamination(const AesItemView& aesItemView);
|
||||
void handleNContamination(const AreaEffectSimulation::NContamination& data);
|
||||
void handleBCContamination(const AesItemView& aesItemView);
|
||||
void handleBCContamination(const AreaEffectSimulation::BCContamination& data);
|
||||
void handleExplosionArea(const AesItemView& aesItemView);
|
||||
void handleExplosionArea(const AreaEffectSimulation::ExplosionArea& data);
|
||||
void handleExplosionSingle(const AesItemView& aesItemView);
|
||||
void handleExplosionSingle(const AreaEffectSimulation::ExplosionSingle& data);
|
||||
void handleMineArea(const AesItemView& aesItemView);
|
||||
void handleMineArea(const AreaEffectSimulation::MineArea& data);
|
||||
void handleMineCorridor(const AesItemView& aesItemView);
|
||||
void handleMineCorridor(const AreaEffectSimulation::MineCorridor& data);
|
||||
void handleBoobyTrap(const AesItemView& aesItemView);
|
||||
void handleBoobyTrap(const AreaEffectSimulation::BoobyTrap& data);
|
||||
void handleOffRouteMine(const AesItemView& aesItemView);
|
||||
void handleOffRouteMine(const AreaEffectSimulation::OffRouteMine& data);
|
||||
void handleGasPipe(const AesItemView& aesItemView);
|
||||
void handleGasPipe(const AreaEffectSimulation::GasPipe& data);
|
||||
void handleDangerArea(const AesItemView& aesItemView);
|
||||
void handleDangerArea(const AreaEffectSimulation::DangerArea& data);
|
||||
void handleBorderline(const AesItemView& aesItemView);
|
||||
void handleBorderline(const AreaEffectSimulation::Borderline& data);
|
||||
void handleFunctionalArea(const AesItemView& aesItemView);
|
||||
void handleFunctionalArea(const AreaEffectSimulation::FunctionalArea& data);
|
||||
void handleAirSupportImpact(const AesItemView& aesItemView);
|
||||
void handleAirSupportImpact(const AreaEffectSimulation::AirSupportImpact& data);
|
||||
void handleMineAraeSingleMine();
|
||||
void handleMineAraeSingleMine(const Core::GeoPosition2D& position, const DusMine& mine);
|
||||
void handleSingleDusMine();
|
||||
void handleExplosionCluster(const AesItemView& aesItemView);
|
||||
void handleExplosionCluster(const AreaEffectSimulation::ExplosionCluster& data);
|
||||
void handleEffectCluster(const AesItemView& aesItemView);
|
||||
void handleEffectCluster(const AreaEffectSimulation::EffectCluster& data);
|
||||
|
||||
bool cbFunc(const AesItemView &aesItemView);
|
||||
bool cbFunc(const AesItemView& aesItemView);
|
||||
|
||||
void handleAesItem(const AesItem &aesData, AesType aesTypeId);
|
||||
void handleAesItem(const AesItem& aesData, AesType aesTypeId);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFindOnMap();
|
||||
void onShowDetails();
|
||||
bool onResetDusMines();
|
||||
private Q_SLOTS:
|
||||
void onFindOnMap();
|
||||
void onShowDetails();
|
||||
bool onResetDusMines();
|
||||
|
||||
void onNContaminationChanged(const AreaEffectSimulation::NContamination &data, DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data, DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data, DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data, DataModification modType);
|
||||
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea &data, DataModification modType);
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
|
||||
void onMineAreaChanged(const AreaEffectSimulation::MineArea &data, DataModification modType);
|
||||
void onMineCorridorChanged(const AreaEffectSimulation::MineCorridor &data, DataModification modType);
|
||||
void onGasPipeChanged(const GasPipe &data, DataModification modType);
|
||||
void onDangerAreaChanged(const AreaEffectSimulation::DangerArea &data, DataModification modType);
|
||||
void onBorderlineChanged(const AreaEffectSimulation::Borderline &data, DataModification modType);
|
||||
void onFunctionalAreaChanged(const AreaEffectSimulation::FunctionalArea &data, DataModification modType);
|
||||
void onAirSupportImpactChanged(const AirSupportImpact &data, DataModification modType);
|
||||
void onDusMineStateChanged(const DusMineState &data, DataModification modType);
|
||||
void onDusSingleMineChanged(const DusSingleMine &data, DataModification modType);
|
||||
void onExplosionClusterChanged(const ExplosionCluster &data, DataModification modType);
|
||||
void onEffectClusterChanged(const EffectCluster &data, DataModification modType);
|
||||
void onNContaminationChanged(const AreaEffectSimulation::NContamination& data, DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination& data, DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap& data, DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine& data, DataModification modType);
|
||||
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea& data, DataModification modType);
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle& data, DataModification modType);
|
||||
void onMineAreaChanged(const AreaEffectSimulation::MineArea& data, DataModification modType);
|
||||
void onMineCorridorChanged(const AreaEffectSimulation::MineCorridor& data, DataModification modType);
|
||||
void onGasPipeChanged(const GasPipe& data, DataModification modType);
|
||||
void onDangerAreaChanged(const AreaEffectSimulation::DangerArea& data, DataModification modType);
|
||||
void onBorderlineChanged(const AreaEffectSimulation::Borderline& data, DataModification modType);
|
||||
void onFunctionalAreaChanged(const AreaEffectSimulation::FunctionalArea& data, DataModification modType);
|
||||
void onAirSupportImpactChanged(const AirSupportImpact& data, DataModification modType);
|
||||
void onDusMineStateChanged(const DusMineState& data, DataModification modType);
|
||||
void onDusSingleMineChanged(const DusSingleMine& data, DataModification modType);
|
||||
void onExplosionClusterChanged(const ExplosionCluster& data, DataModification modType);
|
||||
void onEffectClusterChanged(const EffectCluster& data, DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_aesEntityId;
|
||||
QString m_aesEntityName;
|
||||
AreaEffectSimulation::AesType m_aesType;
|
||||
ProjectDataManagement::EffectSource m_aesEffectSource;
|
||||
int m_bcChargeTypeId;
|
||||
int m_singleExpChargeTypeId;
|
||||
int m_areaExpChargeTypeId;
|
||||
bool m_mineIsReactivatable;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
int m_aesEntityId;
|
||||
QString m_aesEntityName;
|
||||
AreaEffectSimulation::AesType m_aesType;
|
||||
ProjectDataManagement::EffectSource m_aesEffectSource;
|
||||
int m_bcChargeTypeId;
|
||||
int m_singleExpChargeTypeId;
|
||||
int m_areaExpChargeTypeId;
|
||||
bool m_mineIsReactivatable;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
LtsSession::LtsSession* m_session;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
|
||||
|
||||
Ui::AesInfoDialog* m_ui;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui::AesInfoDialog* m_ui;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
};
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+243
-253
@@ -1,351 +1,341 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "aes_base_edit.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsWidgets/lts_date_time_edit.h>
|
||||
#include <LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <QSpinBox>
|
||||
#include <LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <LtsWidgets/lts_date_time_edit.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <QJsonDocument>
|
||||
#include <QSpinBox>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BaseEdit::BaseEdit(const QString &menuGroup, const QString &loggerName, QWidget *parent, LtsWidgets::ButtonCombination buttonCombination)
|
||||
: LtsWidgets::LtsDialog(parent, buttonCombination)
|
||||
, m_aesItem()
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_ppmGuiCbxIfc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger(loggerName))
|
||||
BaseEdit::BaseEdit(const QString& menuGroup, const QString& loggerName, QWidget* parent,
|
||||
LtsWidgets::ButtonCombination buttonCombination)
|
||||
: LtsWidgets::LtsDialog(parent, buttonCombination), m_aesItem(), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_sitMapGuiIfc(nullptr), m_ppmGuiCbxIfc(nullptr), m_session(nullptr), m_menuGroup(menuGroup),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_logger(getLogger(loggerName))
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
connect(this, &BaseEdit::visibilityChanged, this, &BaseEdit::onVisibilityChanged);
|
||||
m_aesItem.id(0);
|
||||
connect(this, &BaseEdit::visibilityChanged, this, &BaseEdit::onVisibilityChanged);
|
||||
}
|
||||
|
||||
void BaseEdit::setCombobxToValueIfPossible(QComboBox *cbx, int val)
|
||||
void BaseEdit::setCombobxToValueIfPossible(QComboBox* cbx, int val)
|
||||
{
|
||||
int idx = cbx->findData(val);
|
||||
if (idx >= 0)
|
||||
cbx->setCurrentIndex(idx);
|
||||
int idx = cbx->findData(val);
|
||||
if (idx >= 0)
|
||||
cbx->setCurrentIndex(idx);
|
||||
}
|
||||
|
||||
void BaseEdit::onAesItemCreateReply(const Core::FunctionReplyObject &replyObject)
|
||||
void BaseEdit::onAesItemCreateReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error() && m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error() && m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
void BaseEdit::onAesItemModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
void BaseEdit::onAesItemModifyReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
|
||||
if (!replyObject.error() && m_sitMapGuiIfc )
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
if (!replyObject.error() && m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
bool BaseEdit::isModifiable() const
|
||||
{
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsPrepared ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsCreated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsUnknown ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsReceived) &&
|
||||
(!m_session->isReplayPartition()) &&
|
||||
(m_session->app() != LtsAppDescriptor::App::OC);
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsPrepared ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsCreated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsUnknown ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsReceived) &&
|
||||
(!m_session->isReplayPartition()) && (m_session->app() != LtsAppDescriptor::App::OC);
|
||||
}
|
||||
|
||||
bool BaseEdit::isOnlyNameModifiable() const
|
||||
{
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated) &&
|
||||
(!m_session->isReplayPartition()) &&
|
||||
(m_session->app() != LtsAppDescriptor::App::OC);
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated) &&
|
||||
(!m_session->isReplayPartition()) && (m_session->app() != LtsAppDescriptor::App::OC);
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValue()
|
||||
{
|
||||
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
|
||||
if (sb)
|
||||
return correctSpinBoxValueInternal(sb);
|
||||
QSpinBox* sb = qobject_cast<QSpinBox*>(sender());
|
||||
if (sb)
|
||||
return correctSpinBoxValueInternal(sb);
|
||||
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
if (dsb)
|
||||
return correctSpinBoxValueInternal(dsb);
|
||||
QDoubleSpinBox* dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
if (dsb)
|
||||
return correctSpinBoxValueInternal(dsb);
|
||||
}
|
||||
|
||||
void BaseEdit::onVisibilityChanged(bool visible)
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (!visible)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
else
|
||||
showPreviewObject();
|
||||
if (!visible)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
else
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValueInternal(QSpinBox *sb)
|
||||
void BaseEdit::correctSpinBoxValueInternal(QSpinBox* sb)
|
||||
{
|
||||
if (!sb)
|
||||
return;
|
||||
if (!sb)
|
||||
return;
|
||||
|
||||
int step = sb->singleStep();
|
||||
if (step == 1)
|
||||
return;
|
||||
int step = sb->singleStep();
|
||||
if (step == 1)
|
||||
return;
|
||||
|
||||
int value = sb->value();
|
||||
int remainder = (value - sb->minimum()) % step;
|
||||
if (remainder == 0)
|
||||
return;
|
||||
int value = sb->value();
|
||||
int remainder = (value - sb->minimum()) % step;
|
||||
if (remainder == 0)
|
||||
return;
|
||||
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
|
||||
if(value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
if (value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
|
||||
sb->setValue(value);
|
||||
sb->setValue(value);
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValueInternal(QDoubleSpinBox *sb)
|
||||
void BaseEdit::correctSpinBoxValueInternal(QDoubleSpinBox* sb)
|
||||
{
|
||||
if (!sb)
|
||||
return;
|
||||
if (!sb)
|
||||
return;
|
||||
|
||||
double step = sb->singleStep();
|
||||
if (qFuzzyCompare(step, pow(10, sb->decimals())))
|
||||
return;
|
||||
double step = sb->singleStep();
|
||||
if (qFuzzyCompare(step, pow(10, sb->decimals())))
|
||||
return;
|
||||
|
||||
double value = sb->value();
|
||||
double remainder = fmod(value - sb->minimum(), step);
|
||||
if (qFuzzyCompare(remainder, 0))
|
||||
return;
|
||||
double value = sb->value();
|
||||
double remainder = fmod(value - sb->minimum(), step);
|
||||
if (qFuzzyCompare(remainder, 0))
|
||||
return;
|
||||
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
|
||||
if (value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
if (value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
|
||||
sb->setValue(value);
|
||||
sb->setValue(value);
|
||||
}
|
||||
|
||||
bool BaseEdit::hasValidEffectStart(LtsWidgets::LtsDateTimeEdit *dte) const
|
||||
bool BaseEdit::hasValidEffectStart(LtsWidgets::LtsDateTimeEdit* dte) const
|
||||
{
|
||||
if (isOnlyNameModifiable())
|
||||
return true;
|
||||
|
||||
if (dte->isCheckable() && !dte->isChecked())
|
||||
return true;
|
||||
const auto ms = dte->msecsSinceEpoch();
|
||||
return ms > m_session->partitionTime();
|
||||
if (isOnlyNameModifiable())
|
||||
return true;
|
||||
|
||||
if (dte->isCheckable() && !dte->isChecked())
|
||||
return true;
|
||||
const auto ms = dte->msecsSinceEpoch();
|
||||
return ms > m_session->partitionTime();
|
||||
}
|
||||
|
||||
void BaseEdit::setEffectStartEnabled(LtsWidgets::LtsDateTimeEdit *dte, bool enable)
|
||||
void BaseEdit::setEffectStartEnabled(LtsWidgets::LtsDateTimeEdit* dte, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
int exerciseId = m_session->exerciseId();
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(exmDtc);
|
||||
ExerciseManagement::Exercise exercise = exmDtc->exercise(exerciseId);
|
||||
if (enable)
|
||||
{
|
||||
int exerciseId = m_session->exerciseId();
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(exmDtc);
|
||||
ExerciseManagement::Exercise exercise = exmDtc->exercise(exerciseId);
|
||||
|
||||
|
||||
enable = (exercise.state() == ExerciseManagement::ExerciseState_def::Started ||
|
||||
exercise.state() == ExerciseManagement::ExerciseState_def::Paused);
|
||||
enable = (exercise.state() == ExerciseManagement::ExerciseState_def::Started ||
|
||||
exercise.state() == ExerciseManagement::ExerciseState_def::Paused);
|
||||
|
||||
|
||||
if (exercise.state() == ExerciseManagement::ExerciseState_def::Created)
|
||||
dte->setChecked(false);
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
}
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
|
||||
dte->setEnabled(enable);
|
||||
if (exercise.state() == ExerciseManagement::ExerciseState_def::Created)
|
||||
dte->setChecked(false);
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
}
|
||||
else
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
|
||||
dte->setEnabled(enable);
|
||||
}
|
||||
|
||||
bool BaseEdit::has2DMap(bool showMsgBoxIfNot2D)
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
if (showMsgBoxIfNot2D)
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
if (showMsgBoxIfNot2D)
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const QVector<QPointF> &coords, bool reverse)
|
||||
void BaseEdit::setCoordinates(const QVector<QPointF>& coords, bool reverse)
|
||||
{
|
||||
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
if (!reverse)
|
||||
{
|
||||
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
if (!reverse)
|
||||
{
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto copy(coords);
|
||||
std::reverse(std::begin(copy), std::end(copy));
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(copy.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(copy.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const std::vector<Core::GeoPosition2D>& coords)
|
||||
{
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto copy(coords);
|
||||
std::reverse(std::begin(copy), std::end(copy));
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(copy.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(copy.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const std::vector<Core::GeoPosition2D> &coords)
|
||||
{
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i).lon(), coords.at(i).lat());
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i).lon(), coords.at(i).lat());
|
||||
}
|
||||
|
||||
std::vector<Core::GeoPosition2D> BaseEdit::getCoordinates() const
|
||||
{
|
||||
std::vector<Core::GeoPosition2D> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.emplace_back(Core::GeoPosition2D(coord.x(), coord.y()));
|
||||
}
|
||||
return segments;
|
||||
std::vector<Core::GeoPosition2D> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.emplace_back(Core::GeoPosition2D(coord.x(), coord.y()));
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
QVector<QPointF> BaseEdit::getCoordinatesQPointF() const
|
||||
{
|
||||
QVector<QPointF> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto *cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.push_back(coord);
|
||||
}
|
||||
return segments;
|
||||
QVector<QPointF> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto* cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.push_back(coord);
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
void BaseEdit::clearCoordinates()
|
||||
{
|
||||
for (auto *cw : coordWidgets())
|
||||
cw->clear();
|
||||
for (auto* cw : coordWidgets())
|
||||
cw->clear();
|
||||
}
|
||||
|
||||
void BaseEdit::enabledCoordinates(bool enable)
|
||||
{
|
||||
for (auto *cw : coordWidgets())
|
||||
cw->setEnabled(enable);
|
||||
for (auto* cw : coordWidgets())
|
||||
cw->setEnabled(enable);
|
||||
}
|
||||
|
||||
|
||||
void BaseEdit::onAreaChanged(const AesItem &data, DataModification modType)
|
||||
void BaseEdit::onAreaChanged(const AesItem& data, DataModification modType)
|
||||
{
|
||||
|
||||
|
||||
if (data.id() != m_aesItem.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved || data.effectStateId() == AesEffectState_def::EsRemoved)
|
||||
{
|
||||
|
||||
__unchange__();
|
||||
closeRequest();
|
||||
return;
|
||||
}
|
||||
m_aesItem = data;
|
||||
enableUiElements(isModifiable() && !isOnlyNameModifiable());
|
||||
}
|
||||
if (data.id() != m_aesItem.id())
|
||||
return;
|
||||
|
||||
bool BaseEdit::init(int aesItemId, LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
m_aesItem.id(aesItemId);
|
||||
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
if (m_session->isReplayPartition() || (LtsAppDescriptor::App::OC == m_session->app()))
|
||||
setUnchangeable();
|
||||
|
||||
if (aesItemId == 0)
|
||||
{
|
||||
m_aesItem.effectSourceId(ProjectDataManagement::EffectSource_def::ES_Internal);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Ok, tr("Add"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
double BaseEdit::distance(const Core::GeoPosition2D &p1, const Core::GeoPosition2D &p2)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate start = LtsCoordTrans::UtmCoordinate::fromGeographic(p1.lon(), p1.lat());
|
||||
LtsCoordTrans::UtmCoordinate end = LtsCoordTrans::UtmCoordinate::fromGeographic(p2.lon(), p2.lat(), start.zone);
|
||||
double dx = start.x - end.x;
|
||||
double dy = start.y - end.y;
|
||||
return std::sqrt(dx*dx + dy*dy);
|
||||
}
|
||||
|
||||
bool BaseEdit::checkSegementLengths(QWidget *parent) const
|
||||
{
|
||||
auto segments = getCoordinates();
|
||||
for (auto i=0; i<((int) segments.size() - 1); ++i)
|
||||
{
|
||||
double dis = distance(segments[i], segments[i+1]);
|
||||
if (getMaxLength() != 0 && dis > getMaxLength())
|
||||
if (modType == DataModification::eRemoved || data.effectStateId() == AesEffectState_def::EsRemoved)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(parent, tr("The distance between Coordinate %1 and %2 is too long.\nThe segment is %3m long, but the maximum segment length is %4m.")
|
||||
.arg(i+1).arg(i+2).arg(QString::number(dis,'d',2),QString::number(getMaxLength(),'d',2)));
|
||||
return false;
|
||||
|
||||
__unchange__();
|
||||
closeRequest();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
m_aesItem = data;
|
||||
enableUiElements(isModifiable() && !isOnlyNameModifiable());
|
||||
}
|
||||
|
||||
}
|
||||
bool BaseEdit::init(int aesItemId, LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
m_aesItem.id(aesItemId);
|
||||
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
if (m_session->isReplayPartition() || (LtsAppDescriptor::App::OC == m_session->app()))
|
||||
setUnchangeable();
|
||||
|
||||
if (aesItemId == 0)
|
||||
{
|
||||
m_aesItem.effectSourceId(ProjectDataManagement::EffectSource_def::ES_Internal);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Ok, tr("Add"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
double BaseEdit::distance(const Core::GeoPosition2D& p1, const Core::GeoPosition2D& p2)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate start = LtsCoordTrans::UtmCoordinate::fromGeographic(p1.lon(), p1.lat());
|
||||
LtsCoordTrans::UtmCoordinate end = LtsCoordTrans::UtmCoordinate::fromGeographic(p2.lon(), p2.lat(), start.zone);
|
||||
double dx = start.x - end.x;
|
||||
double dy = start.y - end.y;
|
||||
return std::sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
bool BaseEdit::checkSegementLengths(QWidget* parent) const
|
||||
{
|
||||
auto segments = getCoordinates();
|
||||
for (auto i = 0; i < ((int)segments.size() - 1); ++i)
|
||||
{
|
||||
double dis = distance(segments[i], segments[i + 1]);
|
||||
if (getMaxLength() != 0 && dis > getMaxLength())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
parent, tr("The distance between Coordinate %1 and %2 is too long.\nThe segment is %3m long, but the "
|
||||
"maximum segment length is %4m.")
|
||||
.arg(i + 1)
|
||||
.arg(i + 2)
|
||||
.arg(QString::number(dis, 'd', 2), QString::number(getMaxLength(), 'd', 2)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+233
-266
@@ -1,349 +1,316 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_base_model.h"
|
||||
#include <utility>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <QLocale>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesGuiBasHelpers::AesGuiBasHelpers() : m_aesDtc(nullptr), m_pdmDtc(nullptr), m_ppmDtc(nullptr) {}
|
||||
|
||||
|
||||
|
||||
AesGuiBasHelpers::AesGuiBasHelpers()
|
||||
: m_aesDtc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
{}
|
||||
|
||||
bool AesGuiBasHelpers::initModel(LtsSession::LtsSession *session)
|
||||
bool AesGuiBasHelpers::initModel(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc);
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::stringFromPartyId(const dds::core::optional<int> &id) const
|
||||
QVariant AesGuiBasHelpers::stringFromPartyId(const dds::core::optional<int>& id) const
|
||||
{
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_partyNames.find(id.get());
|
||||
if (it != m_partyNames.end())
|
||||
return it.value();
|
||||
const QString name = ParticipantManagement::trPartyName(m_ppmDtc->party(id.get()).name());
|
||||
m_partyNames.insert(id.get(), name);
|
||||
return name;
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_partyNames.find(id.get());
|
||||
if (it != m_partyNames.end())
|
||||
return it.value();
|
||||
const QString name = ParticipantManagement::trPartyName(m_ppmDtc->party(id.get()).name());
|
||||
m_partyNames.insert(id.get(), name);
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon AesGuiBasHelpers::iconFromPartyId(const dds::core::optional<int> &id) const
|
||||
QIcon AesGuiBasHelpers::iconFromPartyId(const dds::core::optional<int>& id) const
|
||||
{
|
||||
if (!id.is_set() || !m_ppmGuiCbxIfc)
|
||||
return QIcon();
|
||||
auto it = m_partyIcons.find(id.get());
|
||||
if (it != m_partyIcons.end())
|
||||
return it.value();
|
||||
const QRgb col = QRgb(m_ppmDtc->party(id.get()).color());
|
||||
const QIcon icon = m_ppmGuiCbxIfc->pixmapFromParty(col);
|
||||
m_partyIcons.insert(id.get(), icon);
|
||||
return icon;
|
||||
if (!id.is_set() || !m_ppmGuiCbxIfc)
|
||||
return QIcon();
|
||||
auto it = m_partyIcons.find(id.get());
|
||||
if (it != m_partyIcons.end())
|
||||
return it.value();
|
||||
const QRgb col = QRgb(m_ppmDtc->party(id.get()).color());
|
||||
const QIcon icon = m_ppmGuiCbxIfc->pixmapFromParty(col);
|
||||
m_partyIcons.insert(id.get(), icon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::hierarchyFromParticipantId(const dds::core::optional<int> &id) const
|
||||
QVariant AesGuiBasHelpers::hierarchyFromParticipantId(const dds::core::optional<int>& id) const
|
||||
{
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_participantHierarchy.find(id.get());
|
||||
if (it != m_participantHierarchy.end())
|
||||
return it.value();
|
||||
const QString name = m_ppmDtc->hierarchyFromParticipant(id.get());
|
||||
m_participantHierarchy.insert(id.get(), name);
|
||||
return name;
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_participantHierarchy.find(id.get());
|
||||
if (it != m_participantHierarchy.end())
|
||||
return it.value();
|
||||
const QString name = m_ppmDtc->hierarchyFromParticipant(id.get());
|
||||
m_participantHierarchy.insert(id.get(), name);
|
||||
return name;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::chargeTypeName(int chargeTypeId, bool shortName) const
|
||||
{
|
||||
if (shortName)
|
||||
{
|
||||
auto it = m_chargeTypeShortNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeShortNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeShortName(chargeTypeId, true);
|
||||
m_chargeTypeShortNames.insert(chargeTypeId, name);
|
||||
if (shortName)
|
||||
{
|
||||
auto it = m_chargeTypeShortNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeShortNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeShortName(chargeTypeId, true);
|
||||
m_chargeTypeShortNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
}
|
||||
|
||||
auto it = m_chargeTypeNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeName(chargeTypeId, true);
|
||||
m_chargeTypeNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
}
|
||||
|
||||
auto it = m_chargeTypeNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeName(chargeTypeId, true);
|
||||
m_chargeTypeNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
|
||||
}
|
||||
|
||||
QString AesGuiBasHelpers::simulationTypeText(bool isCentral)
|
||||
{
|
||||
return isCentral ? QObject::tr("central") : QObject::tr("peripheral");
|
||||
return isCentral ? QObject::tr("central") : QObject::tr("peripheral");
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::updateEffectStateComboboxFilterData(bool bWithPause)
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
const auto effectStates = {
|
||||
AesEffectState::EsExpired,
|
||||
AesEffectState::EsCreated,
|
||||
AesEffectState::EsPrepared,
|
||||
AesEffectState::EsActivated,
|
||||
AesEffectState::EsPaused,
|
||||
AesEffectState::EsFired,
|
||||
AesEffectState::EsReceived
|
||||
};
|
||||
for (const auto es : effectStates) {
|
||||
if (!bWithPause && es == AesEffectState::EsPaused)
|
||||
continue;
|
||||
cfd.data = es;
|
||||
cfd.text = AreaEffectSimulation::toString(es);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterEffectState = cfc.toVariant();
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
const auto effectStates = {AesEffectState::EsExpired, AesEffectState::EsCreated, AesEffectState::EsPrepared,
|
||||
AesEffectState::EsActivated, AesEffectState::EsPaused, AesEffectState::EsFired,
|
||||
AesEffectState::EsReceived};
|
||||
for (const auto es : effectStates)
|
||||
{
|
||||
if (!bWithPause && es == AesEffectState::EsPaused)
|
||||
continue;
|
||||
cfd.data = es;
|
||||
cfd.text = AreaEffectSimulation::toString(es);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterEffectState = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::updateComboboxFilterData(const QSet<int> &availablePartyIds,
|
||||
const QSet<int> &availabelChargeIds)
|
||||
void AesGuiBasHelpers::updateComboboxFilterData(const QSet<int>& availablePartyIds, const QSet<int>& availabelChargeIds)
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
for (const int i : std::as_const(availabelChargeIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = chargeTypeName(i).toString();
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = true;
|
||||
m_cbxFilterChargeType = cfc.toVariant();
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
for (const int i : std::as_const(availabelChargeIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = chargeTypeName(i).toString();
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = true;
|
||||
m_cbxFilterChargeType = cfc.toVariant();
|
||||
|
||||
cfc.data.clear();
|
||||
for (const int i : std::as_const(availablePartyIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = ParticipantManagement::trPartyName(m_ppmDtc->party(i).name());
|
||||
cfd.icon = iconFromPartyId(i);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterParty = cfc.toVariant();
|
||||
cfc.data.clear();
|
||||
for (const int i : std::as_const(availablePartyIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = ParticipantManagement::trPartyName(m_ppmDtc->party(i).name());
|
||||
cfd.icon = iconFromPartyId(i);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterParty = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AreaEffectSimulation::AesGuiBasHelpers::updateSimulationTypeComboboxFilterData()
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
|
||||
cfd.text = simulationTypeText(true);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
cfd.text = simulationTypeText(true);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
|
||||
cfd.text = simulationTypeText(false);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
cfd.text = simulationTypeText(false);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterSimulationType = cfc.toVariant();
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterSimulationType = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(ProjectDataManagement::GearClass gc)
|
||||
{
|
||||
m_availableChargeIds.clear();
|
||||
const QVector<ProjectDataManagement::ChargeType> availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto &charge : availableCharges)
|
||||
m_availableChargeIds += charge.id();
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
m_availableChargeIds.clear();
|
||||
const QVector<ProjectDataManagement::ChargeType> availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto& charge : availableCharges)
|
||||
m_availableChargeIds += charge.id();
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(const QVector<ProjectDataManagement::GearClass> &gcs)
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(const QVector<ProjectDataManagement::GearClass>& gcs)
|
||||
{
|
||||
m_availableChargeIds.clear();
|
||||
m_availableChargeIds.clear();
|
||||
|
||||
for (auto gc : std::as_const(gcs))
|
||||
{
|
||||
const QVector<ProjectDataManagement::ChargeType> &availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto &charge : std::as_const(availableCharges))
|
||||
m_availableChargeIds += charge.id();
|
||||
}
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AesItemSortFilterProxyModel::AesItemSortFilterProxyModel(LtsSession::LtsSession *session, QObject *parent)
|
||||
: LtsWidgets::LtsColumnFilterProxyModel(parent)
|
||||
, m_session(session)
|
||||
, m_showExpired(false)
|
||||
, m_offset(5 * 60 * 1000)
|
||||
{
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
if (m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Party &party)
|
||||
for (auto gc : std::as_const(gcs))
|
||||
{
|
||||
m_partyColors[party.id()] = QColor::fromRgb(QRgb(party.color()));
|
||||
};
|
||||
ppmDtc->partys(cb);
|
||||
}
|
||||
const QVector<ProjectDataManagement::ChargeType>& availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto& charge : std::as_const(availableCharges))
|
||||
m_availableChargeIds += charge.id();
|
||||
}
|
||||
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
AesItemSortFilterProxyModel::AesItemSortFilterProxyModel(LtsSession::LtsSession* session, QObject* parent)
|
||||
: LtsWidgets::LtsColumnFilterProxyModel(parent), m_session(session), m_showExpired(false), m_offset(5 * 60 * 1000)
|
||||
{
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
if (m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Party& party) {
|
||||
m_partyColors[party.id()] = QColor::fromRgb(QRgb(party.color()));
|
||||
};
|
||||
ppmDtc->partys(cb);
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemSortFilterProxyModel::setShowExpired(bool showExpired)
|
||||
{
|
||||
if (m_showExpired == showExpired)
|
||||
return;
|
||||
if (m_showExpired == showExpired)
|
||||
return;
|
||||
|
||||
m_showExpired = showExpired;
|
||||
invalidateFilter();
|
||||
m_showExpired = showExpired;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AesItemSortFilterProxyModel::setOffset(int offsetMsecs)
|
||||
{
|
||||
if (m_offset == offsetMsecs)
|
||||
return;
|
||||
if (m_offset == offsetMsecs)
|
||||
return;
|
||||
|
||||
m_offset = offsetMsecs;
|
||||
invalidateFilter();
|
||||
m_offset = offsetMsecs;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool AesItemSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool AesItemSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
bool bRet = checkFilter(source_row);
|
||||
if (!bRet)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
bool bRet = checkFilter(source_row);
|
||||
if (!bRet)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
bool AesItemSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
bool AesItemSortFilterProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
|
||||
{
|
||||
if (source_left.column() != source_right.column())
|
||||
if (source_left.column() != source_right.column())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AesGuiBasHelpers::BcEffectStart: {
|
||||
const auto effectStartLeft = aesEffectStart(source_left.row());
|
||||
const auto effectStartRight = aesEffectStart(source_right.row());
|
||||
if (effectStartLeft.is_set() && effectStartRight.is_set())
|
||||
return effectStartLeft.get() < effectStartRight.get();
|
||||
if (effectStartRight.is_set())
|
||||
return true;
|
||||
if (effectStartLeft.is_set())
|
||||
return false;
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectDuration: {
|
||||
const auto effectDurationLeft = aesEffectDuration(source_left.row());
|
||||
const auto effectDurationRight = aesEffectDuration(source_right.row());
|
||||
if (effectDurationLeft == effectDurationRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectDurationLeft < effectDurationRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectState: {
|
||||
const auto effectStateLeft = aesEffectStateId(source_left.row());
|
||||
const auto effectStateRight = aesEffectStateId(source_right.row());
|
||||
if (effectStateLeft == effectStateRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectStateLeft < effectStateRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectSource: {
|
||||
const auto effectSourceLeft = aesEffectSourceId(source_left.row());
|
||||
const auto effectSourceRight = aesEffectSourceId(source_right.row());
|
||||
if (effectSourceLeft == effectSourceRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectSourceLeft < effectSourceRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcParty: {
|
||||
const auto partyIdLeft = partyId(source_left.row());
|
||||
const auto partyIdRight = partyId(source_right.row());
|
||||
if (partyIdLeft == partyIdRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return partyIdLeft < partyIdRight;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AesGuiBasHelpers::BcEffectStart:
|
||||
{
|
||||
const auto effectStartLeft = aesEffectStart(source_left.row());
|
||||
const auto effectStartRight = aesEffectStart(source_right.row());
|
||||
if (effectStartLeft.is_set() && effectStartRight.is_set())
|
||||
return effectStartLeft.get() < effectStartRight.get();
|
||||
if (effectStartRight.is_set())
|
||||
return true;
|
||||
if (effectStartLeft.is_set())
|
||||
return false;
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectDuration:
|
||||
{
|
||||
const auto effectDurationLeft = aesEffectDuration(source_left.row());
|
||||
const auto effectDurationRight = aesEffectDuration(source_right.row());
|
||||
if (effectDurationLeft == effectDurationRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectDurationLeft < effectDurationRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectState:
|
||||
{
|
||||
const auto effectStateLeft = aesEffectStateId(source_left.row());
|
||||
const auto effectStateRight = aesEffectStateId(source_right.row());
|
||||
if (effectStateLeft == effectStateRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectStateLeft < effectStateRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectSource:
|
||||
{
|
||||
const auto effectSourceLeft = aesEffectSourceId(source_left.row());
|
||||
const auto effectSourceRight = aesEffectSourceId(source_right.row());
|
||||
if (effectSourceLeft == effectSourceRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectSourceLeft < effectSourceRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcParty:
|
||||
{
|
||||
const auto partyIdLeft = partyId(source_left.row());
|
||||
const auto partyIdRight = partyId(source_right.row());
|
||||
if (partyIdLeft == partyIdRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return partyIdLeft < partyIdRight;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
|
||||
bool AesItemSortFilterProxyModel::checkFilter(int source_row) const
|
||||
{
|
||||
int32_t party = partyId(source_row);
|
||||
if (party != -1 && !LtsSessionData::LtsSessionData::getInstance()->isVisibleParty(m_session->exerciseId(), party))
|
||||
int32_t party = partyId(source_row);
|
||||
if (party != -1 && !LtsSessionData::LtsSessionData::getInstance()->isVisibleParty(m_session->exerciseId(), party))
|
||||
return false;
|
||||
|
||||
const auto effectStateId = aesEffectStateId(source_row);
|
||||
if (effectStateId == AesEffectState_def::EsRemoved)
|
||||
return false;
|
||||
|
||||
if (showExpired())
|
||||
return true;
|
||||
|
||||
const int id = aesId(source_row);
|
||||
if (id <= 0)
|
||||
return false;
|
||||
|
||||
if (effectStateId != AreaEffectSimulation::AesEffectState::EsExpired &&
|
||||
effectStateId != AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
return true;
|
||||
|
||||
if (!m_session)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto effectStart = aesEffectStart(source_row);
|
||||
qint64 effectEnd = 0;
|
||||
if (effectStart.is_set())
|
||||
effectEnd = effectStart.get() + aesEffectDuration(source_row);
|
||||
|
||||
if (effectStart.is_set() && effectEnd + m_offset > m_session->partitionTime())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
const auto effectStateId = aesEffectStateId(source_row);
|
||||
if (effectStateId == AesEffectState_def::EsRemoved)
|
||||
return false;
|
||||
|
||||
|
||||
if (showExpired())
|
||||
return true;
|
||||
|
||||
const int id = aesId(source_row);
|
||||
if (id <= 0)
|
||||
return false;
|
||||
|
||||
|
||||
if (effectStateId != AreaEffectSimulation::AesEffectState::EsExpired && effectStateId != AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
return true;
|
||||
|
||||
if (!m_session)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto effectStart = aesEffectStart(source_row);
|
||||
qint64 effectEnd = 0;
|
||||
if (effectStart.is_set())
|
||||
effectEnd = effectStart.get() + aesEffectDuration(source_row);
|
||||
|
||||
|
||||
if (effectStart.is_set() &&
|
||||
effectEnd + m_offset > m_session->partitionTime())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+230
-212
@@ -1,300 +1,318 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_itemlist.h"
|
||||
|
||||
#include "aes_base_model.h"
|
||||
#include "ui_aes_itemlist.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Viewer/LtsDataView/lts_data_view.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QJsonDocument>
|
||||
#include <QKeyEvent>
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <Viewer/LtsDataView/lts_data_view.h>
|
||||
|
||||
static const auto ADLER_BTN = LtsWidgets::DialogButton::Export;
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesItemList::AesItemList(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ftc(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_showExpired(false)
|
||||
, m_bHasAddEditOperatorRights(true)
|
||||
, m_bHasAddAdlerOperatorRights(false)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::AesItemList)
|
||||
AesItemList::AesItemList(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ftc(nullptr), m_dtc(nullptr),
|
||||
m_menuGroup(menuGroup), m_requestHelper(new LtsUtils::RequestHelper(this)), m_showExpired(false),
|
||||
m_bHasAddEditOperatorRights(true), m_bHasAddAdlerOperatorRights(false), m_session(nullptr),
|
||||
m_ui(new Ui::AesItemList)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
QCheckBox *cbExpired = new QCheckBox(tr("Show expired"), m_ui->widget);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->widget->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &AesItemList::setShowExpired);
|
||||
QCheckBox* cbExpired = new QCheckBox(tr("Show expired"), m_ui->widget);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->widget->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &AesItemList::setShowExpired);
|
||||
}
|
||||
|
||||
AesItemList::~AesItemList() { delete m_ui; }
|
||||
|
||||
bool AesItemList::init(LtsSession::LtsSession *session)
|
||||
AesItemList::~AesItemList()
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &AesItemList::onPrint);
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AesItemList::onAddAesItem);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AesItemList::onRemoveAesItem);
|
||||
}
|
||||
bool AesItemList::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AesItemList::onEditAesItem);
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &AesItemList::onPrint);
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AesItemList::onAddAesItem);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AesItemList::onRemoveAesItem);
|
||||
}
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Center on Map"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &AesItemList::onCenterAesItem);
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
m_buttonBox->connectButton(ADLER_BTN, this, &AesItemList::onAdlerBtn);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AesItemList::onEditAesItem);
|
||||
|
||||
QCheckBox *cb = qobject_cast<QCheckBox *>(m_ui->widget->customWidget());
|
||||
bool showExpired = (!cb || cb->isChecked());
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Center on Map"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &AesItemList::onCenterAesItem);
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
m_buttonBox->connectButton(ADLER_BTN, this, &AesItemList::onAdlerBtn);
|
||||
|
||||
createModel();
|
||||
model()->setShowExpired(showExpired);
|
||||
QCheckBox* cb = qobject_cast<QCheckBox*>(m_ui->widget->customWidget());
|
||||
bool showExpired = (!cb || cb->isChecked());
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_session, &LtsSession::LtsSession::signalExerciseDataChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::explosionClusterChanged, this, &AesItemList::onHandleAdler);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::effectClusterChanged, this, &AesItemList::onHandleAdler);
|
||||
createModel();
|
||||
model()->setShowExpired(showExpired);
|
||||
|
||||
return true;
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_session, &LtsSession::LtsSession::signalExerciseDataChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::explosionClusterChanged, this,
|
||||
&AesItemList::onHandleAdler);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::effectClusterChanged, this,
|
||||
&AesItemList::onHandleAdler);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AesItemList::enaDisa()
|
||||
{
|
||||
const int curSelRow = currentRow();
|
||||
onHandleAdler();
|
||||
LtsWidgets::ExerciseStates allowedStates = LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bEnableEditRemove = false;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
bool isOc = (m_session->app() == LtsAppDescriptor::App::OC);
|
||||
const int curSelRow = currentRow();
|
||||
onHandleAdler();
|
||||
LtsWidgets::ExerciseStates allowedStates =
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bEnableEditRemove = false;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
bool isOc = (m_session->app() == LtsAppDescriptor::App::OC);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, !model()->isExpired(curSelRow));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, !model()->isExpired(curSelRow));
|
||||
|
||||
if (curSelRow >= 0)
|
||||
bEnableEditRemove = !model()->isExpired(curSelRow) && !model()->isExternal(curSelRow);
|
||||
if (!m_bHasAddEditOperatorRights)
|
||||
{
|
||||
bEnableEditRemove = false;
|
||||
bIsAllowedInState = false;
|
||||
}
|
||||
|
||||
if (!m_session->isReplayPartition())
|
||||
{
|
||||
if (!model()->isExternal(curSelRow))
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Edit"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove && bIsAllowedInState);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState);
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bEnableEditRemove && bIsAllowedInState);
|
||||
|
||||
|
||||
bool isEsAdler = false;
|
||||
if (curSelRow >= 0)
|
||||
bEnableEditRemove = !model()->isExpired(curSelRow) && !model()->isExternal(curSelRow);
|
||||
if (!m_bHasAddEditOperatorRights)
|
||||
{
|
||||
const ProjectDataManagement::EffectSource &es = model()->aesEffectSourceId(curSelRow);
|
||||
bEnableEditRemove = false;
|
||||
bIsAllowedInState = false;
|
||||
}
|
||||
|
||||
if (es == ProjectDataManagement::EffectSource::ES_ADLER || es == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
isEsAdler = true;
|
||||
if (!m_session->isReplayPartition())
|
||||
{
|
||||
if (!model()->isExternal(curSelRow))
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Edit"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove && bIsAllowedInState);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState);
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState && !isEsAdler);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights && isEsAdler);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bEnableEditRemove && bIsAllowedInState);
|
||||
|
||||
bool isEsAdler = false;
|
||||
if (curSelRow >= 0)
|
||||
{
|
||||
const ProjectDataManagement::EffectSource& es = model()->aesEffectSourceId(curSelRow);
|
||||
|
||||
if (es == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
es == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
isEsAdler = true;
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState && !isEsAdler);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights && isEsAdler);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
}
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Add ADLER"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove);
|
||||
}
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Add ADLER"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove);
|
||||
}
|
||||
|
||||
if (bEnableEditRemove && bIsAllowedInState)
|
||||
{
|
||||
m_doubleClickConnection = connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &AesItemList::onEditAesItem, Qt::UniqueConnection);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_doubleClickConnection)
|
||||
disconnect(m_doubleClickConnection);
|
||||
}
|
||||
if (bEnableEditRemove && bIsAllowedInState)
|
||||
{
|
||||
m_doubleClickConnection = connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&AesItemList::onEditAesItem, Qt::UniqueConnection);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_doubleClickConnection)
|
||||
disconnect(m_doubleClickConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemList::onPrint() { LtsPrinting::printView(m_session, this, m_ui->widget->treeView()); }
|
||||
void AesItemList::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void AesItemList::onAdlerBtn()
|
||||
{
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
|
||||
DEBUG_LOG(m_logger) << "onAdlerBtn aesEffectState=" << aesEffectState;
|
||||
DEBUG_LOG(m_logger) << "onAdlerBtn aesEffectState=" << aesEffectState;
|
||||
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived:
|
||||
{
|
||||
switch (effectSource.underlying())
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case ProjectDataManagement::EffectSource::ES_ADLER:
|
||||
{
|
||||
AcknowledgeExternalAesItemRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.aesId(aesId);
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->acknowledgeExternalAesItemRequest(req, this); });
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived: {
|
||||
switch (effectSource.underlying())
|
||||
{
|
||||
case ProjectDataManagement::EffectSource::ES_ADLER: {
|
||||
AcknowledgeExternalAesItemRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.aesId(aesId);
|
||||
m_requestHelper->startSingleRequest(
|
||||
[req, this]() { return m_ftc->acknowledgeExternalAesItemRequest(req, this); });
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ExplosionClusterReleaseReceivedRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.id(aesId);
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->explosionClusterReleaseReceivedRequest(req, this); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ExplosionClusterReleaseReceivedRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.id(aesId);
|
||||
m_requestHelper->startSingleRequest(
|
||||
[req, this]() { return m_ftc->explosionClusterReleaseReceivedRequest(req, this); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared:
|
||||
{
|
||||
if (effectSource == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
AreaEffectSimulation::SetAesItemEffectorStateRequest req;
|
||||
req.aesId(model()->aesId(currentRow()));
|
||||
req.newEffectorState(AesEffectorState::EsReadyToFire);
|
||||
DEBUG_LOG(m_logger) << "Send setAesItemEffectorStateRequest with aesId: " << req.aesId() << ", AesEffectorState: " << req.newEffectorState();
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared: {
|
||||
if (effectSource == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
AreaEffectSimulation::SetAesItemEffectorStateRequest req;
|
||||
req.aesId(model()->aesId(currentRow()));
|
||||
req.newEffectorState(AesEffectorState::EsReadyToFire);
|
||||
DEBUG_LOG(m_logger) << "Send setAesItemEffectorStateRequest with aesId: " << req.aesId()
|
||||
<< ", AesEffectorState: " << req.newEffectorState();
|
||||
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->setAesItemEffectorStateRequest(req, this); });
|
||||
m_requestHelper->startSingleRequest(
|
||||
[req, this]() { return m_ftc->setAesItemEffectorStateRequest(req, this); });
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AesItemList::onHandleAdler()
|
||||
{
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
DEBUG_LOG(m_logger) << "onHandleAdler aesEffectState=" << aesEffectState;
|
||||
auto *adlerBtn = m_buttonBox->getButton(ADLER_BTN);
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
DEBUG_LOG(m_logger) << "onHandleAdler aesEffectState=" << aesEffectState;
|
||||
auto* adlerBtn = m_buttonBox->getButton(ADLER_BTN);
|
||||
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived:
|
||||
{
|
||||
adlerBtn->setText(tr("Mark received"));
|
||||
adlerBtn->setIcon(QIcon(QStringLiteral("icon:mortar_ammunition_administration.svg")));
|
||||
adlerBtn->show();
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared:
|
||||
{
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
if (effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
const EffectCluster &ecData = m_dtc->effectCluster(model()->aesId(currentRow()));
|
||||
if (ecData.effectorState() == AreaEffectSimulation::AesEffectorState::EsNotReadyToFire)
|
||||
{
|
||||
adlerBtn->setText(tr("Ready To Fire"));
|
||||
adlerBtn->show();
|
||||
}
|
||||
else
|
||||
adlerBtn->hide();
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived: {
|
||||
adlerBtn->setText(tr("Mark received"));
|
||||
adlerBtn->setIcon(QIcon(QStringLiteral("icon:mortar_ammunition_administration.svg")));
|
||||
adlerBtn->show();
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared: {
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
if (effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
const EffectCluster& ecData = m_dtc->effectCluster(model()->aesId(currentRow()));
|
||||
if (ecData.effectorState() == AreaEffectSimulation::AesEffectorState::EsNotReadyToFire)
|
||||
{
|
||||
adlerBtn->setText(tr("Ready To Fire"));
|
||||
adlerBtn->show();
|
||||
}
|
||||
else
|
||||
adlerBtn->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
adlerBtn->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
adlerBtn->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemList::onCenterAesItem()
|
||||
{
|
||||
int aesId = model()->aesId(currentRow());
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToAesObject(aesId);
|
||||
int aesId = model()->aesId(currentRow());
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToAesObject(aesId);
|
||||
}
|
||||
|
||||
void AesItemList::hideColumn(int col) { m_ui->widget->hideColumn(col); }
|
||||
void AesItemList::hideColumn(int col)
|
||||
{
|
||||
m_ui->widget->hideColumn(col);
|
||||
}
|
||||
|
||||
void AesItemList::showColumn(int col) { m_ui->widget->showColumn(col); }
|
||||
void AesItemList::showColumn(int col)
|
||||
{
|
||||
m_ui->widget->showColumn(col);
|
||||
}
|
||||
|
||||
int AesItemList::currentRow() const
|
||||
{
|
||||
const auto selRows = m_ui->widget->selectedRows();
|
||||
if (selRows.count() != 1)
|
||||
return -1;
|
||||
return selRows.first().row();
|
||||
const auto selRows = m_ui->widget->selectedRows();
|
||||
if (selRows.count() != 1)
|
||||
return -1;
|
||||
return selRows.first().row();
|
||||
}
|
||||
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel *model, const std::function<LtsDataView::AbstractDisplayWidget *()> &customDisplayWidgetCreator)
|
||||
void AesItemList::setDataViewModel(
|
||||
QAbstractItemModel* model, const std::function<LtsDataView::AbstractDisplayWidget*()>& customDisplayWidgetCreator)
|
||||
{
|
||||
m_ui->widget->setModel(model, customDisplayWidgetCreator);
|
||||
m_ui->widget->setModel(model, customDisplayWidgetCreator);
|
||||
}
|
||||
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel *model) { m_ui->widget->setModel(model); }
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel* model)
|
||||
{
|
||||
m_ui->widget->setModel(model);
|
||||
}
|
||||
|
||||
void AesItemList::setShowExpired(bool show) { model()->setShowExpired(show); }
|
||||
void AesItemList::setShowExpired(bool show)
|
||||
{
|
||||
model()->setShowExpired(show);
|
||||
}
|
||||
|
||||
void AesItemList::setSortIndicator(int col) { m_ui->widget->setSortIndicator(col, Qt::AscendingOrder); }
|
||||
void AesItemList::setSortIndicator(int col)
|
||||
{
|
||||
m_ui->widget->setSortIndicator(col, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
void AesItemList::translateBase(const QString &windowTitle) { translate(m_ui, windowTitle); }
|
||||
void AesItemList::translateBase(const QString& windowTitle)
|
||||
{
|
||||
translate(m_ui, windowTitle);
|
||||
}
|
||||
|
||||
void AesItemList::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+55
-59
@@ -1,110 +1,106 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_adler_list.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QInputDialog>
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <QInputDialog>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeAdministrationAdlerList::ChargeAdministrationAdlerList(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_sourceModel(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ChargeAdministrationList)
|
||||
ChargeAdministrationAdlerList::ChargeAdministrationAdlerList(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_model(nullptr), m_sourceModel(nullptr),
|
||||
m_session(nullptr), m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::ChargeAdministrationList)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->cbParty, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ChargeAdministrationAdlerList::onPartyChanged);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ChargeAdministrationAdlerList::onPartyChanged);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration_Adler"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration_Adler"));
|
||||
}
|
||||
|
||||
ChargeAdministrationAdlerList::~ChargeAdministrationAdlerList()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Charge Administration Adler"));
|
||||
translate(m_ui, tr("Charge Administration Adler"));
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::onPartyChanged()
|
||||
{
|
||||
m_model->setParty(m_ui->cbParty->currentData().toInt());
|
||||
m_model->setParty(m_ui->cbParty->currentData().toInt());
|
||||
}
|
||||
|
||||
bool ChargeAdministrationAdlerList::init(LtsSession::LtsSession *session)
|
||||
bool ChargeAdministrationAdlerList::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationAdlerList::onPrint);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationAdlerList::onPrint);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationAdlerModel(this);
|
||||
m_sourceModel = new ChargeAdministrationAdlerModel(this);
|
||||
|
||||
if (!m_sourceModel->initModel(m_session))
|
||||
return false;
|
||||
if (!m_sourceModel->initModel(m_session))
|
||||
return false;
|
||||
|
||||
m_model = new ChargeAdministrationAdlerSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColId, true);
|
||||
m_model = new ChargeAdministrationAdlerSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColId, true);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
bool onlydebugMode =true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColChanged, onlydebugMode);
|
||||
bool onlydebugMode = true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColChanged, onlydebugMode);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationAdlerModel::ColTypeName, Qt::AscendingOrder);
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationAdlerModel::ColTypeName, Qt::AscendingOrder);
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::onPrint()
|
||||
{
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header );
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+191
-198
@@ -1,263 +1,256 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include <utility>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setSourceModel(QAbstractItemModel* model)
|
||||
{
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationAdlerModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationAdlerModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationAdlerSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool ChargeAdministrationAdlerSortFilterProxyModel::filterAcceptsRow(int source_row,
|
||||
const QModelIndex& source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministrationAdler &item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
const ChargeAdministrationAdler& item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
int ChargeAdministrationAdlerSortFilterProxyModel::party() const
|
||||
{
|
||||
return m_party;
|
||||
return m_party;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setParty(int party)
|
||||
{
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ChargeAdministrationAdlerModel::ChargeAdministrationAdlerModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministrationAdler>({tr("Id"),
|
||||
tr("Charge Type Id"),
|
||||
tr("Changed"),
|
||||
tr("Charge Type Name"),
|
||||
tr("Total Stock"),
|
||||
tr("Gear Class")},
|
||||
parent)
|
||||
{}
|
||||
|
||||
bool ChargeAdministrationAdlerModel::initModel(LtsSession::LtsSession *session)
|
||||
ChargeAdministrationAdlerModel::ChargeAdministrationAdlerModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministrationAdler>(
|
||||
{tr("Id"), tr("Charge Type Id"), tr("Changed"), tr("Charge Type Name"), tr("Total Stock"), tr("Gear Class")},
|
||||
parent)
|
||||
{
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
|
||||
m_DynamicParticipantDataMap = m_ppmDtc->dynamicParticipantDatas();
|
||||
QMapIterator<qint32, ParticipantManagement::DynamicParticipantData> iter(m_DynamicParticipantDataMap);
|
||||
while(iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
updateParticipantChargeTypeMap(iter.value());
|
||||
}
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!m_ppmDtc->visibleParties(parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (const ParticipantManagement::Party &p : std::as_const(parties))
|
||||
{
|
||||
updateItem(p.id());
|
||||
}
|
||||
|
||||
connect (m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged,
|
||||
this, &ChargeAdministrationAdlerModel::onStateChanged);
|
||||
connect (m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &ChargeAdministrationAdlerModel::onParticipantChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onStateChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
|
||||
bool ChargeAdministrationAdlerModel::initModel(LtsSession::LtsSession* session)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ DataModification --> " << modType;
|
||||
updateParticipantChargeTypeMap(data);
|
||||
|
||||
updateItem(m_ppmDtc->participant(data.participantId()).partyId());
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
|
||||
m_DynamicParticipantDataMap = m_ppmDtc->dynamicParticipantDatas();
|
||||
QMapIterator<qint32, ParticipantManagement::DynamicParticipantData> iter(m_DynamicParticipantDataMap);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
updateParticipantChargeTypeMap(iter.value());
|
||||
}
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!m_ppmDtc->visibleParties(
|
||||
parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const ParticipantManagement::Party& p : std::as_const(parties))
|
||||
{
|
||||
updateItem(p.id());
|
||||
}
|
||||
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged, this,
|
||||
&ChargeAdministrationAdlerModel::onStateChanged);
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged, this,
|
||||
&ChargeAdministrationAdlerModel::onParticipantChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onParticipantChanged(const ParticipantManagement::Participant &data,
|
||||
void ChargeAdministrationAdlerModel::onStateChanged(const ParticipantManagement::DynamicParticipantData& data,
|
||||
DataModification modType)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
DEBUG_LOG(m_logger) << "+++++++++ DataModification --> " << modType;
|
||||
updateParticipantChargeTypeMap(data);
|
||||
|
||||
updateItem(m_ppmDtc->participant(data.participantId()).partyId());
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onParticipantChanged(const ParticipantManagement::Participant& data,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType)
|
||||
qint32 typeId = data.typeId();
|
||||
qint32 participantId = data.id();
|
||||
Q_UNUSED(modType)
|
||||
qint32 typeId = data.typeId();
|
||||
qint32 participantId = data.id();
|
||||
|
||||
|
||||
if (!data.isDeleted() || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
if (!data.isDeleted() || (!m_ppmDtc->isAdlerType(typeId) && (m_ppmDtc->type(typeId).typeClass().underlying() !=
|
||||
ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
|
||||
if (m_participantChargeTypeMap.contains(participantId))
|
||||
{
|
||||
|
||||
QList<qint32> keys = m_participantChargeTypeMap.value(participantId).chargeTypeTotalStockMap.keys();
|
||||
for ( int key : keys)
|
||||
if (m_participantChargeTypeMap.contains(participantId))
|
||||
{
|
||||
int row = findRowForChargeTypeId(key, m_participantChargeTypeMap.value(participantId).partyId);
|
||||
if (row != -1)
|
||||
removeRow(row);
|
||||
}
|
||||
|
||||
m_participantChargeTypeMap.remove(participantId);
|
||||
}
|
||||
|
||||
|
||||
updateItem(data.partyId());
|
||||
QList<qint32> keys = m_participantChargeTypeMap.value(participantId).chargeTypeTotalStockMap.keys();
|
||||
for (int key : keys)
|
||||
{
|
||||
int row = findRowForChargeTypeId(key, m_participantChargeTypeMap.value(participantId).partyId);
|
||||
if (row != -1)
|
||||
removeRow(row);
|
||||
}
|
||||
|
||||
m_participantChargeTypeMap.remove(participantId);
|
||||
}
|
||||
|
||||
updateItem(data.partyId());
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::updateParticipantChargeTypeMap(const ParticipantManagement::DynamicParticipantData &data)
|
||||
void ChargeAdministrationAdlerModel::updateParticipantChargeTypeMap(
|
||||
const ParticipantManagement::DynamicParticipantData& data)
|
||||
{
|
||||
qint32 participantId = data.participantId();
|
||||
qint64 sampleTime = data.sampleTime();
|
||||
qint32 typeId = m_ppmDtc->participant(participantId).typeId();
|
||||
bool isDeleted = m_ppmDtc->participant(participantId).isDeleted();
|
||||
qint32 participantId = data.participantId();
|
||||
qint64 sampleTime = data.sampleTime();
|
||||
qint32 typeId = m_ppmDtc->participant(participantId).typeId();
|
||||
bool isDeleted = m_ppmDtc->participant(participantId).isDeleted();
|
||||
|
||||
if (isDeleted || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
if (isDeleted || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
for (const ParticipantManagement::GearInformation &ct : data.gear())
|
||||
{
|
||||
if (m_pdmDtc->adlerChargeTypeName(ct.chargeTypeId()).isEmpty())
|
||||
continue;
|
||||
|
||||
GearData gearData;
|
||||
gearData.remain = ct.remain();
|
||||
gearData.lastUpdate = ct.lastUpdate();
|
||||
if (chargeTypeGearData.contains(ct.chargeTypeId()))
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
for (const ParticipantManagement::GearInformation& ct : data.gear())
|
||||
{
|
||||
gearData.remain += chargeTypeGearData.value(ct.chargeTypeId()).remain;
|
||||
if (m_pdmDtc->adlerChargeTypeName(ct.chargeTypeId()).isEmpty())
|
||||
continue;
|
||||
|
||||
GearData gearData;
|
||||
gearData.remain = ct.remain();
|
||||
gearData.lastUpdate = ct.lastUpdate();
|
||||
if (chargeTypeGearData.contains(ct.chargeTypeId()))
|
||||
{
|
||||
gearData.remain += chargeTypeGearData.value(ct.chargeTypeId()).remain;
|
||||
}
|
||||
chargeTypeGearData.insert(ct.chargeTypeId(), gearData);
|
||||
}
|
||||
chargeTypeGearData.insert(ct.chargeTypeId(), gearData);
|
||||
}
|
||||
m_participantChargeTypeMap.insert(participantId,
|
||||
ChargeStruct(participantId, m_ppmDtc->participant(participantId).partyId(),
|
||||
sampleTime, chargeTypeGearData));
|
||||
m_participantChargeTypeMap.insert(
|
||||
participantId,
|
||||
ChargeStruct(participantId, m_ppmDtc->participant(participantId).partyId(), sampleTime, chargeTypeGearData));
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::updateItem(int partyId)
|
||||
{
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
qint64 sampleTime=0;
|
||||
ChargeAdministrationAdler item;
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
qint64 sampleTime = 0;
|
||||
ChargeAdministrationAdler item;
|
||||
|
||||
for (const ChargeStruct &participantCharges : std::as_const(m_participantChargeTypeMap))
|
||||
{
|
||||
if (participantCharges.partyId != partyId)
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "+++++++++ ParticipantId -> " << participantCharges.participantId << ", sampleTime ->" << sampleTime;
|
||||
for (auto it = participantCharges.chargeTypeTotalStockMap.cbegin(), end = participantCharges.chargeTypeTotalStockMap.cend(); it != end; ++it)
|
||||
for (const ChargeStruct& participantCharges : std::as_const(m_participantChargeTypeMap))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ chargeRemain ->" << it.key() << ": " << it.value().remain
|
||||
<< it.value().lastUpdate;
|
||||
GearData data;
|
||||
data.lastUpdate = it.value().lastUpdate;
|
||||
data.remain = it.value().remain;
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
{
|
||||
data.remain += chargeTypeGearData.value(it.key()).remain;
|
||||
}
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
if (chargeTypeGearData.value(it.key()).lastUpdate > data.lastUpdate)
|
||||
data.lastUpdate = chargeTypeGearData.value(it.key()).lastUpdate;
|
||||
if (participantCharges.partyId != partyId)
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "+++++++++ ParticipantId -> " << participantCharges.participantId << ", sampleTime ->"
|
||||
<< sampleTime;
|
||||
for (auto it = participantCharges.chargeTypeTotalStockMap.cbegin(),
|
||||
end = participantCharges.chargeTypeTotalStockMap.cend();
|
||||
it != end; ++it)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ chargeRemain ->" << it.key() << ": " << it.value().remain
|
||||
<< it.value().lastUpdate;
|
||||
GearData data;
|
||||
data.lastUpdate = it.value().lastUpdate;
|
||||
data.remain = it.value().remain;
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
{
|
||||
data.remain += chargeTypeGearData.value(it.key()).remain;
|
||||
}
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
if (chargeTypeGearData.value(it.key()).lastUpdate > data.lastUpdate)
|
||||
data.lastUpdate = chargeTypeGearData.value(it.key()).lastUpdate;
|
||||
|
||||
chargeTypeGearData.insert(it.key(), data);
|
||||
chargeTypeGearData.insert(it.key(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.partyId = partyId;
|
||||
for (auto gearData = chargeTypeGearData.cbegin(), end = chargeTypeGearData.cend(); gearData != end; ++gearData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "### PartyId " << item.partyId << " insert item -> chargeTypeId: " << gearData.key() << ", amount: " << gearData.value().remain
|
||||
<< ", lastUpdate:" << gearData.value().lastUpdate;
|
||||
item.partyId = partyId;
|
||||
for (auto gearData = chargeTypeGearData.cbegin(), end = chargeTypeGearData.cend(); gearData != end; ++gearData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "### PartyId " << item.partyId << " insert item -> chargeTypeId: " << gearData.key()
|
||||
<< ", amount: " << gearData.value().remain
|
||||
<< ", lastUpdate:" << gearData.value().lastUpdate;
|
||||
|
||||
item.chargeTypeId = gearData.key();
|
||||
item.sampleTime = gearData.value().lastUpdate;
|
||||
item.amount = gearData.value().remain;
|
||||
int row = findRowForChargeTypeId(item.chargeTypeId, item.partyId);
|
||||
if (row < 0)
|
||||
insertRow(item);
|
||||
else
|
||||
setRowData(row, item);
|
||||
}
|
||||
item.chargeTypeId = gearData.key();
|
||||
item.sampleTime = gearData.value().lastUpdate;
|
||||
item.amount = gearData.value().remain;
|
||||
int row = findRowForChargeTypeId(item.chargeTypeId, item.partyId);
|
||||
if (row < 0)
|
||||
insertRow(item);
|
||||
else
|
||||
setRowData(row, item);
|
||||
}
|
||||
}
|
||||
|
||||
int ChargeAdministrationAdlerModel::findRowForChargeTypeId(qint32 typeId, qint32 partyId) const
|
||||
{
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
if (m_vecData.at(i).chargeTypeId == typeId && m_vecData.at(i).partyId == partyId)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
if (m_vecData.at(i).chargeTypeId == typeId && m_vecData.at(i).partyId == partyId)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
QVariant ChargeAdministrationAdlerModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ChargeAdministrationAdlerModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministrationAdler& item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id;
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId;
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime);
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId, true);
|
||||
case ColStock:
|
||||
return item.amount;
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId));
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministrationAdler &item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id;
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId;
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime);
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId, true);
|
||||
case ColStock:
|
||||
return item.amount;
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+119
-117
@@ -1,188 +1,190 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_list.h"
|
||||
#include <utility>
|
||||
|
||||
#include "CustomView/aes_charge_administration.h"
|
||||
#include "aes_charge_administration_model.h"
|
||||
#include "aes_charge_edit.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeAdministrationList::ChargeAdministrationList(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_sourceModel(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ChargeAdministrationList)
|
||||
ChargeAdministrationList::ChargeAdministrationList(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_model(nullptr), m_sourceModel(nullptr),
|
||||
m_session(nullptr), m_ftc(nullptr), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_ui(new Ui::ChargeAdministrationList)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this,
|
||||
&ChargeAdministrationList::onPartyChanged);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ChargeAdministrationList::onPartyChanged);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration"));
|
||||
}
|
||||
|
||||
ChargeAdministrationList::~ChargeAdministrationList() { delete m_ui; }
|
||||
ChargeAdministrationList::~ChargeAdministrationList()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::retranslate() { translate(m_ui, tr("Charge Administration")); }
|
||||
void ChargeAdministrationList::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Charge Administration"));
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::enaDisa()
|
||||
{
|
||||
LtsWidgets::ExerciseStates allowedStates = LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
LtsWidgets::ExerciseStates allowedStates =
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit,
|
||||
bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove,
|
||||
bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onPartyChanged() { m_model->setParty(m_ui->cbParty->currentData().toInt()); }
|
||||
void ChargeAdministrationList::onPartyChanged()
|
||||
{
|
||||
m_model->setParty(m_ui->cbParty->currentData().toInt());
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onChargeAdministrationModifyReply(const Core::FunctionReplyObject &replyObject) { m_requestHelper->requestReply(replyObject); }
|
||||
void ChargeAdministrationList::onChargeAdministrationModifyReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationList::init(LtsSession::LtsSession *session)
|
||||
bool ChargeAdministrationList::init(LtsSession::LtsSession* session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &ChargeAdministrationList::onEditCharge);
|
||||
}
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationList::onPrint);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationModel(this);
|
||||
|
||||
QVector<ChargeAdministrationModifyRequest> reqs;
|
||||
if (!m_sourceModel->initModel(m_session, reqs))
|
||||
return false;
|
||||
|
||||
if (!reqs.isEmpty())
|
||||
{
|
||||
for (const ChargeAdministrationModifyRequest &req : std::as_const(reqs))
|
||||
if (m_session)
|
||||
{
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_model = new ChargeAdministrationSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewChargeAdministration(this); });
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this,
|
||||
&ChargeAdministrationList::onEditCharge);
|
||||
}
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ChargeAdministrationList::enaDisa);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationList::onPrint);
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationModel(this);
|
||||
|
||||
QVector<ChargeAdministrationModifyRequest> reqs;
|
||||
if (!m_sourceModel->initModel(m_session, reqs))
|
||||
return false;
|
||||
|
||||
if (!reqs.isEmpty())
|
||||
{
|
||||
for (const ChargeAdministrationModifyRequest& req : std::as_const(reqs))
|
||||
{
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
}
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
m_model = new ChargeAdministrationSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewChargeAdministration(this); });
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ChargeAdministrationList::enaDisa);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
bool onlydebugMode = true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColChanged, onlydebugMode);
|
||||
bool onlydebugMode = true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColChanged, onlydebugMode);
|
||||
#endif
|
||||
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationModel::ColTypeName, Qt::AscendingOrder);
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationModel::ColTypeName, Qt::AscendingOrder);
|
||||
enaDisa();
|
||||
|
||||
enaDisa();
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onPrint()
|
||||
{
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header);
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onEditCharge()
|
||||
{
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
if (item.id() < 0)
|
||||
return;
|
||||
if (item.id() < 0)
|
||||
return;
|
||||
|
||||
ProjectDataManagement::ChargeType ct = m_sourceModel->chargeType(item.chargeTypeId());
|
||||
ProjectDataManagement::ChargeType ct = m_sourceModel->chargeType(item.chargeTypeId());
|
||||
|
||||
const QModelIndex temp = m_ui->widget->currentIndex();
|
||||
const QModelIndex temp = m_ui->widget->currentIndex();
|
||||
|
||||
const QModelIndex mi = temp.sibling(temp.row(), ChargeAdministrationModel::ColTypeName);
|
||||
auto ce = new ChargeEdit(ct.id(), m_sourceModel->data(mi).toString(), item.amount(), this);
|
||||
connect(ce, &ChargeEdit::newStock, this, &ChargeAdministrationList::onChargeEditFinished);
|
||||
connect(ce, &ChargeEdit::newStock, ce, &ChargeEdit::deleteLater);
|
||||
ce->show();
|
||||
const QModelIndex mi = temp.sibling(temp.row(), ChargeAdministrationModel::ColTypeName);
|
||||
auto ce = new ChargeEdit(ct.id(), m_sourceModel->data(mi).toString(), item.amount(), this);
|
||||
connect(ce, &ChargeEdit::newStock, this, &ChargeAdministrationList::onChargeEditFinished);
|
||||
connect(ce, &ChargeEdit::newStock, ce, &ChargeEdit::deleteLater);
|
||||
ce->show();
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onChargeEditFinished(int chargeId, int newStock)
|
||||
{
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
if (item.chargeTypeId() != chargeId)
|
||||
return;
|
||||
if (item.chargeTypeId() != chargeId)
|
||||
return;
|
||||
|
||||
if (item.amount() == newStock)
|
||||
return;
|
||||
item.amount(newStock);
|
||||
if (item.amount() == newStock)
|
||||
return;
|
||||
item.amount(newStock);
|
||||
|
||||
bool amountChangedByOperator = true;
|
||||
const ChargeAdministrationModifyRequest req(item.id(),
|
||||
item.chargeTypeId(),
|
||||
item.partyId(),
|
||||
item.effectSourceId(),
|
||||
item.amount(),
|
||||
amountChangedByOperator);
|
||||
bool amountChangedByOperator = true;
|
||||
const ChargeAdministrationModifyRequest req(item.id(), item.chargeTypeId(), item.partyId(), item.effectSourceId(),
|
||||
item.amount(), amountChangedByOperator);
|
||||
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
m_requestHelper->startRequests();
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable → Regular
+121
-126
@@ -1,172 +1,167 @@
|
||||
|
||||
|
||||
|
||||
#include "aes_charge_administration_model.h"
|
||||
#include <utility>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChargeAdministrationSortFilterProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
void ChargeAdministrationSortFilterProxyModel::setSourceModel(QAbstractItemModel* model)
|
||||
{
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationModel *>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool ChargeAdministrationSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministration& item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId() != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministration &item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId() != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
int ChargeAdministrationSortFilterProxyModel::party() const { return m_party; }
|
||||
int ChargeAdministrationSortFilterProxyModel::party() const
|
||||
{
|
||||
return m_party;
|
||||
}
|
||||
|
||||
void ChargeAdministrationSortFilterProxyModel::setParty(int party)
|
||||
{
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ChargeAdministrationModel::ChargeAdministrationModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministration>({tr("Id"),
|
||||
tr("Charge Type Id"),
|
||||
tr("Changed"),
|
||||
tr("Charge Type Name"),
|
||||
tr("Total Stock"),
|
||||
tr("Planned"),
|
||||
tr("Available"),
|
||||
tr("Used"),
|
||||
tr("Gear Class")},
|
||||
ChargeAdministrationModel::ChargeAdministrationModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministration>({tr("Id"), tr("Charge Type Id"), tr("Changed"),
|
||||
tr("Charge Type Name"), tr("Total Stock"), tr("Planned"),
|
||||
tr("Available"), tr("Used"), tr("Gear Class")},
|
||||
parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool ChargeAdministrationModel::initModel(LtsSession::LtsSession *session, QVector<ChargeAdministrationModifyRequest> &reqs)
|
||||
bool ChargeAdministrationModel::initModel(LtsSession::LtsSession* session,
|
||||
QVector<ChargeAdministrationModifyRequest>& reqs)
|
||||
{
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
return false;
|
||||
|
||||
m_chargeTypeMap = m_pdmDtc->chargeTypes();
|
||||
|
||||
connect(m_aesDtc.get(), &Interface::Dtc::chargeAdministrationChanged, this, &ChargeAdministrationModel::onChargeAdministrationChanged);
|
||||
|
||||
QVector<QPair<int, int>> chargesInserted;
|
||||
auto cb = [this, &chargesInserted](const ChargeAdministration &item)
|
||||
{
|
||||
|
||||
const int chargeTypeId = item.chargeTypeId();
|
||||
if (m_pdmDtc->isAdlerChargeType(chargeTypeId))
|
||||
return;
|
||||
|
||||
insertRow(item);
|
||||
chargesInserted.append(qMakePair<int, int>(item.chargeTypeId(), item.partyId()));
|
||||
};
|
||||
m_aesDtc->chargeAdministrations(cb);
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!ppmDtc->visibleParties(parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<ProjectDataManagement::ChargeType> chargesForGearClass
|
||||
= m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Artillery) + m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Mortar);
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableRocket = ps->value(QStringLiteral("aes"), QStringLiteral("enableRocket"), false).toBool();
|
||||
if (enableRocket)
|
||||
chargesForGearClass += m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Rocket);
|
||||
for (const ParticipantManagement::Party &p : std::as_const(parties))
|
||||
{
|
||||
for (const ProjectDataManagement::ChargeType &ct : std::as_const(chargesForGearClass))
|
||||
if (m_aesDtc)
|
||||
{
|
||||
if (chargesInserted.contains(qMakePair(ct.id(), p.id())) || isDummy(ct) || m_pdmDtc->isAdlerChargeType(ct.id()))
|
||||
continue;
|
||||
|
||||
reqs << ChargeAdministrationModifyRequest(0, ct.id(), p.id(), ProjectDataManagement::EffectSource::ES_Internal, 0, true);
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
return false;
|
||||
|
||||
m_chargeTypeMap = m_pdmDtc->chargeTypes();
|
||||
|
||||
connect(m_aesDtc.get(), &Interface::Dtc::chargeAdministrationChanged, this,
|
||||
&ChargeAdministrationModel::onChargeAdministrationChanged);
|
||||
|
||||
QVector<QPair<int, int>> chargesInserted;
|
||||
auto cb = [this, &chargesInserted](const ChargeAdministration& item) {
|
||||
const int chargeTypeId = item.chargeTypeId();
|
||||
if (m_pdmDtc->isAdlerChargeType(chargeTypeId))
|
||||
return;
|
||||
|
||||
insertRow(item);
|
||||
chargesInserted.append(qMakePair<int, int>(item.chargeTypeId(), item.partyId()));
|
||||
};
|
||||
m_aesDtc->chargeAdministrations(cb);
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!ppmDtc->visibleParties(
|
||||
parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<ProjectDataManagement::ChargeType> chargesForGearClass =
|
||||
m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Artillery) +
|
||||
m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Mortar);
|
||||
|
||||
LtsUtils::ProjectSettings* ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableRocket = ps->value(QStringLiteral("aes"), QStringLiteral("enableRocket"), false).toBool();
|
||||
if (enableRocket)
|
||||
chargesForGearClass += m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Rocket);
|
||||
for (const ParticipantManagement::Party& p : std::as_const(parties))
|
||||
{
|
||||
for (const ProjectDataManagement::ChargeType& ct : std::as_const(chargesForGearClass))
|
||||
{
|
||||
if (chargesInserted.contains(qMakePair(ct.id(), p.id())) || isDummy(ct) ||
|
||||
m_pdmDtc->isAdlerChargeType(ct.id()))
|
||||
continue;
|
||||
|
||||
reqs << ChargeAdministrationModifyRequest(0, ct.id(), p.id(),
|
||||
ProjectDataManagement::EffectSource::ES_Internal, 0, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChargeAdministrationModel::isDummy(const ProjectDataManagement::ChargeType &ct)
|
||||
bool ChargeAdministrationModel::isDummy(const ProjectDataManagement::ChargeType& ct)
|
||||
{
|
||||
return LtsUtils::JsonObject::fromJson(ct.properties()).valueOr<bool>("isDummy", false);
|
||||
return LtsUtils::JsonObject::fromJson(ct.properties()).valueOr<bool>("isDummy", false);
|
||||
}
|
||||
|
||||
QVariant ChargeAdministrationModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ChargeAdministrationModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministration& item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id();
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId();
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime());
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId(), true);
|
||||
case ColStock:
|
||||
return item.amount();
|
||||
case ColAvailable:
|
||||
return item.amount() - item.planned();
|
||||
case ColPlanned:
|
||||
return item.planned();
|
||||
case ColUsed:
|
||||
return item.used();
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId()));
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministration &item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id();
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId();
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime());
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId(), true);
|
||||
case ColStock:
|
||||
return item.amount();
|
||||
case ColAvailable:
|
||||
return item.amount() - item.planned();
|
||||
case ColPlanned:
|
||||
return item.planned();
|
||||
case ColUsed:
|
||||
return item.used();
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId()));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ChargeAdministrationModel::onChargeAdministrationChanged(const ChargeAdministration &data, DataModification modType)
|
||||
void ChargeAdministrationModel::onChargeAdministrationChanged(const ChargeAdministration& data,
|
||||
DataModification modType)
|
||||
{
|
||||
|
||||
if (m_pdmDtc->isAdlerChargeType(data.chargeTypeId()))
|
||||
return;
|
||||
onDataChanged(data, modType);
|
||||
|
||||
if (m_pdmDtc->isAdlerChargeType(data.chargeTypeId()))
|
||||
return;
|
||||
onDataChanged(data, modType);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Reference in new issue
Block a user