diff options
| author | Peter Penz <[email protected]> | 2011-12-09 21:49:59 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-12-09 21:52:31 +0100 |
| commit | 54745c440cc9361e32e82a3c1db50288805efcd6 (patch) | |
| tree | 6c742ae2a417ceaeab2e7a20ca512c50e57ec05d /src | |
| parent | 9a7a77e973c3359e8caec2d8bb12fe1483bac368 (diff) | |
Fix issue with duplicate items in details view
When expanding an item, collapsing it and expanding it again before the items for the first expanding could be loaded, it was possible that items have been inserted twice into the model.
BUG: 288521
FIXED-IN: 4.8.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 8eb47f5ec..00a856e25 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -404,11 +404,11 @@ bool KFileItemModel::setExpanded(int index, bool expanded) return false; } + KDirLister* dirLister = m_dirLister.data(); const KUrl url = m_itemData.at(index)->item.url(); if (expanded) { m_expandedUrls.insert(url); - KDirLister* dirLister = m_dirLister.data(); if (dirLister) { dirLister->openUrl(url, KDirLister::Keep); return true; @@ -416,6 +416,10 @@ bool KFileItemModel::setExpanded(int index, bool expanded) } else { m_expandedUrls.remove(url); + if (dirLister) { + dirLister->stop(url); + } + KFileItemList itemsToRemove; const int expansionLevel = data(index)["expansionLevel"].toInt(); ++index; @@ -666,6 +670,22 @@ void KFileItemModel::slotCanceled() void KFileItemModel::slotNewItems(const KFileItemList& items) { + if (m_requestRole[ExpansionLevelRole] && m_rootExpansionLevel >= 0) { + // If the expanding of items is enabled in the model, it might be + // possible that the call dirLister->openUrl(url, KDirLister::Keep) in + // KFileItemModel::setExpanded() results in emitting of the same items + // twice due to the Keep-parameter. This case happens if an item gets + // expanded, collapsed and expanded again before the items could be loaded + // for the first expansion. + foreach (const KFileItem& item, items) { + const int index = m_items.value(item.url(), -1); + if (index >= 0) { + // The items are already part of the model. + return; + } + } + } + if (m_nameFilter.isEmpty()) { m_pendingItemsToInsert.append(items); } else { |
