┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/dolphinview.cpp
diff options
context:
space:
mode:
authorEugene Popov <[email protected]>2023-12-28 12:06:09 +0200
committerMéven Car <[email protected]>2024-01-13 08:28:52 +0000
commitc8dffc433caacc9955b3054f6255ae50176e5533 (patch)
treeee4e4a9be6bd8d753fefe999daec5f49470b6455 /src/views/dolphinview.cpp
parent3619e74eb17f8ed2e76dadbef9c052304decd18b (diff)
Always automatically choose a new file name while duplicating
Since now when duplicating items we automatically generate a name for the new item, we can do the same if an item with that name already exists. BUG: 475410
Diffstat (limited to 'src/views/dolphinview.cpp')
-rw-r--r--src/views/dolphinview.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index d51ed0e06..6b77a46ea 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -863,9 +863,12 @@ void DolphinView::duplicateSelectedItems()
const QMimeDatabase db;
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ m_selectJobCreatedItems = true;
+
// Duplicate all selected items and append "copy" to the end of the file name
// but before the filename extension, if present
- QList<QUrl> newSelection;
for (const auto &item : itemList) {
const QUrl originalURL = item.url();
const QString originalDirectoryPath = originalURL.adjusted(QUrl::RemoveFilename).path();
@@ -890,15 +893,14 @@ void DolphinView::duplicateSelectedItems()
}
KIO::CopyJob *job = KIO::copyAs(originalURL, duplicateURL);
+ job->setAutoRename(true);
KJobWidgets::setWindow(job, this);
- if (job) {
- newSelection << duplicateURL;
- KIO::FileUndoManager::self()->recordCopyJob(job);
- }
+ connect(job, &KIO::CopyJob::result, this, &DolphinView::slotJobResult);
+ connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotItemCreatedFromJob);
+ connect(job, &KIO::CopyJob::copyingLinkDone, this, &DolphinView::slotItemLinkCreatedFromJob);
+ KIO::FileUndoManager::self()->recordCopyJob(job);
}
-
- forceUrlsSelection(newSelection.first(), newSelection);
}
void DolphinView::stopLoading()
@@ -1422,6 +1424,11 @@ void DolphinView::slotItemCreatedFromJob(KIO::Job *, const QUrl &, const QUrl &t
slotItemCreated(to);
}
+void DolphinView::slotItemLinkCreatedFromJob(KIO::Job *, const QUrl &, const QString &, const QUrl &to)
+{
+ slotItemCreated(to);
+}
+
void DolphinView::slotItemCreated(const QUrl &url)
{
if (m_markFirstNewlySelectedItemAsCurrent) {