]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodel.h
Build with QT_NO_KEYWORDS
[dolphin.git] / src / kitemviews / kfileitemmodel.h
index 3266a49f9246c92bf87201f7421654d715eb41a9..886a1c6de52e72b3e0651b2797d6717256905a36 100644 (file)
@@ -1,21 +1,8 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #ifndef KFILEITEMMODEL_H
 #define KFILEITEMMODEL_H
@@ -198,7 +185,7 @@ public:
      */
     static QList<RoleInfo> rolesInformation();
 
-signals:
+Q_SIGNALS:
     /**
      * Is emitted if the loading of a directory has been started. It is
      * assured that a signal directoryLoadingCompleted() will be send after
@@ -263,7 +250,7 @@ protected:
     void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true) override;
     void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override;
 
-private slots:
+private Q_SLOTS:
     /**
      * Resorts all items dependent on the set sortRole(), sortOrder()
      * and foldersFirst() settings.
@@ -288,7 +275,7 @@ private:
         // User visible roles available with Baloo:
         CommentRole, TagsRole, RatingRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
         WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
-        BitrateRole, OriginUrlRole,
+        BitrateRole, OriginUrlRole, AspectRatioRole, FrameRateRole,
         // Non-visible roles:
         IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole,
         // Mandatory last entry:
@@ -355,6 +342,11 @@ private:
 
     QHash<QByteArray, QVariant> retrieveData(const KFileItem& item, const ItemData* parent) const;
 
+    /**
+     * @return True if role values benefit from natural or case insensitive sorting.
+     */
+    static bool isRoleValueNatural(const RoleType roleType);
+
     /**
      * @return True if \a a has a KFileItem whose text is 'less than' the one
      *         of \a b according to QString::operator<(const QString&).
@@ -371,7 +363,7 @@ private:
      * Sorts the items between \a begin and \a end using the comparison
      * function lessThan().
      */
-    void sort(QList<ItemData*>::iterator begin, QList<ItemData*>::iterator end) const;
+    void sort(const QList<ItemData*>::iterator &begin, const QList<ItemData*>::iterator &end) const;
 
     /**
      * Helper method for lessThan() and expandedParentsCountCompare(): Compares
@@ -382,11 +374,9 @@ private:
 
     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> > timeRoleGroups(std::function<QDateTime(const ItemData *)> fileTimeCb) const;
+    QList<QPair<int, QVariant> > timeRoleGroups(const std::function<QDateTime(const ItemData *)> &fileTimeCb) const;
     QList<QPair<int, QVariant> > permissionRoleGroups() const;
     QList<QPair<int, QVariant> > ratingRoleGroups() const;
     QList<QPair<int, QVariant> > genericStringRoleGroups(const QByteArray& typeForRole) const;
@@ -506,12 +496,27 @@ private:
     friend class DolphinPart;                  // Accesses m_dirLister
 };
 
+inline bool KFileItemModel::isRoleValueNatural(RoleType roleType)
+{
+    return (roleType == TypeRole ||
+            roleType == TagsRole ||
+            roleType == CommentRole ||
+            roleType == TitleRole ||
+            roleType == ArtistRole ||
+            roleType == GenreRole ||
+            roleType == AlbumRole ||
+            roleType == PathRole ||
+            roleType == DestinationRole ||
+            roleType == OriginUrlRole ||
+            roleType == OwnerRole ||
+            roleType == GroupRole);
+}
+
 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) {