Fix DND MTP Bug

Summary:
Bug Description: DND from mtp:// mounted folders do not work. DND of local files works, though.
	 Patched src/foldermodel.cpp by hand. Had a nice cpp exercise. XD

Test Plan: Test if DND from mtp:// mounted folders works or not.

Reviewers: tsimonq2, wxl

Reviewed By: tsimonq2, wxl

Subscribers: kc2bez

Maniphest Tasks: T99

Differential Revision: https://phab.lubuntu.me/D32
ubuntu/eoan
Raman Sarda 5 years ago committed by Walter Lapchynski
parent faec7ee9c2
commit 3663fb0ed1

6
debian/changelog vendored

@ -1,3 +1,9 @@
libfm-qt (0.14.1-9ubuntu3) eoan; urgency=medium
* Fixed DND not working for mtp:// mounted folders
-- Raman Sarda <theloudspeaker@lubuntu.me> Sat, 17 Aug 2019 10:11:52 +0530
libfm-qt (0.14.1-9ubuntu2) eoan; urgency=medium libfm-qt (0.14.1-9ubuntu2) eoan; urgency=medium
* Rebuild against Qt 5.12.4. * Rebuild against Qt 5.12.4.

@ -0,0 +1,48 @@
Description: Fix DND for MTP mounted folders
Author: Tsu Jan <tsujan2000@gmail.com>
Bug-Upstream: https://github.com/lxqt/pcmanfm-qt/issues/301
Applied-Upstream: https://github.com/lxqt/libfm-qt/commit/7de18bc89b9b47f66de54a7e347bf8d391d44a48
Last-Update: 2019-08-17
--- a/src/foldermodel.cpp
+++ b/src/foldermodel.cpp
@@ -384,7 +384,7 @@ QStringList FolderModel::mimeTypes() con
// the real implementation is in FolderView::childDropEvent().
types << "XdndDirectSave0";
types << "text/uri-list";
- // types << "x-special/gnome-copied-files";
+ types << QStringLiteral("libfm/files"); // see FolderModel::mimeData() below
return types;
}
@@ -407,6 +407,9 @@ QMimeData* FolderModel::mimeData(const Q
}
}
data->setData("text/uri-list", urilist);
+ // NOTE: The mimetype "text/uri-list" changes the list in QMimeData::setData() to get URLs
+ // but some protocols (like MTP) may need the original list to query file info.
+ data->setData(QStringLiteral("libfm/files"), urilist);
return data;
}
@@ -442,10 +445,19 @@ bool FolderModel::dropMimeData(const QMi
destPath = path();
}
+ Fm::FilePathList srcPaths;
+ // try to get paths from the original data
+ if(data->hasFormat(QStringLiteral("libfm/files"))) {
+ QByteArray _data = data->data(QStringLiteral("libfm/files"));
+ srcPaths = pathListFromUriList(_data.data());
+ }
+ if(srcPaths.empty() && data->hasUrls()) {
+ srcPaths = Fm::pathListFromQUrls(data->urls());
+ }
+
// FIXME: should we put this in dropEvent handler of FolderView instead?
- if(data->hasUrls()) {
+ if(!srcPaths.empty()) {
//qDebug("drop action: %d", action);
- auto srcPaths = pathListFromQUrls(data->urls());
switch(action) {
case Qt::CopyAction:
FileOperation::copyFiles(srcPaths, destPath);

@ -4,3 +4,4 @@ fix-license-headers.patch
dont-ignore-crea-del-sequences.patch dont-ignore-crea-del-sequences.patch
workaround-glib-recursive-moving-error.patch workaround-glib-recursive-moving-error.patch
workaround-missed-file-monitoring.patch workaround-missed-file-monitoring.patch
fix-dnd-mtp.patch

Loading…
Cancel
Save