Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,259 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection AES Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_aes_model.h"
#include <ngltools/ngltools_dtg.h>
#include <QDateTime>
namespace ReportManagement
{
ReportAesModel::ReportAesModel(const ReportType &reportType,
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ReportAesEntry>({
tr("Name"),
tr("Charge Type"),
tr("Start Time"),
tr("End Time"),
tr("Party")}, parent)
, m_partyId(-1)
, m_aesDtc(aesDtc)
, m_pdmDtc(pdmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportAesModel"))
{
}
bool ReportAesModel::initModel(int partyId)
{
if (!m_aesDtc || !m_pdmDtc)
return false;
m_partyId = partyId;
clear();
switch (m_reportType.underlying())
{
case ReportType::Nbc:
{
auto cb = [this](const AreaEffectSimulation::BCContamination & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||
m_partyId == 0 || cont.partyId() != m_partyId)
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->bCContaminations(cb);
auto cbN = [this](const AreaEffectSimulation::NContamination & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared || m_partyId > 0) // No N-areas for other Party selected than Pool
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->nContaminations(cbN);
break;
}
case ReportType::Firings:
case ReportType::AirSupport:
case ReportType::ExplosiveDevice:
{
auto cb = [this](const AreaEffectSimulation::ExplosionSingle & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||
(m_partyId > 0 && cont.partyId() != m_partyId))
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->explosionSingles(cb);
auto cbA = [this](const AreaEffectSimulation::ExplosionArea & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||
(m_partyId > 0 && cont.partyId() != m_partyId))
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->explosionAreas(cbA);
break;
}
case ReportType::MineArea:
{
auto cb = [this](const AreaEffectSimulation::MineArea & cont)
{
// do not show deleted mine areas!
if (cont.isDeleted() || /*cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||*/
(m_partyId > 0 && cont.partyId() != m_partyId))
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->mineAreas(cb);
break;
}
default:
return false;
}
return true;
}
//int ReportAesModel::getAesId(const QModelIndex &index) const
//{
// if (index.row() > m_vecData.size())
// return -1;
// return m_vecData.at(index.row()).id;
//}
QVariant ReportAesModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const ReportAesEntry entry = m_vecData.at(index.row());
switch (index.column())
{
case Name:
return entry.name;
case ChargeType:
return m_pdmDtc->trChargeTypeShortName(entry.chargeType, true);
case StartTime:
return QDateTime::fromMSecsSinceEpoch(entry.startTime); //USE same converter from AES
case EndTime:
return QDateTime::fromMSecsSinceEpoch(entry.endTime);
case Party:
return entry.partyId;
}
return QVariant();
}
//
// ReportAesProxyModel
//
bool ReportAesProxyModel::initModel(int partyId)
{
return m_sourceModel ? m_sourceModel->initModel(partyId) : false;
}
int ReportAesProxyModel::getId(const QModelIndex &index) const
{
if (!m_sourceModel)
{
Q_ASSERT(false);
return -1;
}
return m_sourceModel->getId(mapToSource(index));
}
void ReportAesProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
m_sourceModel = qobject_cast<ReportAesModel*>(sourceModel);
QSortFilterProxyModel::setSourceModel(sourceModel);
}
bool ReportAesProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{
if (!m_sourceModel ||
source_left.column() != source_right.column() ||
!source_left.isValid() ||
!source_right.isValid())
return QSortFilterProxyModel::lessThan(source_left, source_right);
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
switch (source_left.column())
{
case ReportAesModel::StartTime:
return dataLeft.startTime < dataRight.startTime;
case ReportAesModel::EndTime:
return dataLeft.endTime < dataRight.endTime;
case ReportAesModel::Name:
case ReportAesModel::ChargeType:
case ReportAesModel::Party:
break;
}
return QSortFilterProxyModel::lessThan(source_left, source_right);
}
} //namespace ReportManagement
@@ -0,0 +1,86 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection AES Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h> //oh hell.. we will split this someday..
#include <ReportManagement/rep_enums.hpp>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <QSortFilterProxyModel>
namespace ReportManagement
{
// This struct needs a "id()" method, to be able to evaluate LtsWidgets::LtsAbstractTableModel<ReportAesEntry>::getId() properly.
struct ReportAesEntry
{
QString name;
int64_t startTime = 0;
int64_t endTime = 0;
int chargeType = 0;
int partyId = 0;
int id() const { return _id; }
void setId(int newId) { _id = newId; }
private:
int _id = 0;
};
class ReportAesModel final : public LtsWidgets::LtsAbstractTableModel<ReportAesEntry>
{
public:
enum Columns
{
Name,
ChargeType,
StartTime,
EndTime,
Party
};
Q_OBJECT
public:
explicit ReportAesModel(const ReportType &reportType,
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent = nullptr);
bool initModel(int partyId);
QVariant data(const QModelIndex &index, int role) const override final;
private:
int m_partyId;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
friend class ReportAesProxyModel;
};
class ReportAesProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
using QSortFilterProxyModel::QSortFilterProxyModel;
bool initModel(int partyId);
int getId(const QModelIndex &index) const;
void setSourceModel(QAbstractItemModel *sourceModel) override;
protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
private:
ReportAesModel *m_sourceModel = nullptr;
};
} //namespace
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Buildings Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_building_model.h"
namespace ReportManagement
{
ReportBuildingModel::ReportBuildingModel(LtsSession::LtsSession *session,
const ReportManagement::ReportType &reportType,
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<InfrastructureManagement::MainStructureElement>(
{
tr("Name")
},
parent)
, m_session(session)
, m_ismDtc(ismDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportBuildingModel"))
{
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
this, &ReportBuildingModel::onDataChanged);
initModel();
}
bool ReportBuildingModel::initModel()
{
if (!m_ismDtc)
return false;
clear();
auto cb = [this] (const InfrastructureManagement::MainStructureElement &mse)
{
#ifdef GUEZ_MODE
if (m_ismDtc->isElementAssignedToExercise(mse, m_session->exerciseId()) && mse.id() >= 1000)
#else
if (m_ismDtc->isElementAssignedToExercise(mse, m_session->exerciseId()) && mse.externalWlsId() > 0)
#endif
onDataChanged(mse, DataModification::eAdded);
};
m_ismDtc->mainStructureElements(cb);
return true;
}
QVariant ReportBuildingModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const InfrastructureManagement::MainStructureElement &mse = m_vecData.at(index.row());
switch (index.column())
{
case BUILDING_NAME:
return m_ismDtc->getBuildingDisplayName(mse);
}
return QVariant();
}
} //namespace ReportManagement
@@ -0,0 +1,45 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Buildings Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_enums.hpp>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <LtsSession/lts_session.h>
namespace ReportManagement
{
class ReportBuildingModel final : public LtsWidgets::LtsAbstractTableModel<InfrastructureManagement::MainStructureElement>
{
Q_OBJECT
public:
enum Columns
{
BUILDING_NAME = 0
};
explicit ReportBuildingModel(LtsSession::LtsSession *session,
const ReportManagement::ReportType &reportType,
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
QObject *parent = nullptr);
~ReportBuildingModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
private:
LtsSession::LtsSession *m_session;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
} //namespace ReportManagement
@@ -0,0 +1,154 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Charge Types Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_charge_model.h"
#include <ProjectDataManagement/pdm_translation.h>
#include <LtsUtils/LtsUtilsCore/json_object.h>
namespace ReportManagement
{
ReportChargeModel::ReportChargeModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::ChargeType>(
{
tr("Name"),
tr("Gear Class"),
tr("Charge Id")
},
parent)
, m_pdmDtc(pdmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportChargeModel"))
{
connect(m_pdmDtc.get(), &ProjectDataManagement::Interface::Dtc::chargeTypeChanged,
this, &ReportChargeModel::onDataChanged);
initModel();
}
bool ReportChargeModel::initModel()
{
if (!m_pdmDtc)
return false;
clear();
auto cb = [this](const ProjectDataManagement::ChargeType &ct)
{
onDataChanged(ct, DataModification::eAdded);
};
return m_pdmDtc->chargeTypes(cb);
}
QVariant ReportChargeModel::data(const QModelIndex &index, int role) const
{
if (!indexIsValid(index))
return QVariant();
const ProjectDataManagement::ChargeType &charge = m_vecData.at(index.row());
if (role == Qt::ToolTipRole && index.column() == ChargeTypeName)
return m_pdmDtc->trChargeTypeName(charge.id(), true);
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case ChargeTypeName:
return m_pdmDtc->trChargeTypeShortName(charge.id(), true);
case GearClass:
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(charge.id()));
case ChargeTypeId:
return charge.id();
}
}
return QVariant();
}
bool ReportChargeModel::isFiltered(const ProjectDataManagement::ChargeType &data, DataModification modType) const
{
Q_UNUSED(modType);
if (LtsUtils::JsonObject::fromJson(data.properties()).valueOr<bool>("suppressVisibility", false))
return true;
const ProjectDataManagement::GearClass gc = m_pdmDtc->gearClassFromChargeTypeId(data.id());
switch (m_reportType.underlying())
{
case ReportType::ChargeAdministration:
return (gc != ProjectDataManagement::GearClass::Artillery &&
gc != ProjectDataManagement::GearClass::Mortar &&
gc != ProjectDataManagement::GearClass::Rocket);
case ReportType::ChargeResupply:
// return !m_pdmDtc->isDryFire(data.id());
// update 29.09.2020 after discussion with Ulli: showing same charge types as in Firings report
case ReportType::Firings:
// NOTE: igniterType/IgniterFunciton = 0 as long as ReportChargeModel does not contain values
return (gc != ProjectDataManagement::GearClass::DuelSim ||
m_pdmDtc->isDryFire(data.id(),0,0) || m_pdmDtc->isIed(data.id(),0,0));
// IO 04.09.2018 - REGG-5031: Not only DuelSim, but also Unknown except DryFire and Ied
// update 25.09.2018: Only DuelSim except Ied and DryFire
case ReportType::AirSupport:
return (gc != ProjectDataManagement::GearClass::AirSupport);
case ReportType::ExplosiveDevice:
return !m_pdmDtc->isIed(data.id(),0,0);
default:
break;
}
return false;
}
//
// ReportChargeProxyModel
//
bool ReportChargeProxyModel::initModel()
{
return m_sourceModel ? m_sourceModel->initModel() : false;
}
int ReportChargeProxyModel::getId(const QModelIndex &index) const
{
if (!m_sourceModel)
{
Q_ASSERT(false);
return -1;
}
return m_sourceModel->getId(mapToSource(index));
}
void ReportChargeProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
m_sourceModel = qobject_cast<ReportChargeModel*>(sourceModel);
QSortFilterProxyModel::setSourceModel(sourceModel);
}
bool ReportChargeProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{
if (!m_sourceModel ||
source_left.column() != source_right.column() ||
!source_left.isValid() ||
!source_right.isValid())
return QSortFilterProxyModel::lessThan(source_left, source_right);
//const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
//const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
switch (source_left.column())
{
case ReportChargeModel::GearClass:
case ReportChargeModel::ChargeTypeName:
case ReportChargeModel::ChargeTypeId:
break;
}
return QSortFilterProxyModel::lessThan(source_left, source_right);
}
} //namespace ReportManagement
@@ -0,0 +1,65 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Charge Types Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_dtc.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <QSortFilterProxyModel>
namespace ReportManagement
{
class ReportChargeModel final : public LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::ChargeType>
{
Q_OBJECT
public:
enum Columns
{
ChargeTypeName = 0,
GearClass = 1,
ChargeTypeId = 2
};
explicit ReportChargeModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent = nullptr);
~ReportChargeModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
protected:
bool isFiltered(const ProjectDataManagement::ChargeType &data, DataModification modType) const override;
private:
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
class ReportChargeProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
using QSortFilterProxyModel::QSortFilterProxyModel;
bool initModel();
int getId(const QModelIndex &index) const;
void setSourceModel(QAbstractItemModel *sourceModel) override;
protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
private:
ReportChargeModel *m_sourceModel = nullptr;
};
} //namespace ReportManagement
@@ -0,0 +1,65 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#include "rep_input_sanitation_material_model.h"
#include <ProjectDataManagement/pdm_translation.h>
namespace ReportManagement
{
ReportSanitationMaterialModel::ReportSanitationMaterialModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::SanitationMaterial>(
{
tr("Id"),
tr("Name")
},
parent)
, m_pdmDtc(pdmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportSanitationMaterialModel"))
{
connect(m_pdmDtc.get(), &ProjectDataManagement::Interface::Dtc::sanitationMaterialChanged,
this, &ReportSanitationMaterialModel::onDataChanged);
initModel();
}
bool ReportSanitationMaterialModel::initModel()
{
if (!m_pdmDtc)
return false;
clear();
auto cb = [this](const ProjectDataManagement::SanitationMaterial &sm)
{
onDataChanged(sm, DataModification::eAdded);
};
return m_pdmDtc->sanitationMaterials(cb);
}
QVariant ReportSanitationMaterialModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const ProjectDataManagement::SanitationMaterial &sanMat = m_vecData.at(index.row());
switch (index.column())
{
case MaterialId:
return sanMat.id();
case MaterialName:
return ProjectDataManagement::trSanitationMaterialName(sanMat.name());
}
return QVariant();
}
} //namespace ReportManagement
@@ -0,0 +1,43 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_dtc.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
namespace ReportManagement
{
class ReportSanitationMaterialModel final : public LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::SanitationMaterial>
{
Q_OBJECT
public:
enum Columns
{
MaterialId = 0,
MaterialName = 1
};
explicit ReportSanitationMaterialModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent = nullptr);
~ReportSanitationMaterialModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
private:
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
} //namespace ReportManagement
@@ -0,0 +1,90 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Participant Type Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_type_model.h"
#include <ParticipantManagement/ppm_translation.h>
namespace ReportManagement
{
ReportTypeModel::ReportTypeModel(const ReportType &reportType,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ParticipantManagement::Type>(
{
tr("Name"),
tr("Type Class")
},
parent)
, m_ppmDtc(ppmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportTypeModel"))
{
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::typeChanged,
this, &ReportTypeModel::onDataChanged);
initModel();
}
bool ReportTypeModel::initModel()
{
auto cb = [this](const ParticipantManagement::Type &type)
{
// hide units and types not used
if (m_ppmDtc->isTypeInUse(type.id()) &&
type.typeClass() != ParticipantManagement::TypeClass::Unit &&
type.typeClass() != ParticipantManagement::TypeClass::SupportUnit &&
type.typeClass() != ParticipantManagement::TypeClass::SupportEntity )
onDataChanged(type, DataModification::eAdded);
};
return m_ppmDtc->types(cb);
}
QVariant ReportTypeModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const ParticipantManagement::Type &entry = m_vecData.at(index.row());
switch (index.column())
{
case TypeClass:
return ParticipantManagement::toString(entry.typeClass());
case TypeName:
return QString::fromStdString(entry.name());
}
return QVariant();
}
bool ReportTypeModel::isFiltered(const ParticipantManagement::Type &data, DataModification) const
{
const auto tc = data.typeClass();
switch (m_reportType.underlying())
{
case ReportManagement::ReportType::VehicleRepair:
return (tc != ParticipantManagement::TypeClass::GroundVehicle &&
tc != ParticipantManagement::TypeClass::VehicleWithGear &&
tc != ParticipantManagement::TypeClass::WeaponSystem);
case ReportManagement::ReportType::Decontamination:
case ReportManagement::ReportType::Treatment:
case ReportManagement::ReportType::TreatmentPriority:
case ReportManagement::ReportType::TreatmentTimeline:
case ReportManagement::ReportType::TreatmentChain:
return (tc != ParticipantManagement::TypeClass::Human);
default:
return (tc == ParticipantManagement::TypeClass::Unit ||
tc == ParticipantManagement::TypeClass::SupportUnit ||
tc == ParticipantManagement::TypeClass::SupportEntity);
}
return false;
}
} // namespace ReportManagement
@@ -0,0 +1,47 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Participant Type Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_enums.hpp>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
namespace ReportManagement
{
class ReportTypeModel final : public LtsWidgets::LtsAbstractTableModel<ParticipantManagement::Type>
{
Q_OBJECT
public:
enum Columns
{
TypeName = 0,
TypeClass = 1
};
explicit ReportTypeModel(const ReportType &reportType,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
QObject *parent = nullptr);
~ReportTypeModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
protected:
bool isFiltered(const ParticipantManagement::Type &data, DataModification) const override;
private:
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
} // namespace ReportManagement