diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-10-11 11:42:33 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-10-11 11:42:33 -0300 |
commit | beb40ae4943cc76017c38eee678cae386f51854c (patch) | |
tree | dc0f739992bc41d9bedd979f5c7341eef75bd92e /qt-ui/models.cpp | |
parent | fac316865c083789eb1254abb0ddf2f056a09036 (diff) | |
download | subsurface-beb40ae4943cc76017c38eee678cae386f51854c.tar.gz |
Finish clearing up the TableModels
There are other models ( Tree Models and Model Items
) that are not affected by this commits, this is
already a good cleanup but it can be extended
to also fix those two other possibilities.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r-- | qt-ui/models.cpp | 58 |
1 files changed, 4 insertions, 54 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index bc1213faa..e70bece19 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -674,11 +674,6 @@ void TankInfoModel::clear() { } -int TankInfoModel::columnCount(const QModelIndex& parent) const -{ - return 3; -} - QVariant TankInfoModel::data(const QModelIndex& index, int role) const { QVariant ret; @@ -711,41 +706,14 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const return ret; } -QVariant TankInfoModel::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 BAR: - ret = tr("Bar"); - break; - case ML: - ret = tr("Ml"); - break; - case DESCRIPTION: - ret = tr("Description"); - break; - } - break; - } - return ret; -} - int TankInfoModel::rowCount(const QModelIndex& parent) const { return rows+1; } -TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1) +TankInfoModel::TankInfoModel() : rows(-1) { + setHeaderDataStrings( QStringList() << tr("Description") << tr("Ml") << tr("Bar")); struct tank_info_t *info = tank_info; for (info = tank_info; info->name; info++, rows++){ QString infoName(info->name); @@ -1163,31 +1131,13 @@ void DiveTripModel::setLayout(DiveTripModel::Layout layout) *#################################################################### */ -DiveComputerModel::DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject* parent): QAbstractTableModel(parent) +DiveComputerModel::DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject* parent): CleanerTableModel() { + setHeaderDataStrings(QStringList() << "" << tr("Model") << tr("Device ID") << tr("Nickname")); dcWorkingMap = dcMap; numRows = 0; } -int DiveComputerModel::columnCount(const QModelIndex& parent) const -{ - return COLUMNS; -} - -QVariant DiveComputerModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - QVariant ret; - if (role != Qt::DisplayRole || orientation != Qt::Horizontal){ - return ret; - } - switch(section){ - case ID: ret = tr("Device ID"); break; - case MODEL: ret = tr("Model"); break; - case NICKNAME: ret = tr("Nickname"); break; - } - return ret; -} - QVariant DiveComputerModel::data(const QModelIndex& index, int role) const { QList<DiveComputerNode> values = dcWorkingMap.values(); |