#include <kitemviews/private/kfileitemmodelfilter.h>
#include <QHash>
+#include <QSet>
class KFileItemModelDirLister;
class QTimer;
bool showDirectoriesOnly() const;
/** @reimp */
- virtual QMimeData* createMimeData(const QSet<int>& indexes) const;
+ virtual QMimeData* createMimeData(const KItemSet& indexes) const;
/** @reimp */
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const;
};
void insertItems(QList<ItemData*>& items);
- void removeItems(const KFileItemList& items, RemoveItemsBehavior behavior);
+ void removeItems(const KItemRangeList& itemRanges, RemoveItemsBehavior behavior);
/**
* Helper method for insertItems() and removeItems(): Creates
*/
QList<ItemData*> createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const;
+ /**
+ * Prepares the items for sorting. Normally, the hash 'values' in ItemData is filled
+ * lazily to save time and memory, but for some sort roles, it is expected that the
+ * sort role data is stored in 'values'.
+ */
+ void prepareItemsForSorting(QList<ItemData*>& itemDataList);
+
static int expandedParentsCount(const ItemData* data);
void removeExpandedItems();
QHash<QByteArray, QVariant> retrieveData(const KFileItem& item, const ItemData* parent) const;
+ /**
+ * @return True if \a a has a KFileItem whose text is 'less than' the one
+ * of \a b according to QString::operator<(const QString&).
+ */
+ static bool nameLessThan(const ItemData* a, const ItemData* b);
+
/**
* @return True if the item-data \a a should be ordered before the item-data
* \b. The item-data may have different parent-items.
*/
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.
* Removes filtered items whose expanded parents have been deleted
* or collapsed via setExpanded(parentIndex, false).
*/
- void removeFilteredChildren(const KFileItemList& parentsList);
+ void removeFilteredChildren(const KItemRangeList& parents);
/**
* Maps the QByteArray-roles to RoleTypes and provides translation- and
friend class DolphinPart; // Accesses m_dirLister
};
+inline bool KFileItemModel::nameLessThan(const ItemData* a, const ItemData* b)
+{
+ return a->item.text() < b->item.text();
+}
+
+
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