Use taxonomy or coords on the delegate

The Taxonomy text should be used if there's a taxonomy
for the dive site. If there isn't, then use coords. If
there's none, then nothing will appear on the bottom
of the dive site name.

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-08 11:09:51 -03:00 committed by Dirk Hohndel
parent 967bd68e64
commit 2f9e859615

View file

@ -502,9 +502,20 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
if (!ds)
return;
const char *gpsCoords = printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg);
QString diveSiteCoords(gpsCoords);
free( (void*) gpsCoords);
QString bottomText;
for (int i = 0; i < ds->taxonomy.nr; i++) {
if(ds->taxonomy.category[i].category == TC_NONE)
continue;
if(!bottomText.isEmpty())
bottomText += " ";
bottomText += QString(ds->taxonomy.category[i].value) + " ";
}
if (bottomText.isEmpty()) {
const char *gpsCoords = printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg);
bottomText = QString(gpsCoords);
free( (void*) gpsCoords);
}
fontBigger.setPointSize(fontBigger.pointSize() + 1);
fontBigger.setBold(true);
@ -526,7 +537,7 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height(), diveSiteName);
painter->setFont(fontSmaller);
painter->setBrush(option.palette.brightText());
painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height() * 2, diveSiteCoords);
painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height() * 2, bottomText);
painter->restore();
}