diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-08-13 11:53:05 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-18 08:34:53 +0200 |
commit | 2ef3ac72fc068b825f2185ab3682219dc7246464 (patch) | |
tree | ef08dbea5c53c950a22fe8752ec4b2f0f3d990ab /src/gui/itemmodels | |
parent | 72604f8eb9e0cab8e0de8f30576af11aebaf3e11 (diff) |
Emit layoutChange signals when changing QPersistentModelIndexes.
This is necessary whenever QPersistentModelIndexes are changed. Omitting
it means that views are not able to react to the change, such as QTreeView
clearing its (manually held) QModelIndex cache, and the QItemSelectionModel
clearing the item from its storage.
It is necessary to change a QSortFilterProxyModel test which assumed setItem
does not have any such effect. That test is ported to setData instead.
Task-number: QTBUG-18539
Change-Id: Id7a602f18b9773ba4d11019418de886860d26d3e
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/gui/itemmodels')
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 2d296a0e59..223c34a517 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -139,6 +139,11 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, QStandardItem *oldItem = children.at(index); if (item == oldItem) return; + + if (model && emitChanged) { + emit model->layoutAboutToBeChanged(); + } + if (item) { if (item->d_func()->parent == 0) { item->d_func()->setParentAndModel(q, model); @@ -152,6 +157,10 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, oldItem->d_func()->setModel(0); delete oldItem; children.replace(index, item); + + if (model && emitChanged) + emit model->layoutChanged(); + if (emitChanged && model) model->d_func()->itemChanged(item); } |