From fac316865c083789eb1254abb0ddf2f056a09036 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 11 Oct 2013 11:13:16 -0300 Subject: [PATCH] Another Model Cleanup Conversion of the WSInfoModel, that populates the list of weigthsystems in the Equipment tab. Signed-off-by: Tomaz Canabrava --- qt-ui/models.cpp | 33 ++------------------------------- qt-ui/models.h | 4 +--- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index df957ea7c..bc1213faa 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -545,11 +545,6 @@ void WSInfoModel::clear() { } -int WSInfoModel::columnCount(const QModelIndex& parent) const -{ - return 2; -} - QVariant WSInfoModel::data(const QModelIndex& index, int role) const { QVariant ret; @@ -578,31 +573,6 @@ QVariant WSInfoModel::data(const QModelIndex& index, int role) const return ret; } -QVariant WSInfoModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - QVariant ret; - - if (orientation != Qt::Horizontal) - return ret; - - switch(role){ - case Qt::FontRole : - ret = defaultModelFont(); - break; - case Qt::DisplayRole : - switch(section) { - case GR: - ret = tr("kg"); - break; - case DESCRIPTION: - ret = tr("Description"); - break; - } - break; - } - return ret; -} - int WSInfoModel::rowCount(const QModelIndex& parent) const { return rows+1; @@ -613,8 +583,9 @@ const QString& WSInfoModel::biggerString() const return biggerEntry; } -WSInfoModel::WSInfoModel() : QAbstractTableModel(), rows(-1) +WSInfoModel::WSInfoModel() : rows(-1) { + setHeaderDataStrings( QStringList() << tr("Description") << tr("kg")); struct ws_info_t *info = ws_info; for (info = ws_info; info->name; info++, rows++){ QString wsInfoName(info->name); diff --git a/qt-ui/models.h b/qt-ui/models.h index 5e3d07121..3f73c40ef 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -55,7 +55,7 @@ private: }; /* Encapsulate ws_info */ -class WSInfoModel : public QAbstractTableModel { +class WSInfoModel : public CleanerTableModel { Q_OBJECT public: static WSInfoModel* instance(); @@ -63,8 +63,6 @@ public: enum Column {DESCRIPTION, GR}; WSInfoModel(); - /*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - /*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const; /*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; /*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const; /*reimp*/ bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());