diff options
author | Pierre Rossi <pierre.rossi@nokia.com> | 2009-10-13 14:26:10 (GMT) |
---|---|---|
committer | Pierre Rossi <pierre.rossi@nokia.com> | 2009-10-13 17:51:01 (GMT) |
commit | 19030e2af098e319e3c3f3883c51e28364bf3ccf (patch) | |
tree | 4f61bc22fc7aa1572cf63f96a5025a673ebee8e5 /src | |
parent | 6420f43f30e2d5cf7ae74702f96c176d7bf22a84 (diff) | |
download | Qt-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 'src')
-rw-r--r-- | src/gui/itemviews/qtablewidget.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index a086498..65758b8 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -571,6 +571,8 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order, colItems.remove(oldRow); vit = sortedInsertionIterator(vit, colItems.end(), order, item); int newRow = qMax((int)(vit - colItems.begin()), 0); + if ((newRow < oldRow) && !(*item < *colItems.at(oldRow - 1))) + newRow = oldRow; vit = colItems.insert(vit, item); if (newRow != oldRow) { changed = true; |