mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added support for showing the Stars on the DiveTable
For the stars on the dive table I had to rework a bit my StarRating widget, because it used a pixmap for each widget that were created. Not it uses only 2 pixmaps: the active and inactive ones. A new file was created named modeldelegates(h, cpp) that should hold all delegates of the models. For the GTK / C folks, a 'Delegate' ia s way to bypass the default behavior of the view that's displaying the data. I also added the code to display the stars if no delegate is set ( good for debugging. ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
1d0d42f861
commit
2f4d6bbe53
9 changed files with 115 additions and 59 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue