mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Selects next item in list after delete/trash actions
BUG: 419914 BUG: 181214
This commit is contained in:
parent
b6c280c306
commit
36dfe5795f
|
@ -87,6 +87,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
|
||||||
, m_view(nullptr)
|
, m_view(nullptr)
|
||||||
, m_container(nullptr)
|
, m_container(nullptr)
|
||||||
, m_toolTipManager(nullptr)
|
, m_toolTipManager(nullptr)
|
||||||
|
, m_selectNextItem(false)
|
||||||
, m_selectionChangedTimer(nullptr)
|
, m_selectionChangedTimer(nullptr)
|
||||||
, m_currentItemUrl()
|
, m_currentItemUrl()
|
||||||
, m_scrollToCurrentItem(false)
|
, m_scrollToCurrentItem(false)
|
||||||
|
@ -749,6 +750,7 @@ void DolphinView::trashSelectedItems()
|
||||||
using Iface = KIO::AskUserActionInterface;
|
using Iface = KIO::AskUserActionInterface;
|
||||||
auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Trash, Iface::DefaultConfirmation, this);
|
auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Trash, Iface::DefaultConfirmation, this);
|
||||||
connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
|
connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
|
||||||
|
m_selectNextItem = true;
|
||||||
trashJob->start();
|
trashJob->start();
|
||||||
#else
|
#else
|
||||||
KIO::JobUiDelegate uiDelegate;
|
KIO::JobUiDelegate uiDelegate;
|
||||||
|
@ -770,6 +772,7 @@ void DolphinView::deleteSelectedItems()
|
||||||
using Iface = KIO::AskUserActionInterface;
|
using Iface = KIO::AskUserActionInterface;
|
||||||
auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Delete, Iface::DefaultConfirmation, this);
|
auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Delete, Iface::DefaultConfirmation, this);
|
||||||
connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
|
connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
|
||||||
|
m_selectNextItem = true;
|
||||||
trashJob->start();
|
trashJob->start();
|
||||||
#else
|
#else
|
||||||
KIO::JobUiDelegate uiDelegate;
|
KIO::JobUiDelegate uiDelegate;
|
||||||
|
@ -1389,6 +1392,7 @@ void DolphinView::slotJobResult(KJob *job)
|
||||||
|
|
||||||
void DolphinView::slotSelectionChanged(const KItemSet ¤t, const KItemSet &previous)
|
void DolphinView::slotSelectionChanged(const KItemSet ¤t, const KItemSet &previous)
|
||||||
{
|
{
|
||||||
|
m_selectNextItem = false;
|
||||||
const int currentCount = current.count();
|
const int currentCount = current.count();
|
||||||
const int previousCount = previous.count();
|
const int previousCount = previous.count();
|
||||||
const bool selectionStateChanged = (currentCount == 0 && previousCount > 0) || (currentCount > 0 && previousCount == 0);
|
const bool selectionStateChanged = (currentCount == 0 && previousCount > 0) || (currentCount > 0 && previousCount == 0);
|
||||||
|
@ -1741,6 +1745,7 @@ void DolphinView::slotTwoClicksRenamingTimerTimeout()
|
||||||
void DolphinView::slotTrashFileFinished(KJob *job)
|
void DolphinView::slotTrashFileFinished(KJob *job)
|
||||||
{
|
{
|
||||||
if (job->error() == 0) {
|
if (job->error() == 0) {
|
||||||
|
selectNextItem(); // Fixes BUG: 419914 via selecting next item
|
||||||
Q_EMIT operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
|
Q_EMIT operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
|
||||||
} else if (job->error() != KIO::ERR_USER_CANCELED) {
|
} else if (job->error() != KIO::ERR_USER_CANCELED) {
|
||||||
Q_EMIT errorMessage(job->errorString());
|
Q_EMIT errorMessage(job->errorString());
|
||||||
|
@ -1750,12 +1755,37 @@ void DolphinView::slotTrashFileFinished(KJob *job)
|
||||||
void DolphinView::slotDeleteFileFinished(KJob *job)
|
void DolphinView::slotDeleteFileFinished(KJob *job)
|
||||||
{
|
{
|
||||||
if (job->error() == 0) {
|
if (job->error() == 0) {
|
||||||
|
selectNextItem(); // Fixes BUG: 419914 via selecting next item
|
||||||
Q_EMIT operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
|
Q_EMIT operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
|
||||||
} else if (job->error() != KIO::ERR_USER_CANCELED) {
|
} else if (job->error() != KIO::ERR_USER_CANCELED) {
|
||||||
Q_EMIT errorMessage(job->errorString());
|
Q_EMIT errorMessage(job->errorString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinView::selectNextItem()
|
||||||
|
{
|
||||||
|
if (m_active && m_selectNextItem) {
|
||||||
|
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
|
||||||
|
if (selectedItems().isEmpty()) {
|
||||||
|
Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto lastSelectedIndex = m_model->index(selectedItems().last());
|
||||||
|
if (lastSelectedIndex < 0) {
|
||||||
|
Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto nextItem = lastSelectedIndex + 1;
|
||||||
|
if (nextItem >= itemsCount()) {
|
||||||
|
nextItem = lastSelectedIndex - selectedItemsCount();
|
||||||
|
}
|
||||||
|
if (nextItem >= 0) {
|
||||||
|
selectionManager->setSelected(nextItem, 1);
|
||||||
|
}
|
||||||
|
m_selectNextItem = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinView::slotRenamingResult(KJob *job)
|
void DolphinView::slotRenamingResult(KJob *job)
|
||||||
{
|
{
|
||||||
if (job->error()) {
|
if (job->error()) {
|
||||||
|
|
|
@ -796,6 +796,11 @@ private Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
void observeCreatedItem(const QUrl &url);
|
void observeCreatedItem(const QUrl &url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the next item after prev selection deleted/trashed
|
||||||
|
*/
|
||||||
|
void selectNextItem();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a redirection happens.
|
* Called when a redirection happens.
|
||||||
* Testcase: fish://localhost
|
* Testcase: fish://localhost
|
||||||
|
@ -893,6 +898,7 @@ private:
|
||||||
bool m_isFolderWritable;
|
bool m_isFolderWritable;
|
||||||
bool m_dragging; // True if a dragging is done. Required to be able to decide whether a
|
bool m_dragging; // True if a dragging is done. Required to be able to decide whether a
|
||||||
// tooltip may be shown when hovering an item.
|
// tooltip may be shown when hovering an item.
|
||||||
|
bool m_selectNextItem;
|
||||||
|
|
||||||
enum class LoadingState { Idle, Loading, Canceled, Completed };
|
enum class LoadingState { Idle, Loading, Canceled, Completed };
|
||||||
LoadingState m_loadingState = LoadingState::Idle;
|
LoadingState m_loadingState = LoadingState::Idle;
|
||||||
|
|
|
@ -93,6 +93,7 @@ void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper *ac
|
||||||
|
|
||||||
auto trashAction = KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection);
|
auto trashAction = KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection);
|
||||||
auto trashShortcuts = trashAction->shortcuts();
|
auto trashShortcuts = trashAction->shortcuts();
|
||||||
|
trashAction->setAutoRepeat(false);
|
||||||
if (!trashShortcuts.contains(QKeySequence::Delete)) {
|
if (!trashShortcuts.contains(QKeySequence::Delete)) {
|
||||||
trashShortcuts.append(QKeySequence::Delete);
|
trashShortcuts.append(QKeySequence::Delete);
|
||||||
m_actionCollection->setDefaultShortcuts(trashAction, trashShortcuts);
|
m_actionCollection->setDefaultShortcuts(trashAction, trashShortcuts);
|
||||||
|
@ -105,6 +106,7 @@ void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper *ac
|
||||||
|
|
||||||
auto deleteAction = KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
|
auto deleteAction = KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
|
||||||
auto deleteShortcuts = deleteAction->shortcuts();
|
auto deleteShortcuts = deleteAction->shortcuts();
|
||||||
|
deleteAction->setAutoRepeat(false);
|
||||||
if (!deleteShortcuts.contains(Qt::SHIFT | Qt::Key_Delete)) {
|
if (!deleteShortcuts.contains(Qt::SHIFT | Qt::Key_Delete)) {
|
||||||
deleteShortcuts.append(Qt::SHIFT | Qt::Key_Delete);
|
deleteShortcuts.append(Qt::SHIFT | Qt::Key_Delete);
|
||||||
m_actionCollection->setDefaultShortcuts(deleteAction, deleteShortcuts);
|
m_actionCollection->setDefaultShortcuts(deleteAction, deleteShortcuts);
|
||||||
|
|
Loading…
Reference in a new issue