mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b766525183
commit
652b78657e
3 changed files with 8 additions and 2 deletions
|
@ -56,7 +56,7 @@ Item {
|
||||||
anchorPoint.x: 0
|
anchorPoint.x: 0
|
||||||
anchorPoint.y: mapItemImage.height
|
anchorPoint.y: mapItemImage.height
|
||||||
coordinate: model.coordinate
|
coordinate: model.coordinate
|
||||||
z: mapHelper.model.isSelected(model.divesite) ? mapHelper.model.count - 1 : 0
|
z: model.z
|
||||||
sourceItem: Image {
|
sourceItem: Image {
|
||||||
id: mapItemImage
|
id: mapItemImage
|
||||||
source: model.pixmap
|
source: model.pixmap
|
||||||
|
|
|
@ -14,6 +14,7 @@ const char *MapLocation::PROPERTY_NAME_COORDINATE = "coordinate";
|
||||||
const char *MapLocation::PROPERTY_NAME_DIVESITE = "divesite";
|
const char *MapLocation::PROPERTY_NAME_DIVESITE = "divesite";
|
||||||
const char *MapLocation::PROPERTY_NAME_NAME = "name";
|
const char *MapLocation::PROPERTY_NAME_NAME = "name";
|
||||||
const char *MapLocation::PROPERTY_NAME_PIXMAP = "pixmap";
|
const char *MapLocation::PROPERTY_NAME_PIXMAP = "pixmap";
|
||||||
|
const char *MapLocation::PROPERTY_NAME_Z = "z";
|
||||||
|
|
||||||
#define MIN_DISTANCE_BETWEEN_DIVE_SITES_M 50.0
|
#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") :
|
return m_selected ? QString("qrc:///dive-location-marker-selected-icon") :
|
||||||
inEditMode() ? QString("qrc:///dive-location-marker-inactive-icon") :
|
inEditMode() ? QString("qrc:///dive-location-marker-inactive-icon") :
|
||||||
QString("qrc:///dive-location-marker-icon");
|
QString("qrc:///dive-location-marker-icon");
|
||||||
|
case Roles::RoleZ:
|
||||||
|
return m_selected ? 1 : 0;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
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::RoleCoordinate] = MapLocation::PROPERTY_NAME_COORDINATE;
|
||||||
m_roles[MapLocation::Roles::RoleName] = MapLocation::PROPERTY_NAME_NAME;
|
m_roles[MapLocation::Roles::RoleName] = MapLocation::PROPERTY_NAME_NAME;
|
||||||
m_roles[MapLocation::Roles::RolePixmap] = MapLocation::PROPERTY_NAME_PIXMAP;
|
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);
|
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MapLocationModel::diveSiteChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
static const char *PROPERTY_NAME_DIVESITE;
|
static const char *PROPERTY_NAME_DIVESITE;
|
||||||
static const char *PROPERTY_NAME_NAME;
|
static const char *PROPERTY_NAME_NAME;
|
||||||
static const char *PROPERTY_NAME_PIXMAP;
|
static const char *PROPERTY_NAME_PIXMAP;
|
||||||
|
static const char *PROPERTY_NAME_Z;
|
||||||
|
|
||||||
explicit MapLocation();
|
explicit MapLocation();
|
||||||
explicit MapLocation(struct dive_site *ds, QGeoCoordinate coord, QString name, bool selected);
|
explicit MapLocation(struct dive_site *ds, QGeoCoordinate coord, QString name, bool selected);
|
||||||
|
@ -37,7 +38,8 @@ public:
|
||||||
RoleDivesite = Qt::UserRole + 1,
|
RoleDivesite = Qt::UserRole + 1,
|
||||||
RoleCoordinate,
|
RoleCoordinate,
|
||||||
RoleName,
|
RoleName,
|
||||||
RolePixmap
|
RolePixmap,
|
||||||
|
RoleZ
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue