]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodel.cpp
Port Dolphin to Baloo
[dolphin.git] / src / kitemviews / kfileitemmodel.cpp
index 739384bf9f0431c8e6b6cd3f1f900247811746c8..734950257ada3702af1f837dcc040f702316b6ca 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "kfileitemmodel.h"
 
-#include <KDirModel>
 #include <KGlobalSettings>
 #include <KLocale>
 #include <KStringHandler>
@@ -247,9 +246,23 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
     KUrl::List urls;
     KUrl::List mostLocalUrls;
     bool canUseMostLocalUrls = true;
+    const ItemData* lastAddedItem = 0;
 
     foreach (int index, indexes) {
-        const KFileItem item = fileItem(index);
+        const ItemData* itemData = m_itemData.at(index);
+        const ItemData* parent = itemData->parent;
+
+        while (parent && parent != lastAddedItem) {
+            parent = parent->parent;
+        }
+
+        if (parent && parent == lastAddedItem) {
+            // A parent of 'itemData' has been added already.
+            continue;
+        }
+
+        lastAddedItem = itemData;
+        const KFileItem& item = itemData->item;
         if (!item.isNull()) {
             urls << item.targetUrl();
 
@@ -262,9 +275,7 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
     }
 
     const bool different = canUseMostLocalUrls && mostLocalUrls != urls;
-    urls = KDirModel::simplifiedUrlList(urls); // TODO: Check if we still need KDirModel for this in KDE 5.0
     if (different) {
-        mostLocalUrls = KDirModel::simplifiedUrlList(mostLocalUrls);
         urls.populateMimeData(mostLocalUrls, data);
     } else {
         urls.populateMimeData(data);
@@ -662,7 +673,7 @@ QList<KFileItemModel::RoleInfo> KFileItemModel::rolesInformation()
                     // menus tries to put the actions into sub menus otherwise.
                     info.group = QString();
                 }
-                info.requiresNepomuk = map[i].requiresNepomuk;
+                info.requiresBaloo = map[i].requiresBaloo;
                 info.requiresIndexer = map[i].requiresIndexer;
                 rolesInfo.append(info);
             }
@@ -967,6 +978,20 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
             m_items.remove(oldItem.url());
             m_items.insert(newItem.url(), index);
             indexes.append(index);
+        } else {
+            // Check if 'oldItem' is one of the filtered items.
+            QHash<KFileItem, ItemData*>::iterator it = m_filteredItems.find(oldItem);
+            if (it != m_filteredItems.end()) {
+                ItemData* itemData = it.value();
+                itemData->item = newItem;
+
+                // The data stored in 'values' might have changed. Therefore, we clear
+                // 'values' and re-populate it the next time it is requested via data(int).
+                itemData->values.clear();
+
+                m_filteredItems.erase(it);
+                m_filteredItems.insert(newItem, itemData);
+            }
         }
     }
 
@@ -2056,7 +2081,7 @@ void KFileItemModel::emitSortProgress(int resolvedCount)
 const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
 {
     static const RoleInfoMap rolesInfoMap[] = {
-    //  | role         | roleType       | role translation                                | group translation           | requires Nepomuk | requires indexer
+    //  | role         | roleType       | role translation                                | group translation           | requires Baloo   | requires indexer
         { 0,             NoRole,          0, 0,                                             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 },