┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-10-26 09:36:40 +0200
committerFrank Reininghaus <[email protected]>2013-10-26 09:36:50 +0200
commit5a019aec3ac47363ed46e843d0c7eab6a6c2aeb9 (patch)
tree8741659761747f719d2736933572f713e1296ea8 /src
parent70cd04df40b152fd7a448964b9f9ca4948291eb3 (diff)
Restore the tree state in Details View if a folder is re-expanded
This patch actually does two things when collapsing an expanded folder with expanded children: (a) It removes all expanded children (which are removed from the model) from m_expandedDirs. (b) It remembers the expanded children and restores them if the top-level folder is re-expanded. BUG: 304363 FIXED-IN: 4.12.0 REVIEW: 113293
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index ea7ac2fc1..f21edbf4a 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -440,6 +440,11 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
if (expanded) {
m_expandedDirs.insert(targetUrl, url);
m_dirLister->openUrl(url, KDirLister::Keep);
+
+ const KUrl::List previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<KUrl::List>();
+ foreach (const KUrl& url, previouslyExpandedChildren) {
+ m_urlsToExpand.insert(url);
+ }
} else {
m_expandedDirs.remove(targetUrl);
m_dirLister->stop(url);
@@ -448,14 +453,24 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
const int itemCount = m_itemData.count();
const int firstChildIndex = index + 1;
+ KUrl::List expandedChildren;
+
int childIndex = firstChildIndex;
while (childIndex < itemCount && expandedParentsCount(childIndex) > parentLevel) {
+ ItemData* itemData = m_itemData.at(childIndex);
+ if (itemData->values.value("isExpanded").toBool()) {
+ const KUrl targetUrl = itemData->item.targetUrl();
+ m_expandedDirs.remove(targetUrl);
+ expandedChildren.append(targetUrl);
+ }
++childIndex;
}
const int childrenCount = childIndex - firstChildIndex;
removeFilteredChildren(KItemRangeList() << KItemRange(index, 1 + childrenCount));
removeItems(KItemRangeList() << KItemRange(firstChildIndex, childrenCount), DeleteItemData);
+
+ m_itemData.at(index)->values.insert("previouslyExpandedChildren", expandedChildren);
}
return true;