diff options
author | Caroline Chao <caroline.chao@digia.com> | 2013-02-19 15:10:31 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-20 15:39:57 +0100 |
commit | 8712384b8185348f364b9580516180a067fb96ce (patch) | |
tree | d5c228e75ddae2db9b2e75afa021a75a4d35b213 /tests/manual/testbench | |
parent | f5946cdd55993b149b9322daf0f0661e17232397 (diff) | |
download | qtquickcontrols-8712384b8185348f364b9580516180a067fb96ce.tar.gz |
TestBench: Add enum field
For the enum properties.
Change-Id: I45a128525949c939612e2599fd5f1c20678e1158
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/manual/testbench')
-rw-r--r-- | tests/manual/testbench/content/PropertyLayouts.qml | 28 | ||||
-rw-r--r-- | tests/manual/testbench/main.qml | 85 |
2 files changed, 109 insertions, 4 deletions
diff --git a/tests/manual/testbench/content/PropertyLayouts.qml b/tests/manual/testbench/content/PropertyLayouts.qml index e2ae9c94..61ebc201 100644 --- a/tests/manual/testbench/content/PropertyLayouts.qml +++ b/tests/manual/testbench/content/PropertyLayouts.qml @@ -106,4 +106,32 @@ QtObject { Layout.horizontalSizePolicy: Layout.Expanding } } + + property Component enumLayout: RowLayout { + id: enumLayout + spacing: 4 + height: 20 + Text { + text: name + ":" + Layout.minimumWidth: 100 + } + + ComboBox { + height: 20 + model: enumModel + Layout.horizontalSizePolicy: Layout.Expanding + onSelectedIndexChanged: loader.item[name] = model.get(selectedIndex).value + + + Component.onCompleted: selectedIndex = getDefaultIndex() + function getDefaultIndex() { + for (var index = 0 ; index < model.count ; ++index) { + if ( model.get(index).value === result ) + return index + } + return 0; + } + + } + } } diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml index 12dc8135..3f3f9a9a 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/main.qml @@ -44,7 +44,7 @@ import "content" ApplicationWindow { width: 950 - height: 500 + height: 600 property var propertyMap: [] Components{ id: components } @@ -148,6 +148,8 @@ ApplicationWindow { var typeName = "None"; var layout + var enumModelData + var isColor = false switch (substr) { case "ActiveFocusOnPress": @@ -191,6 +193,77 @@ ApplicationWindow { typeName = "String"; break; + case "HorizontalAlignment": + layout = layouts.enumLayout + enumModelData = Qt.createQmlObject('import QtQuick 2.0; import QtDesktop 1.0; ListModel {}', layout, ''); + typeName = "Enum"; + enumModelData.append({ text: "TextEdit.AlignLeft", value: TextEdit.AlignLeft}); + enumModelData.append({ text: "TextEdit.AlignRight", value: TextEdit.AlignRight}); + enumModelData.append({ text: "TextEdit.AlignHCenter", value: TextEdit.AlignHCenter}); + break; + + case "VerticalAlignment": + layout = layouts.enumLayout + enumModelData = Qt.createQmlObject('import QtQuick 2.0; import QtDesktop 1.0; ListModel {}', layout, ''); + typeName = "Enum"; + enumModelData.append({ text: "TextEdit.AlignTop", value: TextEdit.AlignTop}); + enumModelData.append({ text: "TextEdit.AlignBottom", value: TextEdit.AlignBottom}); + enumModelData.append({ text: "TextEdit.AlignVCenter", value: TextEdit.AlignVCenter}); + break; + + case "InputMethodHints": + layout = layouts.enumLayout + enumModelData = Qt.createQmlObject('import QtQuick 2.0; import QtDesktop 1.0; ListModel {}', layout, ''); + typeName = "Enum"; + enumModelData.append({ text: "Qt.ImhNone", value: Qt.ImhNone}); + enumModelData.append({ text: "Qt.ImhHiddenText", value: Qt.ImhHiddenText}); + enumModelData.append({ text: "Qt.ImhSensitiveData", value: Qt.ImhSensitiveData}); + enumModelData.append({ text: "Qt.ImhNoAutoUppercase", value: Qt.ImhNoAutoUppercase}); + enumModelData.append({ text: "Qt.ImhPreferNumbers", value: Qt.ImhPreferNumbers}); + enumModelData.append({ text: "Qt.ImhPreferUppercase", value: Qt.ImhPreferUppercase}); + enumModelData.append({ text: "Qt.ImhPreferLowercase", value: Qt.ImhPreferLowercase}); + enumModelData.append({ text: "Qt.ImhNoPredictiveText", value: Qt.ImhNoPredictiveText}); + enumModelData.append({ text: "Qt.ImhDate", value: Qt.ImhDate}); + enumModelData.append({ text: "Qt.ImhTime", value: Qt.ImhTime}); + enumModelData.append({ text: "Qt.ImhDigitsOnly", value: Qt.ImhDigitsOnly}); + enumModelData.append({ text: "Qt.ImhFormattedNumbersOnly", value: Qt.ImhFormattedNumbersOnly}); + enumModelData.append({ text: "Qt.ImhUppercaseOnly", value: Qt.ImhUppercaseOnly}); + enumModelData.append({ text: "Qt.ImhLowercaseOnly", value: Qt.ImhLowercaseOnly}); + enumModelData.append({ text: "Qt.ImhDialableCharactersOnly",value: Qt.ImhDialableCharactersOnly}); + enumModelData.append({ text: "Qt.ImhEmailCharactersOnly", value: Qt.ImhEmailCharactersOnly}); + enumModelData.append({ text: "Qt.ImhUrlCharactersOnly", value: Qt.ImhUrlCharactersOnly}); + break; + + case "Orientation": + layout = layouts.enumLayout + enumModelData = Qt.createQmlObject('import QtQuick 2.0; import QtDesktop 1.0; ListModel {}', layout, ''); + typeName = "Enum"; + enumModelData.append({ text: "Qt.Horizontal", value: Qt.Horizontal}); + enumModelData.append({ text: "Qt.Vertical", value: Qt.Vertical}); + break; + + case "EchoMode": + layout = layouts.enumLayout + enumModelData = Qt.createQmlObject('import QtQuick 2.0; import QtDesktop 1.0; ListModel {}', layout, ''); + typeName = "Enum"; + enumModelData.append({ text: "TextInput.Normal", value: TextInput.Normal}); + enumModelData.append({ text: "TextInput.Password", value: TextInput.Password}); + enumModelData.append({ text: "TextInput.NoEcho", value: TextInput.NoEcho}); + enumModelData.append({ text: "TextInput.PasswordEchoOnEdit",value: TextInput.PasswordEchoOnEdit}); + break; + + case "BackgroundColor": + case "TextColor": + isColor = true + layout = layouts.enumLayout + enumModelData = Qt.createQmlObject('import QtQuick 2.0; import QtDesktop 1.0; ListModel {}', layout, ''); + typeName = "Enum"; + enumModelData.append({ text: "Amber", value: "#FF7E00"}); + enumModelData.append({ text: "Azure", value: "#007FFF"}); + enumModelData.append({ text: "Carmine red", value: "#FF0038"}); + break; + + default: break; } @@ -203,9 +276,12 @@ ApplicationWindow { var val = item[substr] + "" // All model properties must be the same type if (typeName != "None" && val !== undefined) { + if (isColor) + enumModelData.append({ text: "Default", value: val}) + if (arr[typeName] === undefined) arr[typeName] = [] - arr[typeName].push({name: substr , result: val, typeString: typeName, layoutComponent: layout}) + arr[typeName].push({name: substr , result: val, typeString: typeName, layoutComponent: layout, enumModel: enumModelData}) } } propertyMap = arr; @@ -272,7 +348,7 @@ ApplicationWindow { Rectangle { id: sidebar color : syspal.window - width: 200 + width: 300 ScrollArea { id: scrollArea anchors.fill: parent @@ -285,7 +361,7 @@ ApplicationWindow { width: scrollArea.viewport.width - 20 spacing: 8 Repeater { - model: ["Boolean", "String","Int", "Real", "ReadOnly"] + model: ["Boolean", "String","Int", "Real", "ReadOnly", "Enum"] Repeater { model: propertyMap[modelData] Loader { @@ -294,6 +370,7 @@ ApplicationWindow { property string name: modelData.name property var value: modelData.value property var result: modelData.result + property var enumModel: modelData.enumModel } } } |