/** * @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 #include #include #include namespace WarehouseManagement { InjuryModelModel::InjuryModelModel(QObject *parent) : LtsWidgets::LtsAbstractTableModel({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 &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 InjuryModelModel::takenIds() const { QSet set; set.reserve(m_vecData.size()); for(const auto &m : m_vecData) set << m.id(); return set; } } // namespace WarehouseManagement