-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMarker.qml
81 lines (73 loc) · 1.94 KB
/
Marker.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import QtQuick 2.12
Item {
id: marker
width: Math.max(20, markerText.implicitWidth)
Rectangle {
x: -parent.width / 2
y: -parent.height / 2
width: parent.width
height: parent.height
color: model.state ? "#cce6f5" : "#cdf5cc"
transform: Rotation {
id: scanning
origin.x: width / 2
origin.y: height / 2
angle: marker.seconds * 90
Behavior on angle {
SpringAnimation {
spring: 2
damping: 0.2
modulus: 360
}
}
}
MouseArea {
id: markerarea
anchors.fill: parent
drag.target: marker
onDoubleClicked: if (model.state)
posModel.remove(index)
drag.onActiveChanged: {
if (!markerarea.drag.active) {
this.forceActiveFocus()
pos = Qt.point(marker.x, marker.y)
}
}
}
Text {
id: markerText
text: {
if (isNaN(model.z))
return ""
return Math.round(model.z / heatMapLegend.zstepSize)
}
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
property int seconds
function timeChanged() {
var date = new Date
seconds = date.getUTCSeconds()
}
Timer {
interval: 100
running: !model.state
repeat: true
onRunningChanged: if (!running) {
seconds = 0
}
onTriggered: marker.timeChanged()
}
Binding {
target: marker
property: "x"
value: pos.x
}
Binding {
target: marker
property: "y"
value: pos.y
}
}