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/D32ubuntu/eoan
parent
faec7ee9c2
commit
3663fb0ed1
@ -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);
|
Loading…
Reference in new issue