FactComboBox.qml 613 Bytes
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2

import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0

QGCComboBox {
10
    property Fact fact: Fact { }
11 12 13 14 15 16 17 18 19 20
    property bool indexModel: true  ///< true: model must be specifed, selected index is fact value, false: use enum meta data

    model: fact.enumStrings

    currentIndex: indexModel ? fact.value : fact.enumIndex

    onActivated: {
        if (indexModel) {
            fact.value = index
        } else {
Don Gagne's avatar
Don Gagne committed
21
            fact.value = fact.enumValues[index]
22 23
        }
    }
Don Gagne's avatar
Don Gagne committed
24
}