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>
This commit is contained in:
Tomaz Canabrava 2015-07-14 18:43:47 -03:00 committed by Dirk Hohndel
parent 4dfb39cc49
commit cd3f10d5ad
4 changed files with 73 additions and 9 deletions

View file

@ -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