MeasurementItemEditor.qml 4.25 KB
Newer Older
1
import QtQuick 2.3
2 3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
4 5 6 7 8 9 10 11 12 13 14 15
import QtQuick.Dialogs 1.2
import QtQuick.Extras 1.4
import QtQuick.Layouts 1.3

import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Vehicle 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.FlightMap 1.0
16
import MeasurementComplexItem 1.0 as MCI
17 18

Rectangle {
19 20 21 22 23
    id: _root
    height: visible ? (mainColumn.height + (_margin * 2)) : 0
    width: availableWidth
    color: qgcPal.windowShadeDark
    radius: _radius
24 25 26 27

    // The following properties must be available up the hierarchy chain
    //property real   availableWidth    ///< Width for control
    //property var    missionItem       ///< Mission Item for editor
28 29 30
    property real _margin: ScreenTools.defaultFontPixelWidth / 2
    property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
    property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
31 32
    property var _missionItem: missionItem
    property var _areaData: missionItem.areaData
33

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    QGCPalette {
        id: qgcPal
        colorGroupEnabled: true
    }

    Column {
        // main Column
        id: mainColumn
        anchors.margins: _margin
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right

        QGCTabBar {
            id: tabBar
            anchors.left: parent.left
            anchors.right: parent.right

            enabled: !editing || editing && correct

            readonly property int areaEditorIndex: 0
            readonly property int parameterEditorIndex: 1
56
            readonly property int nemoEditorIndex: 2
57 58 59 60 61 62
            property bool editing: _missionItem.editing
            property bool correct: false

            Component.onCompleted: currentIndex = editing ? areaEditorIndex : parameterEditorIndex

            QGCTabButton {
63
                icon.source: "qrc:/res/waypoint.svg"
64 65 66 67 68 69 70
                icon.height: ScreenTools.defaultFontPixelHeight
            }
            QGCTabButton {
                icon.source: "/qmlimages/PatternGrid.png"
                icon.height: ScreenTools.defaultFontPixelHeight
            }
            QGCTabButton {
71
                icon.source: "qrc:/res/fish.svg"
72 73
                icon.height: ScreenTools.defaultFontPixelHeight
            }
74

75 76 77 78 79
            onEditingChanged: {
                if (editing) {
                    areasCorrectTimer.start()
                } else {
                    areasCorrectTimer.stop()
80
                }
81
            }
82

83 84 85 86 87
            onCurrentIndexChanged: {
                if (currentIndex === areaEditorIndex) {
                    _missionItem.startEditing()
                } else {
                    _missionItem.stopEditing()
88 89
                }
            }
90

91 92 93 94 95 96 97 98 99 100
            Timer {
                id: areasCorrectTimer
                running: false
                interval: 100
                repeat: true

                onTriggered: {
                    tabBar.correct = _missionItem.areaData.isCorrect(
                                false /*show gui message*/
                                )
101 102
                }
            }
103
        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
104

105 106 107 108 109 110 111 112 113 114
        MCI.AreaDataEditor {
            id: areaEditor

            visible: tabBar.currentIndex === tabBar.areaEditorIndex
            checked: visible
            missionItem: _root._missionItem
            availableWidth: mainColumn.width
            onAbort: {
                missionItem.abortEditing()
                tabBar.currentIndex = tabBar.parameterEditorIndex
115
            }
116
        }
117

118 119
        MCI.ParameterEditor {
            id: parameterEditor
120

121 122 123 124 125
            visible: tabBar.currentIndex === tabBar.parameterEditorIndex
            checked: visible
            missionItem: _root._missionItem
            availableWidth: mainColumn.width
        }
126

127 128
        MCI.NemoEditor {
            id: nemoEditor
129

130 131 132 133
            visible: tabBar.currentIndex === tabBar.nemoEditorIndex
            checked: visible
            missionItem: _root._missionItem
            availableWidth: mainColumn.width
134
        }
135
    } // main Column
136
} // Rectangle