summaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-07-14 18:43:47 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-14 14:54:01 -0700
commitcd3f10d5ad4124960b66112074797a16517117e9 (patch)
tree0863ac82d534553a53b640cc4dcf3cd20828849a /qt-ui/modeldelegates.cpp
parent4dfb39cc490ed889e872ff54437f70df3ed88553 (diff)
downloadsubsurface-cd3f10d5ad4124960b66112074797a16517117e9.tar.gz
Offer an option to just complete the text
Make the kids fight no more. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r--qt-ui/modeldelegates.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index 3357d3909..953c16b87 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -495,14 +495,22 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
QStyledItemDelegate::initStyleOption(&opt, index);
QBrush bg;
QString diveSiteName = index.data().toString();
-
+ QString bottomText;
+ QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
struct dive_site *ds = get_dive_site_by_uuid(
index.model()->data(index.model()->index(index.row(),0)).toInt()
);
+
+ //Special case: do not show name, but instead, show
+ if (index.row() == 0) {
+ diveSiteName = index.data().toString();
+ bottomText = index.data(Qt::ToolTipRole).toString();
+ goto print_part;
+ }
+
if (!ds)
return;
- QString bottomText;
for (int i = 0; i < ds->taxonomy.nr; i++) {
if(ds->taxonomy.category[i].category == TC_NONE)
continue;
@@ -517,11 +525,13 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
free( (void*) gpsCoords);
}
+ print_part:
fontBigger.setPointSize(fontBigger.pointSize() + 1);
fontBigger.setBold(true);
initStyleOption(&opt, index);
opt.text = QString();
+ opt.icon = QIcon();
qApp->style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, NULL);
painter->save();
@@ -539,6 +549,14 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
painter->setBrush(option.palette.brightText());
painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height() * 2, bottomText);
painter->restore();
+
+ if (!icon.isNull()) {
+ painter->save();
+ painter->drawPixmap(
+ option.rect.x() + option.rect.width() - 24,
+ option.rect.y() + option.rect.height() - 24, icon.pixmap(20,20));
+ painter->restore();
+ }
}
QSize LocationFilterDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const