┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugene Popov <[email protected]>2023-04-21 15:15:31 +0300
committerMéven Car <[email protected]>2023-04-23 09:33:09 +0000
commit78a3cd3e4bc75fc299a6b05b266bdd58fe7f8dcf (patch)
treef8b7a6c0bebb56513f482c7400205990468d25a8 /src
parenta9f2abeea4908ebd343a79962087e4ea0d6b1cca (diff)
Improve copying and moving items between panels
Currently, copying the selected items between panels is performed by the active panel, which is wrong, because the inactive panel cannot select the copied items after the operation is completed (as it happens when drag'n'dropping or copying using keyboard shortcuts).
Diffstat (limited to 'src')
-rw-r--r--src/dolphintabwidget.cpp36
-rw-r--r--src/views/dolphinview.cpp16
2 files changed, 38 insertions, 14 deletions
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index bb3680f58..9ee80160a 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -325,36 +325,44 @@ void DolphinTabWidget::restoreClosedTab(const QByteArray &state)
void DolphinTabWidget::copyToInactiveSplitView()
{
- const DolphinTabPage *tabPage = tabPageAt(currentIndex());
- DolphinViewContainer *activeViewContainer = currentTabPage()->activeViewContainer();
- if (!tabPage->splitViewEnabled() || activeViewContainer->view()->selectedItems().isEmpty()) {
+ const DolphinTabPage *tabPage = currentTabPage();
+ if (!tabPage->splitViewEnabled()) {
return;
}
+ const KFileItemList selectedItems = tabPage->activeViewContainer()->view()->selectedItems();
+ if (selectedItems.isEmpty()) {
+ return;
+ }
+
+ DolphinView *inactiveView;
if (tabPage->primaryViewActive()) {
- // copy from left panel to right
- activeViewContainer->view()->copySelectedItems(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
+ inactiveView = tabPage->secondaryViewContainer()->view();
} else {
- // copy from right panel to left
- activeViewContainer->view()->copySelectedItems(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
+ inactiveView = tabPage->primaryViewContainer()->view();
}
+ inactiveView->copySelectedItems(selectedItems, inactiveView->url());
}
void DolphinTabWidget::moveToInactiveSplitView()
{
- const DolphinTabPage *tabPage = tabPageAt(currentIndex());
- DolphinViewContainer *activeViewContainer = currentTabPage()->activeViewContainer();
- if (!tabPage->splitViewEnabled() || activeViewContainer->view()->selectedItems().isEmpty()) {
+ const DolphinTabPage *tabPage = currentTabPage();
+ if (!tabPage->splitViewEnabled()) {
+ return;
+ }
+
+ const KFileItemList selectedItems = tabPage->activeViewContainer()->view()->selectedItems();
+ if (selectedItems.isEmpty()) {
return;
}
+ DolphinView *inactiveView;
if (tabPage->primaryViewActive()) {
- // move from left panel to right
- activeViewContainer->view()->moveSelectedItems(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
+ inactiveView = tabPage->secondaryViewContainer()->view();
} else {
- // move from right panel to left
- activeViewContainer->view()->moveSelectedItems(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
+ inactiveView = tabPage->primaryViewContainer()->view();
}
+ inactiveView->moveSelectedItems(selectedItems, inactiveView->url());
}
void DolphinTabWidget::detachTab(int index)
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 66b6c23a8..b33353e3a 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -814,6 +814,14 @@ void DolphinView::copySelectedItemsToClipboard()
void DolphinView::copySelectedItems(const KFileItemList &selection, const QUrl &destinationUrl)
{
+ if (selection.isEmpty() || !destinationUrl.isValid()) {
+ return;
+ }
+
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ m_selectJobCreatedItems = true;
+
KIO::CopyJob *job = KIO::copy(selection.urlList(), destinationUrl, KIO::DefaultFlags);
KJobWidgets::setWindow(job, this);
@@ -825,6 +833,14 @@ void DolphinView::copySelectedItems(const KFileItemList &selection, const QUrl &
void DolphinView::moveSelectedItems(const KFileItemList &selection, const QUrl &destinationUrl)
{
+ if (selection.isEmpty() || !destinationUrl.isValid()) {
+ return;
+ }
+
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ m_selectJobCreatedItems = true;
+
KIO::CopyJob *job = KIO::move(selection.urlList(), destinationUrl, KIO::DefaultFlags);
KJobWidgets::setWindow(job, this);