File indexing completed on 2024-06-16 06:56:50

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
0004     SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0005     SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org>
0006     SPDX-FileCopyrightText: 2013 Dawit Alemayehu <adawit@kde.org>
0007     SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
0008 
0009     SPDX-License-Identifier: LGPL-2.0-or-later
0010 */
0011 
0012 #ifndef KIO_JOBUIDELEGATE_H
0013 #define KIO_JOBUIDELEGATE_H
0014 
0015 #include <KDialogJobUiDelegate>
0016 #include <kio/askuseractioninterface.h>
0017 #include <kio/global.h>
0018 #include <kio/jobuidelegateextension.h>
0019 #include <kio/renamedialog.h>
0020 #include <kio/skipdialog.h>
0021 
0022 class KJob;
0023 class KDirOperator;
0024 class KIOWidgetJobUiDelegateFactory;
0025 
0026 namespace KIO
0027 {
0028 class JobUiDelegatePrivate;
0029 
0030 class FileUndoManager;
0031 
0032 class Job;
0033 
0034 /**
0035  * @class KIO::JobUiDelegate jobuidelegate.h <KIO/JobUiDelegate>
0036  *
0037  * A UI delegate tuned to be used with KIO Jobs.
0038  */
0039 class KIOWIDGETS_EXPORT JobUiDelegate : public KDialogJobUiDelegate, public JobUiDelegateExtension
0040 {
0041     Q_OBJECT
0042     // Allow the factory to construct. Everyone else needs to go through the factory or derive!
0043     friend class ::KIOWidgetJobUiDelegateFactory;
0044     // KIO internals don't need to derive either
0045     friend class KIO::FileUndoManager;
0046 
0047 protected:
0048     friend class ::KDirOperator;
0049 
0050     /**
0051      * Constructs a new KIO Job UI delegate.
0052      * @param flags allows to enable automatic error/warning handling
0053      * @param window the window associated with this delegate, see setWindow.
0054      * @param ifaces Interface instances such as OpenWithHandlerInterface to replace the default interfaces
0055      * @since 5.98
0056      */
0057     explicit JobUiDelegate(KJobUiDelegate::Flags flags = AutoHandlingDisabled, QWidget *window = nullptr, const QList<QObject *> &ifaces = {});
0058 
0059 public:
0060     /**
0061      * Destroys the KIO Job UI delegate.
0062      */
0063     ~JobUiDelegate() override;
0064 
0065 public:
0066     /**
0067      * Associate this job with a window given by @p window.
0068      * @param window the window to associate to
0069      * @see window()
0070      */
0071     void setWindow(QWidget *window) override;
0072 
0073     /**
0074      * Unregister the given window from kded.
0075      * This is normally done automatically when the window is destroyed.
0076      *
0077      * This method is useful for instance when keeping a hidden window
0078      * around to make it faster to reuse later.
0079      * @since 5.2
0080      */
0081     static void unregisterWindow(QWidget *window);
0082 
0083     /**
0084      * Ask for confirmation before deleting/trashing @p urls.
0085      *
0086      * Note that this method is not called automatically by KIO jobs. It's the application's
0087      * responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash().
0088      *
0089      * @param urls the urls about to be deleted/trashed
0090      * @param deletionType the type of deletion (Delete for real deletion, Trash otherwise)
0091      * @param confirmation see ConfirmationType. Normally set to DefaultConfirmation.
0092      * Note: the window passed to setWindow is used as the parent for the message box.
0093      * @return true if confirmed
0094      */
0095     bool askDeleteConfirmation(const QList<QUrl> &urls, DeletionType deletionType, ConfirmationType confirmationType) override;
0096 
0097     /**
0098      * Creates a clipboard updater
0099      */
0100     ClipboardUpdater *createClipboardUpdater(Job *job, ClipboardUpdaterMode mode) override;
0101     /**
0102      * Update URL in clipboard, if present
0103      */
0104     void updateUrlInClipboard(const QUrl &src, const QUrl &dest) override;
0105 
0106 private:
0107     std::unique_ptr<JobUiDelegatePrivate> const d;
0108 };
0109 }
0110 
0111 #endif