]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodel.h
Change "Date" to "Modified" and allow access to new "Accessed" time field
[dolphin.git] / src / kitemviews / kfileitemmodel.h
index 535e0f3e4b18a02f74327c04903810b6c2a4f531..dc5746a8916f1048809c477c50ac5ef3d84e5171 100644 (file)
 #ifndef KFILEITEMMODEL_H
 #define KFILEITEMMODEL_H
 
-#include <libdolphin_export.h>
-#include <KFileItemList>
+#include "dolphin_export.h"
+#include <KFileItem>
 #include <QUrl>
 #include <kitemviews/kitemmodelbase.h>
 #include <kitemviews/private/kfileitemmodelfilter.h>
 
+#include <QCollator>
 #include <QHash>
 #include <QSet>
 
@@ -42,7 +43,7 @@ class QTimer;
  * Recursive expansion of sub-directories is supported by
  * KFileItemModel::setExpanded().
  */
-class LIBDOLPHINPRIVATE_EXPORT KFileItemModel : public KItemModelBase
+class DOLPHIN_EXPORT KFileItemModel : public KItemModelBase
 {
     Q_OBJECT
 
@@ -272,19 +273,19 @@ private slots:
     void slotItemsDeleted(const KFileItemList& items);
     void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
     void slotClear();
-    void slotNaturalSortingChanged();
+    void slotSortingChoiceChanged();
 
     void dispatchPendingItemsToInsert();
 
 private:
     enum RoleType {
         // User visible roles:
-        NoRole, NameRole, SizeRole, DateRole, PermissionsRole, OwnerRole,
+        NoRole, NameRole, SizeRole, ModificationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
         GroupRole, TypeRole, DestinationRole, PathRole,
         // User visible roles available with Baloo:
         CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole,
-        WordCountRole, LineCountRole, ArtistRole, AlbumRole, DurationRole, TrackRole,
-        CopiedFromRole,
+        WordCountRole, TitleRole, LineCountRole, ArtistRole, AlbumRole, DurationRole, TrackRole,
+        OriginUrlRole,
         // Non-visible roles:
         IsDirRole, IsLinkRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole,
         // Mandatory last entry:
@@ -361,7 +362,7 @@ private:
      * @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 lessThan(const ItemData* a, const ItemData* b) const;
+    bool lessThan(const ItemData* a, const ItemData* b, const QCollator& collator) const;
 
     /**
      * Sorts the items between \a begin and \a end using the comparison
@@ -374,15 +375,15 @@ private:
      * the passed item-data using m_sortRole as criteria. Both items must
      * have the same parent item, otherwise the comparison will be wrong.
      */
-    int sortRoleCompare(const ItemData* a, const ItemData* b) const;
+    int sortRoleCompare(const ItemData* a, const ItemData* b, const QCollator& collator) const;
 
-    int stringCompare(const QString& a, const QString& b) const;
+    int stringCompare(const QString& a, const QString& b, const QCollator& collator) const;
 
     bool useMaximumUpdateInterval() const;
 
     QList<QPair<int, QVariant> > nameRoleGroups() const;
     QList<QPair<int, QVariant> > sizeRoleGroups() const;
-    QList<QPair<int, QVariant> > dateRoleGroups() const;
+    QList<QPair<int, QVariant> > timeRoleGroups(KFileItem::FileTimes which) const;
     QList<QPair<int, QVariant> > permissionRoleGroups() const;
     QList<QPair<int, QVariant> > ratingRoleGroups() const;
     QList<QPair<int, QVariant> > genericStringRoleGroups(const QByteArray& typeForRole) const;
@@ -414,6 +415,11 @@ private:
      */
     void removeFilteredChildren(const KItemRangeList& parents);
 
+    /**
+     * Loads the selected choice of sorting method from Dolphin General Settings
+     */
+    void loadSortingSettings();
+
     /**
      * Maps the QByteArray-roles to RoleTypes and provides translation- and
      * group-contexts.
@@ -455,13 +461,13 @@ private:
 private:
     KFileItemModelDirLister* m_dirLister;
 
+    QCollator m_collator;
     bool m_naturalSorting;
     bool m_sortDirsFirst;
 
     RoleType m_sortRole;
     int m_sortingProgressPercent; // Value of directorySortingProgress() signal
     QSet<QByteArray> m_roles;
-    Qt::CaseSensitivity m_caseSensitivity;
 
     QList<ItemData*> m_itemData;