Skip to content
Snippets Groups Projects
WimaView.qml 58.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                            areaItem:           object
    
                            width:              parent.width
                            readOnly:           false
                            rootQgcView:        _qgcView
    
                            onRemove: {
                                var removeIndex = index
    
                            }
                        }
                    }
                }
                //-------------------------------------------------------
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                // Mission Item Editor
                Item {
                    id:                     missionItemEditor
                    anchors.left:           parent.left
                    anchors.right:          parent.right
                    anchors.top:            rightControls.bottom
                    anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.5
                    anchors.bottom:         parent.bottom
                    anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 0.25
                    visible:                _editingLayer == _layerMission && !planControlColapsed
                    QGCListView {
                        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
                        highlightMoveDuration: 250
                        visible:        _editingLayer == _layerMission && !planControlColapsed
    
                        //-- List Elements
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        delegate: MissionItemEditor {
                            map:                editorMap
                            masterController:  _planMasterController
                            missionItem:        object
                            width:              parent.width
                            readOnly:           false
                            rootQgcView:        _qgcView
                            onClicked:  _missionController.setCurrentPlanViewIndex(object.sequenceNumber, false)
                            onRemove: {
                                var removeIndex = index
                                _missionController.removeMissionItem(removeIndex)
                                if (removeIndex >= _missionController.visualItems.count) {
                                    removeIndex--
                                }
                                _missionController.setCurrentPlanViewIndex(removeIndex, true)
                            }
                            onInsertWaypoint:       insertSimpleMissionItem(editorMap.center, index)
                            onInsertComplexItem:    insertComplexMissionItem(complexItemName, editorMap.center, index)
                        }
                    }
                }
            }
    
            MapScale {
                id:                 mapScale
                anchors.margins:    ScreenTools.defaultFontPixelHeight * (0.66)
                anchors.bottom:     waypointValuesDisplay.visible ? waypointValuesDisplay.top : parent.bottom
                anchors.left:       parent.left
                mapControl:         editorMap
                visible:            _toolStripBottom < y
            }
    
            MissionItemStatus {
                id:                 waypointValuesDisplay
                anchors.margins:    ScreenTools.defaultFontPixelWidth
                anchors.left:       parent.left
                height:             ScreenTools.defaultFontPixelHeight * 7
                maxWidth:           parent.width - rightPanel.width - x
                anchors.bottom:     parent.bottom
                missionItems:       _missionController.visualItems
                visible:            _editingLayer === _layerMission && (_toolStripBottom + mapScale.height) < y && QGroundControl.corePlugin.options.showMissionStatus
            }
        }
    
    
        Component {
                id: syncLoadFromVehicleOverwrite
                QGCViewMessage {
                    id:         syncLoadFromVehicleCheck
                    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?")
                    function accept() {
                        hideDialog()
                        masterController.loadFromVehicle()
                    }
                }
         }
    
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
        Component {
            id: syncLoadFromFileOverwrite
            QGCViewMessage {
                id:         syncLoadFromVehicleCheck
                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?")
                function accept() {
                    hideDialog()
                    masterController.loadFromSelectedFile()
                }
            }
        }
    
        Component {
            id: removeAllPromptDialog
            QGCViewMessage {
                message: qsTr("Are you sure you want to remove all items and create a new plan? ") +
                         (_planMasterController.offline ? "" : qsTr("This will also remove all items from the vehicle."))
                function accept() {
                    if (_planMasterController.offline) {
                        masterController.removeAll()
                    } else {
                        masterController.removeAllFromVehicle()
                    }
                    hideDialog()
                }
            }
        }
    
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
        Component {
            id: wimaRemoveAllPromptDialog
            QGCViewMessage {
                message: qsTr("Are you sure you want to remove all items and create a Wima mission? ")
                function accept() {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
        Component {
            id: clearVehicleMissionDialog
            QGCViewMessage {
                message: qsTr("Are you sure you want to remove all mission items and clear the mission from the vehicle?")
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                function accept() {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                    masterController.removeAllFromVehicle()
                    hideDialog()
                }
            }
        }
    
        //- ToolStrip DropPanel Components
    
        Component {
            id: centerMapDropPanel
    
            CenterMapDropPanel {
                map:            editorMap
                fitFunctions:   mapFitFunctions
            }
        }
    
    
        Component {
            id: patternDropPanel
    
            ColumnLayout {
                spacing:    ScreenTools.defaultFontPixelWidth * 0.5
    
                QGCLabel { text: qsTr("Create complex pattern:") }
    
                Repeater {
                    model: _missionController.complexMissionItemNames
    
                    QGCButton {
                        text:               modelData
                        Layout.fillWidth:   true
    
                        onClicked: {
                            addComplexItem(modelData)
                            dropPanel.hide()
                        }
                    }
                }
    
                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
                    enabled:            !masterController.syncInProgress
                    onClicked: {
                        masterController.loadShapeFromSelectedFile()
                        dropPanel.hide()
                    }
                }
            } // Column
        }
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
    
        Component {
            id: syncDropPanel
    
            Column {
                id:         columnHolder
                spacing:    _margin
    
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                property string _overwriteText: qsTr("Mission overwrite")
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
    
                QGCLabel {
                    width:      sendSaveGrid.width
                    wrapMode:   Text.WordWrap
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                    text:       masterController.dirty ?
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                                    (_activeVehicle ?
                                         qsTr("You have unsaved changes. You should upload to your vehicle, or save to a file:") :
                                         qsTr("You have unsaved changes.")
                                    ) :
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                                    qsTr("File:")
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                }
    
                GridLayout {
                    id:                 sendSaveGrid
                    columns:            2
                    anchors.margins:    _margin
                    rowSpacing:         _margin
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
    
                    QGCButton {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        Layout.fillWidth:   true
    
                        enabled:            _wimaVisualItems.count >= 1 || _missionController.visualItems.count > 1
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        onClicked:  {
                            dropPanel.hide()
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                            _qgcView.showDialog(wimaRemoveAllPromptDialog, qsTr("New Plan"), _qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        }
                    }
    
                    QGCButton {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        Layout.fillWidth:   true
    
                        enabled:            true//!masterController.syncInProgress
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        onClicked: {
                            dropPanel.hide()
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        }
                    }
    
                    QGCButton {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        Layout.fillWidth:   true
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        onClicked: {
                            dropPanel.hide()
    
                            wimaPlaner.saveToCurrent()
                            console.log("saveing to: ", wimaPlaner.currentFile)
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        }
                    }
    
                    QGCButton {
                        text:               qsTr("Save As...")
                        Layout.fillWidth:   true
    
                        enabled:            _wimaVisualItems.count >= 1
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        onClicked: {
                            dropPanel.hide()
    
                    /*QGCButton {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        text:               qsTr("Save Mission Waypoints As KML...")
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        Layout.columnSpan:  2
                        enabled:            !masterController.syncInProgress && _visualItems.count > 1
                        onClicked: {
                            // First point does not count
                            if (_visualItems.count < 2) {
                                _qgcView.showDialog(noItemForKML, qsTr("KML"), _qgcView.showDialogDefaultWidth, StandardButton.Cancel)
                                return
                            }
                            dropPanel.hide()
                            masterController.saveKmlToSelectedFile()
                        }
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
    
                    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
                    }
    
                    QGCButton {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        Layout.fillWidth:   true
    
                        enabled:            !masterController.offline && !masterController.syncInProgress && _visualItems.count > 1
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                        onClicked: {
                            dropPanel.hide()
                            masterController.upload()
                        }
                    }
    
                    QGCButton {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        Layout.fillWidth:   true
                        enabled:            !masterController.offline && !masterController.syncInProgress
                        visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                        onClicked: {
                            dropPanel.hide()
                            if (masterController.dirty) {
                                _qgcView.showDialog(syncLoadFromVehicleOverwrite, columnHolder._overwriteText, _qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
                            } else {
                                masterController.loadFromVehicle()
                            }
                        }
                    }
    
                    QGCButton {
    
                        text:               qsTr("Clear Vehicle Mission")
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
                        Layout.fillWidth:   true
                        Layout.columnSpan:  2
                        enabled:            !masterController.offline && !masterController.syncInProgress
                        visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                        onClicked: {
                            dropPanel.hide()
                            _qgcView.showDialog(clearVehicleMissionDialog, text, _qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
                        }
                    }
    
                }
            }
        }
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
    
            visible: false
    
            anchors.bottom: parent.bottom
            width: parent.width*0.7
            x: (parent.width-width)/2
            height: 150
    
            border.color: "black"
    
            QGCListView {
                anchors.fill: parent
    
                delegate: Rectangle{
                            height: 15
                            color: "lightsteelblue"
                            radius: 1
                            Text {
    
    Valentin Platzgummer's avatar
    Valentin Platzgummer committed
    } // QGCVIew