/***************************************************************************
- * 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 *
#include "dolphinviewcontroller.h"
#include "zoomlevelinfo.h"
-#include <kdirmodel.h>
-#include <kfileitemactions.h>
+#include <KDirModel>
+#include <KFileItemActions>
#include <QAbstractProxyModel>
#include <QApplication>
#include <QClipboard>
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);
}
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();
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)
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());
}