summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2009-10-13 14:26:10 (GMT)
committerPierre Rossi <pierre.rossi@nokia.com>2009-10-13 17:51:01 (GMT)
commit19030e2af098e319e3c3f3883c51e28364bf3ccf (patch)
tree4f61bc22fc7aa1572cf63f96a5025a673ebee8e5 /tests
parent6420f43f30e2d5cf7ae74702f96c176d7bf22a84 (diff)
downloadQt-19030e2af098e319e3c3f3883c51e28364bf3ccf.zip
Qt-19030e2af098e319e3c3f3883c51e28364bf3ccf.tar.gz
Qt-19030e2af098e319e3c3f3883c51e28364bf3ccf.tar.bz2
Sorting bug in QTableView fix
When the DisplayRole is identical for two or more items, any modification of one item (e.g. backgroundColorRole) may trigger a re-ordering, which is obviously not an behaviour to be expected. Same fix as the one used for QTreewidget in c9eacfa1c791e2d228a3c8f0c119d02d7f46ee02. Task-number: QTBUG-4856 Task-number: 262056 Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtablewidget/tst_qtablewidget.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qtablewidget/tst_qtablewidget.cpp b/tests/auto/qtablewidget/tst_qtablewidget.cpp
index 5aa2d1d..b85851f 100644
--- a/tests/auto/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/qtablewidget/tst_qtablewidget.cpp
@@ -102,6 +102,7 @@ private slots:
void cellWidget();
void task231094();
void task219380_removeLastRow();
+ void task262056_sortDuplicate();
private:
QTableWidget *testWidget;
@@ -1474,6 +1475,26 @@ void tst_QTableWidget::task219380_removeLastRow()
QCOMPARE(testWidget->cellWidget(18, 0)->geometry(), testWidget->visualItemRect(&item));
}
+void tst_QTableWidget::task262056_sortDuplicate()
+{
+ testWidget->setColumnCount(2);
+ testWidget->setRowCount(8);
+ testWidget->setSortingEnabled(true);
+ QStringList items = (QStringList() << "AAA" << "BBB" << "CCC" << "CCC" << "DDD"\
+ << "EEE" << "FFF" << "GGG");
+ for (int i = 0; i<8; i++ ) {
+ QTableWidgetItem *twi = new QTableWidgetItem(items.at(i));
+ testWidget->setItem(i,0,twi);
+ testWidget->setItem(i,1,new QTableWidgetItem(QString("item %1").arg(i)));
+ }
+ testWidget->sortItems(0, Qt::AscendingOrder);
+ QSignalSpy layoutChangedSpy(testWidget->model(), SIGNAL(layoutChanged()));
+ testWidget->item(3,0)->setBackgroundColor(Qt::red);
+
+ QCOMPARE(layoutChangedSpy.count(),0);
+
+}
+
QTEST_MAIN(tst_QTableWidget)
#include "tst_qtablewidget.moc"