diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-04-27 20:53:25 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-04-27 20:53:25 -0700 |
commit | 4179885da79d4d2ba0a4893331e162235765ad0f (patch) | |
tree | a01a38c68deab7ca159c11658fa053133c15254e /qt-ui/models.cpp | |
parent | 4bb0cd8cef2bbbbe3df6fc3daa9ccca95f065038 (diff) | |
parent | 2f4d6bbe535a195046b4746fd3a771087ee4a6c4 (diff) | |
download | subsurface-4179885da79d4d2ba0a4893331e162235765ad0f.tar.gz |
Merge branch 'RenderStarsOnTable' of https://github.com/tcanabrava/subsurface into Qt
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r-- | qt-ui/models.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 5f803766f..0944fe3e3 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -5,9 +5,6 @@ * */ #include "models.h" -#include "../dive.h" -#include "../divelist.h" - #include <QtDebug> extern struct tank_info tank_info[100]; @@ -284,6 +281,7 @@ void TankInfoModel::update() } } + /*! A DiveItem for use with a DiveTripModel * * A simple class which wraps basic stats for a dive (e.g. duration, depth) and @@ -314,6 +312,8 @@ public: return tw.grams; } + int diveRating() const { return dive->rating; } + QString displayDuration() const; QString displayDepth() const; QString displayTemperature() const; @@ -335,6 +335,7 @@ private: QList <DiveItem*> childlist; }; + DiveItem::DiveItem(struct dive *d, DiveItem *p): dive(d), parentItem(p) @@ -490,6 +491,16 @@ QVariant DiveTripModel::data(const QModelIndex &index, int role) const case LOCATION: retVal = item->diveLocation(); break; + case RATING: + retVal = item->diveRating(); + break; + } + } + if (role == DelegatesRole){ + switch(index.column()){ + case RATING: + retVal = item->diveRating(); + break; } } return retVal; @@ -569,8 +580,6 @@ int DiveTripModel::rowCount(const QModelIndex &parent) const return item ? item->children().count() : 0; } - - int DiveTripModel::columnCount(const QModelIndex &parent) const { return parent.isValid() && parent.column() != 0 ? 0 : COLUMNS; |