summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtableview
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-13 15:40:20 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-13 15:53:41 (GMT)
commit6420f43f30e2d5cf7ae74702f96c176d7bf22a84 (patch)
tree9635542cb598ff74a421f9d657b9444de21d989c /tests/auto/qtableview
parent9c04890642f9836fe25289d91a470cdd2de4e183 (diff)
downloadQt-6420f43f30e2d5cf7ae74702f96c176d7bf22a84.zip
Qt-6420f43f30e2d5cf7ae74702f96c176d7bf22a84.tar.gz
Qt-6420f43f30e2d5cf7ae74702f96c176d7bf22a84.tar.bz2
Fix sorting after changing a QTableView's header
Keep the sorting states in sync with the header when setting custom headers Reviewed-by: Gabriel Task-number: QTBUG-3128 task-number: 234926
Diffstat (limited to 'tests/auto/qtableview')
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index eab5a35..5b11823 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -193,6 +193,7 @@ private slots:
void mouseWheel();
void addColumnWhileEditing();
+ void task234926_setHeaderSorting();
};
// Testing get/set functions
@@ -3774,5 +3775,41 @@ void tst_QTableView::task191545_dragSelectRows()
}
}
+void tst_QTableView::task234926_setHeaderSorting()
+{
+ QStringListModel model;
+ QStringList data;
+ data << "orange" << "apple" << "banana" << "lemon" << "pumpkin";
+ QStringList sortedDataA = data;
+ QStringList sortedDataD = data;
+ qSort(sortedDataA);
+ qSort(sortedDataD.begin(), sortedDataD.end(), qGreater<const QString &>());
+ model.setStringList(data);
+ QTableView view;
+ view.setModel(&model);
+// view.show();
+ QTest::qWait(20);
+ QCOMPARE(model.stringList(), data);
+ view.setSortingEnabled(true);
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataA);
+
+ view.horizontalHeader()->setSortIndicator(0, Qt::DescendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataD);
+
+ QHeaderView *h = new QHeaderView(Qt::Horizontal);
+ h->setModel(&model);
+ view.setHorizontalHeader(h);
+ h->setSortIndicator(0, Qt::AscendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataA);
+
+ h->setSortIndicator(0, Qt::DescendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataD);
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"