diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-04-24 16:17:24 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-05-18 12:04:21 +0000 |
commit | c427650d62c369ed71d95cacd05c21dd7bf79810 (patch) | |
tree | 88642ea33a549d3c86227558ce376ccb27db144c | |
parent | 76a4ed6b5ff3e115bcffb8eb6a3cfb6a7365cfb8 (diff) | |
download | qt-creator-c427650d62c369ed71d95cacd05c21dd7bf79810.tar.gz |
Search results: Fix that auto-expand failed on first set of results
They were expanded but collapsed again when the model was reset in the
setShowReplaceUI(bool show) call. Avoid resetting the model by informing
about the data change individually.
Change-Id: I48a94f2aec5b5d31d11166a299a2463b757939fa
Task-number: QTCREATORBUG-14320
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
-rw-r--r-- | src/plugins/coreplugin/find/searchresulttreemodel.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/coreplugin/find/searchresulttreemodel.cpp b/src/plugins/coreplugin/find/searchresulttreemodel.cpp index d7809160a2..b5f9c6741a 100644 --- a/src/plugins/coreplugin/find/searchresulttreemodel.cpp +++ b/src/plugins/coreplugin/find/searchresulttreemodel.cpp @@ -57,9 +57,21 @@ SearchResultTreeModel::~SearchResultTreeModel() void SearchResultTreeModel::setShowReplaceUI(bool show) { - beginResetModel(); m_showReplaceUI = show; - endResetModel(); + // We cannot send dataChanged for the whole hierarchy in one go, + // because all items in a dataChanged must have the same parent. + // Send dataChanged for each parent of children individually... + QList<QModelIndex> changeQueue; + changeQueue.append(QModelIndex()); + while (!changeQueue.isEmpty()) { + const QModelIndex current = changeQueue.takeFirst(); + int childCount = rowCount(current); + if (childCount > 0) { + emit dataChanged(index(0, 0, current), index(childCount - 1, 0, current)); + for (int r = 0; r < childCount; ++r) + changeQueue.append(index(r, 0, current)); + } + } } void SearchResultTreeModel::setTextEditorFont(const QFont &font, const SearchResultColor &color) |