mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
fc420927ff
commit
a5d2003e3a
1 changed files with 5 additions and 2 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue