7pragma ValueTypeBehavior: Addressable
11import org.kde.kosmindoormap
12import QtQuick.Controls as QQC2
19 property alias mapLoader: map.loader
21 property alias styleSheet: map.styleSheet
23 property alias floorLevels: map.floorLevels
25 property alias view: map.view
27 property alias hasError: map.hasError
29 property alias mapData: map.mapData
31 property alias overlaySources: map.overlaySources
33 property alias region: map.region
35 property alias timeZone: map.timeZone
37 property alias hoveredElement: map.hoveredElement
42 signal elementPicked(var element);
46 signal elementLongPressed(var element);
49 signal tapped(mapPointerEvent event);
51 signal longPressed(mapPointerEvent event);
54 function mapEventPointToScreen(eventPoint) {
55 let root = mapRoot.parent;
56 while (root.parent) { root = root.parent; }
57 return map.mapFromItem(root, eventPoint.scenePosition.x, eventPoint.scenePosition.y);
60 function mapEventPointToGeo(eventPoint) {
61 return map.view.mapSceneToGeoPoint(
map.view.mapScreenToScene(mapRoot.mapEventPointToScreen(eventPoint)));
65 function elementAt(screenPosition) {
66 return map.elementAt(screenPosition.x, screenPosition.y);
76 boundsBehavior: Flickable.StopAtBounds
78 interactive: !pinchHandler.active
79 contentX:
map.view.panX
80 contentY:
map.view.panY
81 contentWidth:
map.view.panWidth
82 contentHeight:
map.view.panHeight
87 map.view.panTopLeft(flickable.contentX, flickable.contentY);
93 map.view.panTopLeft(flickable.contentX, flickable.contentY);
98 QQC2.ScrollBar.vertical: QQC2.ScrollBar {}
99 QQC2.ScrollBar.horizontal: QQC2.ScrollBar {}
103 acceptedButtons:
Qt.LeftButton |
Qt.RightButton
104 onTapped: (eventPoint, button) => {
106 element: mapRoot.elementAt(mapRoot.mapEventPointToScreen(eventPoint)),
107 geoPosition: mapRoot.mapEventPointToGeo(eventPoint),
108 screenPosition: mapRoot.mapEventPointToScreen(eventPoint),
110 modifiers: tapHandler.point.modifiers,
111 } as mapPointerEvent;
112 if (!ev.element.isNull) {
113 elementPicked(ev.element);
117 onLongPressed: function() {
119 element: mapRoot.elementAt(mapRoot.mapEventPointToScreen(tapHandler.point)),
120 geoPosition: mapRoot.mapEventPointToGeo(tapHandler.point),
121 screenPosition: mapRoot.mapEventPointToScreen(tapHandler.point),
122 button: tapHandler.point.pressedButtons,
123 modifiers: tapHandler.point.modifiers,
124 } as mapPointerEvent;
125 if (!ev.element.isNull) {
126 elementLongPressed(ev.element);
128 mapRoot.longPressed(ev);
134 property double initialZoom
136 initialZoom =
map.view.zoomLevel
138 onActiveScaleChanged: {
139 map.view.setZoomLevel(pinchHandler.initialZoom + Math.log2(pinchHandler.activeScale),
140 Qt.point(pinchHandler.centroid.position.x - flickable.contentX, pinchHandler.centroid.position.y - flickable.contentY));
150 orientation:
Qt.Vertical
151 acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
152 property double initialZoom: 0.0
154 wheelHandler.initialZoom =
map.view.zoomLevel
155 wheelHandler.rotation = 0;
159 map.view.setZoomLevel(wheelHandler.initialZoom + 0.05 * wheelHandler.rotation,
160 Qt.point(wheelHandler.point.position.x - flickable.contentX, wheelHandler.point.position.y - flickable.contentY));
167 function onTransformationChanged() {
168 flickable.contentX =
map.view.panX;
169 flickable.contentY =
map.view.panY;
174 anchors.centerIn: parent
175 running:
map.loader.isLoading
180 text:
map.errorMessage
181 visible:
map.hasError
182 wrapMode:
Text.WordWrap
183 horizontalAlignment:
Qt.AlignHCenter
184 verticalAlignment:
Qt.AlignVCenter
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)