summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Olszak <olszak.tomasz@gmail.com>2014-01-08 23:35:12 +0100
committerTomasz Olszak <olszak.tomasz@gmail.com>2014-01-08 23:36:56 +0100
commit22d42f42a16b19738daffac1ea763a6879bdcdc7 (patch)
tree5acf61e88209e7212619e8f47dd39c9beb3cea10
parent564da231d5416032d3ebe4fdd325345a351ad7c2 (diff)
parent08a32dff66a89fb517e86d3a2232407bd37fb715 (diff)
downloadqtquickcontrols-22d42f42a16b19738daffac1ea763a6879bdcdc7.tar.gz
qtquickcontrols-22d42f42a16b19738daffac1ea763a6879bdcdc7.tar.bz2
qtquickcontrols-22d42f42a16b19738daffac1ea763a6879bdcdc7.zip
Merge remote-tracking branch 'origin/stable' into wip/tizen
Change-Id: Ib1bf616d13701f64cbfc268dd6cfaa8c17af8fcd
-rw-r--r--examples/quick/controls/gallery/content/ChildWindow.qml6
-rw-r--r--src/controls/ComboBox.qml27
-rw-r--r--src/controls/Label.qml2
-rw-r--r--src/controls/TableView.qml2
-rw-r--r--src/controls/plugin.cpp6
-rw-r--r--src/layouts/qquicklinearlayout.cpp5
-rw-r--r--tests/auto/controls/data/tst_combobox.qml18
-rw-r--r--tests/auto/controls/data/tst_gridlayout.qml22
-rw-r--r--tests/auto/controls/data/tst_tableview.qml28
9 files changed, 107 insertions, 9 deletions
diff --git a/examples/quick/controls/gallery/content/ChildWindow.qml b/examples/quick/controls/gallery/content/ChildWindow.qml
index 21f2489a..a645e476 100644
--- a/examples/quick/controls/gallery/content/ChildWindow.qml
+++ b/examples/quick/controls/gallery/content/ChildWindow.qml
@@ -59,7 +59,7 @@ Window {
color: syspal.window
anchors.fill: parent
- Text {
+ Label {
id: dimensionsText
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
@@ -67,7 +67,7 @@ Window {
horizontalAlignment: Text.AlignHCenter
}
- Text {
+ Label {
id: availableDimensionsText
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: dimensionsText.bottom
@@ -75,7 +75,7 @@ Window {
horizontalAlignment: Text.AlignHCenter
}
- Text {
+ Label {
id: closeText
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: availableDimensionsText.bottom
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml
index 419bc117..74def897 100644
--- a/src/controls/ComboBox.qml
+++ b/src/controls/ComboBox.qml
@@ -119,6 +119,9 @@ Control {
/*! \qmlproperty int ComboBox::currentIndex
The index of the currently selected item in the ComboBox.
+ Setting currentIndex to \c -1 will reset the selection and clear the text
+ label. If \l editable is \c true, you may also need to manually clear \l editText.
+
\sa model
*/
property alias currentIndex: popup.__selectedIndex
@@ -342,7 +345,6 @@ Control {
enabled: editable
focus: true
clip: contentWidth > width
- text: currentText
anchors.fill: parent
anchors.leftMargin: 8
@@ -358,9 +360,11 @@ Control {
onAccepted: {
var idx = input.find(editText, Qt.MatchFixedString)
if (idx > -1) {
+ editTextMatches = true;
currentIndex = idx;
editText = textAt(idx);
} else {
+ editTextMatches = false;
currentIndex = -1;
popup.currentText = editText;
}
@@ -369,6 +373,7 @@ Control {
property bool blockUpdate: false
property string prevText
+ property bool editTextMatches: true
function find (text, searchType) {
for (var i = 0 ; i < popupItems.count ; ++i) {
@@ -425,7 +430,7 @@ Control {
Keys.onPressed: allowComplete = (event.key !== Qt.Key_Backspace && event.key !== Qt.Key_Delete);
onTextChanged: {
- if (editable && !blockUpdate && allowComplete) {
+ if (editable && !blockUpdate && allowComplete && text.length > 0) {
var completed = input.tryComplete(text)
if (completed.length > text.length) {
var oldtext = input.text;
@@ -437,6 +442,13 @@ Control {
}
}
+ Binding {
+ target: input
+ property: "text"
+ value: popup.currentText
+ when: input.editTextMatches
+ }
+
onTextRoleChanged: popup.resolveTextValue(textRole)
Menu {
@@ -449,7 +461,12 @@ Control {
onSelectedTextChanged: if (selectedText) popup.currentText = selectedText
property string selectedText
- on__SelectedIndexChanged: updateSelectedText()
+ on__SelectedIndexChanged: {
+ if (__selectedIndex === -1)
+ popup.currentText = ""
+ else
+ updateSelectedText()
+ }
property string textRole: ""
property bool ready: false
@@ -559,8 +576,10 @@ Control {
function updateSelectedText() {
var selectedItem;
- if (__selectedIndex !== -1 && (selectedItem = items[__selectedIndex]))
+ if (__selectedIndex !== -1 && (selectedItem = items[__selectedIndex])) {
+ input.editTextMatches = true
selectedText = selectedItem.text
+ }
}
}
diff --git a/src/controls/Label.qml b/src/controls/Label.qml
index 01f2a162..8a102011 100644
--- a/src/controls/Label.qml
+++ b/src/controls/Label.qml
@@ -88,4 +88,6 @@ Text {
id: pal
colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
}
+ Accessible.name: text
+ Accessible.role: Accessible.StaticText
}
diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml
index 736ac6e3..595c13ca 100644
--- a/src/controls/TableView.qml
+++ b/src/controls/TableView.qml
@@ -696,7 +696,7 @@ ScrollView {
model: root.model
function keySelect(shiftPressed, row) {
- if (row < 0 || row === rowCount - 1)
+ if (row < 0 || row > rowCount - 1)
return
if (shiftPressed && (selectionMode >= SelectionMode.ExtendedSelection)) {
selection.__ranges = new Array()
diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp
index 2a676e48..55be136a 100644
--- a/src/controls/plugin.cpp
+++ b/src/controls/plugin.cpp
@@ -61,6 +61,11 @@
#include "Private/qquickstyleitem_p.h"
#endif
+static void initResources()
+{
+ Q_INIT_RESOURCE(controls);
+}
+
QT_BEGIN_NAMESPACE
static const struct {
@@ -100,6 +105,7 @@ static const struct {
void QtQuickControlsPlugin::registerTypes(const char *uri)
{
+ initResources();
qmlRegisterType<QQuickAction>(uri, 1, 0, "Action");
qmlRegisterType<QQuickExclusiveGroup>(uri, 1, 0, "ExclusiveGroup");
qmlRegisterType<QQuickMenu>(uri, 1, 0, "MenuPrivate");
diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp
index 2b1ce66e..4f776b1f 100644
--- a/src/layouts/qquicklinearlayout.cpp
+++ b/src/layouts/qquicklinearlayout.cpp
@@ -736,6 +736,9 @@ void QQuickGridLayout::insertLayoutItems()
Q_ASSERT(columnSpan >= 1);
Q_ASSERT(rowSpan >= 1);
+ const int sp = span[flowOrientation];
+ if (sp > flowBound)
+ return;
if (row >= 0)
nextRow = row;
@@ -758,7 +761,7 @@ void QQuickGridLayout::insertLayoutItems()
bool cellAcceptsItem;
while (true) {
// Check if the item does not span beyond the layout bound
- cellAcceptsItem = (flowColumn + span[flowOrientation]) <= flowBound;
+ cellAcceptsItem = (flowColumn + sp) <= flowBound;
// Check if all the required cells are not taken
for (int rs = 0; cellAcceptsItem && rs < rowSpan; ++rs) {
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index f63a6ee7..6758c982 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -267,6 +267,7 @@ TestCase {
compare(comboBox.acceptedCount, 3)
comboBox.editText = ""
+ compare(comboBox.editText, "")
keyPress(Qt.Key_A)
compare(comboBox.currentText, "Cocomuffin")
@@ -679,5 +680,22 @@ TestCase {
}
return index
}
+
+ function test_minusOneIndexResetsSelection_QTBUG_35794() {
+ var qmlObjects = ['import QtQuick.Controls 1.1 ; ComboBox { model: ["A", "B", "C"] }',
+ 'import QtQuick.Controls 1.1 ; ComboBox { editable: true; model: ["A", "B", "C"] }']
+ for (var i = 0; i < qmlObjects.length; i++) {
+ var comboBox = Qt.createQmlObject(qmlObjects[i], testCase, '');
+ compare(comboBox.currentIndex, 0)
+ compare(comboBox.currentText, "A")
+ comboBox.currentIndex = -1
+ compare(comboBox.currentIndex, -1)
+ compare(comboBox.currentText, "")
+ comboBox.currentIndex = 1
+ compare(comboBox.currentIndex, 1)
+ compare(comboBox.currentText, "B")
+ comboBox.destroy()
+ }
+ }
}
}
diff --git a/tests/auto/controls/data/tst_gridlayout.qml b/tests/auto/controls/data/tst_gridlayout.qml
index 0e4f8509..7e6240fd 100644
--- a/tests/auto/controls/data/tst_gridlayout.qml
+++ b/tests/auto/controls/data/tst_gridlayout.qml
@@ -438,6 +438,28 @@ Item {
layout.destroy();
}
+ Component {
+ id: layout_spanIsMoreThanColumns_Component
+
+ GridLayout {
+ columnSpacing: 1
+ rowSpacing: 1
+ columns: 2
+
+ Rectangle {
+ implicitWidth: 10
+ implicitHeight: 10
+ Layout.columnSpan: 3
+ }
+ }
+ }
+
+ function test_spanIsMoreThanColumns() {
+ var layout = layout_spanIsMoreThanColumns_Component.createObject(container);
+ // item was not added, therefore implicit width is 0
+ compare(layout.implicitWidth, 0);
+ layout.destroy();
+ }
function test_sizeHints() {
var layout = layout_spanAcrossEmptyRows_Component.createObject(container);
diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml
index 7f1b48dc..192e29b5 100644
--- a/tests/auto/controls/data/tst_tableview.qml
+++ b/tests/auto/controls/data/tst_tableview.qml
@@ -148,6 +148,34 @@ TestCase {
verify(table.selection.contains(4))
verify(table.selection.contains(5))
verify(table.selection.count === 2)
+
+ // Navigate to end using arrow keys
+ table.selectionMode = SelectionMode.SingleSelection
+ table.model = 3
+ table.currentRow = -1
+ keyClick(Qt.Key_Down);
+ verify(table.currentRow === 0)
+ verify(rangeTest([[0,0]], table))
+ verify(table.selection.contains(0))
+ keyClick(Qt.Key_Down);
+ verify(table.currentRow === 1)
+ verify(table.selection.contains(1))
+ keyClick(Qt.Key_Down);
+ verify(table.currentRow === 2)
+ verify(table.selection.contains(2))
+ keyClick(Qt.Key_Down);
+ verify(table.currentRow === 2)
+ verify(table.selection.contains(2))
+ keyClick(Qt.Key_Up);
+ verify(table.currentRow === 1)
+ verify(table.selection.contains(1))
+ keyClick(Qt.Key_Up);
+ verify(table.currentRow === 0)
+ verify(table.selection.contains(0))
+ keyClick(Qt.Key_Up);
+ verify(table.currentRow === 0)
+ verify(table.selection.contains(0))
+
table.destroy()
}