/*************************************************************************** * Copyright (C) 2007-2011 by Peter Penz * * Copyright (C) 2007 by David Faure * * * * 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 "draganddrophelper.h" #include #include #include #include #include #include #include QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event) { Q_ASSERT(!destItem.isNull()); const KUrl destination = destItem.url(); if (!destItem.isWritable()) { return i18nc("@info:status", "Access denied. Could not write to %1", destination.pathOrUrl()); } const QMimeData* mimeData = event->mimeData(); if (mimeData->hasFormat("application/x-kde-dndextract")) { const QString remoteDBusClient = mimeData->data("application/x-kde-dndextract"); QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, "/DndExtract", "org.kde.DndExtract", "extractSelectedFilesTo"); message.setArguments(QVariantList() << destination.pathOrUrl()); QDBusConnection::sessionBus().call(message); } else { const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); foreach (const KUrl& url, urls) { if (url == destination) { return i18nc("@info:status", "A folder cannot be dropped into itself"); } } KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow()); } return QString(); }