Debian Codegraph @

src/GUI/qml/SettingsComboBox.qml

raw
1 import QtQuick 2.4
2 import FlightGear 1.0
3
4 SettingControl {
5 id: root
6
7 property alias choices: choicesModel.values
8 property var model: null
9
10 property alias displayRole: popup.displayRole
11
12 property alias selectedIndex: popup.currentIndex
13 property int defaultIndex: 0
14
15 // alias for save+restore
16 property alias value: popup.currentIndex
17 property alias defaultValue: root.defaultIndex
18
19 implicitHeight: popup.height + Style.margin + description.height
20
21 StringListModel {
22 id: choicesModel
23 }
24
25 PopupChoice {
26 id: popup
27 label: root.label
28 enabled: root.enabled
29 width: root.width
30
31 // if we have an explicit model, use it, otherwise use
32 // our local string list model
33 model: root.model ? root.model : choicesModel
34 }
35
36 SettingDescription {
37 id: description
38 enabled: root.enabled
39 text: root.description
40 anchors.top: popup.bottom
41 anchors.topMargin: Style.margin
42 width: root.width
43 }
44
45 function setValue(newValue)
46 {
47 popup.currentIndex = newValue;
48 }
49 }