mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Port away from deprecated KIO API
This commit is contained in:
parent
a0c0b43b97
commit
197a7f6905
|
@ -14,8 +14,6 @@
|
|||
#include <KFileItemListProperties>
|
||||
#include <KIO/CopyJob>
|
||||
#include <KIO/DeleteJob>
|
||||
#include <KIO/FileUndoManager>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#include <KIO/Paste>
|
||||
#include <KIO/PasteJob>
|
||||
#include <KJobWidgets>
|
||||
|
@ -24,6 +22,14 @@
|
|||
#include <KSharedConfig>
|
||||
#include <KUrlMimeData>
|
||||
|
||||
#include <kio_version.h>
|
||||
#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
|
||||
#include <KIO/DeleteOrTrashJob>
|
||||
#else
|
||||
#include <KIO/FileUndoManager>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#endif
|
||||
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
|
@ -193,6 +199,11 @@ void TreeViewContextMenu::rename()
|
|||
|
||||
void TreeViewContextMenu::moveToTrash()
|
||||
{
|
||||
#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
|
||||
using Iface = KIO::AskUserActionInterface;
|
||||
auto *deleteJob = new KIO::DeleteOrTrashJob(QList{m_fileItem.url()}, Iface::Trash, Iface::DefaultConfirmation, m_parent);
|
||||
deleteJob->start();
|
||||
#else
|
||||
const QList<QUrl> list{m_fileItem.url()};
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(m_parent);
|
||||
|
@ -202,10 +213,16 @@ void TreeViewContextMenu::moveToTrash()
|
|||
KJobWidgets::setWindow(job, m_parent);
|
||||
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TreeViewContextMenu::deleteItem()
|
||||
{
|
||||
#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
|
||||
using Iface = KIO::AskUserActionInterface;
|
||||
auto *deleteJob = new KIO::DeleteOrTrashJob(QList{m_fileItem.url()}, Iface::Delete, Iface::DefaultConfirmation, m_parent);
|
||||
deleteJob->start();
|
||||
#else
|
||||
const QList<QUrl> list{m_fileItem.url()};
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(m_parent);
|
||||
|
@ -214,6 +231,7 @@ void TreeViewContextMenu::deleteItem()
|
|||
KJobWidgets::setWindow(job, m_parent);
|
||||
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TreeViewContextMenu::showProperties()
|
||||
|
|
|
@ -49,6 +49,11 @@
|
|||
|
||||
#include <kwidgetsaddons_version.h>
|
||||
|
||||
#include <kio_version.h>
|
||||
#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
|
||||
#include <KIO/DeleteOrTrashJob>
|
||||
#endif
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QActionGroup>
|
||||
#include <QApplication>
|
||||
|
@ -753,6 +758,13 @@ void DolphinView::renameSelectedItems()
|
|||
void DolphinView::trashSelectedItems()
|
||||
{
|
||||
const QList<QUrl> list = simplifiedSelectedUrls();
|
||||
|
||||
#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
|
||||
using Iface = KIO::AskUserActionInterface;
|
||||
auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Trash, Iface::DefaultConfirmation, this);
|
||||
connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
|
||||
trashJob->start();
|
||||
#else
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(window());
|
||||
if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
|
@ -762,12 +774,19 @@ void DolphinView::trashSelectedItems()
|
|||
connect(job, &KIO::Job::result,
|
||||
this, &DolphinView::slotTrashFileFinished);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DolphinView::deleteSelectedItems()
|
||||
{
|
||||
const QList<QUrl> list = simplifiedSelectedUrls();
|
||||
|
||||
#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
|
||||
using Iface = KIO::AskUserActionInterface;
|
||||
auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Delete, Iface::DefaultConfirmation, this);
|
||||
connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
|
||||
trashJob->start();
|
||||
#else
|
||||
KIO::JobUiDelegate uiDelegate;
|
||||
uiDelegate.setWindow(window());
|
||||
if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
|
||||
|
@ -776,6 +795,7 @@ void DolphinView::deleteSelectedItems()
|
|||
connect(job, &KIO::Job::result,
|
||||
this, &DolphinView::slotDeleteFileFinished);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DolphinView::cutSelectedItemsToClipboard()
|
||||
|
|
Loading…
Reference in a new issue