8import QGroundControl.Controls
9import QGroundControl.FactControls
11/// Mission item edit control
13 required property var missionItem ///< MissionItem associated with this editor
14 required property var map ///< Map control
18 signal selectNextNotReadyItem
19 signal editorExpandedAndLoaded
22 height: _currentItem ? (editorLoader.y + editorLoader.height + _innerMargin) : (topRowLayout.y + topRowLayout.height + _margin)
23 color: _currentItem ? qgcPal.accent : qgcPal.windowCard
25 opacity: _currentItem ? 1.0 : 0.7
26 border.width: _readyForSave ? 0 : 2
27 border.color: qgcPal.errorText
29 property var _masterController: missionItem.masterController
30 property var _missionController: _masterController.missionController
31 property bool _currentItem: missionItem.isCurrentItem
32 property color _outerTextColor: _currentItem ? qgcPal.accentText : qgcPal.textPrimary
33 property bool _noMissionItemsAdded: _missionController.visualItems ? _missionController.visualItems.count <= 1 : true
34 property real _sectionSpacer: ScreenTools.defaultFontPixelWidth / 2 // spacing between section headings
35 property bool _singleComplexItem: _missionController.complexMissionItems.length === 1
36 property bool _readyForSave: missionItem.readyForSaveState === VisualMissionItem.ReadyForSave
38 readonly property real _editFieldWidth: Math.min(width - _innerMargin * 2, ScreenTools.defaultFontPixelWidth * 12)
39 readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
40 readonly property real _innerMargin: 2
41 readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
42 readonly property real _hamburgerSize: commandPicker.height * 0.75
43 readonly property real _trashSize: commandPicker.height * 0.75
44 readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
48 colorGroupEnabled: enabled
58 if (mainWindow.allowViewSwitch()) {
59 currentItemScope.focus = true
68 missionItem: _root.missionItem
73 anchors.margins: _margin
74 anchors.left: parent.left
75 anchors.top: parent.top
79 id: notReadyForSaveIndicator
80 anchors.verticalCenter: parent.verticalCenter
83 color: qgcPal.errorIndicator
85 visible: !_readyForSave
89 anchors.centerIn: parent
90 //: Indicator in Plan view to show mission item is not ready for save/send
92 color: qgcPal.indicatorText
93 font.pointSize: ScreenTools.smallFontPointSize
99 anchors.verticalCenter: parent.verticalCenter
100 height: _hamburgerSize
102 sourceSize.height: height
103 fillMode: Image.PreserveAspectFit
106 color: qgcPal.accentText
107 visible: _currentItem && missionItem.sequenceNumber !== 0
108 source: "/res/TrashDelete.svg"
118 anchors.verticalCenter: parent.verticalCenter
119 height: ScreenTools.implicitComboBoxHeight
120 width: innerLayout.width
121 visible: !commandLabel.visible
125 anchors.verticalCenter: parent.verticalCenter
128 property real _padding: ScreenTools.comboBoxPadding
130 QGCLabel { text: missionItem.commandName }
133 height: ScreenTools.defaultFontPixelWidth
135 fillMode: Image.PreserveAspectFit
138 color: qgcPal.textPrimary
139 source: "/qmlimages/arrow-down.png"
145 onClicked: commandDialogFactory.open()
148 QGCPopupDialogFactory {
149 id: commandDialogFactory
151 dialogComponent: commandDialog
157 MissionCommandDialog {
158 vehicle: _masterController.controllerVehicle
159 missionItem: _root.missionItem
161 // FIXME: Disabling fly through commands doesn't work since you may need to change from an RTL to something else
162 flyThroughCommandsAllowed: true //_missionController.flyThroughCommandsAllowed
169 anchors.verticalCenter: parent.verticalCenter
170 width: commandPicker.width
171 height: commandPicker.height
172 visible: !missionItem.isCurrentItem || !missionItem.isSimpleItem || _waypointsOnlyMode || missionItem.isTakeoffItem
173 verticalAlignment: Text.AlignVCenter
174 text: missionItem.commandName
175 color: _outerTextColor
181 anchors.margins: _margin
182 anchors.right: parent.right
183 anchors.verticalCenter: topRowLayout.verticalCenter
184 width: _hamburgerSize
185 height: _hamburgerSize
186 sourceSize.height: _hamburgerSize
187 source: "qrc:/qmlimages/Hamburger.svg"
188 visible: missionItem.isCurrentItem && missionItem.sequenceNumber !== 0
189 color: qgcPal.accentText
193 onClicked: (position) => {
194 currentItemScope.focus = true
195 itemMenu.openAt(hamburger, position)
202 id: notReadyForSaveLabel
203 anchors.margins: _margin
204 anchors.left: notReadyForSaveIndicator.right
205 anchors.right: parent.right
206 anchors.top: commandPicker.bottom
207 visible: _currentItem && !_readyForSave
208 text: missionItem.readyForSaveState === VisualMissionItem.NotReadyForSaveTerrain ?
209 qsTr("Incomplete: Waiting on terrain data.") :
210 qsTr("Incomplete: Item not fully specified.")
211 wrapMode: Text.WordWrap
212 horizontalAlignment: Text.AlignHCenter
213 color: qgcPal.errorText
218 MissionItemEditorLoader {
220 anchors.margins: _innerMargin
221 anchors.left: parent.left
222 anchors.top: topRowLayout.bottom
223 missionItem: _root.missionItem
224 availableWidth: _root.width - (anchors.margins * 2)
229 if (_currentItem && editorLoader.status === Loader.Ready) {
230 _editorHeightSettleTimer.restart()
235 id: _editorHeightSettleTimer
237 onTriggered: _root.editorExpandedAndLoaded()