KIO

jobuidelegate.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2000 Stephan Kulow <[email protected]>
4  SPDX-FileCopyrightText: 2000 David Faure <[email protected]>
5  SPDX-FileCopyrightText: 2006 Kevin Ottens <[email protected]>
6  SPDX-FileCopyrightText: 2013 Dawit Alemayehu <[email protected]>
7  SPDX-FileCopyrightText: 2022 Harald Sitter <[email protected]>
8 
9  SPDX-License-Identifier: LGPL-2.0-or-later
10 */
11 
12 #ifndef KIO_JOBUIDELEGATE_H
13 #define KIO_JOBUIDELEGATE_H
14 
15 #include <KDialogJobUiDelegate>
16 #include <kio/askuseractioninterface.h>
17 #include <kio/global.h>
18 #include <kio/jobuidelegateextension.h>
19 #include <kio/renamedialog.h>
20 #include <kio/skipdialog.h>
21 
22 class KJob;
23 class KDirOperator;
24 class KIOWidgetJobUiDelegateFactory;
25 
26 namespace KIO
27 {
28 class JobUiDelegatePrivate;
29 
30 class FileUndoManager;
31 
32 class Job;
33 
34 /**
35  * @class KIO::JobUiDelegate jobuidelegate.h <KIO/JobUiDelegate>
36  *
37  * A UI delegate tuned to be used with KIO Jobs.
38  */
39 class KIOWIDGETS_EXPORT JobUiDelegate : public KDialogJobUiDelegate, public JobUiDelegateExtension
40 {
41  Q_OBJECT
42  // Allow the factory to construct. Everyone else needs to go through the factory or derive!
43  friend class ::KIOWidgetJobUiDelegateFactory;
44  // KIO internals don't need to derive either
45  friend class KIO::FileUndoManager;
46 
47 public:
48 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 98)
49  /**
50  * Constructs a new KIO Job UI delegate.
51  * @deprecated Since 5.98, use KIO::createDefaultJobUiDelegate or versioned constructor instead
52  */
53  KIOWIDGETS_DEPRECATED_VERSION(5, 98, "use KIO::createDefaultJobUiDelegate or versioned constructor instead")
54  JobUiDelegate();
55 #endif
56 
57 #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 98)
58  /**
59  * Constructs a new KIO Job UI Delegate.
60  * @param flags allows to enable automatic error/warning handling
61  * @param window the window associated with this delegate, see setWindow.
62  * @since 5.70,
63  * @deprecated Since 5.98, use KIO::createDefaultJobUiDelegate or versioned constructor instead
64  */
65  KIOWIDGETS_DEPRECATED_VERSION(5, 98, "use KIO::createDefaultJobUiDelegate or versioned constructor instead")
66  explicit JobUiDelegate(KJobUiDelegate::Flags flags, QWidget *window);
67 #endif
68 
69 protected:
70  friend class ::KDirOperator;
71 
72  enum class Version {
73  V2,
74  };
75 
76  /**
77  * Constructs a new KIO Job UI delegate.
78  * @param version does nothing purely here to disambiguate this constructor from the deprecated older constructors.
79  * @param flags allows to enable automatic error/warning handling
80  * @param window the window associated with this delegate, see setWindow.
81  * @param ifaces Interface instances such as OpenWithHandlerInterface to replace the default interfaces
82  * @since 5.98
83  */
84  explicit JobUiDelegate(Version version, KJobUiDelegate::Flags flags = AutoHandlingDisabled, QWidget *window = nullptr, const QList<QObject *> &ifaces = {});
85 
86 public:
87  /**
88  * Destroys the KIO Job UI delegate.
89  */
90  ~JobUiDelegate() override;
91 
92 public:
93  /**
94  * Associate this job with a window given by @p window.
95  * @param window the window to associate to
96  * @see window()
97  */
98  void setWindow(QWidget *window) override;
99 
100  /**
101  * Unregister the given window from kded.
102  * This is normally done automatically when the window is destroyed.
103  *
104  * This method is useful for instance when keeping a hidden window
105  * around to make it faster to reuse later.
106  * @since 5.2
107  */
108  static void unregisterWindow(QWidget *window);
109 
110  /**
111  * \relates KIO::RenameDialog
112  * Construct a modal, parent-less "rename" dialog, and return
113  * a result code, as well as the new dest. Much easier to use than the
114  * class RenameDialog directly.
115  *
116  * @param title the title for the dialog box
117  * @param src the URL of the file/dir we're trying to copy, as it's part of the text message
118  * @param dest the URL of the destination file/dir, i.e. the one that already exists
119  * @param options parameters for the dialog (which buttons to show...)
120  * @param newDestPath the new destination path, valid if R_RENAME was returned.
121  * @param sizeSrc size of source file
122  * @param sizeDest size of destination file
123  * @param ctimeSrc creation time of source file
124  * @param ctimeDest creation time of destination file
125  * @param mtimeSrc modification time of source file
126  * @param mtimeDest modification time of destination file
127  * @return the result
128  */
129  RenameDialog_Result askFileRename(KJob *job,
130  const QString &title,
131  const QUrl &src,
132  const QUrl &dest,
134  QString &newDest,
135  KIO::filesize_t sizeSrc = KIO::filesize_t(-1),
136  KIO::filesize_t sizeDest = KIO::filesize_t(-1),
137  const QDateTime &ctimeSrc = QDateTime(),
138  const QDateTime &ctimeDest = QDateTime(),
139  const QDateTime &mtimeSrc = QDateTime(),
140  const QDateTime &mtimeDest = QDateTime()) override;
141 
142  /**
143  * @internal
144  * See skipdialog.h
145  */
146  SkipDialog_Result askSkip(KJob *job, KIO::SkipDialog_Options options, const QString &error_text) override;
147 
148  /**
149  * Ask for confirmation before deleting/trashing @p urls.
150  *
151  * Note that this method is not called automatically by KIO jobs. It's the application's
152  * responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash().
153  *
154  * @param urls the urls about to be deleted/trashed
155  * @param deletionType the type of deletion (Delete for real deletion, Trash otherwise)
156  * @param confirmation see ConfirmationType. Normally set to DefaultConfirmation.
157  * Note: the window passed to setWindow is used as the parent for the message box.
158  * @return true if confirmed
159  */
160  bool askDeleteConfirmation(const QList<QUrl> &urls, DeletionType deletionType, ConfirmationType confirmationType) override;
161 
162  /**
163  * This function allows for the delegation user prompts from the KIO workers.
164  *
165  * @param type the desired type of message box.
166  * @param text the message shown to the user.
167  * @param title the title of the message dialog box.
168  * @param primaryActionText the text for the primary action button.
169  * @param secondaryActionText the text for the secondary action button.
170  * @param primaryActionIconName the icon shown on the primary action button.
171  * @param secondaryActionIconName the icon shown on the secondary action button.
172  * @param dontAskAgainName the name used to store result from 'Do not ask again' checkbox.
173  * @param metaData SSL information used by the SSLMessageBox. Since 5.66 this is also used for privilege operation details.
174  *
175  * @since 4.11
176  *
177  * @internal
178  */
179  // KF6 TODO Add a QString parameter for "details" and keep in sync with API in SlaveBase, SlaveInterface, and JobUiDelegateExtension.
180  int requestMessageBox(MessageBoxType type,
181  const QString &text,
182  const QString &title,
183  const QString &primaryActionText,
184  const QString &secondaryActionText,
185  const QString &primaryActionIconName = QString(),
186  const QString &secondaryActionIconName = QString(),
187  const QString &dontAskAgainName = QString(),
188  const KIO::MetaData &metaData = KIO::MetaData()) override;
189 
190  /**
191  * Creates a clipboard updater
192  */
193  ClipboardUpdater *createClipboardUpdater(Job *job, ClipboardUpdaterMode mode) override;
194  /**
195  * Update URL in clipboard, if present
196  */
197  void updateUrlInClipboard(const QUrl &src, const QUrl &dest) override;
198 
199 private:
200  std::unique_ptr<JobUiDelegatePrivate> const d;
201 };
202 }
203 
204 #endif
DeletionType
The type of deletion: real deletion, moving the files to the trash or emptying the trash Used by askD...
qulonglong filesize_t
64-bit file size
Definition: global.h:39
A widget for displaying files and browsing directories.
Definition: kdiroperator.h:94
ConfirmationType
ForceConfirmation: always ask the user for confirmation DefaultConfirmation: don't ask the user if he...
A namespace for KIO globals.
RenameDialog_Result
The result of a rename or skip dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Oct 3 2023 03:50:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.