]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/iconmanager.cpp
Fix dolphin to only enable the Cut context menu option if the file capabilites suppor...
[dolphin.git] / src / iconmanager.cpp
index c6c07be7bd9b1eb10299c6e426f3f441fd753565..a8ccc9ed1d090ac9b018162117a96dbce2e95955 100644 (file)
@@ -84,8 +84,9 @@ void IconManager::updatePreviews()
     }
 
     killJobs();
-    KFileItemList itemList;
+    m_cutItemsCache.clear();
 
+    KFileItemList itemList;
     const int rowCount = m_dolphinModel->rowCount();
     for (int row = 0; row < rowCount; ++row) {
         const QModelIndex index = m_dolphinModel->index(row, 0);
@@ -94,10 +95,13 @@ void IconManager::updatePreviews()
     }
 
     generatePreviews(itemList);
+    updateCutItems();
 }
 
-void IconManager::generatePreviews(const KFileItemList &items)
+void IconManager::generatePreviews(const KFileItemListitems)
 {
+    applyCutItemEffect();
+
     if (!m_showPreview) {
         return;
     }
@@ -230,6 +234,20 @@ void IconManager::replaceIcon(const KUrl& url, const QPixmap& pixmap)
 
         const QMimeData* mimeData = QApplication::clipboard()->mimeData();
         if (KonqMimeData::decodeIsCutSelection(mimeData) && isCutItem(item)) {
+            // Remember the current icon in the cache for cut items before
+            // the disabled effect is applied. This makes it possible restoring
+            // the uncut version again when cutting other items.
+            QList<ItemInfo>::iterator begin = m_cutItemsCache.begin();
+            QList<ItemInfo>::iterator end   = m_cutItemsCache.end();
+            for (QList<ItemInfo>::iterator it = begin; it != end; ++it) {
+                if ((*it).url == item.url()) {
+                    (*it).pixmap = icon;
+                    break;
+                }
+            }
+
+            // apply the disabled effect to the icon for marking it as "cut item"
+            // and apply the icon to the item
             KIconEffect iconEffect;
             icon = iconEffect.apply(icon, KIconLoader::Desktop, KIconLoader::DisabledState);
             m_dolphinModel->setData(idx, QIcon(icon), Qt::DecorationRole);
@@ -274,7 +292,8 @@ void IconManager::applyCutItemEffect()
             const QVariant value = m_dolphinModel->data(index, Qt::DecorationRole);
             if (value.type() == QVariant::Icon) {
                 const QIcon icon(qvariant_cast<QIcon>(value));
-                QPixmap pixmap = icon.pixmap(m_view->iconSize());
+                const QSize actualSize = icon.actualSize(m_view->iconSize());
+                QPixmap pixmap = icon.pixmap(actualSize);
 
                 // remember current pixmap for the item to be able
                 // to restore it when other items get cut