Skip to content
GeoAreaVisualLoader.qml 1.66 KiB
Newer Older
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

import QtQuick          2.3
import QtQuick.Controls 1.2
import QtLocation       5.3
import QtPositioning    5.3

import QGroundControl.ScreenTools   1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl               1.0
Valentin Platzgummer's avatar
Valentin Platzgummer committed
    property var map: undefined        ///< Map control to place item in
    property var geoArea: undefined    ///< GeoArea derived class

    signal clicked(int sequenceNumber)

Valentin Platzgummer's avatar
Valentin Platzgummer committed
    property var _visualItem: undefined

    Component.onCompleted: {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
        console.assert(map !== undefined, "please set the map property")
        console.assert(geoArea !== undefined, "please set the geoArea property")

        if (_root.geoArea.mapVisualQML && !_visualItem) {
            var component = Qt.createComponent(_root.geoArea.mapVisualQML)
            if (component.status === Component.Error) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
                console.log("Error loading Qml: ", _root.geoArea.mapVisualQML, component.errorString())
            } else {
                _root._visualItem = component.createObject(_root.map, { map: _root.map, geoArea: _root.geoArea})
                _root._visualItem.clicked.connect(_root.clicked)
            }
        }
    }

    Component.onDestruction: {
        if (_visualItem) {
            _visualItem.destroy()
        }
    }
}