Commit 2bd25c03 authored by Volker Krause's avatar Volker Krause
Browse files

Provide long-press signals for map elements as well

This allows to offer the element details dialog for otherwise interactive
elements like elevators or escalators as well for example.
parent cfdc5517
......@@ -34,6 +34,8 @@ Item {
/** Emitted when a map element has been picked by clicking/tapping on it. */
signal elementPicked(var element);
/** Emitted when a map element has been long-pressed. */
signal elementLongPressed(var element);
MapItemImpl {
id: map
......@@ -68,8 +70,9 @@ Item {
QQC2.ScrollBar.horizontal: QQC2.ScrollBar {}
TapHandler {
id: tapHandler
acceptedButtons: Qt.LeftButton
onTapped: {
onTapped: function(eventPoint) {
var root = parent;
while (root.parent) { root = root.parent; }
var localPos = map.mapFromItem(root, eventPoint.scenePosition.x, eventPoint.scenePosition.y);
......@@ -78,6 +81,15 @@ Item {
elementPicked(element);
}
}
onLongPressed: function() {
var root = parent;
while (root.parent) { root = root.parent; }
var localPos = map.mapFromItem(root, tapHandler.point.scenePosition.x, tapHandler.point.scenePosition.y);
var element = map.elementAt(localPos.x, localPos.y);
if (!element.isNull) {
elementLongPressed(element);
}
}
}
PinchHandler {
id: pinchHandler
......
......@@ -190,6 +190,13 @@ Kirigami.Page {
elementDetailsSheet.sheetOpen = true;
}
}
onElementLongPressed: {
// this provides info model access for elements with other interactions
infoModel.element = element;
if (infoModel.name != "" || infoModel.debug) {
elementDetailsSheet.sheetOpen = true;
}
}
}
onCoordinateChanged: map.mapLoader.loadForCoordinate(coordinate.y, coordinate.x);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment