┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2013-02-27 19:56:55 +0100
committerEmmanuel Pescosta <[email protected]>2013-02-27 19:56:55 +0100
commit4e4078c66a3ffa2a7044b72858b631002a3e0293 (patch)
tree4aa2da190c0fafc0914268ec7fc6c5b8d3ba555d /src/kitemviews
parentf2d70693db58f0b912e29330017298928b0ddc0d (diff)
Removed everything related to m_expandedParentsCountRoot ->
This concept is not needed anymore because of the new "determine parents and expansion levels" approach Side effect: Enables treeview for trash, ... REVIEW: 109191
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp43
-rw-r--r--src/kitemviews/kfileitemmodel.h15
2 files changed, 8 insertions, 50 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index c25061d8c..2d11e8758 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -54,7 +54,6 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_resortAllItemsTimer(0),
m_pendingItemsToInsert(),
m_groups(),
- m_expandedParentsCountRoot(UninitializedExpandedParentsCountRoot),
m_expandedDirs(),
m_urlsToExpand()
{
@@ -729,7 +728,7 @@ void KFileItemModel::slotItemsAdded(const KUrl& directoryUrl, const KFileItemLis
KUrl parentUrl = directoryUrl;
parentUrl.adjustPath(KUrl::RemoveTrailingSlash);
- if (m_requestRole[ExpandedParentsCountRole] && m_expandedParentsCountRoot >= 0) {
+ if (m_requestRole[ExpandedParentsCountRole]) {
// To be able to compare whether the new items may be inserted as children
// of a parent item the pending items must be added to the model first.
dispatchPendingItemsToInsert();
@@ -786,7 +785,7 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
dispatchPendingItemsToInsert();
KFileItemList itemsToRemove = items;
- if (m_requestRole[ExpandedParentsCountRole] && m_expandedParentsCountRoot >= 0) {
+ if (m_requestRole[ExpandedParentsCountRole]) {
// Assure that removing a parent item also results in removing all children
foreach (const KFileItem& item, items) {
itemsToRemove.append(childItems(item));
@@ -802,7 +801,7 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
}
}
- if (m_requestRole[ExpandedParentsCountRole] && m_expandedParentsCountRoot >= 0) {
+ if (m_requestRole[ExpandedParentsCountRole]) {
// Remove all filtered children of deleted items. First, we put the
// deleted URLs into a set to provide fast lookup while iterating
// over m_filteredItems and prevent quadratic complexity if there
@@ -925,8 +924,6 @@ void KFileItemModel::slotClear()
m_resortAllItemsTimer->stop();
m_pendingItemsToInsert.clear();
- m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
-
const int removedCount = m_itemData.count();
if (removedCount > 0) {
qDeleteAll(m_itemData);
@@ -1134,10 +1131,6 @@ void KFileItemModel::removeItems(const KFileItemList& items, RemoveItemsBehavior
m_items.insert(m_itemData.at(i)->item.url(), i);
}
- if (count() <= 0) {
- m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
- }
-
emit itemsRemoved(itemRanges);
}
@@ -1176,7 +1169,6 @@ void KFileItemModel::removeExpandedItems()
// a bigger count have been removed.
removeItems(expandedItems, DeleteItemData);
- m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
m_expandedDirs.clear();
}
@@ -1329,31 +1321,12 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
}
if (m_requestRole[ExpandedParentsCountRole]) {
- if (m_expandedParentsCountRoot == UninitializedExpandedParentsCountRoot) {
- const KUrl rootUrl = m_dirLister->url();
- const QString protocol = rootUrl.protocol();
- const bool forceExpandedParentsCountRoot = (protocol == QLatin1String("trash") ||
- protocol == QLatin1String("nepomuk") ||
- protocol == QLatin1String("remote") ||
- protocol.contains(QLatin1String("search")));
- if (forceExpandedParentsCountRoot) {
- m_expandedParentsCountRoot = ForceExpandedParentsCountRoot;
- } else {
- const QString rootDir = rootUrl.path(KUrl::AddTrailingSlash);
- m_expandedParentsCountRoot = rootDir.count('/');
- }
+ int level = 0;
+ if (parent) {
+ level = parent->values["expandedParentsCount"].toInt() + 1;
}
- if (m_expandedParentsCountRoot == ForceExpandedParentsCountRoot) {
- data.insert("expandedParentsCount", -1);
- } else {
- const QString dir = item.url().directory(KUrl::AppendTrailingSlash);
- int level = 0;
- if (parent) {
- level = parent->values["expandedParentsCount"].toInt() + 1;
- }
- data.insert("expandedParentsCount", level);
- }
+ data.insert("expandedParentsCount", level);
}
if (item.isMimeTypeKnown()) {
@@ -1371,7 +1344,7 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
{
int result = 0;
- if (m_expandedParentsCountRoot >= 0 && a->parent != b->parent) {
+ if (a->parent != b->parent) {
const int expansionLevelA = a->values.value("expandedParentsCount").toInt();
const int expansionLevelB = b->values.value("expandedParentsCount").toInt();
diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h
index c233246c6..1939671a5 100644
--- a/src/kitemviews/kfileitemmodel.h
+++ b/src/kitemviews/kfileitemmodel.h
@@ -454,21 +454,6 @@ private:
// Cache for KFileItemModel::groups()
mutable QList<QPair<int, QVariant> > m_groups;
- // Stores the smallest expansion level of the root-URL. Is required to calculate
- // the "expandedParentsCount" role in an efficient way. A value < 0 indicates a
- // special meaning:
- enum ExpandedParentsCountRootTypes
- {
- // m_expandedParentsCountRoot is uninitialized and must be determined by checking
- // the root URL from the KDirLister.
- UninitializedExpandedParentsCountRoot = -1,
- // All items should be forced to get an expanded parents count of 0 even if they
- // represent child items. This is useful for slaves that provide no parent items
- // for child items like e.g. the search IO slaves.
- ForceExpandedParentsCountRoot = -2
- };
- mutable int m_expandedParentsCountRoot;
-
// Stores the URLs of the expanded directories.
QSet<KUrl> m_expandedDirs;