mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Merge branch 'release/22.04'
This commit is contained in:
commit
d5d710ed0a
|
@ -6,11 +6,13 @@
|
|||
|
||||
#include "dolphinplacesmodelsingleton.h"
|
||||
#include "trash/dolphintrash.h"
|
||||
#include "views/draganddrophelper.h"
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KFilePlacesModel>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QMimeData>
|
||||
|
||||
DolphinPlacesModel::DolphinPlacesModel(const QString &alternativeApplicationName, QObject *parent)
|
||||
: KFilePlacesModel(alternativeApplicationName, parent)
|
||||
|
@ -47,6 +49,25 @@ void DolphinPlacesModel::setPanelsLocked(bool locked)
|
|||
}
|
||||
}
|
||||
|
||||
QStringList DolphinPlacesModel::mimeTypes() const
|
||||
{
|
||||
QStringList types = KFilePlacesModel::mimeTypes();
|
||||
types << DragAndDropHelper::arkDndServiceMimeType()
|
||||
<< DragAndDropHelper::arkDndPathMimeType();
|
||||
return types;
|
||||
}
|
||||
|
||||
bool DolphinPlacesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
// We make the view accept the drag by returning them from mimeTypes()
|
||||
// but the drop should be handled exclusively by PlacesPanel::slotUrlsDropped
|
||||
if (DragAndDropHelper::isArkDndMimeType(data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return KFilePlacesModel::dropMimeData(data, action, row, column, parent);
|
||||
}
|
||||
|
||||
QVariant DolphinPlacesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
|
|
|
@ -29,6 +29,9 @@ public:
|
|||
bool panelsLocked() const;
|
||||
void setPanelsLocked(bool locked);
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
protected:
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
|
|
|
@ -35,10 +35,9 @@ bool DragAndDropHelper::urlListMatchesUrl(const QList<QUrl>& urls, const QUrl& d
|
|||
KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window)
|
||||
{
|
||||
const QMimeData* mimeData = event->mimeData();
|
||||
if (mimeData->hasFormat(QStringLiteral("application/x-kde-ark-dndextract-service")) &&
|
||||
mimeData->hasFormat(QStringLiteral("application/x-kde-ark-dndextract-path"))) {
|
||||
const QString remoteDBusClient = mimeData->data(QStringLiteral("application/x-kde-ark-dndextract-service"));
|
||||
const QString remoteDBusPath = mimeData->data(QStringLiteral("application/x-kde-ark-dndextract-path"));
|
||||
if (isArkDndMimeType(mimeData)) {
|
||||
const QString remoteDBusClient = mimeData->data(arkDndServiceMimeType());
|
||||
const QString remoteDBusPath = mimeData->data(arkDndPathMimeType());
|
||||
|
||||
QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, remoteDBusPath,
|
||||
QStringLiteral("org.kde.ark.DndExtract"), QStringLiteral("extractSelectedFilesTo"));
|
||||
|
@ -63,3 +62,8 @@ void DragAndDropHelper::clearUrlListMatchesUrlCache()
|
|||
DragAndDropHelper::m_urlListMatchesUrlCache.clear();
|
||||
}
|
||||
|
||||
bool DragAndDropHelper::isArkDndMimeType(const QMimeData *mimeData)
|
||||
{
|
||||
return mimeData->hasFormat(arkDndServiceMimeType())
|
||||
&& mimeData->hasFormat(arkDndPathMimeType());
|
||||
}
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
#include "dolphin_export.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
class QDropEvent;
|
||||
class QMimeData;
|
||||
class QWidget;
|
||||
namespace KIO { class DropJob; }
|
||||
|
||||
|
@ -42,6 +44,13 @@ public:
|
|||
*/
|
||||
static bool urlListMatchesUrl(const QList<QUrl>& urls, const QUrl& destUrl);
|
||||
|
||||
/**
|
||||
* @return True if mimeData contains Ark's drag and drop mime types.
|
||||
*/
|
||||
static bool isArkDndMimeType(const QMimeData *mimeData);
|
||||
static QString arkDndServiceMimeType() { return QStringLiteral("application/x-kde-ark-dndextract-service"); }
|
||||
static QString arkDndPathMimeType() { return QStringLiteral("application/x-kde-ark-dndextract-path"); }
|
||||
|
||||
/**
|
||||
* clear the internal cache.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue