]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinviewcontroller.cpp
Fix Dolphin session management regression
[dolphin.git] / src / views / dolphinviewcontroller.cpp
index 6e2570007e5ec065a81fd4a7d64f124b50f0492e..e182e48c1e5e9feac9cc84867c7b8c682f6f93d1 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2010 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com>             *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -20,8 +20,8 @@
 #include "dolphinviewcontroller.h"
 #include "zoomlevelinfo.h"
 
-#include <kdirmodel.h>
-#include <kfileitemactions.h>
+#include <KDirModel>
+#include <KFileItemActions>
 #include <QAbstractProxyModel>
 #include <QApplication>
 #include <QClipboard>
@@ -53,14 +53,14 @@ void DolphinViewController::requestUrlChange(const KUrl& url)
 
 void DolphinViewController::setItemView(QAbstractItemView* view)
 {
-    if (m_itemView != 0) {
+    if (m_itemView) {
         disconnect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
                    this, SLOT(updateMouseButtonState()));
     }
 
     m_itemView = view;
 
-    if (m_itemView != 0) {
+    if (m_itemView) {
         // TODO: this is a workaround until  Qt-issue 176832 has been fixed
         connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
                 this, SLOT(updateMouseButtonState()));
@@ -84,11 +84,9 @@ void DolphinViewController::requestActivation()
     emit activated();
 }
 
-void DolphinViewController::indicateDroppedUrls(const KFileItem& destItem,
-                                            const KUrl& destPath,
-                                            QDropEvent* event)
+void DolphinViewController::indicateDroppedUrls(const KFileItem& destItem, QDropEvent* event)
 {
-    emit urlsDropped(destItem, destPath, event);
+    emit urlsDropped(destItem, m_dolphinView->url(), event);
 }
 
 
@@ -128,7 +126,7 @@ QList<QAction*> DolphinViewController::versionControlActions(const KFileItemList
 
 void DolphinViewController::handleKeyPressEvent(QKeyEvent* event)
 {
-    if (m_itemView == 0) {
+    if (!m_itemView) {
         return;
     }
 
@@ -141,10 +139,8 @@ void DolphinViewController::handleKeyPressEvent(QKeyEvent* event)
         return;
     }
 
-    // Collect the non-directory files into a list and
-    // call runPreferredApplications for that list.
-    // Several selected directories are opened in separate tabs,
-    // one selected directory will get opened in the view.
+    // Collect selected files and selected directories
+    // as two separate lists.
     QModelIndexList dirQueue;
     const QModelIndexList indexList = selModel->selectedIndexes();
     KFileItemList fileOpenList;
@@ -156,14 +152,20 @@ void DolphinViewController::handleKeyPressEvent(QKeyEvent* event)
         }
     }
 
-    KFileItemActions fileItemActions;
-    fileItemActions.runPreferredApplications(fileOpenList, "DesktopEntryName != 'dolphin'");
+    // Handle selected files
+    if (fileOpenList.count() == 1) {
+        emit itemTriggered(fileOpenList.first());
+    } else {
+        KFileItemActions fileItemActions;
+        fileItemActions.runPreferredApplications(fileOpenList, "DesktopEntryName != 'dolphin'");
+    }
 
-    if (dirQueue.length() == 1) {
-        // open directory in the view
+    // Handle selected directories
+    if (dirQueue.count() == 1) {
+        // Open directory in the view
         emit itemTriggered(itemForIndex(dirQueue[0]));
     } else {
-        // open directories in separate tabs
+        // Open directories in separate tabs
         foreach(const QModelIndex& dir, dirQueue) {
             emit tabRequested(itemForIndex(dir).url());
         }
@@ -196,9 +198,9 @@ void DolphinViewController::emitItemTriggered(const KFileItem& item)
 
 KFileItem DolphinViewController::itemForIndex(const QModelIndex& index) const
 {
-    if (m_itemView != 0) {
+    if (m_itemView) {
         QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(m_itemView->model());
-        if (proxyModel != 0) {
+        if (proxyModel) {
             KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
             const QModelIndex dirIndex = proxyModel->mapToSource(index);
             return dirModel->itemForIndex(dirIndex);
@@ -214,7 +216,7 @@ void DolphinViewController::triggerItem(const QModelIndex& index)
         const KFileItem item = itemForIndex(index);
         if (index.isValid() && (index.column() == KDirModel::Name)) {
             emit itemTriggered(item);
-        } else if (m_itemView != 0) {
+        } else if (m_itemView) {
             m_itemView->clearSelection();
             emit itemEntered(KFileItem());
         }