From 2f9e859615b462a195ccbbe67c67f6ae05367fe6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 8 Jul 2015 11:09:51 -0300 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/modeldelegates.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 0399722ba..423eea3e3 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -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(); } -- cgit v1.2.3-70-g09d2