]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinviewcontroller.cpp
Update e-mail address from peter.penz@gmx.at to peter.penz19@gmail.com
[dolphin.git] / src / views / dolphinviewcontroller.cpp
index 6ef32f07fc3b86782e816003052495e5d717e78e..f8f27ea382099ee4eb89c8587370d294a9d89cca 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>
@@ -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,9 @@ QList<QAction*> DolphinViewController::versionControlActions(const KFileItemList
 
 void DolphinViewController::handleKeyPressEvent(QKeyEvent* event)
 {
-    Q_ASSERT(m_itemView != 0);
+    if (m_itemView == 0) {
+        return;
+    }
 
     const QItemSelectionModel* selModel = m_itemView->selectionModel();
     const QModelIndex currentIndex = selModel->currentIndex();
@@ -194,12 +194,16 @@ void DolphinViewController::emitItemTriggered(const KFileItem& item)
 
 KFileItem DolphinViewController::itemForIndex(const QModelIndex& index) const
 {
-    Q_ASSERT(m_itemView != 0);
+    if (m_itemView != 0) {
+        QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(m_itemView->model());
+        if (proxyModel != 0) {
+            KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
+            const QModelIndex dirIndex = proxyModel->mapToSource(index);
+            return dirModel->itemForIndex(dirIndex);
+        }
+    }
 
-    QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(m_itemView->model());
-    KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
-    const QModelIndex dirIndex = proxyModel->mapToSource(index);
-    return dirModel->itemForIndex(dirIndex);
+    return KFileItem();
 }
 
 void DolphinViewController::triggerItem(const QModelIndex& index)
@@ -208,7 +212,7 @@ void DolphinViewController::triggerItem(const QModelIndex& index)
         const KFileItem item = itemForIndex(index);
         if (index.isValid() && (index.column() == KDirModel::Name)) {
             emit itemTriggered(item);
-        } else {
+        } else if (m_itemView != 0) {
             m_itemView->clearSelection();
             emit itemEntered(KFileItem());
         }