summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-08-30 18:09:37 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-06 11:48:47 -0700
commit652b78657ebe18ff101d3f6cd2ac9f3458db1881 (patch)
tree10df535833370de16c1ff056af6806d533f8ed55
parentb7665251835cb6786c3b268fd0d04d69dccf36ed (diff)
downloadsubsurface-652b78657ebe18ff101d3f6cd2ac9f3458db1881.tar.gz
Map: calculate the z value in the model
Since not fully reloading the map on selection change, the selected sites were not moved to the top. Not calculating the z-value in QML, but making it a simple model property helps. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--map-widget/qml/MapWidget.qml2
-rw-r--r--qt-models/maplocationmodel.cpp4
-rw-r--r--qt-models/maplocationmodel.h4
3 files changed, 8 insertions, 2 deletions
diff --git a/map-widget/qml/MapWidget.qml b/map-widget/qml/MapWidget.qml
index fb5545e88..8116163cf 100644
--- a/map-widget/qml/MapWidget.qml
+++ b/map-widget/qml/MapWidget.qml
@@ -56,7 +56,7 @@ Item {
anchorPoint.x: 0
anchorPoint.y: mapItemImage.height
coordinate: model.coordinate
- z: mapHelper.model.isSelected(model.divesite) ? mapHelper.model.count - 1 : 0
+ z: model.z
sourceItem: Image {
id: mapItemImage
source: model.pixmap
diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp
index 10d983575..4ca4a3a53 100644
--- a/qt-models/maplocationmodel.cpp
+++ b/qt-models/maplocationmodel.cpp
@@ -14,6 +14,7 @@ const char *MapLocation::PROPERTY_NAME_COORDINATE = "coordinate";
const char *MapLocation::PROPERTY_NAME_DIVESITE = "divesite";
const char *MapLocation::PROPERTY_NAME_NAME = "name";
const char *MapLocation::PROPERTY_NAME_PIXMAP = "pixmap";
+const char *MapLocation::PROPERTY_NAME_Z = "z";
#define MIN_DISTANCE_BETWEEN_DIVE_SITES_M 50.0
@@ -51,6 +52,8 @@ QVariant MapLocation::getRole(int role) const
return m_selected ? QString("qrc:///dive-location-marker-selected-icon") :
inEditMode() ? QString("qrc:///dive-location-marker-inactive-icon") :
QString("qrc:///dive-location-marker-icon");
+ case Roles::RoleZ:
+ return m_selected ? 1 : 0;
default:
return QVariant();
}
@@ -88,6 +91,7 @@ MapLocationModel::MapLocationModel(QObject *parent) : QAbstractListModel(parent)
m_roles[MapLocation::Roles::RoleCoordinate] = MapLocation::PROPERTY_NAME_COORDINATE;
m_roles[MapLocation::Roles::RoleName] = MapLocation::PROPERTY_NAME_NAME;
m_roles[MapLocation::Roles::RolePixmap] = MapLocation::PROPERTY_NAME_PIXMAP;
+ m_roles[MapLocation::Roles::RoleZ] = MapLocation::PROPERTY_NAME_Z;
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MapLocationModel::diveSiteChanged);
}
diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h
index 3335822e2..4b2066186 100644
--- a/qt-models/maplocationmodel.h
+++ b/qt-models/maplocationmodel.h
@@ -22,6 +22,7 @@ public:
static const char *PROPERTY_NAME_DIVESITE;
static const char *PROPERTY_NAME_NAME;
static const char *PROPERTY_NAME_PIXMAP;
+ static const char *PROPERTY_NAME_Z;
explicit MapLocation();
explicit MapLocation(struct dive_site *ds, QGeoCoordinate coord, QString name, bool selected);
@@ -37,7 +38,8 @@ public:
RoleDivesite = Qt::UserRole + 1,
RoleCoordinate,
RoleName,
- RolePixmap
+ RolePixmap,
+ RoleZ
};
private: