From a5d2003e3a8bb16ace11fefa7afd32e7f5746e78 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 25 Sep 2015 12:19:41 -0300 Subject: Only get the icon for add/geocode once Each time we searched for an icon on the qt resource we had to open, inflate, create, store, delete the icon. now we search for it only once, use as cache and make the world a better place. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/locationinformation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp index 213d63be1..bbb4449fc 100644 --- a/qt-ui/locationinformation.cpp +++ b/qt-ui/locationinformation.cpp @@ -301,6 +301,9 @@ void DiveLocationModel::resetModel() QVariant DiveLocationModel::data(const QModelIndex& index, int role) const { + static const QIcon plusIcon(":plus"); + static const QIcon geoCode(":geocode"); + if(index.row() <= 1) { // two special cases. if(index.column() == UUID) { return RECENTLY_ADDED_DIVESITE; @@ -308,7 +311,7 @@ QVariant DiveLocationModel::data(const QModelIndex& index, int role) const switch(role) { case Qt::DisplayRole : return new_ds_value[index.row()]; case Qt::ToolTipRole : return "Create a new dive site"; - case Qt::DecorationRole : return QIcon(":plus"); + case Qt::DecorationRole : return plusIcon; } } @@ -328,7 +331,7 @@ QVariant DiveLocationModel::data(const QModelIndex& index, int role) const break; case Qt::DecorationRole : { if (dive_site_has_gps_location(ds)) - return QIcon(":geocode"); + return geoCode; } } return QVariant(); -- cgit v1.2.3-70-g09d2