m_resortAllItemsTimer(0),
m_pendingItemsToInsert(),
m_groups(),
- m_expandedParentsCountRoot(UninitializedExpandedParentsCountRoot),
m_expandedDirs(),
m_urlsToExpand()
{
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();
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));
}
}
- 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
m_resortAllItemsTimer->stop();
m_pendingItemsToInsert.clear();
- m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
-
const int removedCount = m_itemData.count();
if (removedCount > 0) {
qDeleteAll(m_itemData);
m_items.insert(m_itemData.at(i)->item.url(), i);
}
- if (count() <= 0) {
- m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
- }
-
emit itemsRemoved(itemRanges);
}
// a bigger count have been removed.
removeItems(expandedItems, DeleteItemData);
- m_expandedParentsCountRoot = UninitializedExpandedParentsCountRoot;
m_expandedDirs.clear();
}
}
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()) {
{
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();
// 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;