import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.FlightMap     1.0

GridLayout {
    id:                 editorColumn
    columns: 2
    columnSpacing: _margin
    rowSpacing: _margin
    width:      availableWidth

    property var geoArea: undefined
    property int availableWidth

    property real _margin: ScreenTools.defaultFontPixelWidth / 2

    Component.onCompleted: {
        console.assert(geoArea !== undefined, "please set the areaItem property")
    }

    SectionHeader {
        id:         tilesHeader
        text:       qsTr("Tiles")
        Layout.columnSpan: 2
        Layout.fillWidth: true
    }

    GridLayout{
        visible: tilesHeader.checked
        Layout.fillWidth: true
        Layout.columnSpan: 2
        columnSpacing: _margin
        rowSpacing: _margin
        columns: 2

        QGCLabel {
            text: qsTr("Height")
            Layout.fillWidth:   true
        }

        FactTextField {
            fact:               geoArea.tileHeight
            Layout.fillWidth:   true
        }

        QGCLabel {
            text: qsTr("Width")
            Layout.fillWidth: true
        }

        FactTextField {
            fact:               geoArea.tileWidth
            Layout.fillWidth:   true
        }

        QGCLabel {
            text: qsTr("Min. Area")
            Layout.fillWidth:   true
        }

        FactTextField {
            fact:               geoArea.minTileArea
            Layout.fillWidth:   true
        }


        FactCheckBox {
            text:               qsTr("Show Tiles")
            fact:               geoArea.showTiles
        }
    }


    SectionHeader {
        id:     statsHeader
        text:   qsTr("Statistics")
        Layout.fillWidth: true
        Layout.columnSpan: 2
    }

    GridLayout{
        visible: statsHeader.checked
        Layout.fillWidth: true
        Layout.columnSpan: 2
        columnSpacing: _margin
        rowSpacing: _margin
        columns: 2

        QGCLabel { text: qsTr("Area") }
//        QGCLabel { text: QGroundControl.squareMetersToAppSettingsAreaUnits(geoArea.area).toFixed(2) + " " + QGroundControl.appSettingsAreaUnitsString }


        QGCLabel { text: qsTr("Tiles") }
        QGCLabel { text: geoArea.tiles.count }

        QGCLabel { text: qsTr("Max. Tiles") }
        QGCLabel { text: geoArea.maxTiles }
    }
} // Column
