summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-04-06 17:59:08 (GMT)
committerPierre Rossi <pierre.rossi@nokia.com>2010-05-26 14:27:40 (GMT)
commitcf1e3150247d6694e8c00b924627c66e798f2382 (patch)
tree4d51fd6f6f525a0d51f5b8eb583af8837ca72a57 /tests
parent4837518d3161c77b4e811057d638dcbd22b89195 (diff)
downloadQt-cf1e3150247d6694e8c00b924627c66e798f2382.zip
Qt-cf1e3150247d6694e8c00b924627c66e798f2382.tar.gz
Qt-cf1e3150247d6694e8c00b924627c66e798f2382.tar.bz2
Fixes a proxymodel sorting odity.
Sort order was modified when sorted according to an empty column always in the same order Reviewed-by: Thierry
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 992c95e..53fefee 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -127,6 +127,8 @@ private slots:
void sortColumnTracking1();
void sortColumnTracking2();
+ void sortStable();
+
void task236755_hiddenColumns();
void task247867_insertRowsSort();
void task248868_staticSorting();
@@ -2442,6 +2444,40 @@ void tst_QSortFilterProxyModel::sortColumnTracking2()
QCOMPARE(proxyModel.data(proxyModel.index(strings.count()-1,0)).toString(),QString::fromLatin1("zz"));
}
+void tst_QSortFilterProxyModel::sortStable()
+{
+ QStandardItemModel* model = new QStandardItemModel(5, 2);
+ for (int r=0; r<5; r++) {
+ for (int c=0; c<2; c++) {
+ QStandardItem* item = new QStandardItem(
+ QString("Row:%0, Column:%1").arg(r).arg(c) );
+ for( int i=0; i<3; i++ ) {
+ QStandardItem* child = new QStandardItem(
+ QString("Item %0").arg(i) );
+ item->appendRow( child );
+ }
+ model->setItem(r, c, item);
+ }
+ }
+ model->setHorizontalHeaderItem( 0, new QStandardItem( "Name" ));
+ model->setHorizontalHeaderItem( 1, new QStandardItem( "Value" ) );
+
+
+ QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(model);
+ filterModel->setSourceModel(model);
+
+ QTreeView *view = new QTreeView;
+ view->setModel(filterModel);
+ QModelIndex firstRoot = filterModel->index(0,0);
+ view->expand(firstRoot);
+ view->setSortingEnabled(true);
+
+ view->model()->sort(1, Qt::DescendingOrder);
+ QVariant lastItemData =filterModel->index(2,0, firstRoot).data();
+ view->model()->sort(1, Qt::DescendingOrder);
+ QCOMPARE(lastItemData, filterModel->index(2,0, firstRoot).data());
+}
+
void tst_QSortFilterProxyModel::task236755_hiddenColumns()
{
class MyStandardItemModel : public QStandardItemModel