94 lines
2.5 KiB
C++
Executable File
94 lines
2.5 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* The ParticipantModel provices participant data for SimulationDialog
|
|
* $Id: ism_asset_list_dialog_model.h 58852 2023-02-01 11:28:56Z fritsche_h $
|
|
* $HeadURL: svn://192.168.133.21/TDS/branches/product/features/3dws_devel/Lts/Plugins/InfrastructureManagement/Gui/ResourceManagement/AssetList/ism_asset_list_dialog_model.h $
|
|
* $Author: fritsche_h $
|
|
* Created by Hannes Fritsche, ESZS, 2024-09-19
|
|
*/
|
|
|
|
#include "cds_participant_model.h"
|
|
|
|
#include <ParticipantManagement/ppm_dtc.h>
|
|
|
|
namespace CollateralDamageSimulation
|
|
{
|
|
|
|
ParticipantModel::ParticipantModel(QObject *parent)
|
|
: LtsWidgets::LtsAbstractTableModel<ParticipantManagement::Participant>(
|
|
{
|
|
tr("Party"),
|
|
tr("Equipment Number"),
|
|
tr("Designator"),
|
|
tr("Tactical Identifier")
|
|
},
|
|
parent)
|
|
{
|
|
|
|
}
|
|
|
|
QVariant ParticipantModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if (role != Qt::DisplayRole || !indexIsValid(index))
|
|
return QVariant();
|
|
|
|
if (role == Qt::DisplayRole)
|
|
{
|
|
const ParticipantManagement::Participant &participant = m_vecData.at(index.row());
|
|
|
|
switch (index.column())
|
|
{
|
|
case PARTY:
|
|
{
|
|
const int partyId = participant.partyId();
|
|
|
|
if (!m_partyCache.contains(partyId))
|
|
m_partyCache.insert(partyId, m_ppmDtc->party(partyId));
|
|
|
|
const ParticipantManagement::Party &party = m_partyCache.value(partyId);
|
|
|
|
return QString::fromStdString(party.name());
|
|
}
|
|
case EQUIPMENT_NUMBER:
|
|
return participant.equipmentNumber().is_set() ? participant.equipmentNumber().get() : 0;
|
|
case DESIGNATOR:
|
|
return QString::fromStdString(participant.designator());
|
|
case TACTICAL_IDENTIFIER:
|
|
return QString::fromStdString(participant.tacticalIdentifier());
|
|
default:
|
|
return QVariant();
|
|
}
|
|
}
|
|
|
|
return QVariant();
|
|
}
|
|
|
|
bool ParticipantModel::initModel(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc, const QVector<int> &participantIds)
|
|
{
|
|
m_partyCache.clear();
|
|
|
|
m_vecData.clear();
|
|
m_vecData.reserve(participantIds.size());
|
|
|
|
m_ppmDtc = ppmDtc;
|
|
|
|
if (!m_ppmDtc->isParticipantEnabled())
|
|
{
|
|
m_ppmDtc->enableParticipant();
|
|
m_ppmDtc->waitForHistoricalDataParticipant(3000);
|
|
}
|
|
|
|
if (!m_ppmDtc->isPartyEnabled())
|
|
{
|
|
m_ppmDtc->enableParty();
|
|
m_ppmDtc->waitForHistoricalDataParty(3000);
|
|
}
|
|
|
|
for (int currentParticipantId : participantIds)
|
|
m_vecData.append(m_ppmDtc->participant(currentParticipantId));
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace CollateralDamageSimulation
|