]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodel.cpp
A complete build does not fix the crashes I'm having.
[dolphin.git] / src / kitemviews / kfileitemmodel.cpp
index 8c736ccfe50f1425fe590becefc69a70e744e571..9db3a2e5a8d3f5ee531d00cb0d0279cc50f55be1 100644 (file)
 #include "kfileitemmodel.h"
 
 #include "dolphin_generalsettings.h"
+#include "dolphindebug.h"
+#include "private/kfileitemmodeldirlister.h"
+#include "private/kfileitemmodelsortalgorithm.h"
 
 #include <KLocalizedString>
 #include <KUrlMimeData>
 
-#include "dolphindebug.h"
-
-#include "private/kfileitemmodelsortalgorithm.h"
-#include "private/kfileitemmodeldirlister.h"
-
 #include <QElapsedTimer>
 #include <QMimeData>
 #include <QTimer>
 #include <QWidget>
 
-#include <algorithm>
-#include <vector>
-
 // #define KFILEITEMMODEL_DEBUG
 
 KFileItemModel::KFileItemModel(QObject* parent) :
@@ -251,7 +246,6 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
     // Copyright (C) 2006 David Faure <faure@kde.org>
     QList<QUrl> urls;
     QList<QUrl> mostLocalUrls;
-    bool canUseMostLocalUrls = true;
     const ItemData* lastAddedItem = nullptr;
 
     for (int index : indexes) {
@@ -274,9 +268,6 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
 
             bool isLocal;
             mostLocalUrls << item.mostLocalUrl(isLocal);
-            if (!isLocal) {
-                canUseMostLocalUrls = false;
-            }
         }
     }
 
@@ -1214,7 +1205,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
     } else {
         m_itemData.reserve(totalItemCount);
         for (int i = existingItemCount; i < totalItemCount; ++i) {
-            m_itemData.append(0);
+            m_itemData.append(nullptr);
         }
 
         // We build the new list m_itemData in reverse order to minimize
@@ -1284,7 +1275,7 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe
                 delete m_itemData.at(index);
             }
 
-            m_itemData[index] = 0;
+            m_itemData[index] = nullptr;
         }
     }
 
@@ -1325,7 +1316,7 @@ QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const QUrl&
     }
 
     const int parentIndex = index(parentUrl);
-    ItemData* parentItem = parentIndex < 0 ? 0 : m_itemData.at(parentIndex);
+    ItemData* parentItem = parentIndex < 0 ? nullptr : m_itemData.at(parentIndex);
 
     QList<ItemData*> itemDataList;
     itemDataList.reserve(items.count());
@@ -1855,16 +1846,14 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const
         break;
     }
 
-    case RatingRole: {
-        result = a->values.value("rating").toInt() - b->values.value("rating").toInt();
-        break;
-    }
-
-    case ImageSizeRole: {
-        // Alway use a natural comparing to interpret the numbers of a string like
-        // "1600 x 1200" for having a correct sorting.
-        result = collator.compare(a->values.value("imageSize").toString(),
-                                  b->values.value("imageSize").toString());
+    case RatingRole:
+    case WidthRole:
+    case HeightRole:
+    case WordCountRole:
+    case LineCountRole:
+    case TrackRole:
+    case ReleaseYearRole: {
+        result = a->values.value(roleForType(m_sortRole)).toInt() - b->values.value(roleForType(m_sortRole)).toInt();
         break;
     }
 
@@ -2314,7 +2303,8 @@ const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
         { "wordCount",   WordCountRole,   I18N_NOOP2_NOSTRIP("@label", "Word Count"),       I18N_NOOP2_NOSTRIP("@label", "Document"), true,  true  },
         { "lineCount",   LineCountRole,   I18N_NOOP2_NOSTRIP("@label", "Line Count"),       I18N_NOOP2_NOSTRIP("@label", "Document"), true,  true  },
         { "imageDateTime",   ImageDateTimeRole,   I18N_NOOP2_NOSTRIP("@label", "Date Photographed"),       I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
-        { "imageSize",   ImageSizeRole,   I18N_NOOP2_NOSTRIP("@label", "Image Size"),       I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
+        { "width",       WidthRole,       I18N_NOOP2_NOSTRIP("@label", "Width"),            I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
+        { "height",      HeightRole,      I18N_NOOP2_NOSTRIP("@label", "Height"),           I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
         { "orientation", OrientationRole, I18N_NOOP2_NOSTRIP("@label", "Orientation"),      I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
         { "artist",      ArtistRole,      I18N_NOOP2_NOSTRIP("@label", "Artist"),           I18N_NOOP2_NOSTRIP("@label", "Audio"),    true,  true  },
         { "genre",       GenreRole,       I18N_NOOP2_NOSTRIP("@label", "Genre"),            I18N_NOOP2_NOSTRIP("@label", "Audio"),    true,  true  },