]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add role for file creation time.
authorTobias C. Berner <tcberner@FreeBSD.org>
Fri, 16 Jun 2017 18:00:45 +0000 (20:00 +0200)
committerTobias C. Berner <tcberner@FreeBSD.org>
Tue, 18 Jul 2017 16:44:14 +0000 (18:44 +0200)
Summary: At least on FreeBSD UFS and ZFS support birthtimes of files.

Reviewers: #freebsd, #dolphin

Subscribers: #konqueror

Differential Revision: https://phabricator.kde.org/D6243

src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kfileitemmodel.h

index da64895fbe12df009d7e7b80d24b2e0d0bff2c4f..b725d950797b4620f61955b373f0b8e2399e6360 100644 (file)
@@ -334,6 +334,11 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
                 return item->item.time(KFileItem::ModificationTime);
             });
             break;
                 return item->item.time(KFileItem::ModificationTime);
             });
             break;
+        case CreationTimeRole:
+            m_groups = timeRoleGroups([](const ItemData *item) {
+                return item->item.time(KFileItem::CreationTime);
+            });
+            break;
         case AccessTimeRole:
             m_groups = timeRoleGroups([](const ItemData *item) {
                 return item->item.time(KFileItem::AccessTime);
         case AccessTimeRole:
             m_groups = timeRoleGroups([](const ItemData *item) {
                 return item->item.time(KFileItem::AccessTime);
@@ -1562,6 +1567,14 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
         data.insert(sharedValue("modificationtime"), dateTime);
     }
 
         data.insert(sharedValue("modificationtime"), dateTime);
     }
 
+    if (m_requestRole[CreationTimeRole]) {
+        // Don't use KFileItem::timeString() as this is too expensive when
+        // having several thousands of items. Instead the formatting of the
+        // date-time will be done on-demand by the view when the date will be shown.
+        const QDateTime dateTime = item.time(KFileItem::CreationTime);
+        data.insert(sharedValue("creationtime"), dateTime);
+    }
+
     if (m_requestRole[AccessTimeRole]) {
         // Don't use KFileItem::timeString() as this is too expensive when
         // having several thousands of items. Instead the formatting of the
     if (m_requestRole[AccessTimeRole]) {
         // Don't use KFileItem::timeString() as this is too expensive when
         // having several thousands of items. Instead the formatting of the
@@ -1811,6 +1824,17 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const
         break;
     }
 
         break;
     }
 
+    case CreationTimeRole: {
+        const QDateTime dateTimeA = itemA.time(KFileItem::CreationTime);
+        const QDateTime dateTimeB = itemB.time(KFileItem::CreationTime);
+        if (dateTimeA < dateTimeB) {
+            result = -1;
+        } else if (dateTimeA > dateTimeB) {
+            result = +1;
+        }
+        break;
+    }
+
     case DeletionTimeRole: {
         const QDateTime dateTimeA = a->values.value("deletiontime").toDateTime();
         const QDateTime dateTimeB = b->values.value("deletiontime").toDateTime();
     case DeletionTimeRole: {
         const QDateTime dateTimeA = a->values.value("deletiontime").toDateTime();
         const QDateTime dateTimeB = b->values.value("deletiontime").toDateTime();
@@ -2271,6 +2295,7 @@ const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
         { "text",        NameRole,        I18N_NOOP2_NOSTRIP("@label", "Name"),             0, 0,                                     false, false },
         { "size",        SizeRole,        I18N_NOOP2_NOSTRIP("@label", "Size"),             0, 0,                                     false, false },
         { "modificationtime",        ModificationTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Modified"),             0, 0,                                     false, false },
         { "text",        NameRole,        I18N_NOOP2_NOSTRIP("@label", "Name"),             0, 0,                                     false, false },
         { "size",        SizeRole,        I18N_NOOP2_NOSTRIP("@label", "Size"),             0, 0,                                     false, false },
         { "modificationtime",        ModificationTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Modified"),             0, 0,                                     false, false },
+        { "creationtime",        CreationTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Created"),             0, 0,                                     false, false },
         { "accesstime",        AccessTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Accessed"),             0, 0,                                     false, false },
         { "type",        TypeRole,        I18N_NOOP2_NOSTRIP("@label", "Type"),             0, 0,                                     false, false },
         { "rating",      RatingRole,      I18N_NOOP2_NOSTRIP("@label", "Rating"),           0, 0,                                     true,  false },
         { "accesstime",        AccessTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Accessed"),             0, 0,                                     false, false },
         { "type",        TypeRole,        I18N_NOOP2_NOSTRIP("@label", "Type"),             0, 0,                                     false, false },
         { "rating",      RatingRole,      I18N_NOOP2_NOSTRIP("@label", "Rating"),           0, 0,                                     true,  false },
index c73df905044aabac010526a279431435b6aa2271..ef902775fcf1abbf340ef382d3e76e6d8ab4f3f6 100644 (file)
@@ -282,7 +282,7 @@ private slots:
 private:
     enum RoleType {
         // User visible roles:
 private:
     enum RoleType {
         // User visible roles:
-        NoRole, NameRole, SizeRole, ModificationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
+        NoRole, NameRole, SizeRole, ModificationTimeRole, CreationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
         GroupRole, TypeRole, DestinationRole, PathRole, DeletionTimeRole,
         // User visible roles available with Baloo:
         CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole,
         GroupRole, TypeRole, DestinationRole, PathRole, DeletionTimeRole,
         // User visible roles available with Baloo:
         CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole,