diff --git a/src/core/pastehelper.cpp b/src/core/pastehelper.cpp --- a/src/core/pastehelper.cpp +++ b/src/core/pastehelper.cpp @@ -216,7 +216,7 @@ } } -bool PasteHelper::canPaste(const QMimeData *mimeData, const Collection &collection) +bool PasteHelper::canPaste(const QMimeData *mimeData, const Collection &collection, Qt::DropAction action) { if (!mimeData || !collection.isValid()) { return false; @@ -230,7 +230,11 @@ for (const QUrl &url : urls) { const QUrlQuery query(url); if (query.hasQueryItem(QStringLiteral("item"))) { - neededRights |= Collection::CanCreateItem; + if (action == Qt::LinkAction) { + neededRights |= Collection::CanLinkItem; + } else { + neededRights |= Collection::CanCreateItem; + } } else if (query.hasQueryItem(QStringLiteral("collection"))) { neededRights |= Collection::CanCreateCollection; } @@ -267,9 +271,9 @@ return false; } -KJob *PasteHelper::paste(const QMimeData *mimeData, const Collection &collection, bool copy, Session *session) +KJob *PasteHelper::paste(const QMimeData *mimeData, const Collection &collection, Qt::DropAction action, Session *session) { - if (!canPaste(mimeData, collection)) { + if (!canPaste(mimeData, collection, action)) { return nullptr; } @@ -300,16 +304,16 @@ } // data contains an url list - return pasteUriList(mimeData, collection, copy ? Qt::CopyAction : Qt::MoveAction, session); + return pasteUriList(mimeData, collection, action, session); } KJob *PasteHelper::pasteUriList(const QMimeData *mimeData, const Collection &destination, Qt::DropAction action, Session *session) { if (!mimeData->hasUrls()) { return nullptr; } - if (!canPaste(mimeData, destination)) { + if (!canPaste(mimeData, destination, action)) { return nullptr; } diff --git a/src/core/pastehelper_p.h b/src/core/pastehelper_p.h --- a/src/core/pastehelper_p.h +++ b/src/core/pastehelper_p.h @@ -45,17 +45,18 @@ Check whether the given mime data can be pasted into the given collection. @param mimeData The pasted/dropped data. @param collection The collection to paste/drop into. + @param action Indicate whether this is a copy, a move or link. */ -AKONADICORE_EXPORT bool canPaste(const QMimeData *mimeData, const Collection &collection); +AKONADICORE_EXPORT bool canPaste(const QMimeData *mimeData, const Collection &collection, Qt::DropAction action); /** Paste/drop the given mime data into the given collection. @param mimeData The pasted/dropped data. @param collection The target collection. - @param copy Indicate whether this is a copy or a move. + @param action Indicate whether this is a copy, a move or link. @returns The job performing the paste, 0 if there is nothing to paste. */ -AKONADICORE_EXPORT KJob *paste(const QMimeData *mimeData, const Collection &collection, bool copy = true, Session *session = nullptr); +AKONADICORE_EXPORT KJob *paste(const QMimeData *mimeData, const Collection &collection, Qt::DropAction action, Session *session = nullptr); /** URI list paste/drop. diff --git a/src/widgets/actionstatemanager.cpp b/src/widgets/actionstatemanager.cpp --- a/src/widgets/actionstatemanager.cpp +++ b/src/widgets/actionstatemanager.cpp @@ -226,7 +226,7 @@ collectionsAreFolders); // it must be a valid folder collection #ifndef QT_NO_CLIPBOARD enableAction(StandardActionManager::Paste, singleCollectionSelected && // we can paste only into a single collection - PasteHelper::canPaste(QApplication::clipboard()->mimeData(), collection)); // there must be data on the clipboard + PasteHelper::canPaste(QApplication::clipboard()->mimeData(), collection, Qt::CopyAction)); // there must be data on the clipboard #else enableAction(StandardActionManager::Paste, false); // no support for clipboard -> no paste #endif