* Move code which checks whether the dragging of a MIME type is supported to DragAndDropHelper. This allows adding an improved support for dropping compressed files from Ark to Dolphin later...
CCMAIL: haraldhv@stud.ntnu.no
svn path=/trunk/KDE/kdebase/apps/; revision=875611
dolphiniconsview.cpp
dolphincolumnview.cpp
dolphincolumnwidget.cpp
- dolphindropcontroller.cpp
dolphinfileitemdelegate.cpp
dolphinmodel.cpp
dolphinsettings.cpp
void DolphinColumnWidget::dragEnterEvent(QDragEnterEvent* event)
{
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::isMimeDataSupported(event->mimeData())) {
event->acceptProposedAction();
}
}
}
setDirtyRegion(m_dropRect);
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::isMimeDataSupported(event->mimeData())) {
// accept url drops, independently from the destination item
event->acceptProposedAction();
}
void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
{
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::isMimeDataSupported(event->mimeData())) {
event->acceptProposedAction();
}
setDirtyRegion(m_dropRect);
}
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::isMimeDataSupported(event->mimeData())) {
// accept url drops, independently from the destination item
event->acceptProposedAction();
}
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
- * Copyright (C) 2007 by David Faure <faure@kde.org> *
- * *
- * 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 *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
-
-#include "dolphindropcontroller.h"
-#include <kfileitem.h>
-#include <konq_operations.h>
-
-void DolphinDropController::dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event,
- QWidget* widget)
-{
- const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
- const KUrl destination = dropToItem ? destItem.url() : destPath;
-
- const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- const KUrl sourceDir = KUrl(urls.first().directory());
- if (sourceDir != destination) {
- if (dropToItem) {
- KonqOperations::doDrop(destItem, destination, event, widget);
- } else {
- KonqOperations::doDrop(KFileItem(), destination, event, widget);
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2007 by David Faure <faure@kde.org> *
- * *
- * 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 *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
-
-#ifndef DOLPHINDROPCONTROLLER_H
-#define DOLPHINDROPCONTROLLER_H
-
-#include "libdolphin_export.h"
-
-class QDropEvent;
-class QWidget;
-class KUrl;
-class KFileItem;
-
-/**
- * @brief Handler for drop events, shared between DolphinView and TreeViewSidebarPage
- */
-class LIBDOLPHINPRIVATE_EXPORT DolphinDropController
-{
-public:
- /**
- * Handles the dropping of URLs to the given
- * destination. A context menu with the options
- * 'Move Here', 'Copy Here', 'Link Here' and
- * 'Cancel' is offered to the user.
- * @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.
- */
- static void dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event,
- QWidget* widget);
-};
-
-#endif // DOLPHINDROPCONTROLLER_H
***************************************************************************/
#include "dolphinfileplacesview.h"
-#include "dolphindropcontroller.h"
+#include "draganddrophelper.h"
#include <kfileitem.h>
#include <konq_operations.h>
void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
- DolphinDropController::dropUrls(KFileItem(), dest, event, parent);
+ DragAndDropHelper::dropUrls(KFileItem(), dest, event, parent);
}
void DolphinFilePlacesView::emitExtendedUrlChangedSignal(const KUrl& url)
void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
{
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::isMimeDataSupported(event->mimeData())) {
event->acceptProposedAction();
}
}
m_dropRect.setSize(QSize()); // set as invalid
}
}
- if (event->mimeData()->hasUrls()) {
+ if (DragAndDropHelper::isMimeDataSupported(event->mimeData())) {
// accept url drops, independently from the destination item
event->acceptProposedAction();
}
#include "dolphinmainwindow.h"
#include "dolphinviewactionhandler.h"
-#include "dolphindropcontroller.h"
#include <config-nepomuk.h>
#include <ktoggleaction.h>
#include <kurl.h>
-#include "dolphindropcontroller.h"
#include "dolphinmodel.h"
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
#include "dolphiniconsview.h"
#include "dolphinsettings.h"
#include "dolphin_generalsettings.h"
+#include "draganddrophelper.h"
#include "folderexpander.h"
#include "renamedialog.h"
#include "tooltipmanager.h"
const KUrl& destPath,
QDropEvent* event)
{
- DolphinDropController::dropUrls(destItem, destPath, event, this);
+ DragAndDropHelper::dropUrls(destItem, destPath, event, this);
}
void DolphinView::updateSorting(DolphinView::Sorting sorting)
#include "dolphinmodel.h"
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
-#include "dolphindropcontroller.h"
#include "dolphinstatusbar.h"
#include "dolphinmainwindow.h"
#include "dolphindirlister.h"
#include "dolphindetailsview.h"
#include "dolphiniconsview.h"
#include "dolphincontextmenu.h"
+#include "draganddrophelper.h"
#include "filterbar.h"
#include "kurlnavigator.h"
#include "viewproperties.h"
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
{
- DolphinDropController::dropUrls(KFileItem(), destination, event, this);
+ DragAndDropHelper::dropUrls(KFileItem(), destination, event, this);
}
void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
/***************************************************************************
* Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
- * *
+ * Copyright (C) 2007 by David Faure <faure@kde.org> * * *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
#include "dolphincontroller.h"
#include <kdirmodel.h>
+#include <kfileitem.h>
#include <kicon.h>
+#include <konq_operations.h>
#include <QAbstractItemView>
#include <QAbstractProxyModel>
#include <QDrag>
+bool DragAndDropHelper::isMimeDataSupported(const QMimeData* mimeData)
+{
+ return mimeData->hasUrls() || mimeData->hasFormat("application/x-kde-dndextract");
+}
+
void DragAndDropHelper::startDrag(QAbstractItemView* itemView,
Qt::DropActions supportedActions,
DolphinController* controller)
drag->exec(supportedActions, Qt::IgnoreAction);
}
}
+
+void DragAndDropHelper::dropUrls(const KFileItem& destItem,
+ const KUrl& destPath,
+ QDropEvent* event,
+ QWidget* widget)
+{
+ const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
+ const KUrl destination = dropToItem ? destItem.url() : destPath;
+
+ const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+ const KUrl sourceDir = KUrl(urls.first().directory());
+ if (sourceDir != destination) {
+ if (dropToItem) {
+ KonqOperations::doDrop(destItem, destination, event, widget);
+ } else {
+ KonqOperations::doDrop(KFileItem(), destination, event, widget);
+ }
+ }
+}
/***************************************************************************
* Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
- * *
+ * Copyright (C) 2007 by David Faure <faure@kde.org> * * *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
#include <QtCore/Qt>
class DolphinController;
+class KFileItem;
+class KUrl;
+class QDropEvent;
+class QMimeData;
class QAbstractItemView;
class QBrush;
class QRect;
{
public:
+ /**
+ * Returns true, if Dolphin supports the dragging of
+ * the given mime data.
+ */
+ static bool isMimeDataSupported(const QMimeData* mimeData);
+
/**
* Creates a drag object for the view \a itemView for all selected items.
*/
static void startDrag(QAbstractItemView* itemView,
Qt::DropActions supportedActions,
DolphinController* controller = 0);
+
+ /**
+ * Handles the dropping of URLs to the given
+ * destination. A context menu with the options
+ * 'Move Here', 'Copy Here', 'Link Here' and
+ * 'Cancel' is offered to the user.
+ * @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.
+ */
+ static void dropUrls(const KFileItem& destItem,
+ const KUrl& destPath,
+ QDropEvent* event,
+ QWidget* widget);
};
#endif
#include "treeviewsidebarpage.h"
-#include "dolphindropcontroller.h"
#include "dolphinmodel.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
#include "dolphinsettings.h"
#include "dolphin_folderspanelsettings.h"
#include "dolphin_generalsettings.h"
+#include "draganddrophelper.h"
#include "folderexpander.h"
#include "renamedialog.h"
#include "sidebartreeview.h"
KFileItem item = m_dolphinModel->itemForIndex(dirIndex);
Q_ASSERT(!item.isNull());
if (item.isDir()) {
- DolphinDropController::dropUrls(item, item.url(), event, this);
+ DragAndDropHelper::dropUrls(item, item.url(), event, this);
}
}
}