7pragma ValueTypeBehavior: Addressable
10import org.kde.kosmindoormap
11import QtQuick.Controls as QQC2
18 property alias mapLoader: map.loader
20 property alias styleSheet: map.styleSheet
22 property alias floorLevels: map.floorLevels
24 property alias view: map.view
26 property alias hasError: map.hasError
28 property alias mapData: map.mapData
30 property alias overlaySources: map.overlaySources
32 property alias region: map.region
34 property alias timeZone: map.timeZone
36 property alias hoveredElement: map.hoveredElement
41 signal elementPicked(var element);
45 signal elementLongPressed(var element);
48 signal tapped(mapPointerEvent event);
50 signal longPressed(mapPointerEvent event);
53 function mapEventPointToScreen(eventPoint) {
54 let root = mapRoot.parent;
55 while (root.parent) { root = root.parent; }
56 return map.mapFromItem(root, eventPoint.scenePosition.x, eventPoint.scenePosition.y);
59 function mapEventPointToGeo(eventPoint) {
60 return map.view.mapSceneToGeoPoint(
map.view.mapScreenToScene(mapRoot.mapEventPointToScreen(eventPoint)));
64 function elementAt(screenPosition) {
65 return map.elementAt(screenPosition.x, screenPosition.y);
75 boundsBehavior: Flickable.StopAtBounds
77 interactive: !pinchHandler.active
78 contentX:
map.view.panX
79 contentY:
map.view.panY
80 contentWidth:
map.view.panWidth
81 contentHeight:
map.view.panHeight
86 map.view.panTopLeft(flickable.contentX, flickable.contentY);
92 map.view.panTopLeft(flickable.contentX, flickable.contentY);
97 QQC2.ScrollBar.vertical: QQC2.ScrollBar {}
98 QQC2.ScrollBar.horizontal: QQC2.ScrollBar {}
102 acceptedButtons:
Qt.LeftButton |
Qt.RightButton
103 onTapped: (eventPoint, button) => {
105 element: mapRoot.elementAt(mapRoot.mapEventPointToScreen(eventPoint)),
106 geoPosition: mapRoot.mapEventPointToGeo(eventPoint),
107 screenPosition: mapRoot.mapEventPointToScreen(eventPoint),
109 modifiers: tapHandler.point.modifiers,
110 } as mapPointerEvent;
111 if (!ev.element.isNull) {
112 mapRoot.elementPicked(ev.element);
116 onLongPressed: function() {
118 element: mapRoot.elementAt(mapRoot.mapEventPointToScreen(tapHandler.point)),
119 geoPosition: mapRoot.mapEventPointToGeo(tapHandler.point),
120 screenPosition: mapRoot.mapEventPointToScreen(tapHandler.point),
121 button: tapHandler.point.pressedButtons,
122 modifiers: tapHandler.point.modifiers,
123 } as mapPointerEvent;
124 if (!ev.element.isNull) {
125 mapRoot.elementLongPressed(ev.element);
127 mapRoot.longPressed(ev);
133 property double initialZoom
135 initialZoom =
map.view.zoomLevel
137 onActiveScaleChanged: {
138 map.view.setZoomLevel(pinchHandler.initialZoom + Math.log2(pinchHandler.activeScale),
139 Qt.point(pinchHandler.centroid.position.x - flickable.contentX, pinchHandler.centroid.position.y - flickable.contentY));
149 orientation:
Qt.Vertical
150 acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
151 property double initialZoom: 0.0
153 wheelHandler.initialZoom =
map.view.zoomLevel
154 wheelHandler.rotation = 0;
158 map.view.setZoomLevel(wheelHandler.initialZoom + 0.05 * wheelHandler.rotation,
159 Qt.point(wheelHandler.point.position.x - flickable.contentX, wheelHandler.point.position.y - flickable.contentY));
166 function onTransformationChanged() {
167 flickable.contentX =
map.view.panX;
168 flickable.contentY =
map.view.panY;
173 anchors.centerIn: parent
174 running:
map.loader.isLoading
179 text:
map.errorMessage
180 visible:
map.hasError
181 wrapMode:
Text.WordWrap
182 horizontalAlignment:
Qt.AlignHCenter
183 verticalAlignment:
Qt.AlignVCenter
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)