mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Port away from KonqOperations::askDeleteConfirmation and KonqOperations::del
and remove them. Porting docs added to https://community.kde.org/Frameworks/Porting_Notes#libkonq
This commit is contained in:
parent
e44ddfa5ab
commit
ee946d362c
|
@ -22,9 +22,12 @@
|
|||
|
||||
#include <KFileItem>
|
||||
#include <KIconLoader>
|
||||
#include <KIO/CopyJob>
|
||||
#include <KIO/DeleteJob>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#include <KMenu>
|
||||
#include <KIcon>
|
||||
#include <KJobWidgets>
|
||||
#include <KSharedConfig>
|
||||
#include <KConfigGroup>
|
||||
#include <kurlmimedata.h>
|
||||
|
@ -32,6 +35,7 @@
|
|||
#include <konq_operations.h>
|
||||
#include <KLocale>
|
||||
#include <KIO/Paste>
|
||||
#include <KIO/FileUndoManager>
|
||||
#include <KPropertiesDialog>
|
||||
|
||||
#include "folderspanel.h"
|
||||
|
@ -187,12 +191,27 @@ void TreeViewContextMenu::rename()
|
|||
|
||||
void TreeViewContextMenu::moveToTrash()
|
||||
{
|
||||
KonqOperations::del(m_parent, KonqOperations::TRASH, KUrl::List() << m_fileItem.url());
|
||||
KUrl::List list = KUrl::List() << m_fileItem.url();
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(m_parent);
|
||||
if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
KIO::Job* job = KIO::trash(list);
|
||||
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, KUrl("trash:/"), job);
|
||||
KJobWidgets::setWindow(job, m_parent);
|
||||
job->ui()->setAutoErrorHandlingEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void TreeViewContextMenu::deleteItem()
|
||||
{
|
||||
KonqOperations::del(m_parent, KonqOperations::DEL, KUrl::List() << m_fileItem.url());
|
||||
KUrl::List list = KUrl::List() << m_fileItem.url();
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(m_parent);
|
||||
if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
KIO::Job* job = KIO::del(list);
|
||||
KJobWidgets::setWindow(job, m_parent);
|
||||
job->ui()->setAutoErrorHandlingEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void TreeViewContextMenu::showProperties()
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <kitemviews/kitemlistselectionmanager.h>
|
||||
#include <kitemviews/kitemlistview.h>
|
||||
#include <kitemviews/kitemlistcontroller.h>
|
||||
#include <KIO/CopyJob>
|
||||
#include <KIO/DeleteJob>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#include <KIO/NetAccess>
|
||||
|
@ -673,22 +674,26 @@ void DolphinView::renameSelectedItems()
|
|||
void DolphinView::trashSelectedItems()
|
||||
{
|
||||
const KUrl::List list = simplifiedSelectedUrls();
|
||||
KonqOperations::del(this, KonqOperations::TRASH, list);
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(window());
|
||||
if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
KIO::Job* job = KIO::trash(list);
|
||||
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, KUrl("trash:/"), job);
|
||||
KJobWidgets::setWindow(job, this);
|
||||
connect(job, &KIO::Job::result,
|
||||
this, &DolphinView::slotTrashFileFinished);
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinView::deleteSelectedItems()
|
||||
{
|
||||
const KUrl::List list = simplifiedSelectedUrls();
|
||||
const bool del = KonqOperations::askDeleteConfirmation(list,
|
||||
KonqOperations::DEL,
|
||||
KonqOperations::DEFAULT_CONFIRMATION,
|
||||
this);
|
||||
|
||||
if (del) {
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(window());
|
||||
if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
KIO::Job* job = KIO::del(list);
|
||||
if (job->ui()) {
|
||||
KJobWidgets::setWindow(job, this);
|
||||
}
|
||||
KJobWidgets::setWindow(job, this);
|
||||
connect(job, &KIO::Job::result,
|
||||
this, &DolphinView::slotDeleteFileFinished);
|
||||
}
|
||||
|
@ -1357,6 +1362,15 @@ void DolphinView::calculateItemCount(int& fileCount,
|
|||
}
|
||||
}
|
||||
|
||||
void DolphinView::slotTrashFileFinished(KJob* job)
|
||||
{
|
||||
if (job->error() == 0) {
|
||||
emit operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
|
||||
} else if (job->error() != KIO::ERR_USER_CANCELED) {
|
||||
emit errorMessage(job->errorString());
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinView::slotDeleteFileFinished(KJob* job)
|
||||
{
|
||||
if (job->error() == 0) {
|
||||
|
|
|
@ -619,6 +619,12 @@ private slots:
|
|||
*/
|
||||
void slotDeleteFileFinished(KJob* job);
|
||||
|
||||
/**
|
||||
* Indicates in the status bar that the trash operation
|
||||
* of the job \a job has been finished.
|
||||
*/
|
||||
void slotTrashFileFinished(KJob* job);
|
||||
|
||||
void slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue