QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MissionItemInspector.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7import "PlanPanelLogic.js" as Logic
8
9/// Inspector for the current plan view mission item: pinned header with the item actions, scrolling editor below
10Item {
11 id: root
12
13 required property var missionController
14 required property var map
15 property bool drillIn: false ///< true: show the back and previous/next buttons
16
17 signal backRequested
18
19 readonly property var _item: missionController.currentPlanViewItem
20 readonly property int _itemCount: missionController.visualItems ? missionController.visualItems.count : 0
21 readonly property int _currentIndex: missionController.currentPlanViewVIIndex
22 readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
23 readonly property bool _commandEditable: _item ? (_item.isSimpleItem && !_waypointsOnlyMode && !_item.isTakeoffItem) : false
24 readonly property bool _deletable: _item ? _item.sequenceNumber !== 0 : false
25 readonly property bool _ready: _item ? _item.readyForSaveState === VisualMissionItem.ReadyForSave : true
26
27 function _step(delta) {
28 if (!mainWindow.allowViewSwitch()) {
29 return
30 }
31 const index = Logic.steppedIndex(_currentIndex, delta, _itemCount)
32 if (index >= 0) {
33 missionController.setCurrentPlanViewSeqNum(missionController.visualItems.get(index).sequenceNumber, false)
34 }
35 }
36
37 function _remove() {
38 if (!mainWindow.allowViewSwitch()) {
39 return
40 }
41 if (_item && _deletable) {
42 const viIndex = missionController.visualItemIndexForObject(_item)
43 if (viIndex > 0) {
44 missionController.removeVisualItem(viIndex)
45 }
46 }
47 }
48
49 QGCPalette { id: qgcPal }
50
51 Loader {
52 id: menuLoader
53 active: root._item !== null
54
55 sourceComponent: MissionItemMenu {
56 missionItem: root._item
57 }
58 }
59
60 QGCPopupDialogFactory {
61 id: commandDialogFactory
62
63 dialogComponent: commandDialog
64 }
65
66 Component {
67 id: commandDialog
68
69 MissionCommandDialog {
70 vehicle: root._item ? root._item.masterController.controllerVehicle : null
71 missionItem: root._item
72 map: root.map
73 flyThroughCommandsAllowed: true
74 }
75 }
76
77 ColumnLayout {
78 anchors.fill: parent
79 anchors.margins: ScreenTools.defaultFontPixelWidth / 2
80 spacing: ScreenTools.defaultFontPixelHeight * 0.4
81
82 RowLayout {
83 Layout.fillWidth: true
84 spacing: ScreenTools.defaultFontPixelWidth / 2
85
86 PlanPanelIconButton {
87 objectName: "planPanel_inspectorBack"
88 accessibleName: qsTr("Back")
89 iconSource: "/InstrumentValueIcons/cheveron-right.svg"
90 iconRotation: 180
91 visible: root.drillIn
92 onClicked: root.backRequested()
93 }
94
95 QGCLabel {
96 Layout.fillWidth: true
97 text: root._item ? qsTr("#%1").arg(root._item.sequenceNumber) : ""
98 color: qgcPal.textSecondary
99 }
100
101 PlanPanelIconButton {
102 objectName: "planPanel_inspectorPrevious"
103 accessibleName: qsTr("Previous")
104 iconSource: "/InstrumentValueIcons/cheveron-right.svg"
105 iconRotation: -90
106 visible: root.drillIn
107 enabled: Logic.steppedIndex(root._currentIndex, -1, root._itemCount) >= 0
108 onClicked: root._step(-1)
109 }
110
111 PlanPanelIconButton {
112 objectName: "planPanel_inspectorNext"
113 accessibleName: qsTr("Next")
114 iconSource: "/InstrumentValueIcons/cheveron-right.svg"
115 iconRotation: 90
116 visible: root.drillIn
117 enabled: Logic.steppedIndex(root._currentIndex, 1, root._itemCount) >= 0
118 onClicked: root._step(1)
119 }
120
121 PlanPanelIconButton {
122 id: menuButton
123 objectName: "planPanel_inspectorMenu"
124 accessibleName: qsTr("Menu")
125 iconSource: "qrc:/qmlimages/Hamburger.svg"
126 visible: root._deletable
127 onClicked: {
128 if (menuLoader.item) {
129 menuLoader.item.openAt(menuButton, Qt.point(width / 2, height / 2))
130 }
131 }
132 }
133
134 PlanPanelIconButton {
135 objectName: "planPanel_inspectorDelete"
136 accessibleName: qsTr("Delete")
137 iconSource: "/res/TrashDelete.svg"
138 danger: true
139 visible: root._deletable
140 onClicked: root._remove()
141 }
142 }
143
144 RowLayout {
145 Layout.fillWidth: true
146 spacing: ScreenTools.defaultFontPixelWidth / 2
147
148 QGCLabel {
149 objectName: "planPanel_inspectorTitle"
150 Layout.fillWidth: true
151 text: root._item ? root._item.commandName : ""
152 font.bold: true
153 font.capitalization: Font.AllUppercase
154 font.letterSpacing: ScreenTools.defaultFontPixelWidth * 0.1
155 elide: Text.ElideRight
156 }
157
158 QGCButton {
159 objectName: "planPanel_inspectorCommand"
160 small: true
161 text: qsTr("Change...")
162 visible: root._commandEditable
163 onClicked: commandDialogFactory.open()
164 }
165 }
166
167 QGCLabel {
168 objectName: "planPanel_inspectorIncomplete"
169 Layout.fillWidth: true
170 visible: !root._ready
171 wrapMode: Text.WordWrap
172 font.pointSize: ScreenTools.smallFontPointSize
173 color: qgcPal.warningText
174 text: root._item && root._item.readyForSaveState === VisualMissionItem.NotReadyForSaveTerrain ?
175 qsTr("Incomplete: Waiting on terrain data.") :
176 qsTr("Incomplete: Item not fully specified.")
177 }
178
179 QGCFlickable {
180 id: flickable
181
182 objectName: "planPanel_inspectorFlickable"
183 Layout.fillWidth: true
184 Layout.fillHeight: true
185 contentHeight: editorLoader.height
186 clip: true
187
188 MissionItemEditorLoader {
189 id: editorLoader
190
191 objectName: "planPanel_inspectorEditor"
192 missionItem: root._item
193 availableWidth: flickable.width
194 }
195 }
196 }
197}