diff options
| author | Kai Uwe Broulik <[email protected]> | 2022-04-07 21:41:43 +0200 |
|---|---|---|
| committer | Kai Uwe Broulik <[email protected]> | 2022-04-11 18:01:51 +0200 |
| commit | 0c7f7c92ed961ce46a7b42aeeb1c30070c95ae17 (patch) | |
| tree | 82dabd76e9ab21f0d2c24b9aaef8bcad0b12c25b /src/dolphinplacesmodelsingleton.cpp | |
| parent | 3bf471e02a440bd008d69c5939b7c5bf2c03df54 (diff) | |
[Places Panel] Support drag and drop from Ark
Accepts Ark's special dnd mime types so that archive contents can
be dragged onto a place to extract and/or (mount and) switch to the
hovered location.
Diffstat (limited to 'src/dolphinplacesmodelsingleton.cpp')
| -rw-r--r-- | src/dolphinplacesmodelsingleton.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dolphinplacesmodelsingleton.cpp b/src/dolphinplacesmodelsingleton.cpp index c31ffc4c3..258be155b 100644 --- a/src/dolphinplacesmodelsingleton.cpp +++ b/src/dolphinplacesmodelsingleton.cpp @@ -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) { |
