summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-25 12:19:41 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-27 06:43:18 -0400
commita5d2003e3a8bb16ace11fefa7afd32e7f5746e78 (patch)
treebd3d8438b0e888e37156404c8022b88a59f144da /qt-ui
parentfc420927ff9039c543cd533f1c0be039c008147f (diff)
downloadsubsurface-a5d2003e3a8bb16ace11fefa7afd32e7f5746e78.tar.gz
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 <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/locationinformation.cpp7
1 files changed, 5 insertions, 2 deletions
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();