]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Show an error when dragging above a folder without write access
authorPeter Penz <peter.penz19@gmail.com>
Tue, 20 Dec 2011 07:56:32 +0000 (08:56 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 20 Dec 2011 07:58:24 +0000 (08:58 +0100)
Got OK from the translator team to add this new string.

src/panels/folders/folderspanel.cpp
src/panels/places/placespanel.cpp
src/views/dolphinview.cpp
src/views/draganddrophelper.cpp
src/views/draganddrophelper.h

index 275cd7772f981eed7269aabe0bb394ad2b6ecd13..bb2198d487ea0ee4d2697cfdfda19955527ffd9b 100644 (file)
@@ -259,7 +259,15 @@ void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos)
 void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
 {
     if (index >= 0) {
-        const KFileItem destItem = fileItemModel()->fileItem(index);
+        KFileItemModel* model = fileItemModel();
+        KFileItem destItem = model->fileItem(index);
+        if (destItem.isNull()) {
+            destItem = model->rootItem();
+            if (destItem.isNull()) {
+                kWarning() << "No destination item available for drop operation.";
+                return;
+            }
+        }
 
         QDropEvent dropEvent(event->pos().toPoint(),
                              event->possibleActions(),
@@ -267,7 +275,7 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve
                              event->buttons(),
                              event->modifiers());
 
-        DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
+        DragAndDropHelper::dropUrls(destItem, &dropEvent);
     }
 }
 
index 902c436cf62e82b05434f431228703453d67c8dc..6f522fad2ea44d916c3cc985bad43fbabad85d07 100644 (file)
@@ -48,7 +48,8 @@ void PlacesPanel::mousePressEvent(QMouseEvent* event)
 void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
 {
     Q_UNUSED(parent);
-    DragAndDropHelper::dropUrls(KFileItem(), dest, event);
+    const KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, dest);
+    DragAndDropHelper::dropUrls(destItem, event);
 }
 
 void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url)
index 0edcb2894462923fa868d7fce06da47afe84a31e..f17749b8318ea2e01fcaa2a1134ce99b2de264c8 100644 (file)
@@ -815,7 +815,14 @@ void DolphinView::slotItemUnhovered(int index)
 
 void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
 {
-    const KFileItem destItem = fileItemModel()->fileItem(index);
+    KFileItem destItem = fileItemModel()->fileItem(index);
+    if (destItem.isNull()) {
+        destItem = fileItemModel()->rootItem();
+        if (destItem.isNull()) {
+            kWarning() << "No destination item available for drop operation.";
+            return;
+        }
+    }
 
     QDropEvent dropEvent(event->pos().toPoint(),
                          event->possibleActions(),
@@ -823,7 +830,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
                          event->buttons(),
                          event->modifiers());
 
-    const QString error = DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
+    const QString error = DragAndDropHelper::dropUrls(destItem, &dropEvent);
     if (!error.isEmpty()) {
         emit errorMessage(error);
     }
index ea92787ab07d52c77e01b39116e83fad796cc9d6..91eb4267d84dfe848e89f16b5f6474400e8f5c2a 100644 (file)
 #include <QtDBus>
 #include <QDropEvent>
 
-QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
-                                    const KUrl& destPath,
-                                    QDropEvent* event)
+QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event)
 {
-    const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
-    const KUrl destination = dropToItem ? destItem.url() : destPath;
+    Q_ASSERT(!destItem.isNull());
+
+    const KUrl destination = destItem.url();
+    if (!destItem.isWritable()) {
+        return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destination.pathOrUrl());
+    }
 
     const QMimeData* mimeData = event->mimeData();
     if (mimeData->hasFormat("application/x-kde-dndextract")) {
@@ -50,11 +52,7 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
             }
         }
 
-        if (dropToItem) {
-            KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
-        } else {
-            KonqOperations::doDrop(KFileItem(), destination, event, QApplication::activeWindow());
-        }
+        KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
     }
 
     return QString();
index d00e111579c3abb6748f40b42f2abcc3f2963f84..1998a85a0e676e6eb8c27048d5136cd8f55c4ada 100644 (file)
@@ -38,15 +38,12 @@ public:
      * destination. A context menu with the options
      * 'Move Here', 'Copy Here', 'Link Here' and
      * 'Cancel' is offered to the user.
-     * @param destItem  Item of the destination (can be null, see KFileItem::isNull()).
-     * @param destPath  Path of the destination.
+     * @param destItem  Item of the destination.
      * @param event     Drop event.
      * @return          Error message if dropping is not possible. If an empty string
      *                  is returned, the dropping has been successful.
      */
-    static QString dropUrls(const KFileItem& destItem,
-                            const KUrl& destPath,
-                            QDropEvent* event);
+    static QString dropUrls(const KFileItem& destItem, QDropEvent* event);
 };
 
 #endif