mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 00:11:21 +00:00
Fix drag & drop issues with non-local URLs
BUG: 292821 BUG: 292355 FIXED-IN: 4.8.1
This commit is contained in:
parent
0a33aad3d2
commit
1d7088b1ad
|
@ -1330,7 +1330,7 @@ void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event)
|
||||||
const ViewTab& viewTab = m_viewTab[tab];
|
const ViewTab& viewTab = m_viewTab[tab];
|
||||||
const DolphinView* view = viewTab.isPrimaryViewActive ? viewTab.primaryView->view()
|
const DolphinView* view = viewTab.isPrimaryViewActive ? viewTab.primaryView->view()
|
||||||
: viewTab.secondaryView->view();
|
: viewTab.secondaryView->view();
|
||||||
DragAndDropHelper::dropUrls(view->rootItem(), event);
|
DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -538,8 +538,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
|
||||||
|
|
||||||
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
|
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
|
||||||
{
|
{
|
||||||
const KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, destination);
|
DragAndDropHelper::dropUrls(KFileItem(), destination, event);
|
||||||
DragAndDropHelper::dropUrls(destItem, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
|
void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
|
||||||
|
|
|
@ -263,11 +263,7 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve
|
||||||
KFileItemModel* model = fileItemModel();
|
KFileItemModel* model = fileItemModel();
|
||||||
KFileItem destItem = model->fileItem(index);
|
KFileItem destItem = model->fileItem(index);
|
||||||
if (destItem.isNull()) {
|
if (destItem.isNull()) {
|
||||||
destItem = model->rootItem();
|
return;
|
||||||
if (destItem.isNull()) {
|
|
||||||
kWarning() << "No destination item available for drop operation.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDropEvent dropEvent(event->pos().toPoint(),
|
QDropEvent dropEvent(event->pos().toPoint(),
|
||||||
|
@ -276,7 +272,7 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve
|
||||||
event->buttons(),
|
event->buttons(),
|
||||||
event->modifiers());
|
event->modifiers());
|
||||||
|
|
||||||
DragAndDropHelper::dropUrls(destItem, &dropEvent);
|
DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ void PlacesPanel::mousePressEvent(QMouseEvent* event)
|
||||||
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
|
void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
const KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, dest);
|
DragAndDropHelper::dropUrls(KFileItem(), dest, event);
|
||||||
DragAndDropHelper::dropUrls(destItem, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url)
|
void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl& url)
|
||||||
|
|
|
@ -809,13 +809,13 @@ void DolphinView::slotItemUnhovered(int index)
|
||||||
|
|
||||||
void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
|
void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
|
||||||
{
|
{
|
||||||
|
KUrl destUrl;
|
||||||
KFileItem destItem = fileItemModel()->fileItem(index);
|
KFileItem destItem = fileItemModel()->fileItem(index);
|
||||||
if (destItem.isNull()) {
|
if (destItem.isNull()) {
|
||||||
destItem = fileItemModel()->rootItem();
|
destItem = fileItemModel()->rootItem();
|
||||||
if (destItem.isNull()) {
|
destUrl = url();
|
||||||
kWarning() << "No destination item available for drop operation.";
|
} else {
|
||||||
return;
|
destUrl = destItem.url();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDropEvent dropEvent(event->pos().toPoint(),
|
QDropEvent dropEvent(event->pos().toPoint(),
|
||||||
|
@ -824,7 +824,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
|
||||||
event->buttons(),
|
event->buttons(),
|
||||||
event->modifiers());
|
event->modifiers());
|
||||||
|
|
||||||
const QString error = DragAndDropHelper::dropUrls(destItem, &dropEvent);
|
const QString error = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent);
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
emit errorMessage(error);
|
emit errorMessage(error);
|
||||||
}
|
}
|
||||||
|
@ -959,12 +959,7 @@ bool DolphinView::hasSelection() const
|
||||||
|
|
||||||
KFileItem DolphinView::rootItem() const
|
KFileItem DolphinView::rootItem() const
|
||||||
{
|
{
|
||||||
KFileItem item = m_dirLister->rootItem();
|
return m_dirLister->rootItem();
|
||||||
if (item.isNull()) {
|
|
||||||
// The directory has not been loaded yet
|
|
||||||
item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url());
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::observeCreatedItem(const KUrl& url)
|
void DolphinView::observeCreatedItem(const KUrl& url)
|
||||||
|
|
|
@ -28,13 +28,10 @@
|
||||||
#include <QtDBus>
|
#include <QtDBus>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
|
|
||||||
QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event)
|
QString DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!destItem.isNull());
|
if (!destItem.isNull() && !destItem.isWritable()) {
|
||||||
|
return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
|
||||||
const KUrl destination = destItem.url();
|
|
||||||
if (!destItem.isWritable()) {
|
|
||||||
return i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destination.pathOrUrl());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMimeData* mimeData = event->mimeData();
|
const QMimeData* mimeData = event->mimeData();
|
||||||
|
@ -42,17 +39,17 @@ QString DragAndDropHelper::dropUrls(const KFileItem& destItem, QDropEvent* event
|
||||||
const QString remoteDBusClient = mimeData->data("application/x-kde-dndextract");
|
const QString remoteDBusClient = mimeData->data("application/x-kde-dndextract");
|
||||||
QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, "/DndExtract",
|
QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, "/DndExtract",
|
||||||
"org.kde.DndExtract", "extractSelectedFilesTo");
|
"org.kde.DndExtract", "extractSelectedFilesTo");
|
||||||
message.setArguments(QVariantList() << destination.pathOrUrl());
|
message.setArguments(QVariantList() << destUrl.pathOrUrl());
|
||||||
QDBusConnection::sessionBus().call(message);
|
QDBusConnection::sessionBus().call(message);
|
||||||
} else {
|
} else {
|
||||||
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
|
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
|
||||||
foreach (const KUrl& url, urls) {
|
foreach (const KUrl& url, urls) {
|
||||||
if (url == destination) {
|
if (url == destUrl) {
|
||||||
return i18nc("@info:status", "A folder cannot be dropped into itself");
|
return i18nc("@info:status", "A folder cannot be dropped into itself");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KonqOperations::doDrop(destItem, destination, event, QApplication::activeWindow());
|
KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
@ -38,12 +38,19 @@ public:
|
||||||
* destination. A context menu with the options
|
* destination. A context menu with the options
|
||||||
* 'Move Here', 'Copy Here', 'Link Here' and
|
* 'Move Here', 'Copy Here', 'Link Here' and
|
||||||
* 'Cancel' is offered to the user.
|
* 'Cancel' is offered to the user.
|
||||||
* @param destItem Item of the destination.
|
* @param destItem Item of the destination. Can be 0 (KFileItem::isNull()) if
|
||||||
|
* no file-item is available for the destination. In this case
|
||||||
|
* destUrl is used as fallback. For performance reasons it is
|
||||||
|
* recommended to pass a file-item if available.
|
||||||
|
* @param destUrl URL of the item destination. Is used only if destItem::isNull()
|
||||||
|
* is true.
|
||||||
* @param event Drop event.
|
* @param event Drop event.
|
||||||
* @return Error message if dropping is not possible. If an empty string
|
* @return Error message if dropping is not possible. If an empty string
|
||||||
* is returned, the dropping has been successful.
|
* is returned, the dropping has been successful.
|
||||||
*/
|
*/
|
||||||
static QString dropUrls(const KFileItem& destItem, QDropEvent* event);
|
static QString dropUrls(const KFileItem& destItem,
|
||||||
|
const KUrl& destUrl,
|
||||||
|
QDropEvent* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue