Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+79
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for ParticipantsMoveDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLSE, 2018-01-02
|
||||
*/
|
||||
|
||||
#include "alm_participant_model.h"
|
||||
|
||||
#include <AlarmManagement/logger.h>
|
||||
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
//----------------------------------------------------------------------------
|
||||
ParticipantAlarmModel::ParticipantAlarmModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc)
|
||||
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc)
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantAlarmModel"))
|
||||
{
|
||||
m_titles += tr("Alarm Assignable");
|
||||
|
||||
DEBUG_LOG(m_logger) << "ParticipantAlarmModel::ParticipantAlarmModel";
|
||||
}
|
||||
|
||||
QVariant ParticipantAlarmModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
// ColSimulated is the last column
|
||||
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
||||
{
|
||||
bool bIsSimulated = false;
|
||||
if (!isSelectableByAlarm(index, &bIsSimulated))
|
||||
return QVariant();
|
||||
return !bIsSimulated ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
||||
}
|
||||
|
||||
void ParticipantAlarmModel::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.partyId() != partyId())
|
||||
return;
|
||||
|
||||
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
||||
onReinitModel(partyId());
|
||||
emit newData();
|
||||
}
|
||||
|
||||
bool ParticipantAlarmModel::isSelectableByAlarm(const QModelIndex &index, bool *bIsSimulated) const
|
||||
{
|
||||
bool isSimulatable = false;
|
||||
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
||||
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
isSimulatable = true;
|
||||
|
||||
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 ParticipantAlarms
|
||||
Reference in new issue
Block a user