Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+76
@@ -0,0 +1,76 @@
|
||||
#include "asm_training_area_model.h"
|
||||
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
AsmTrainingAreaDialogModel::AsmTrainingAreaDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Botton Left x"),
|
||||
tr("Bottom Left y"),
|
||||
tr("Height"),
|
||||
tr("Width")},
|
||||
//tr("image")},
|
||||
parent)
|
||||
,m_asmDtc(nullptr)
|
||||
,m_logger(getLogger("AsmTrainingAreaDialogModel"))
|
||||
{}
|
||||
|
||||
AsmTrainingAreaDialogModel::~AsmTrainingAreaDialogModel()
|
||||
{}
|
||||
|
||||
bool AsmTrainingAreaDialogModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc, bool hideRemoved)
|
||||
{
|
||||
m_asmDtc = dtc;
|
||||
m_hideRemoved = hideRemoved;
|
||||
|
||||
if (m_asmDtc)
|
||||
{
|
||||
connect(m_asmDtc.get(), &Interface::Dtc::trainingAreaChanged, this, &AsmTrainingAreaDialogModel::onDataChanged);
|
||||
|
||||
m_asmDtc->trainingAreas([this](const AssetManagement::TrainingArea &data)
|
||||
{
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
});
|
||||
|
||||
} else {
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " no m_asmDtc";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AsmTrainingAreaDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index)) //role != Qt::DisplayRole ||
|
||||
return QVariant();
|
||||
|
||||
const AssetManagement::TrainingArea &asmTrainingArea = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return asmTrainingArea.id();
|
||||
case Name:
|
||||
return QString::fromStdString(asmTrainingArea.name());
|
||||
case BottomLeft_x:
|
||||
return asmTrainingArea.bottomLeft().lon();
|
||||
case BottomLeft_y:
|
||||
return asmTrainingArea.bottomLeft().lat();
|
||||
case Height:
|
||||
return asmTrainingArea.height();
|
||||
case Width:
|
||||
return asmTrainingArea.width();
|
||||
// case Image:
|
||||
// return asmTrainingArea.image();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user