81 lines
2.7 KiB
C++
Executable File
81 lines
2.7 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Model for ParticipantsMoveDialog
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Gerlinde Rudolphus, SLSE, 2018-01-02
|
|
*/
|
|
|
|
#include "participants_move_model.h"
|
|
|
|
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
|
|
|
|
|
namespace CentralEffectSimulation
|
|
{
|
|
//----------------------------------------------------------------------------
|
|
ParticipantMoveModel::ParticipantMoveModel(QObject *parent,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
|
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc)
|
|
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc)
|
|
, m_logger(getLogger("ParticipantMoveModel"))
|
|
{
|
|
m_titles += tr("Simulated");
|
|
|
|
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
|
this, &ParticipantMoveModel::onParticipantChanged);
|
|
|
|
DEBUG_LOG(m_logger) << "ParticipantMoveModel::ParticipantMoveModel";
|
|
}
|
|
|
|
|
|
QVariant ParticipantMoveModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
// ColSimulated is the last column
|
|
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
|
{
|
|
bool bIsSimulated = false;
|
|
if (!isSelectableBySimulation(index, &bIsSimulated))
|
|
return QVariant();
|
|
return bIsSimulated ? tr("Yes") : tr("No");
|
|
}
|
|
|
|
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
|
}
|
|
|
|
void ParticipantMoveModel::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
|
{
|
|
Q_UNUSED(modType)
|
|
if (data.partyId() != m_partyId)
|
|
return;
|
|
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
|
onReinitModel(partyId());
|
|
emit newData();
|
|
}
|
|
|
|
bool ParticipantMoveModel::isSelectableBySimulation(const QModelIndex &index, bool *bIsSimulated) const
|
|
{
|
|
bool isSimulatable = true;
|
|
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
|
|
|
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
|
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
|
isSimulatable = false;
|
|
|
|
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id()
|
|
<< " isSimulated:" << data.isSimulated()
|
|
<< " equipmentNo:" << data.equipmentNumber()
|
|
<< " typeId=" << data.typeId()
|
|
<< " modId=" << data.modId()
|
|
<< " typeClass=" << m_dtc->type(data.typeId()).typeClass()
|
|
<< " isSimulatable=" << isSimulatable;
|
|
|
|
if (bIsSimulated)
|
|
*bIsSimulated = data.isSimulated();
|
|
|
|
return isSimulatable;
|
|
}
|
|
|
|
} // namespace CentralEffectSimulation
|