summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-08-04 14:28:00 +0200
committerMitch Curtis <mitch.curtis@theqtcompany.com>2015-08-12 10:42:44 +0000
commit34bf7f52165b11aa862f46e4f7ace7670bf7bc48 (patch)
tree6f81a4e4cfe34eda1a6ca5c8319ce1b3f9e58c6a
parent54852626c143211e1d5c68b0863fbf29ac460ab5 (diff)
downloadqtquickcontrols-34bf7f52165b11aa862f46e4f7ace7670bf7bc48.tar.gz
Make TableView sort indicator follow moved columns.
Change-Id: I7041fbe141f9f95be3e6d5c6a9f0abf543877194 Task-number: QTBUG-44185 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
-rw-r--r--src/controls/Private/BasicTableView.qml4
-rw-r--r--tests/auto/controls/data/tst_tableview.qml48
2 files changed, 51 insertions, 1 deletions
diff --git a/src/controls/Private/BasicTableView.qml b/src/controls/Private/BasicTableView.qml
index 4e1c45ab..27635bc9 100644
--- a/src/controls/Private/BasicTableView.qml
+++ b/src/controls/Private/BasicTableView.qml
@@ -297,6 +297,8 @@ ScrollView {
console.warn(__viewTypeName + "::moveColumn(): Can't move column 0")
return
}
+ if (sortIndicatorColumn === from)
+ sortIndicatorColumn = to
columnModel.move(from, to, 1)
}
@@ -682,9 +684,9 @@ ScrollView {
if (repeater.targetIndex >= 0 && repeater.targetIndex !== index ) {
var targetColumn = columnModel.get(repeater.targetIndex).columnItem
if (targetColumn.movable && (!__isTreeView || repeater.targetIndex > 0)) {
- columnModel.move(index, repeater.targetIndex, 1)
if (sortIndicatorColumn === index)
sortIndicatorColumn = repeater.targetIndex
+ columnModel.move(index, repeater.targetIndex, 1)
}
}
repeater.targetIndex = -1
diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml
index 9bb2cd67..a01df56f 100644
--- a/tests/auto/controls/data/tst_tableview.qml
+++ b/tests/auto/controls/data/tst_tableview.qml
@@ -1070,5 +1070,53 @@ TestCase {
control.destroy()
}
+
+ ListModel {
+ id: testModel
+
+ ListElement {
+ name: "Red"
+ color: "#ff0000"
+ }
+ ListElement {
+ name: "Green"
+ color: "#00ff00"
+ }
+ ListElement {
+ name: "Blue"
+ color: "#0000ff"
+ }
+ }
+
+ Component {
+ id: tableViewComponent
+
+ TableView {
+ model: testModel
+ anchors.fill: parent
+ sortIndicatorVisible: true
+
+ TableViewColumn {
+ title: "Name"
+ role: "name"
+ width: 100
+ }
+
+ TableViewColumn {
+ title: "Color"
+ role: "color"
+ width: 100
+ }
+ }
+ }
+
+ function test_sortIndicatorAfterColumnMoved() {
+ var tableView = tableViewComponent.createObject(testCase);
+ verify(tableView);
+
+ compare(tableView.sortIndicatorColumn, 0);
+ tableView.moveColumn(0, 1);
+ compare(tableView.sortIndicatorColumn, 1);
+ }
}
}