]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Folders Panel cleanups
authorPeter Penz <peter.penz19@gmail.com>
Tue, 6 Dec 2011 18:20:48 +0000 (19:20 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 6 Dec 2011 18:22:55 +0000 (19:22 +0100)
- Reactivate dropping of URLs
- Remove unused/obsolete code
- Simplify DragAndDropHelper interface

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

index 26c7250484a111d18228b5b55db96eb74abed7b5..598d3054a3c97baec4be061fa815e959476fde60 100644 (file)
 
 #include <QApplication>
 #include <QBoxLayout>
+#include <QDropEvent>
+#include <QGraphicsSceneDragDropEvent>
 #include <QGraphicsView>
 #include <QPropertyAnimation>
 #include <QTimer>
 
+#include <views/draganddrophelper.h>
 #include <views/renamedialog.h>
 
 #include <KDebug>
@@ -86,7 +89,7 @@ bool FoldersPanel::hiddenFilesShown() const
 
 void FoldersPanel::setAutoScrolling(bool enable)
 {
-    //m_treeView->setAutoHorizontalScroll(enable);
+    // TODO: Not supported yet in Dolphin 2.0
     FoldersPanelSettings::setAutoScrolling(enable);
 }
 
@@ -177,6 +180,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
         connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
         connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
         connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
+        connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
 
         // TODO: Check whether it makes sense to make an explicit API for KItemListContainer
         // to make the background transparent.
@@ -208,7 +212,6 @@ void FoldersPanel::keyPressEvent(QKeyEvent* event)
     const int key = event->key();
     if ((key == Qt::Key_Enter) || (key == Qt::Key_Return)) {
         event->accept();
-        //updateActiveView(m_treeView->currentIndex());
     } else {
         Panel::keyPressEvent(event);
     }
@@ -254,6 +257,21 @@ void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos)
     }
 }
 
+void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
+{
+    if (index >= 0) {
+        const KFileItem destItem = fileItemModel()->fileItem(index);
+
+        QDropEvent dropEvent(event->pos().toPoint(),
+                             event->possibleActions(),
+                             event->mimeData(),
+                             event->buttons(),
+                             event->modifiers());
+
+        DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
+    }
+}
+
 void FoldersPanel::slotLoadingCompleted()
 {
     if (m_controller->view()->opacity() == 0) {
@@ -275,22 +293,6 @@ void FoldersPanel::slotLoadingCompleted()
     m_updateCurrentItem = false;
 }
 
-void FoldersPanel::slotHorizontalScrollBarMoved(int value)
-{
-    Q_UNUSED(value);
-    // Disable the auto-scrolling until the vertical scrollbar has
-    // been moved by the user.
-    //m_treeView->setAutoHorizontalScroll(false);
-}
-
-void FoldersPanel::slotVerticalScrollBarMoved(int value)
-{
-    Q_UNUSED(value);
-    // Enable the auto-scrolling again (it might have been disabled by
-    // moving the horizontal scrollbar).
-    //m_treeView->setAutoHorizontalScroll(FoldersPanelSettings::autoScrolling());
-}
-
 void FoldersPanel::startFadeInAnimation()
 {
     QPropertyAnimation* anim = new QPropertyAnimation(m_controller->view(), "opacity", this);
index d249f850f334ba3b6da4bee6ccda495f1217c030..c5cd1dec83e7d4595c982564df357f78c37512b8 100644 (file)
@@ -26,6 +26,7 @@
 class KDirLister;
 class KFileItemModel;
 class KItemListController;
+class QGraphicsSceneDragDropEvent;
 
 /**
  * @brief Shows a tree view of the directories starting from
@@ -71,13 +72,10 @@ private slots:
     void slotItemMiddleClicked(int index);
     void slotItemContextMenuRequested(int index, const QPointF& pos);
     void slotViewContextMenuRequested(const QPointF& pos);
+    void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
 
     void slotLoadingCompleted();
 
-    void slotHorizontalScrollBarMoved(int value);
-
-    void slotVerticalScrollBarMoved(int value);
-
     /**
      * Increases the opacity of the view step by step until it is fully
      * opaque.
index a47cc738303c1071edf21cb820595191bee281fc..902c436cf62e82b05434f431228703453d67c8dc 100644 (file)
@@ -47,7 +47,8 @@ void PlacesPanel::mousePressEvent(QMouseEvent* event)
 
 void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
 {
-    DragAndDropHelper::dropUrls(KFileItem(), dest, event, parent);
+    Q_UNUSED(parent);
+    DragAndDropHelper::dropUrls(KFileItem(), dest, event);
 }
 
 void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url)
index 455905f6a6a07cb0c4cac132727b4f6d0688d6e1..7a390356129a42b782ca22a9830b1801e9e94f43 100644 (file)
@@ -831,7 +831,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
                          event->buttons(),
                          event->modifiers());
 
-    DragAndDropHelper::dropUrls(destItem, url(), &dropEvent, this);
+    DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
 }
 
 void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
index 6cd17b6ba4fc99249129ed85b349b4fde60deadb..8e58734808dd756ec45bd00b7c4586c4a9d19fb8 100644 (file)
 #include <KLocale>
 #include <konq_operations.h>
 #include <KUrl>
+#include <QApplication>
 #include <QtDBus>
 #include <QDropEvent>
-#include <QWidget>
 
 QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
                                     const KUrl& destPath,
-                                    QDropEvent* event,
-                                    QWidget* widget)
+                                    QDropEvent* event)
 {
     const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
     const KUrl destination = dropToItem ? destItem.url() : destPath;
@@ -49,9 +48,9 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem,
         if (urlsCount == 1 && urls.first() == destination) {
             return i18nc("@info:status", "A folder cannot be dropped into itself");
         } else if (dropToItem) {
-            KonqOperations::doDrop(destItem, destination, event, widget);
+            KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
         } else {
-            KonqOperations::doDrop(KFileItem(), destination, event, widget);
+            KonqOperations::doDrop(KFileItem(), destination, event, QApplication::activeWindow());
         }
     }
 
index 85e47077d289bfa337c2ce2af12dad7bd89f1a0e..d00e111579c3abb6748f40b42f2abcc3f2963f84 100644 (file)
@@ -41,14 +41,12 @@ public:
      * @param destItem  Item of the destination (can be null, see KFileItem::isNull()).
      * @param destPath  Path of the destination.
      * @param event     Drop event.
-     * @param widget    Source widget where the dragging has been started.
      * @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,
-                            QWidget* widget);
+                            QDropEvent* event);
 };
 
 #endif