67 lines
1.9 KiB
C++
Executable File
67 lines
1.9 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* AreaEffectManangement - Technical Area Overview Dialog Model
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Philipp Dassow, SLEA, 2017-06-09
|
|
*/
|
|
|
|
#include "aes_technical_areas_model.h"
|
|
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
|
#include <QLocale>
|
|
#include <QSet>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
|
|
TechnicalAreasModel::TechnicalAreasModel(QObject *parent)
|
|
: AesGuiBaseModel<TechnicalArea>(parent)
|
|
{}
|
|
|
|
bool TechnicalAreasModel::initModel(LtsSession::LtsSession *session)
|
|
{
|
|
if (!AesGuiBaseModel::initModel(session))
|
|
return false;
|
|
|
|
connect(m_aesDtc.get(), &Interface::Dtc::technicalAreaChanged,
|
|
this, &TechnicalAreasModel::onDataChanged);
|
|
|
|
connect(m_aesDtc.get(), &Interface::Dtc::technicalAreaChanged,
|
|
this, &TechnicalAreasModel::dataChanged);
|
|
|
|
m_aesDtc->technicalAreas([this](const TechnicalArea & item) { insertRow(item); });
|
|
return true;
|
|
}
|
|
|
|
QVariant TechnicalAreasModel::headerData(int section, Qt::Orientation orientation, int role) const
|
|
{
|
|
if (section == BcChargeType && orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
|
return tr("Type");
|
|
if (section == BcEffectState && orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
|
return tr("State");
|
|
return AesGuiBaseModel::headerData(section, orientation, role);
|
|
}
|
|
|
|
QVariant TechnicalAreasModel::data(const QModelIndex &idx, int role) const
|
|
{
|
|
if (!indexIsValid(idx))
|
|
return QVariant();
|
|
// misissue ChargeType for Type :)
|
|
if (role == Qt::DisplayRole && idx.column() == BcChargeType)
|
|
{
|
|
const TechnicalArea &ta = m_vecData.at(idx.row());
|
|
return AreaEffectSimulation::toString(ta.type());
|
|
}
|
|
if (role == Qt::DisplayRole && idx.column() == BcEffectState)
|
|
{
|
|
const TechnicalArea &ta = m_vecData.at(idx.row());
|
|
return AreaEffectSimulation::toString(ta.effectStateId());
|
|
}
|
|
return AesGuiBaseModel::data(idx, role);
|
|
}
|
|
|
|
|
|
|
|
} // namespace AreaEffectSimulation
|