]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodel.h
Merge remote-tracking branch 'origin/KDE/4.12'
[dolphin.git] / src / kitemviews / kfileitemmodel.h
index d005705492e1a0feb4092808eca2f488ac0143ae..0224290238b6a2d77741b625c0d7212ba080baa9 100644 (file)
@@ -27,6 +27,7 @@
 #include <kitemviews/private/kfileitemmodelfilter.h>
 
 #include <QHash>
+#include <QSet>
 
 class KFileItemModelDirLister;
 class QTimer;
@@ -99,7 +100,7 @@ public:
     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;
@@ -319,6 +320,13 @@ private:
      */
     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();
@@ -349,6 +357,12 @@ private:
 
     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.
@@ -485,6 +499,12 @@ private:
     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
 {
     if (m_itemData.at(index)->parent) {