X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ced9de5b82046d6eb6f6b828fa9bbc874bbea857..9f24c02a752584fc3ef82063d42262f91b493eae:/src/kitemviews/kfileitemmodel.h diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index a05d1f9d8..d00570549 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -272,7 +272,7 @@ private slots: void slotCompleted(); void slotCanceled(); - void slotNewItems(const KFileItemList& items); + void slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items); void slotItemsDeleted(const KFileItemList& items); void slotRefreshItems(const QList >& items); void slotClear(); @@ -303,8 +303,13 @@ private: ItemData* parent; }; - void insertItems(const KFileItemList& items); - void removeItems(const KFileItemList& items); + enum RemoveItemsBehavior { + KeepItemData, + DeleteItemData + }; + + void insertItems(QList& items); + void removeItems(const KItemRangeList& itemRanges, RemoveItemsBehavior behavior); /** * Helper method for insertItems() and removeItems(): Creates @@ -312,10 +317,19 @@ private: * Note that the ItemData instances are created dynamically and * must be deleted by the caller. */ - QList createItemDataList(const KFileItemList& items) const; + QList createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const; + + static int expandedParentsCount(const ItemData* data); void removeExpandedItems(); + /** + * This function is called by setData() and slotRefreshItems(). It emits + * the itemsChanged() signal, checks if the sort order is still correct, + * and starts m_resortAllItemsTimer if that is not the case. + */ + void emitItemsChangedAndTriggerResorting(const KItemRangeList& itemRanges, const QSet& changedRoles); + /** * Resets all values from m_requestRole to false. */ @@ -333,7 +347,7 @@ private: */ QByteArray roleForType(RoleType roleType) const; - QHash retrieveData(const KFileItem& item) const; + QHash retrieveData(const KFileItem& item, const ItemData* parent) const; /** * @return True if the item-data \a a should be ordered before the item-data @@ -375,11 +389,6 @@ private: */ bool isChildItem(int index) const; - /** - * @return Recursive list of child items that have \a item as upper most parent. - */ - KFileItemList childItems(const KFileItem& item) const; - /** * Is invoked by KFileItemModelRolesUpdater and results in emitting the * sortProgress signal with a percent-value of the progress. @@ -391,6 +400,12 @@ private: */ void applyFilters(); + /** + * Removes filtered items whose expanded parents have been deleted + * or collapsed via setExpanded(parentIndex, false). + */ + void removeFilteredChildren(const KItemRangeList& parents); + /** * Maps the QByteArray-roles to RoleTypes and provides translation- and * group-contexts. @@ -418,6 +433,12 @@ private: */ static void determineMimeTypes(const KFileItemList& items, int timeout); + /** + * @return Returns a copy of \a value that is implicitly shared + * with other users to save memory. + */ + static QByteArray sharedValue(const QByteArray& value); + /** * Checks if the model's internal data structures are consistent. */ @@ -438,34 +459,19 @@ private: QHash m_items; // Allows O(1) access for KFileItemModel::index(const KFileItem& item) KFileItemModelFilter m_filter; - QSet m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter() + QHash m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter() bool m_requestRole[RolesCount]; QTimer* m_maximumUpdateIntervalTimer; QTimer* m_resortAllItemsTimer; - KFileItemList m_pendingItemsToInsert; + QList m_pendingItemsToInsert; // Cache for KFileItemModel::groups() mutable QList > 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 m_expandedDirs; + // Stores the URLs (key: target url, value: url) of the expanded directories. + QHash m_expandedDirs; // URLs that must be expanded. The expanding is initially triggered in setExpanded() // and done step after step in slotCompleted(). @@ -481,7 +487,11 @@ private: inline bool KFileItemModel::isChildItem(int index) const { - return m_requestRole[ExpandedParentsCountRole] && m_itemData.at(index)->values.value("expandedParentsCount").toInt() > 0; + if (m_itemData.at(index)->parent) { + return true; + } else { + return false; + } } #endif