Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManangement - Operator Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "injury_model_model.h"
|
||||
|
||||
#include <WarehouseGuez/whg_dtc.h>
|
||||
#include <WarehouseGuez/logger.h>
|
||||
#include <WarehouseGuez/whg_translation.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
namespace WarehouseManagement
|
||||
{
|
||||
InjuryModelModel::InjuryModelModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<WarehouseGuez::InjuryModelAgdusWh>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Version"),
|
||||
tr("Description")},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(WarehouseGuez::getLogger(QStringLiteral("InjuryModelModel")))
|
||||
{}
|
||||
|
||||
InjuryModelModel::~InjuryModelModel()
|
||||
{}
|
||||
|
||||
bool InjuryModelModel::initModel(const std::shared_ptr<WarehouseGuez::Interface::Dtc> &dtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
|
||||
if (!m_dtc ||
|
||||
!m_dtc->enableInjuryModelAgdusWh())
|
||||
return false;
|
||||
|
||||
auto cb = [this](const WarehouseGuez::InjuryModelAgdusWh &im)
|
||||
{
|
||||
onDataChanged(im, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->injuryModelAgdusWhs(cb);
|
||||
|
||||
connect(m_dtc.get(), &WarehouseGuez::Interface::Dtc::injuryModelAgdusWhChanged,
|
||||
this, &InjuryModelModel::onDataChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant InjuryModelModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const WarehouseGuez::InjuryModelAgdusWh &inj = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ID:
|
||||
return inj.id();
|
||||
case Name:
|
||||
return QString::fromStdString(inj.name());
|
||||
case Version:
|
||||
return QString::fromStdString(inj.version());
|
||||
case Description:
|
||||
return QString::fromStdString(inj.description());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QSet<int> InjuryModelModel::takenIds() const
|
||||
{
|
||||
QSet<int> set;
|
||||
set.reserve(m_vecData.size());
|
||||
for(const auto &m : m_vecData)
|
||||
set << m.id();
|
||||
return set;
|
||||
}
|
||||
|
||||
} // namespace WarehouseManagement
|
||||
Reference in new issue
Block a user