]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Cleanup of URL drop handling (simplified code, modifier keys work again). After furth...
authorPeter Penz <peter.penz19@gmail.com>
Thu, 25 Jan 2007 17:56:29 +0000 (17:56 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 25 Jan 2007 17:56:29 +0000 (17:56 +0000)
svn path=/trunk/playground/utils/dolphin/; revision=627105

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index 792c39c1e2f07437a48be4fc0842aa8ef0b69a51..cf224971ee9a145299fd57f46f3593ef83425432 100644 (file)
@@ -65,7 +65,6 @@
 #include <kstandardaction.h>\r
 #include <kurl.h>\r
 \r
 #include <kstandardaction.h>\r
 #include <kurl.h>\r
 \r
-#include <Q3ValueList>  // TODO\r
 #include <QCloseEvent>\r
 #include <QClipboard>\r
 #include <QSplitter>\r
 #include <QCloseEvent>\r
 #include <QClipboard>\r
 #include <QSplitter>\r
@@ -117,48 +116,79 @@ void DolphinMainWindow::setActiveView(DolphinView* view)
 void DolphinMainWindow::dropUrls(const KUrl::List& urls,\r
                                  const KUrl& destination)\r
 {\r
 void DolphinMainWindow::dropUrls(const KUrl::List& urls,\r
                                  const KUrl& destination)\r
 {\r
-    m_dropDestination = destination;\r
-    m_droppedUrls = urls;\r
-\r
-    /* KDE4-TODO\r
-    const ButtonState keyboardState = KApplication::keyboardMouseState();\r
-    const bool shiftPressed = (keyboardState & ShiftButton) > 0;\r
-    const bool controlPressed = (keyboardState & ControlButton) > 0;\r
-\r
-\r
+    Qt::DropAction action = Qt::CopyAction;\r
 \r
 \r
+    Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();\r
+    const bool shiftPressed   = modifier & Qt::ShiftModifier;\r
+    const bool controlPressed = modifier & Qt::ControlModifier;\r
     if (shiftPressed && controlPressed) {\r
     if (shiftPressed && controlPressed) {\r
-        // shortcut for 'Linke Here' is used\r
-        selectedIndex = 2;\r
-    }\r
-    else if (controlPressed) {\r
-        // shortcut for 'Copy Here' is used\r
-        selectedIndex = 1;\r
+        // shortcut for 'Link Here' is used\r
+        action = Qt::LinkAction;\r
     }\r
     else if (shiftPressed) {\r
         // shortcut for 'Move Here' is used\r
     }\r
     else if (shiftPressed) {\r
         // shortcut for 'Move Here' is used\r
-        selectedIndex = 0;\r
+        action = Qt::MoveAction;\r
+    }\r
+    else if (controlPressed) {\r
+        // shortcut for 'Copy Here' is used\r
+        action = Qt::CopyAction;\r
     }\r
     }\r
-    else*/ {\r
-        // no shortcut is used, hence open a popup menu\r
+    else {\r
+        // open a context menu which offers the following actions:\r
+        // - Move Here\r
+        // - Copy Here\r
+        // - Link Here\r
+        // - Cancel\r
+\r
         KMenu popup(this);\r
 \r
         KMenu popup(this);\r
 \r
-        QAction* moveAction = popup.addAction(SmallIcon("goto"), i18n("&Move Here"));\r
-        connect(moveAction, SIGNAL(triggered()), this, SLOT(moveDroppedItems()));\r
+        QString seq = QKeySequence(Qt::ShiftModifier).toString();\r
+        seq.chop(1); // chop superfluous '+'\r
+        QAction* moveAction = popup.addAction(KIcon("goto"),\r
+                                              i18n("&Move Here") + "\t" + seq);\r
 \r
 \r
-        QAction* copyAction = popup.addAction(SmallIcon("editcopy"), i18n( "&Copy Here" ));\r
-        connect(copyAction, SIGNAL(triggered()), this, SLOT(copyDroppedItems()));\r
+        seq = QKeySequence(Qt::ControlModifier).toString();\r
+        seq.chop(1);\r
+        QAction* copyAction = popup.addAction(KIcon("editcopy"),\r
+                                              i18n("&Copy Here") + "\t" + seq);\r
 \r
 \r
-        QAction* linkAction = popup.addAction(i18n("&Link Here"));\r
-        connect(linkAction, SIGNAL(triggered()), this, SLOT(linkDroppedItems()));\r
+        seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString();\r
+        seq.chop(1);\r
+        QAction* linkAction = popup.addAction(KIcon("www"),\r
+                                              i18n("&Link Here") + "\t" + seq);\r
 \r
 \r
-        QAction* cancelAction = popup.addAction(SmallIcon("stop"), i18n("Cancel"));\r
-        popup.insertSeparator(cancelAction);\r
+        popup.addSeparator();\r
+        popup.addAction(KIcon("stop"), i18n("Cancel"));\r
 \r
 \r
-        popup.exec(QCursor::pos());\r
+        QAction* activatedAction = popup.exec(QCursor::pos());\r
+        if (activatedAction == moveAction) {\r
+            action = Qt::MoveAction;\r
+        }\r
+        else if (activatedAction == copyAction) {\r
+            action = Qt::CopyAction;\r
+        }\r
+        else if (activatedAction == linkAction) {\r
+            action = Qt::LinkAction;\r
+        }\r
     }\r
 \r
     }\r
 \r
-    m_droppedUrls.clear();\r
+    switch (action) {\r
+        case Qt::MoveAction:\r
+            moveUrls(urls, destination);\r
+            break;\r
+\r
+        case Qt::CopyAction:\r
+            copyUrls(urls, destination);\r
+            break;\r
+\r
+        case Qt::LinkAction:\r
+            KonqOperations::copy(this, KonqOperations::LINK, urls, destination);\r
+            m_undoOperations.append(KonqOperations::LINK);\r
+            break;\r
+\r
+        default:\r
+            break;\r
+    }\r
 }\r
 \r
 void DolphinMainWindow::refreshViews()\r
 }\r
 \r
 void DolphinMainWindow::refreshViews()\r
@@ -280,22 +310,6 @@ void DolphinMainWindow::openNewMainWindow()
     DolphinApplication::app()->createMainWindow()->show();\r
 }\r
 \r
     DolphinApplication::app()->createMainWindow()->show();\r
 }\r
 \r
-void DolphinMainWindow::moveDroppedItems()\r
-{\r
-    moveUrls(m_droppedUrls, m_dropDestination);\r
-}\r
-\r
-void DolphinMainWindow::copyDroppedItems()\r
-{\r
-    copyUrls(m_droppedUrls, m_dropDestination);\r
-}\r
-\r
-void DolphinMainWindow::linkDroppedItems()\r
-{\r
-    KonqOperations::copy(this, KonqOperations::LINK, m_droppedUrls, m_dropDestination);\r
-    m_undoOperations.append(KonqOperations::LINK);\r
-}\r
-\r
 void DolphinMainWindow::closeEvent(QCloseEvent* event)\r
 {\r
     DolphinSettings& settings = DolphinSettings::instance();\r
 void DolphinMainWindow::closeEvent(QCloseEvent* event)\r
 {\r
     DolphinSettings& settings = DolphinSettings::instance();\r
@@ -413,22 +427,18 @@ void DolphinMainWindow::quit()
 void DolphinMainWindow::slotHandleJobError(KJob* job)\r
 {\r
     if (job->error() != 0) {\r
 void DolphinMainWindow::slotHandleJobError(KJob* job)\r
 {\r
     if (job->error() != 0) {\r
-        m_activeView->statusBar()->setMessage(job->errorString(),\r
-                                              DolphinStatusBar::Error);\r
+        DolphinStatusBar* statusBar = m_activeView->statusBar();\r
+        statusBar->setMessage(job->errorString(),\r
+                              DolphinStatusBar::Error);\r
     }\r
 }\r
 \r
 void DolphinMainWindow::slotDeleteFileFinished(KJob* job)\r
 {\r
     if (job->error() == 0) {\r
     }\r
 }\r
 \r
 void DolphinMainWindow::slotDeleteFileFinished(KJob* job)\r
 {\r
     if (job->error() == 0) {\r
-        m_activeView->statusBar()->setMessage(i18n("Delete operation completed."),\r
-                                               DolphinStatusBar::OperationCompleted);\r
-\r
-        // TODO: In opposite to the 'Move to Trash' operation in the class KFileIconView\r
-        // no rearranging of the item position is done when a file has been deleted.\r
-        // This is bypassed by reloading the view, but it might be worth to investigate\r
-        // deeper for the root of this issue.\r
-        m_activeView->reload();\r
+        DolphinStatusBar* statusBar = m_activeView->statusBar();\r
+        statusBar->setMessage(i18n("Delete operation completed."),\r
+                              DolphinStatusBar::OperationCompleted);\r
     }\r
 }\r
 \r
     }\r
 }\r
 \r
@@ -1124,7 +1134,7 @@ void DolphinMainWindow::setupDockWidgets()
 void DolphinMainWindow::updateHistory()\r
 {\r
     int index = 0;\r
 void DolphinMainWindow::updateHistory()\r
 {\r
     int index = 0;\r
-    const Q3ValueList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);\r
+    const QLinkedList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);\r
 \r
     QAction* backAction = actionCollection()->action("go_back");\r
     if (backAction != 0) {\r
 \r
     QAction* backAction = actionCollection()->action("go_back");\r
     if (backAction != 0) {\r
index 2f1474224176964f3314f7b9f168b3a6f3bda0c9..804192aa4ca99d94ab2843e26d40aa7b781cfeab 100644 (file)
@@ -324,24 +324,6 @@ private slots:
     /** Open a new main window. */
     void openNewMainWindow();
 
     /** Open a new main window. */
     void openNewMainWindow();
 
-    /**
-     * Moves the items indicated by m_droppedUrls to the URL
-     * m_destination.
-     */
-    void moveDroppedItems();
-
-    /**
-     * Copies the items indicated by m_droppedUrls to the URL
-     * m_destination.
-     */
-    void copyDroppedItems();
-
-    /**
-     * Links the items indicated by m_droppedUrls to the URL
-     * m_destination.
-     */
-    void linkDroppedItems();
-
 private:
     DolphinMainWindow();
     void init();
 private:
     DolphinMainWindow();
     void init();
@@ -371,9 +353,6 @@ private:
     QSplitter* m_splitter;
     DolphinView* m_activeView;
 
     QSplitter* m_splitter;
     DolphinView* m_activeView;
 
-    KUrl m_dropDestination;
-    KUrl::List m_droppedUrls;
-
     /**
      * DolphinMainWindowsupports only one or two views, which
      * are handled internally as primary and secondary view.
     /**
      * DolphinMainWindowsupports only one or two views, which
      * are handled internally as primary and secondary view.