#include <kio/previewjob.h>
#include <kjob.h>
#include <kmenu.h>
+#include <kmessagebox.h>
#include <kmimetyperesolver.h>
#include <konq_operations.h>
#include <konqmimedata.h>
const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
- // per default the pasting is done into the current Url of the view
- KUrl destUrl(url());
+ // per default the pasting is done into the current URL of the view
+ KUrl destUrl = url();
// check whether the pasting should be done into a selected directory
const KUrl::List selectedUrls = this->selectedUrls();
// only one item is selected which is a directory, hence paste
// into this directory
destUrl = selectedUrls.first();
+ if (sourceUrls.contains(destUrl)) {
+ const QString text = i18nc("@info", "The folder <filename>%1</filename> is pasted into itself. Is this intended?", fileItem.name());
+ int result = KMessageBox::questionYesNo(window(),
+ text,
+ i18nc("@title:window", "Paste into Folder"),
+ KGuiItem(i18nc("@label", "Paste"), "dialog-ok"),
+ KGuiItem(i18nc("@label", "Cancel"), "dialog-cancel"));
+ if (result == KMessageBox::No) {
+ return;
+ }
+ }
}
}
KUrl::List urls = KUrl::List::fromMimeData(mimeData);
if (!urls.isEmpty()) {
ret.first = true;
- ret.second = i18ncp("@action:inmenu", "Paste One File", "Paste %1 Files", urls.count());
+ if (urls.count() == 1) {
+ const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(), true);
+ ret.second = item.isDir() ? i18nc("@action:inmenu", "Paste One Folder") :
+ i18nc("@action:inmenu", "Paste One File");
+
+ } else {
+ ret.second = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count());
+ }
} else {
ret.first = false;
ret.second = i18nc("@action:inmenu", "Paste");