QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MissionItemSelectionPanel.qml
Go to the documentation of this file.
1pragma ComponentBehavior: Bound
2
3import QtQuick
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.PlanView
8
9/// Picker for mission item markers drawn too close together to click individually
10DropPanel {
11 id: root
12
13 modal: false
14
15 required property var groupItems
16
17 signal itemSelected(int sequenceNumber)
18
19 sourceComponent: Component {
20 Item {
21 implicitWidth: itemListView.width
22 implicitHeight: itemListView.height
23
24 QGCListView {
25 id: itemListView
26
27 objectName: "missionItemSelectionList"
28 width: Math.min(Math.max(contentItem.childrenRect.width, _itemExtent), _maxWidth)
29 height: _itemExtent
30 orientation: ListView.Horizontal
31 model: root.groupItems
32 cacheBuffer: width * 2
33 reuseItems: true
34 currentIndex: -1
35
36 readonly property real _itemExtent: Math.max(ScreenTools.minTouchPixels, ScreenTools.defaultFontPixelHeight * 2.5)
37 readonly property real _maxWidth: root.dropViewPort.width * 0.4
38
39 function _scrollBy(delta) {
40 const currentTarget = wheelScrollAnimation.running ? wheelScrollAnimation.to : contentX
41 const target = Math.max(0, Math.min(currentTarget - delta, Math.max(0, contentWidth - width)))
42 wheelScrollAnimation.stop()
43 wheelScrollAnimation.from = contentX
44 wheelScrollAnimation.to = target
45 wheelScrollAnimation.start()
46 }
47
48 delegate: Item {
49 id: itemDelegate
50
51 objectName: "missionItemSelection_" + modelData.sequenceNumber
52 width: Math.max(itemListView._itemExtent, itemLabel.width + ScreenTools.defaultFontPixelWidth)
53 height: itemListView._itemExtent
54
55 required property var modelData
56
57 readonly property bool _usesAbbreviation: modelData.abbreviation !== ""
58 readonly property string _supplementaryLabel: !_usesAbbreviation ? "" : `${modelData.abbreviation} (${modelData.sequenceNumber})`
59
60 MissionItemIndexLabel {
61 id: itemLabel
62 anchors.centerIn: parent
63 checked: itemDelegate.modelData.isCurrentItem || itemDelegate.modelData.hasCurrentChildItem
64 label: itemDelegate.modelData.abbreviation
65 index: itemDelegate._usesAbbreviation ? -1 : itemDelegate.modelData.sequenceNumber
66 small: false
67 supplementaryLabel: itemDelegate._supplementaryLabel
68 }
69
70 MouseArea {
71 anchors.fill: parent
72 onClicked: {
73 root.close()
74 root.itemSelected(itemDelegate.modelData.sequenceNumber)
75 }
76 }
77 }
78
79 NumberAnimation {
80 id: wheelScrollAnimation
81
82 target: itemListView
83 property: "contentX"
84 duration: 120
85 easing.type: Easing.OutCubic
86 }
87
88 WheelHandler {
89 acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
90 orientation: Qt.Vertical
91 target: null
92 onWheel: event => {
93 itemListView._scrollBy(event.pixelDelta.y || event.angleDelta.y)
94 event.accepted = true
95 }
96 }
97
98 WheelHandler {
99 acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
100 orientation: Qt.Horizontal
101 target: null
102 onWheel: event => {
103 itemListView._scrollBy(event.pixelDelta.x || event.angleDelta.x)
104 event.accepted = true
105 }
106 }
107
108 onMovementStarted: wheelScrollAnimation.stop()
109 }
110 }
111 }
112}