]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* fixed drag & drop issue in column view (dropping on files was not possible -> handl...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 30 Oct 2007 19:44:55 +0000 (19:44 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 30 Oct 2007 19:44:55 +0000 (19:44 +0000)
* only show the hover-drop-indicator on directories (dropping on file-items is handled like dropping on the viewport)
* simplified signature of drop signal (source widget not required anymore)

svn path=/trunk/KDE/kdebase/apps/; revision=731129

src/dolphincolumnwidget.cpp
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphiniconsview.cpp
src/dolphinview.cpp
src/dolphinview.h

index c212e6ad82ec2778733739bc62ca7dfa1a264f4f..e2670f10d437b98fe263447d4e85ef3106b5e43e 100644 (file)
@@ -222,7 +222,11 @@ void DolphinColumnWidget::dragMoveEvent(QDragMoveEvent* event)
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     const QModelIndex index = indexAt(event->pos());
     setDirtyRegion(m_dropRect);
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     const QModelIndex index = indexAt(event->pos());
     setDirtyRegion(m_dropRect);
-    m_dropRect = visualRect(index);
+    if (itemForIndex(index).isDir()) {
+        m_dropRect = visualRect(index);
+    } else {
+        m_dropRect.setSize(QSize()); // set as invalid
+    }
     setDirtyRegion(m_dropRect);
 }
 
     setDirtyRegion(m_dropRect);
 }
 
@@ -231,14 +235,11 @@ void DolphinColumnWidget::dropEvent(QDropEvent* event)
     const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
     if (!urls.isEmpty()) {
         const QModelIndex index = indexAt(event->pos());
     const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
     if (!urls.isEmpty()) {
         const QModelIndex index = indexAt(event->pos());
-        if (index.isValid()) {
-            const KFileItem item = itemForIndex(index);
-            m_view->m_controller->indicateDroppedUrls(urls,
-                                                      url(),
-                                                      item,
-                                                      event->source());
-            event->acceptProposedAction();
-        }
+        const KFileItem item = itemForIndex(index);
+        m_view->m_controller->indicateDroppedUrls(urls,
+                                                  url(),
+                                                  item);
+        event->acceptProposedAction();
     }
     QListView::dropEvent(event);
     m_dragging = false;
     }
     QListView::dropEvent(event);
     m_dragging = false;
index 897d4266bc8b2eca039b594c8818de735cba9f57..58f6f681f5122ea6633a659dea13987c9ae1ba6d 100644 (file)
@@ -62,10 +62,9 @@ void DolphinController::requestActivation()
 
 void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
                                             const KUrl& destPath,
 
 void DolphinController::indicateDroppedUrls(const KUrl::List& urls,
                                             const KUrl& destPath,
-                                            const KFileItem& destItem,
-                                            QWidget* source)
+                                            const KFileItem& destItem)
 {
 {
-    emit urlsDropped(urls, destPath, destItem, source);
+    emit urlsDropped(urls, destPath, destItem);
 }
 
 
 }
 
 
index c5f0e1a2bedfa27739b253d2b8ff800cac825ee5..16b5f5587122f311b34be9f4c48a3f5b1b5d95b3 100644 (file)
@@ -128,12 +128,10 @@ public:
      * @param urls      URLs that are dropped above a destination.
      * @param destPath  Path of the destination.
      * @param destItem  Destination item (can be null, see KFileItem::isNull()).
      * @param urls      URLs that are dropped above a destination.
      * @param destPath  Path of the destination.
      * @param destItem  Destination item (can be null, see KFileItem::isNull()).
-     * @param source    Pointer to the view implementation which invoked this method.
      */
     void indicateDroppedUrls(const KUrl::List& urls,
                              const KUrl& destPath,
      */
     void indicateDroppedUrls(const KUrl::List& urls,
                              const KUrl& destPath,
-                             const KFileItem& destItem,
-                             QWidget* source);
+                             const KFileItem& destItem);
 
     /**
      * Informs the abstract Dolphin view about a sorting change done inside
 
     /**
      * Informs the abstract Dolphin view about a sorting change done inside
@@ -251,13 +249,11 @@ signals:
      * Is emitted if the URLs \a urls have been dropped to the destination
      * path \a destPath. If the URLs have been dropped above an item of
      * the destination path, the item is indicated by \a destItem
      * Is emitted if the URLs \a urls have been dropped to the destination
      * path \a destPath. If the URLs have been dropped above an item of
      * the destination path, the item is indicated by \a destItem
-     * (can be null, see KFileItem::isNull()). \a source indicates
-     * the widget where the dragging has been started from.
+     * (can be null, see KFileItem::isNull()).
      */
     void urlsDropped(const KUrl::List& urls,
                      const KUrl& destPath,
      */
     void urlsDropped(const KUrl::List& urls,
                      const KUrl& destPath,
-                     const KFileItem& destItem,
-                     QWidget* source);
+                     const KFileItem& destItem);
 
     /**
      * Is emitted if the sorting has been changed to \a sorting by
 
     /**
      * Is emitted if the sorting has been changed to \a sorting by
index ee123b65cac088a5d27a63c4fa89c93e7021e20b..e55c2582d59c31e9426ec4c7e00a1e2980272ddd 100644 (file)
@@ -249,7 +249,11 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event)
         m_dragging = false;
     } else {
         m_dragging = true;
         m_dragging = false;
     } else {
         m_dragging = true;
-        m_dropRect = visualRect(index);
+        if (itemForIndex(index).isDir()) {
+            m_dropRect = visualRect(index);
+        } else {
+            m_dropRect.setSize(QSize()); // set as invalid
+        }
         setDirtyRegion(m_dropRect);
     }
 }
         setDirtyRegion(m_dropRect);
     }
 }
@@ -260,13 +264,13 @@ void DolphinDetailsView::dropEvent(QDropEvent* event)
     if (!urls.isEmpty()) {
         event->acceptProposedAction();
         const QModelIndex index = indexAt(event->pos());
     if (!urls.isEmpty()) {
         event->acceptProposedAction();
         const QModelIndex index = indexAt(event->pos());
+        KFileItem item;
         if (index.isValid() && (index.column() == DolphinModel::Name)) {
         if (index.isValid() && (index.column() == DolphinModel::Name)) {
-            const KFileItem item = itemForIndex(index);
-            m_controller->indicateDroppedUrls(urls,
-                                              m_controller->url(),
-                                              item,
-                                              event->source());
+            item = itemForIndex(index);
         }
         }
+        m_controller->indicateDroppedUrls(urls,
+                                          m_controller->url(),
+                                          item);
     }
     QTreeView::dropEvent(event);
     m_dragging = false;
     }
     QTreeView::dropEvent(event);
     m_dragging = false;
index 30e47da899fc3be77dc2438977bd5f5a39f758a8..eb3aa13c6d2fb18bb6bb2ab1a968b7f889658586 100644 (file)
@@ -188,7 +188,11 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     const QModelIndex index = indexAt(event->pos());
     setDirtyRegion(m_dropRect);
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     const QModelIndex index = indexAt(event->pos());
     setDirtyRegion(m_dropRect);
-    m_dropRect = visualRect(index);
+    if (itemForIndex(index).isDir()) {
+        m_dropRect = visualRect(index);
+    } else {
+        m_dropRect.setSize(QSize()); // set as invalid
+    }
     setDirtyRegion(m_dropRect);
 }
 
     setDirtyRegion(m_dropRect);
 }
 
@@ -198,14 +202,11 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
         const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
         if (!urls.isEmpty()) {
             const QModelIndex index = indexAt(event->pos());
         const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
         if (!urls.isEmpty()) {
             const QModelIndex index = indexAt(event->pos());
-            if (index.isValid()) {
-                const KFileItem item = itemForIndex(index);
-                m_controller->indicateDroppedUrls(urls,
-                                                  m_controller->url(),
-                                                  item,
-                                                  event->source());
-                event->acceptProposedAction();
-            }
+            const KFileItem item = itemForIndex(index);
+            m_controller->indicateDroppedUrls(urls,
+                                              m_controller->url(),
+                                              item);
+            event->acceptProposedAction();
         }
     }
 
         }
     }
 
index c280b40d0f8f972f2c08c7c323ee41fe6f0dd2e6..004b158ed643b2c3cfc56a513c5bb451f80cf3be 100644 (file)
@@ -103,8 +103,8 @@ DolphinView::DolphinView(QWidget* parent,
 
     connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
             this, SLOT(openContextMenu(const QPoint&)));
 
     connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)),
             this, SLOT(openContextMenu(const QPoint&)));
-    connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)),
-            this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&, QWidget*)));
+    connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&)),
+            this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&)));
     connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
             this, SLOT(updateSorting(DolphinView::Sorting)));
     connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
     connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)),
             this, SLOT(updateSorting(DolphinView::Sorting)));
     connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)),
@@ -730,24 +730,14 @@ void DolphinView::openContextMenu(const QPoint& pos)
 
 void DolphinView::dropUrls(const KUrl::List& urls,
                            const KUrl& destPath,
 
 void DolphinView::dropUrls(const KUrl::List& urls,
                            const KUrl& destPath,
-                           const KFileItem& destItem,
-                           QWidget* source)
-{
-    bool dropAboveDir = false;
-    if (!destItem.isNull()) {
-        dropAboveDir = destItem.isDir();
-        if (!dropAboveDir) {
-            // the dropping is done above a file
-            return;
-        }
-    } else if (source == itemView()) {
-        // the dropping is done into the same viewport where the dragging
-        // has been started
-        return;
+                           const KFileItem& destItem)
+{
+    const KUrl& destination = !destItem.isNull() && destItem.isDir() ?
+                              destItem.url() : destPath;
+    const KUrl sourceDir = KUrl(urls.first().directory());
+    if (sourceDir != destination) {
+        dropUrls(urls, destination);
     }
     }
-
-    const KUrl& destination = dropAboveDir ? destItem.url() : destPath;
-    dropUrls(urls, destination);
 }
 
 void DolphinView::dropUrls(const KUrl::List& urls,
 }
 
 void DolphinView::dropUrls(const KUrl::List& urls,
index 442ff5a60751944db3552a4f347b55b6d6e19cb4..593209e064bae89ad84c010d83b1fb6ac2c6f796 100644 (file)
@@ -489,13 +489,11 @@ private slots:
     /**
      * Drops the URLs \a urls to the destination path \a destPath. If
      * the URLs are dropped above an item inside the destination path,
     /**
      * Drops the URLs \a urls to the destination path \a destPath. If
      * the URLs are dropped above an item inside the destination path,
-     * the item is indicated by \a destItem. \a source
-     * indicates the widget where the dragging has been started from.
+     * the item is indicated by \a destItem.
      */
     void dropUrls(const KUrl::List& urls,
                   const KUrl& destPath,
      */
     void dropUrls(const KUrl::List& urls,
                   const KUrl& destPath,
-                  const KFileItem& destItem,
-                  QWidget* source);
+                  const KFileItem& destItem);
 
     /**
      * Drops the URLs \a urls at the
 
     /**
      * Drops the URLs \a urls at the