PlanView.qml 50.1 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9

10 11
import QtQuick          2.3
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
12
import QtQuick.Dialogs  1.2
13 14 15
import QtLocation       5.3
import QtPositioning    5.3
import QtQuick.Layouts  1.2
16
import QtQuick.Window   2.2
Don Gagne's avatar
Don Gagne committed
17

18 19 20 21 22 23 24 25 26 27 28
import QGroundControl                   1.0
import QGroundControl.FlightMap         1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Controls          1.0
import QGroundControl.FactSystem        1.0
import QGroundControl.FactControls      1.0
import QGroundControl.Palette           1.0
import QGroundControl.Controllers       1.0
import QGroundControl.ShapeFileHelper   1.0
import QGroundControl.Airspace          1.0
import QGroundControl.Airmap            1.0
Don Gagne's avatar
Don Gagne committed
29

30
Item {
31

Gus Grubba's avatar
Gus Grubba committed
32 33
    property bool planControlColapsed: false

34 35
    readonly property int   _decimalPlaces:             8
    readonly property real  _margin:                    ScreenTools.defaultFontPixelHeight * 0.5
DonLakeFlyer's avatar
DonLakeFlyer committed
36
    readonly property real  _toolsTopMargin:            ScreenTools.defaultFontPixelHeight * 0.5
Gus Grubba's avatar
Gus Grubba committed
37
    readonly property real  _radius:                    ScreenTools.defaultFontPixelWidth  * 0.5
38 39 40
    readonly property real  _rightPanelWidth:           Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30)
    readonly property var   _defaultVehicleCoordinate:  QtPositioning.coordinate(37.803784, -122.462276)
    readonly property bool  _waypointsOnlyMode:         QGroundControl.corePlugin.options.missionWaypointsOnly
41

Gus Grubba's avatar
Gus Grubba committed
42
    property bool   _airspaceEnabled:                    QGroundControl.airmapSupported ? (QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue && QGroundControl.airspaceManager.connected): false
Gus Grubba's avatar
Gus Grubba committed
43 44 45 46 47 48 49 50
    property var    _missionController:                 _planMasterController.missionController
    property var    _geoFenceController:                _planMasterController.geoFenceController
    property var    _rallyPointController:              _planMasterController.rallyPointController
    property var    _visualItems:                       _missionController.visualItems
    property bool   _lightWidgetBorders:                editorMap.isSatelliteMap
    property bool   _addWaypointOnClick:                false
    property bool   _addROIOnClick:                     false
    property bool   _singleComplexItem:                 _missionController.complexMissionItemNames.length === 1
Gus Grubba's avatar
Gus Grubba committed
51
    property int    _editingLayer:                      bar.currentIndex ? _layers[bar.currentIndex] : _layerMission
Gus Grubba's avatar
Gus Grubba committed
52
    property int    _toolStripBottom:                   toolStrip.height + toolStrip.y
53
    property var    _appSettings:                       QGroundControl.settingsManager.appSettings
54

Gus Grubba's avatar
Gus Grubba committed
55 56
    readonly property var       _layers:                [_layerMission, _layerGeoFence, _layerRallyPoints]

57 58 59 60
    readonly property int       _layerMission:              1
    readonly property int       _layerGeoFence:             2
    readonly property int       _layerRallyPoints:          3
    readonly property string    _armedVehicleUploadPrompt:  qsTr("Vehicle is currently armed. Do you want to upload the mission to the vehicle?")
61

62 63
    function addComplexItem(complexItemName) {
        var coordinate = editorMap.center
64
        coordinate.latitude  = coordinate.latitude.toFixed(_decimalPlaces)
65
        coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
66
        coordinate.altitude  = coordinate.altitude.toFixed(_decimalPlaces)
67
        insertComplexMissionItem(complexItemName, coordinate, _missionController.visualItems.count)
68 69 70
    }

    function insertComplexMissionItem(complexItemName, coordinate, index) {
71
        _missionController.insertComplexMissionItem(complexItemName, coordinate, index, true /* makeCurrentItem */)
72 73
    }

74
    function insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index) {
75
        _missionController.insertComplexMissionItemFromKMLOrSHP(complexItemName, file, index, true /* makeCurrentItem */)
76 77
    }

78
    function updateAirspace(reset) {
79 80 81 82
        if(_airspaceEnabled) {
            var coordinateNW = editorMap.toCoordinate(Qt.point(0,0), false /* clipToViewPort */)
            var coordinateSE = editorMap.toCoordinate(Qt.point(width,height), false /* clipToViewPort */)
            if(coordinateNW.isValid && coordinateSE.isValid) {
83
                QGroundControl.airspaceManager.setROI(coordinateNW, coordinateSE, true /*planView*/, reset)
84 85 86 87
            }
        }
    }

88 89 90 91 92
    property bool _firstMissionLoadComplete:    false
    property bool _firstFenceLoadComplete:      false
    property bool _firstRallyLoadComplete:      false
    property bool _firstLoadComplete:           false

93
    MapFitFunctions {
94
        id:                         mapFitFunctions  // The name for this id cannot be changed without breaking references outside of this code. Beware!
95 96
        map:                        editorMap
        usePlannedHomePosition:     true
97
        planMasterController:       _planMasterController
98 99
    }

100
    on_AirspaceEnabledChanged: {
101
        if(QGroundControl.airmapSupported) {
102 103
            if(_airspaceEnabled) {
                planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
104
                updateAirspace(true)
105 106 107
            } else {
                planControlColapsed = false
            }
108
        } else {
Gus Grubba's avatar
Gus Grubba committed
109 110 111 112
            planControlColapsed = false
        }
    }

DonLakeFlyer's avatar
DonLakeFlyer committed
113
    Connections {
Gus Grubba's avatar
Gus Grubba committed
114
        target: _appSettings ? _appSettings.defaultMissionItemAltitude : null
DonLakeFlyer's avatar
DonLakeFlyer committed
115 116
        onRawValueChanged: {
            if (_visualItems.count > 1) {
117
                mainWindow.showComponentDialog(applyNewAltitude, qsTr("Apply new alititude"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
DonLakeFlyer's avatar
DonLakeFlyer committed
118 119 120 121 122 123 124 125 126 127
            }
        }
    }

    Component {
        id: applyNewAltitude
        QGCViewMessage {
            message:    qsTr("You have changed the default altitude for mission items. Would you like to apply that altitude to all the items in the current mission?")
            function accept() {
                hideDialog()
128
                _missionController.applyDefaultMissionAltitude()
DonLakeFlyer's avatar
DonLakeFlyer committed
129 130 131 132
            }
        }
    }

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    Component {
        id: activeMissionUploadDialogComponent
        QGCViewDialog {
            Column {
                anchors.fill:   parent
                spacing:        ScreenTools.defaultFontPixelHeight
                QGCLabel {
                    width:      parent.width
                    wrapMode:   Text.WordWrap
                    text:       qsTr("Your vehicle is currently flying a mission. In order to upload a new or modified mission the current mission will be paused.")
                }
                QGCLabel {
                    width:      parent.width
                    wrapMode:   Text.WordWrap
                    text:       qsTr("After the mission is uploaded you can adjust the current waypoint and start the mission.")
                }
                QGCButton {
                    text:       qsTr("Pause and Upload")
                    onClicked: {
Gus Grubba's avatar
Gus Grubba committed
152
                        activeVehicle.flightMode = activeVehicle.pauseFlightMode
153
                        _planMasterController.sendToVehicle()
154
                        hideDialog()
155 156 157 158 159 160
                    }
                }
            }
        }
    }

Gus Grubba's avatar
Gus Grubba committed
161
    Connections {
162
        target: QGroundControl.airspaceManager
163
        onAirspaceVisibleChanged: {
164
            planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
Gus Grubba's avatar
Gus Grubba committed
165 166 167
        }
    }

168 169 170 171 172 173 174
    Component {
        id: noItemForKML
        QGCViewMessage {
            message:    qsTr("You need at least one item to create a KML.")
        }
    }

175
    PlanMasterController {
Gus Grubba's avatar
Gus Grubba committed
176
        id: _planMasterController
177

178
        Component.onCompleted: {
179
            _planMasterController.start(false /* flyView */)
180
            _missionController.setCurrentPlanViewIndex(0, true)
Gus Grubba's avatar
Gus Grubba committed
181
            mainWindow.planMasterControllerPlan = _planMasterController
182 183
        }

184
        function waitingOnDataMessage() {
185
            mainWindow.showMessageDialog(qsTr("Unable to Save/Upload"), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
186 187
        }

188
        function upload() {
189 190 191 192
            if (!readyForSaveSend()) {
                waitingOnDataMessage()
                return
            }
Gus Grubba's avatar
Gus Grubba committed
193
            if (activeVehicle && activeVehicle.armed && activeVehicle.flightMode === activeVehicle.missionFlightMode) {
194
                mainWindow.showComponentDialog(activeMissionUploadDialogComponent, qsTr("Plan Upload"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
195
            } else {
196 197
                sendToVehicle()
            }
DonLakeFlyer's avatar
DonLakeFlyer committed
198 199
        }

200
        function loadFromSelectedFile() {
201
            fileDialog.title =          qsTr("Select Plan File")
DonLakeFlyer's avatar
DonLakeFlyer committed
202
            fileDialog.planFiles =      true
203
            fileDialog.selectExisting = true
Gus Grubba's avatar
Gus Grubba committed
204
            fileDialog.nameFilters =    _planMasterController.loadNameFilters
205 206
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
207
            fileDialog.openForLoad()
208 209 210
        }

        function saveToSelectedFile() {
211 212 213 214
            if (!readyForSaveSend()) {
                waitingOnDataMessage()
                return
            }
215
            fileDialog.title =          qsTr("Save Plan")
216
            fileDialog.planFiles =      true
217
            fileDialog.selectExisting = false
Gus Grubba's avatar
Gus Grubba committed
218
            fileDialog.nameFilters =    _planMasterController.saveNameFilters
219 220
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
221
            fileDialog.openForSave()
222 223
        }

224
        function fitViewportToItems() {
225
            mapFitFunctions.fitMapViewportToMissionItems()
226
        }
227

228 229
        function loadShapeFromSelectedFile() {
            fileDialog.title =          qsTr("Load Shape")
230 231
            fileDialog.planFiles =      false
            fileDialog.selectExisting = true
232 233 234
            fileDialog.nameFilters =    ShapeFileHelper.fileDialogKMLOrSHPFilters
            fileDialog.fileExtension =  _appSettings.kmlFileExtension
            fileDialog.fileExtension2 = _appSettings.shpFileExtension
235 236 237
            fileDialog.openForLoad()
        }

238
        function saveKmlToSelectedFile() {
239 240 241 242
            if (!readyForSaveSend()) {
                waitingOnDataMessage()
                return
            }
243
            fileDialog.title =          qsTr("Save KML")
244
            fileDialog.planFiles =      false
245
            fileDialog.selectExisting = false
246 247
            fileDialog.nameFilters =    ShapeFileHelper.fileDialogKMLFilters
            fileDialog.fileExtension =  _appSettings.kmlFileExtension
248
            fileDialog.fileExtension2 = ""
249 250
            fileDialog.openForSave()
        }
251
    }
252

253 254
    Connections {
        target: _missionController
255

256
        onNewItemsFromVehicle: {
Gus Grubba's avatar
Gus Grubba committed
257
            if (_visualItems && _visualItems.count !== 1) {
258 259
                mapFitFunctions.fitMapViewportToMissionItems()
            }
260
            _missionController.setCurrentPlanViewIndex(0, true)
261 262
        }
    }
263

264 265 266 267
    /// Inserts a new simple mission item
    ///     @param coordinate Location to insert item
    ///     @param index Insert item at this index
    function insertSimpleMissionItem(coordinate, index) {
268
        _missionController.insertSimpleMissionItem(coordinate, index, true /* makeCurrentItem */)
269 270
    }

271 272 273 274 275 276 277
    /// Inserts a new ROI mission item
    ///     @param coordinate Location to insert item
    ///     @param index Insert item at this index
    function insertROIMissionItem(coordinate, index) {
        var sequenceNumber = _missionController.insertROIMissionItem(coordinate, index)
        _missionController.setCurrentPlanViewIndex(sequenceNumber, true)
        _addROIOnClick = false
278
        toolStrip.lastClickedButton.checked = false
279 280
    }

281 282 283 284 285 286 287 288 289 290 291
    function selectNextNotReady() {
        var foundCurrent = false
        for (var i=0; i<_missionController.visualItems.count; i++) {
            var vmi = _missionController.visualItems.get(i)
            if (vmi.readyForSaveState === VisualMissionItem.NotReadyForSaveData) {
                _missionController.setCurrentPlanViewIndex(vmi.sequenceNumber, true)
                break
            }
        }
    }

292 293
    property int _moveDialogMissionItemIndex

294 295
    QGCFileDialog {
        id:             fileDialog
Gus Grubba's avatar
Gus Grubba committed
296
        folder:         _appSettings ? _appSettings.missionSavePath : ""
297

298 299
        property bool planFiles: true    ///< true: working with plan files, false: working with kml file

300
        onAcceptedForSave: {
301
            if (planFiles) {
Gus Grubba's avatar
Gus Grubba committed
302
                _planMasterController.saveToFile(file)
303
            } else {
Gus Grubba's avatar
Gus Grubba committed
304
                _planMasterController.saveToKml(file)
305
            }
306
            close()
307 308
        }

309
        onAcceptedForLoad: {
310
            if (planFiles) {
Gus Grubba's avatar
Gus Grubba committed
311 312
                _planMasterController.loadFromFile(file)
                _planMasterController.fitViewportToItems()
313 314
                _missionController.setCurrentPlanViewIndex(0, true)
            } else {
315 316
                var retList = ShapeFileHelper.determineShapeType(file)
                if (retList[0] == ShapeFileHelper.Error) {
317
                    mainWindow.showMessageDialog("Error", retList[1])
318
                } else if (retList[0] == ShapeFileHelper.Polygon) {
Gus Grubba's avatar
Gus Grubba committed
319
                     var editVehicle = activeVehicle ? activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
320 321 322 323
                    if (editVehicle.fixedWing) {
                        insertComplexMissionItemFromKMLOrSHP(_missionController.surveyComplexItemName, file, -1)
                    } else {
                        polygonSelectPatternFile = file
324
                        mainWindow.showComponentDialog(patternPolygonSelectDialog, fileDialog.title, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel)
325
                    }
326 327
                } else if (retList[0] == ShapeFileHelper.Polyline) {
                    insertComplexMissionItemFromKMLOrSHP(_missionController.corridorScanComplexItemName, file, -1)
328 329
                }
            }
330
            close()
331 332 333
        }
    }

334
    property string polygonSelectPatternFile
335
    Component {
336
        id: patternPolygonSelectDialog
337 338 339 340 341 342 343 344
        QGCViewDialog {
            function accept() {
                var complexItemName
                if (surveyRadio.checked) {
                    complexItemName = _missionController.surveyComplexItemName
                } else {
                    complexItemName = _missionController.structureScanComplexItemName
                }
345
                insertComplexMissionItemFromKMLOrSHP(complexItemName, polygonSelectPatternFile, -1)
346 347 348 349 350 351 352 353 354 355
                hideDialog()
            }
            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        ScreenTools.defaultFontPixelHeight
                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
356
                    text:           qsTr("Create which pattern type?")
357 358 359 360 361 362 363 364 365 366 367 368 369
                }
                QGCRadioButton {
                    id:             surveyRadio
                    text:           qsTr("Survey")
                    checked:        true
                }
                QGCRadioButton {
                    text:           qsTr("Structure Scan")
                }
            }
        }
    }

370 371 372 373 374
    Component {
        id: moveDialog
        QGCViewDialog {
            function accept() {
                var toIndex = toCombo.currentIndex
Gus Grubba's avatar
Gus Grubba committed
375
                if (toIndex === 0) {
376 377
                    toIndex = 1
                }
378
                _missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
379 380 381 382 383 384 385 386 387 388 389
                hideDialog()
            }
            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        ScreenTools.defaultFontPixelHeight

                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
390
                    text:           qsTr("Move the selected mission item to the be after following mission item:")
391 392 393 394
                }

                QGCComboBox {
                    id:             toCombo
395
                    model:          _visualItems.count
396 397 398 399 400 401
                    currentIndex:   _moveDialogMissionItemIndex
                }
            }
        }
    }

402
    Item {
Don Gagne's avatar
Don Gagne committed
403
        id:             panel
404
        anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
405

406
        FlightMap {
407 408 409 410 411
            id:                         editorMap
            anchors.fill:               parent
            mapName:                    "MissionEditor"
            allowGCSLocationCenter:     true
            allowVehicleLocationCenter: true
412
            planView:                   true
Don Gagne's avatar
Don Gagne committed
413

414
            // This is the center rectangle of the map which is not obscured by tools
DonLakeFlyer's avatar
DonLakeFlyer committed
415
            property rect centerViewport:   Qt.rect(_leftToolWidth + _margin, _toolsTopMargin, editorMap.width - _leftToolWidth - _rightToolWidth - (_margin * 2), mapScale.y - _margin - _toolsTopMargin)
416

417 418
            property real _leftToolWidth:       toolStrip.x + toolStrip.width
            property real _rightToolWidth:      rightPanel.width + rightPanel.anchors.rightMargin
419

420
            readonly property real animationDuration: 500
421

422 423
            // Initial map position duplicates Fly view position
            Component.onCompleted: editorMap.center = QGroundControl.flightMapPosition
424

425 426 427 428 429 430
            Behavior on zoomLevel {
                NumberAnimation {
                    duration:       editorMap.animationDuration
                    easing.type:    Easing.InOutQuad
                }
            }
431

432 433
            QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap }

434 435
            onZoomLevelChanged: updateAirspace(false)
            onCenterChanged:    updateAirspace(false)
436

437 438 439
            MouseArea {
                anchors.fill: parent
                onClicked: {
440 441
                    // Take focus to close any previous editing
                    editorMap.focus = true
442 443 444 445
                    var coordinate = editorMap.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */)
                    coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
                    coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
                    coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
446

447 448 449
                    switch (_editingLayer) {
                    case _layerMission:
                        if (_addWaypointOnClick) {
450
                            insertSimpleMissionItem(coordinate, _missionController.visualItems.count)
451 452 453
                        } else if (_addROIOnClick) {
                            _addROIOnClick = false
                            insertROIMissionItem(coordinate, _missionController.visualItems.count)
454
                        }
455 456
                        break
                    case _layerRallyPoints:
Gus Grubba's avatar
Gus Grubba committed
457
                        if (_rallyPointController.supported && _addWaypointOnClick) {
458
                            _rallyPointController.addPoint(coordinate)
459
                        }
460
                        break
Don Gagne's avatar
Don Gagne committed
461
                    }
Don Gagne's avatar
Don Gagne committed
462
                }
463
            }
Don Gagne's avatar
Don Gagne committed
464

DonLakeFlyer's avatar
DonLakeFlyer committed
465 466 467 468 469 470 471 472 473 474 475 476
            PlanStartOverlay {
                id:                     startOverlay
                x:                      editorMap.centerViewport.left
                y:                      editorMap.centerViewport.top
                width:                  editorMap.centerViewport.width
                height:                 editorMap.centerViewport.height
                z:                      QGroundControl.zOrderMapItems + 2
                visible:                !_planMasterController.containsItems
                planMasterController:   _planMasterController
                mapControl:             editorMap
            }

477 478
            // Add the mission item visuals to the map
            Repeater {
479
                model: _editingLayer == _layerMission ? _missionController.visualItems : undefined
480 481
                delegate: MissionItemMapVisual {
                    map:        editorMap
482
                    onClicked:  _missionController.setCurrentPlanViewIndex(sequenceNumber, false)
483
                    visible:    _editingLayer == _layerMission
484
                }
485
            }
486

487 488
            // Add lines between waypoints
            MissionLineView {
489
                model: _editingLayer == _layerMission ? _missionController.waypointLines : undefined
490
            }
491

492 493 494 495 496 497
            MapItemView {
                model: _editingLayer == _layerMission ? _missionController.directionArrows : undefined

                delegate: MapLineArrow {
                    fromCoord:      object ? object.coordinate1 : undefined
                    toCoord:        object ? object.coordinate2 : undefined
498 499 500 501 502 503 504 505 506 507 508 509 510
                    arrowPosition:  3
                    z:              QGroundControl.zOrderWaypointLines + 1
                }
            }

            // UI for splitting the current segment
            MapQuickItem {
                id:             splitSegmentItem
                anchorPoint.x:  sourceItem.width / 2
                anchorPoint.y:  sourceItem.height / 2
                z:              QGroundControl.zOrderWaypointLines + 1

                sourceItem: SplitIndicator {
Don Gagne's avatar
Don Gagne committed
511
                    onClicked:  insertSimpleMissionItem(splitSegmentItem.coordinate, _missionController.visualItemIndexFromSequenceNumber(_missionController.currentPlanViewIndex))
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
                }

                function _updateSplitCoord() {
                    if (_missionController.splitSegment) {
                        var distance = _missionController.splitSegment.coordinate1.distanceTo(_missionController.splitSegment.coordinate2)
                        var azimuth = _missionController.splitSegment.coordinate1.azimuthTo(_missionController.splitSegment.coordinate2)
                        splitSegmentItem.coordinate = _missionController.splitSegment.coordinate1.atDistanceAndAzimuth(distance / 2, azimuth)
                    } else {
                        coordinate = QtPositioning.coordinate()
                    }
                }

                Connections {
                    target:                 _missionController
                    onSplitSegmentChanged:  splitSegmentItem._updateSplitCoord()
                }

                Connections {
                    target:                 _missionController.splitSegment
                    onCoordinate1Changed:   splitSegmentItem._updateSplitCoord()
                    onCoordinate2Changed:   splitSegmentItem._updateSplitCoord()
533 534 535
                }
            }

536 537 538 539 540 541 542
            // Add the vehicles to the map
            MapItemView {
                model: QGroundControl.multiVehicleManager.vehicles
                delegate:
                    VehicleMapItem {
                    vehicle:        object
                    coordinate:     object.coordinate
543
                    map:            editorMap
544 545
                    size:           ScreenTools.defaultFontPixelHeight * 3
                    z:              QGroundControl.zOrderMapItems - 1
546
                }
547
            }
548

549 550
            GeoFenceMapVisuals {
                map:                    editorMap
551
                myGeoFenceController:   _geoFenceController
552
                interactive:            _editingLayer == _layerGeoFence
553
                homePosition:           _missionController.plannedHomePosition
554 555
                planView:               true
            }
556

557 558
            RallyPointMapVisuals {
                map:                    editorMap
559
                myRallyPointController: _rallyPointController
560 561
                interactive:            _editingLayer == _layerRallyPoints
                planView:               true
562
            }
563

564 565
            // Airspace overlap support
            MapItemView {
566
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.circles : []
567 568 569
                delegate: MapCircle {
                    center:         object.center
                    radius:         object.radius
570
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
571 572
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
573 574 575 576
                }
            }

            MapItemView {
577
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.polygons : []
578 579
                delegate: MapPolygon {
                    path:           object.polygon
580
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
581 582
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
583 584
                }
            }
585
        }
586

587 588
        //-----------------------------------------------------------
        // Left tool strip
Gus Grubba's avatar
Gus Grubba committed
589
        ToolStrip {
590
            id:                 toolStrip
591
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
592
            anchors.left:       parent.left
DonLakeFlyer's avatar
DonLakeFlyer committed
593
            anchors.topMargin:  _toolsTopMargin
594 595
            anchors.top:        parent.top
            z:                  QGroundControl.zOrderWidgets
Gus Grubba's avatar
Gus Grubba committed
596
            maxHeight:          mapScale.y - toolStrip.y
597

Gus Grubba's avatar
Gus Grubba committed
598
            property bool _isRally:     _editingLayer == _layerRallyPoints
599

Gus Grubba's avatar
Gus Grubba committed
600 601 602 603 604 605
            model: [
                {
                    name:               qsTr("Fly"),
                    iconSource:         "/qmlimages/PaperPlane.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
606
                },
607
                {
Gus Grubba's avatar
Gus Grubba committed
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
                    name:               qsTr("File"),
                    iconSource:         "/qmlimages/MapSync.svg",
                    buttonEnabled:      !_planMasterController.syncInProgress,
                    buttonVisible:      true,
                    showAlternateIcon:  _planMasterController.dirty,
                    alternateIconSource:"/qmlimages/MapSyncChanged.svg",
                    dropPanelComponent: syncDropPanel
                },
                {
                    name:               _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"),
                    iconSource:         "/qmlimages/MapAddMission.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
                    toggle:             true,
                    checked:            _addWaypointOnClick
                },
                {
                    name:               qsTr("ROI"),
                    iconSource:         "/qmlimages/MapAddMission.svg",
                    buttonEnabled:      true,
                    buttonVisible:      !_isRally && _waypointsOnlyMode,
                    toggle:             true
                },
                {
                    name:               _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"),
                    iconSource:         "/qmlimages/MapDrawShape.svg",
                    buttonEnabled:      true,
                    buttonVisible:      !_isRally,
                    dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
                },
                {
                    name:               qsTr("Center"),
                    iconSource:         "/qmlimages/MapCenter.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
                    dropPanelComponent: centerMapDropPanel
                }
            ]
646

Gus Grubba's avatar
Gus Grubba committed
647 648
            onClicked: {
                switch (index) {
649 650 651 652
                case 0:
                    mainWindow.showFlyView()
                    break;
                case 2:
Gus Grubba's avatar
Gus Grubba committed
653 654 655 656 657 658
                    if(_addWaypointOnClick) {
                        //-- Toggle it off
                        _addWaypointOnClick = false
                        _addROIOnClick = false
                        setChecked(index, false)
                    } else {
659
                        _addWaypointOnClick = checked
660
                        _addROIOnClick = false
Gus Grubba's avatar
Gus Grubba committed
661 662
                    }
                    break
663
                case 3:
Gus Grubba's avatar
Gus Grubba committed
664 665 666
                    _addROIOnClick = checked
                    _addWaypointOnClick = false
                    break
667
                case 4:
Gus Grubba's avatar
Gus Grubba committed
668 669 670 671
                    if (_singleComplexItem) {
                        addComplexItem(_missionController.complexMissionItemNames[0])
                    }
                    break
672 673
                }
            }
Gus Grubba's avatar
Gus Grubba committed
674
        }
675

Gus Grubba's avatar
Gus Grubba committed
676
        //-----------------------------------------------------------
677 678 679
        // Right pane for mission editing controls
        Rectangle {
            id:                 rightPanel
680
            height:             parent.height
681 682
            width:              _rightPanelWidth
            color:              qgcPal.window
683
            opacity:            planExpanded.visible ? 0.2 : 0
Gus Grubba's avatar
Gus Grubba committed
684 685 686
            anchors.bottom:     parent.bottom
            anchors.right:      parent.right
            anchors.rightMargin: ScreenTools.defaultFontPixelWidth
687
        }
Gus Grubba's avatar
Gus Grubba committed
688 689
        //-------------------------------------------------------
        // Right Panel Controls
690
        Item {
Gus Grubba's avatar
Gus Grubba committed
691
            anchors.fill:           rightPanel
DonLakeFlyer's avatar
DonLakeFlyer committed
692
            anchors.topMargin:      _toolsTopMargin
Gus Grubba's avatar
Gus Grubba committed
693 694 695
            DeadMouseArea {
                anchors.fill:   parent
            }
Gus Grubba's avatar
Gus Grubba committed
696 697
            Column {
                id:                 rightControls
Gus Grubba's avatar
Gus Grubba committed
698
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
699 700
                anchors.left:       parent.left
                anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
701 702 703 704
                anchors.top:        parent.top
                //-------------------------------------------------------
                // Airmap Airspace Control
                AirspaceControl {
Gus Grubba's avatar
Gus Grubba committed
705 706
                    id:             airspaceControl
                    width:          parent.width
707
                    visible:        _airspaceEnabled
708
                    planView:       true
709
                    showColapse:    true
710
                }
Gus Grubba's avatar
Gus Grubba committed
711 712 713 714
                //-------------------------------------------------------
                // Mission Controls (Colapsed)
                Rectangle {
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
715
                    height:     planControlColapsed ? colapsedRow.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
716 717
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
718
                    visible:    planControlColapsed && _airspaceEnabled
Gus Grubba's avatar
Gus Grubba committed
719 720 721 722 723 724 725
                    Row {
                        id:                     colapsedRow
                        spacing:                ScreenTools.defaultFontPixelWidth
                        anchors.left:           parent.left
                        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                        QGCColoredImage {
726 727 728 729 730
                            width:              height
                            height:             ScreenTools.defaultFontPixelWidth * 2.5
                            sourceSize.height:  height
                            source:             "qrc:/res/waypoint.svg"
                            color:              qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
731 732 733
                            anchors.verticalCenter: parent.verticalCenter
                        }
                        QGCLabel {
734 735
                            text:               qsTr("Plan")
                            color:              qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
736
                            anchors.verticalCenter: parent.verticalCenter
737 738
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
739 740 741 742
                    QGCColoredImage {
                        width:                  height
                        height:                 ScreenTools.defaultFontPixelWidth * 2.5
                        sourceSize.height:      height
743
                        source:                 QGroundControl.airmapSupported ? "qrc:/airmap/expand.svg" : ""
744
                        color:                  "white"
745
                        visible:                QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
746 747 748 749 750 751
                        anchors.right:          parent.right
                        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                    }
                    MouseArea {
                        anchors.fill:   parent
752
                        enabled:        QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
753
                        onClicked: {
754
                            QGroundControl.airspaceManager.airspaceVisible = false
Gus Grubba's avatar
Gus Grubba committed
755 756
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
757
                }
Gus Grubba's avatar
Gus Grubba committed
758 759 760 761 762
                //-------------------------------------------------------
                // Mission Controls (Expanded)
                Rectangle {
                    id:         planExpanded
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
763
                    height:     (!planControlColapsed || !_airspaceEnabled) ? bar.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
764 765
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
Gus Grubba's avatar
Gus Grubba committed
766
                    visible:    (!planControlColapsed || !_airspaceEnabled) && QGroundControl.corePlugin.options.enablePlanViewSelector
Gus Grubba's avatar
Gus Grubba committed
767
                    Item {
Gus Grubba's avatar
Gus Grubba committed
768
                        height:             bar.height
Gus Grubba's avatar
Gus Grubba committed
769 770
                        anchors.left:       parent.left
                        anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
771
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
Gus Grubba's avatar
Gus Grubba committed
772
                        anchors.verticalCenter: parent.verticalCenter
Gus Grubba's avatar
Gus Grubba committed
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
                        QGCTabBar {
                            id:             bar
                            width:          parent.width
                            anchors.centerIn: parent
                            Component.onCompleted: {
                                currentIndex = 0
                            }
                            QGCTabButton {
                                text:       qsTr("Mission")
                            }
                            QGCTabButton {
                                text:       qsTr("Fence")
                                enabled:    _geoFenceController.supported
                            }
                            QGCTabButton {
                                text:       qsTr("Rally")
                                enabled:    _rallyPointController.supported
Gus Grubba's avatar
Gus Grubba committed
790 791 792 793 794 795 796 797 798 799 800 801
                            }
                        }
                    }
                }
            }
            //-------------------------------------------------------
            // Mission Item Editor
            Item {
                id:                     missionItemEditor
                anchors.left:           parent.left
                anchors.right:          parent.right
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
802
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
803 804 805 806
                anchors.bottom:         parent.bottom
                anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 0.25
                visible:                _editingLayer == _layerMission && !planControlColapsed
                QGCListView {
Gus Grubba's avatar
Gus Grubba committed
807 808 809 810 811 812 813 814
                    id:                 missionItemEditorListView
                    anchors.fill:       parent
                    spacing:            ScreenTools.defaultFontPixelHeight / 4
                    orientation:        ListView.Vertical
                    model:              _missionController.visualItems
                    cacheBuffer:        Math.max(height * 2, 0)
                    clip:               true
                    currentIndex:       _missionController.currentPlanViewIndex
Gus Grubba's avatar
Gus Grubba committed
815
                    highlightMoveDuration: 250
Gus Grubba's avatar
Gus Grubba committed
816
                    visible:            _editingLayer == _layerMission && !planControlColapsed
Gus Grubba's avatar
Gus Grubba committed
817 818
                    //-- List Elements
                    delegate: MissionItemEditor {
Gus Grubba's avatar
Gus Grubba committed
819
                        map:            editorMap
Gus Grubba's avatar
Gus Grubba committed
820
                        masterController:  _planMasterController
Gus Grubba's avatar
Gus Grubba committed
821 822 823 824
                        missionItem:    object
                        width:          parent.width
                        readOnly:       false
                        onClicked:      _missionController.setCurrentPlanViewIndex(object.sequenceNumber, false)
Gus Grubba's avatar
Gus Grubba committed
825 826 827 828 829 830 831 832
                        onRemove: {
                            var removeIndex = index
                            _missionController.removeMissionItem(removeIndex)
                            if (removeIndex >= _missionController.visualItems.count) {
                                removeIndex--
                            }
                            _missionController.setCurrentPlanViewIndex(removeIndex, true)
                        }
833 834 835
                        onInsertWaypoint:           insertSimpleMissionItem(editorMap.center, index)
                        onInsertComplexItem:        insertComplexMissionItem(complexItemName, editorMap.center, index)
                        onSelectNextNotReadyItem:   selectNextNotReady()
Gus Grubba's avatar
Gus Grubba committed
836 837 838 839 840 841
                    }
                }
            }
            // GeoFence Editor
            GeoFenceEditor {
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
842
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Don Gagne's avatar
Don Gagne committed
843
                anchors.bottom:         parent.bottom
Gus Grubba's avatar
Gus Grubba committed
844 845 846 847 848 849 850 851 852 853
                anchors.left:           parent.left
                anchors.right:          parent.right
                myGeoFenceController:   _geoFenceController
                flightMap:              editorMap
                visible:                _editingLayer == _layerGeoFence
            }
            // Rally Point Editor
            RallyPointEditorHeader {
                id:                     rallyPointHeader
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
854
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
855 856 857 858 859 860 861 862
                anchors.left:           parent.left
                anchors.right:          parent.right
                visible:                _editingLayer == _layerRallyPoints
                controller:             _rallyPointController
            }
            RallyPointItemEditor {
                id:                     rallyPointEditor
                anchors.top:            rallyPointHeader.bottom
Gus Grubba's avatar
Gus Grubba committed
863
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
864 865 866 867 868
                anchors.left:           parent.left
                anchors.right:          parent.right
                visible:                _editingLayer == _layerRallyPoints && _rallyPointController.points.count
                rallyPoint:             _rallyPointController.currentRallyPoint
                controller:             _rallyPointController
869
            }
Gus Grubba's avatar
Gus Grubba committed
870
        }
871 872

        MapScale {
873 874 875 876 877 878 879 880 881 882 883
            id:                     mapScale
            anchors.margins:        ScreenTools.defaultFontPixelHeight * (0.66)
            anchors.bottom:         waypointValuesDisplay.visible ? waypointValuesDisplay.top : parent.bottom
            anchors.left:           parent.left
            mapControl:             editorMap
            buttonsOnLeft:          true
            terrainButtonVisible:   true
            visible:                _toolStripBottom < y && _editingLayer === _layerMission
            terrainButtonChecked:   waypointValuesDisplay.visible

            onTerrainButtonClicked: waypointValuesDisplay.toggleVisible()
884 885 886 887 888 889
        }

        MissionItemStatus {
            id:                 waypointValuesDisplay
            anchors.margins:    ScreenTools.defaultFontPixelWidth
            anchors.left:       parent.left
890
            height:             ScreenTools.defaultFontPixelHeight * 7
891
            maxWidth:           parent.width - rightPanel.width - x
892
            anchors.bottom:     parent.bottom
893
            missionItems:       _missionController.visualItems
894 895 896 897 898 899 900
            visible:            _internalVisible && _editingLayer === _layerMission && (_toolStripBottom + mapScale.height) < y && QGroundControl.corePlugin.options.showMissionStatus

            property bool _internalVisible: false

            function toggleVisible() {
                _internalVisible = !_internalVisible
            }
901
        }
Gus Grubba's avatar
Gus Grubba committed
902
    }
903

904 905 906 907
    Component {
        id: syncLoadFromVehicleOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
Don Gagne's avatar
Don Gagne committed
908
            message:   qsTr("You have unsaved/unsent changes. Loading from the Vehicle will lose these changes. Are you sure you want to load from the Vehicle?")
909 910
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
911
                _planMasterController.loadFromVehicle()
912 913 914 915 916 917 918 919
            }
        }
    }

    Component {
        id: syncLoadFromFileOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
DonLakeFlyer's avatar
DonLakeFlyer committed
920
            message:   qsTr("You have unsaved/unsent changes. Loading from a file will lose these changes. Are you sure you want to load from a file?")
921 922
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
923
                _planMasterController.loadFromSelectedFile()
924 925 926 927
            }
        }
    }

928 929 930
    Component {
        id: removeAllPromptDialog
        QGCViewMessage {
931
            message: qsTr("Are you sure you want to remove all items and create a new plan? ") +
932
                     (_planMasterController.offline ? "" : qsTr("This will also remove all items from the vehicle."))
933
            function accept() {
934
                if (_planMasterController.offline) {
Gus Grubba's avatar
Gus Grubba committed
935
                    _planMasterController.removeAll()
936
                } else {
Gus Grubba's avatar
Gus Grubba committed
937
                    _planMasterController.removeAllFromVehicle()
938
                }
939
                _missionController.setCurrentPlanViewIndex(0, true)
DonLakeFlyer's avatar
DonLakeFlyer committed
940
                startOverlay.visible = true
941 942 943 944 945
                hideDialog()
            }
        }
    }

946 947 948 949 950
    Component {
        id: clearVehicleMissionDialog
        QGCViewMessage {
            message: qsTr("Are you sure you want to remove all mission items and clear the mission from the vehicle?")
            function accept() {
Gus Grubba's avatar
Gus Grubba committed
951
                _planMasterController.removeAllFromVehicle()
952
                _missionController.setCurrentPlanViewIndex(0, true)
DonLakeFlyer's avatar
DonLakeFlyer committed
953
                startOverlay.visible = true
954 955 956 957 958
                hideDialog()
            }
        }
    }

959 960 961 962 963 964 965 966 967 968 969
    //- ToolStrip DropPanel Components

    Component {
        id: centerMapDropPanel

        CenterMapDropPanel {
            map:            editorMap
            fitFunctions:   mapFitFunctions
        }
    }

970 971 972 973 974 975 976 977 978
    Component {
        id: patternDropPanel

        ColumnLayout {
            spacing:    ScreenTools.defaultFontPixelWidth * 0.5

            QGCLabel { text: qsTr("Create complex pattern:") }

            Repeater {
979
                model: _missionController.complexMissionItemNames
980 981 982 983 984 985

                QGCButton {
                    text:               modelData
                    Layout.fillWidth:   true

                    onClicked: {
986
                        addComplexItem(modelData)
987 988 989 990
                        dropPanel.hide()
                    }
                }
            }
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003

            Rectangle {
                width:              parent.width * 0.8
                height:             1
                color:              qgcPal.text
                opacity:            0.5
                Layout.fillWidth:   true
                Layout.columnSpan:  2
            }

            QGCButton {
                text:               qsTr("Load KML/SHP...")
                Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1004
                enabled:            !_planMasterController.syncInProgress
1005
                onClicked: {
Gus Grubba's avatar
Gus Grubba committed
1006
                    _planMasterController.loadShapeFromSelectedFile()
1007 1008 1009
                    dropPanel.hide()
                }
            }
1010 1011
        } // Column
    }
1012 1013

    Component {
1014
        id: syncDropPanel
1015

1016 1017 1018
        Column {
            id:         columnHolder
            spacing:    _margin
1019

1020
            property string _overwriteText: (_editingLayer == _layerMission) ? qsTr("Mission overwrite") : ((_editingLayer == _layerGeoFence) ? qsTr("GeoFence overwrite") : qsTr("Rally Points overwrite"))
1021

1022 1023 1024
            QGCLabel {
                width:      sendSaveGrid.width
                wrapMode:   Text.WordWrap
Gus Grubba's avatar
Gus Grubba committed
1025
                text:       _planMasterController.dirty ?
Gus Grubba's avatar
Gus Grubba committed
1026
                                (activeVehicle ?
1027 1028 1029 1030
                                     qsTr("You have unsaved changes. You should upload to your vehicle, or save to a file:") :
                                     qsTr("You have unsaved changes.")
                                ) :
                                qsTr("Plan File:")
1031 1032
            }

1033 1034 1035 1036 1037 1038
            GridLayout {
                id:                 sendSaveGrid
                columns:            2
                anchors.margins:    _margin
                rowSpacing:         _margin
                columnSpacing:      ScreenTools.defaultFontPixelWidth
1039

1040
                QGCButton {
1041
                    text:               qsTr("New...")
1042
                    Layout.fillWidth:   true
1043
                    enabled:            _planMasterController.containsItems
1044
                    onClicked:  {
1045
                        dropPanel.hide()
1046
                        mainWindow.showComponentDialog(removeAllPromptDialog, qsTr("New Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
1047 1048
                    }
                }
1049

1050
                QGCButton {
1051
                    text:               qsTr("Open...")
1052
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1053
                    enabled:            !_planMasterController.syncInProgress
1054 1055
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1056
                        if (_planMasterController.dirty) {
1057
                            mainWindow.showComponentDialog(syncLoadFromFileOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1058
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1059
                            _planMasterController.loadFromSelectedFile()
1060 1061 1062
                        }
                    }
                }
1063

1064
                QGCButton {
1065
                    text:               qsTr("Save")
1066
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1067
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.currentPlanFile !== ""
1068 1069
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1070 1071
                        if(_planMasterController.currentPlanFile !== "") {
                            _planMasterController.saveToCurrent()
1072
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1073
                            _planMasterController.saveToSelectedFile()
1074
                        }
1075 1076 1077 1078
                    }
                }

                QGCButton {
1079
                    text:               qsTr("Save As...")
1080
                    Layout.fillWidth:   true
1081
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.containsItems
1082 1083
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1084
                        _planMasterController.saveToSelectedFile()
1085 1086 1087 1088
                    }
                }

                QGCButton {
1089
                    text:               qsTr("Save Mission Waypoints As KML...")
1090
                    Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
1091
                    enabled:            !_planMasterController.syncInProgress && _visualItems.count > 1
1092
                    onClicked: {
1093
                        // First point does not count
1094
                        if (_visualItems.count < 2) {
1095
                            mainWindow.showComponentDialog(noItemForKML, qsTr("KML"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
1096 1097
                            return
                        }
1098
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1099
                        _planMasterController.saveKmlToSelectedFile()
1100 1101
                    }
                }
1102

1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
                Rectangle {
                    width:              parent.width * 0.8
                    height:             1
                    color:              qgcPal.text
                    opacity:            0.5
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    Layout.fillWidth:   true
                    Layout.columnSpan:  2
                }

1113
                QGCButton {
1114
                    text:               qsTr("Upload")
1115
                    Layout.fillWidth:   true
1116
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress && _planMasterController.containsItems
1117 1118
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
1119
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1120
                        _planMasterController.upload()
1121 1122
                    }
                }
1123 1124 1125 1126

                QGCButton {
                    text:               qsTr("Download")
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1127
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1128 1129 1130
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1131
                        if (_planMasterController.dirty) {
1132
                            mainWindow.showComponentDialog(syncLoadFromVehicleOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1133
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1134
                            _planMasterController.loadFromVehicle()
1135 1136 1137 1138 1139 1140 1141 1142
                        }
                    }
                }

                QGCButton {
                    text:               qsTr("Clear Vehicle Mission")
                    Layout.fillWidth:   true
                    Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
1143
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1144 1145 1146
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
1147
                        mainWindow.showComponentDialog(clearVehicleMissionDialog, text, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1148 1149 1150
                    }
                }

1151
            }
1152 1153
        }
    }
Gus Grubba's avatar
Gus Grubba committed
1154
}