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 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10 
11 #ifndef KIO_JOBUIDELEGATE_H
12 #define KIO_JOBUIDELEGATE_H
13 
14 #include <KDialogJobUiDelegate>
15 #include <kio/askuseractioninterface.h>
16 #include <kio/global.h>
17 #include <kio/jobuidelegateextension.h>
18 #include <kio/renamedialog.h>
19 #include <kio/skipdialog.h>
20 
21 class KJob;
22 namespace KIO
23 {
24 class JobUiDelegatePrivate;
25 
26 class Job;
27 
28 /**
29  * @class KIO::JobUiDelegate jobuidelegate.h <KIO/JobUiDelegate>
30  *
31  * A UI delegate tuned to be used with KIO Jobs.
32  */
33 class KIOWIDGETS_EXPORT JobUiDelegate : public KDialogJobUiDelegate, public JobUiDelegateExtension
34 {
35  Q_OBJECT
36 
37 public:
38  /**
39  * Constructs a new KIO Job UI delegate.
40  */
41  JobUiDelegate();
42 
43  /**
44  * Constructs a new KIO Job UI Delegate.
45  * @param flags allows to enable automatic error/warning handling
46  * @param window the window associated with this delegate, see setWindow.
47  * @since 5.70
48  */
49  explicit JobUiDelegate(
51  QWidget *window); // KF6 TODO: merge with previous ctor using AutoHandlingDisabled and nullptr default values (same in KDialogJobUiDelegate)
52 
53  /**
54  * Destroys the KIO Job UI delegate.
55  */
56  virtual ~JobUiDelegate();
57 
58 public:
59  /**
60  * Associate this job with a window given by @p window.
61  * @param window the window to associate to
62  * @see window()
63  */
64  void setWindow(QWidget *window) override;
65 
66  /**
67  * Unregister the given window from kded.
68  * This is normally done automatically when the window is destroyed.
69  *
70  * This method is useful for instance when keeping a hidden window
71  * around to make it faster to reuse later.
72  * @since 5.2
73  */
74  static void unregisterWindow(QWidget *window);
75 
76  /**
77  * \relates KIO::RenameDialog
78  * Construct a modal, parent-less "rename" dialog, and return
79  * a result code, as well as the new dest. Much easier to use than the
80  * class RenameDialog directly.
81  *
82  * @param caption the caption for the dialog box
83  * @param src the URL of the file/dir we're trying to copy, as it's part of the text message
84  * @param dest the URL of the destination file/dir, i.e. the one that already exists
85  * @param options parameters for the dialog (which buttons to show...)
86  * @param newDestPath the new destination path, valid if R_RENAME was returned.
87  * @param sizeSrc size of source file
88  * @param sizeDest size of destination file
89  * @param ctimeSrc creation time of source file
90  * @param ctimeDest creation time of destination file
91  * @param mtimeSrc modification time of source file
92  * @param mtimeDest modification time of destination file
93  * @return the result
94  */
95  RenameDialog_Result askFileRename(KJob *job,
96  const QString &caption,
97  const QUrl &src,
98  const QUrl &dest,
100  QString &newDest,
101  KIO::filesize_t sizeSrc = KIO::filesize_t(-1),
102  KIO::filesize_t sizeDest = KIO::filesize_t(-1),
103  const QDateTime &ctimeSrc = QDateTime(),
104  const QDateTime &ctimeDest = QDateTime(),
105  const QDateTime &mtimeSrc = QDateTime(),
106  const QDateTime &mtimeDest = QDateTime()) override;
107 
108  /**
109  * @internal
110  * See skipdialog.h
111  */
112  SkipDialog_Result askSkip(KJob *job, KIO::SkipDialog_Options options, const QString &error_text) override;
113 
114  /**
115  * Ask for confirmation before deleting/trashing @p urls.
116  *
117  * Note that this method is not called automatically by KIO jobs. It's the application's
118  * responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash().
119  *
120  * @param urls the urls about to be deleted/trashed
121  * @param deletionType the type of deletion (Delete for real deletion, Trash otherwise)
122  * @param confirmation see ConfirmationType. Normally set to DefaultConfirmation.
123  * Note: the window passed to setWindow is used as the parent for the message box.
124  * @return true if confirmed
125  */
126  bool askDeleteConfirmation(const QList<QUrl> &urls, DeletionType deletionType, ConfirmationType confirmationType) override;
127 
128  /**
129  * This function allows for the delegation user prompts from the ioslaves.
130  *
131  * @param type the desired type of message box.
132  * @param text the message shown to the user.
133  * @param caption the caption of the message dialog box.
134  * @param buttonYes the text for the YES button.
135  * @param buttonNo the text for the NO button.
136  * @param iconYes the icon shown on the YES button.
137  * @param iconNo the icon shown on the NO button.
138  * @param dontAskAgainName the name used to store result from 'Do not ask again' checkbox.
139  * @param metaData SSL information used by the SSLMessageBox. Since 5.66 this is also used for privilege operation details.
140  *
141  * @since 4.11
142  *
143  * @internal
144  */
145  // KF6 TODO Add a QString parameter for "details" and keep in sync with API in SlaveBase, SlaveInterface, and JobUiDelegateExtension.
146  int requestMessageBox(MessageBoxType type,
147  const QString &text,
148  const QString &caption,
149  const QString &buttonYes,
150  const QString &buttonNo,
151  const QString &iconYes = QString(),
152  const QString &iconNo = QString(),
153  const QString &dontAskAgainName = QString(),
154  const KIO::MetaData &metaData = KIO::MetaData()) override;
155 
156  /**
157  * Creates a clipboard updater
158  */
159  ClipboardUpdater *createClipboardUpdater(Job *job, ClipboardUpdaterMode mode) override;
160  /**
161  * Update URL in clipboard, if present
162  */
163  void updateUrlInClipboard(const QUrl &src, const QUrl &dest) override;
164 
165 private:
166  std::unique_ptr<JobUiDelegatePrivate> const d;
167 };
168 }
169 
170 #endif
qulonglong filesize_t
64-bit file size
Definition: global.h:39
DeletionType
The type of deletion: real deletion, moving the files to the trash or emptying the trash Used by askD...
A namespace for KIO globals.
MetaData is a simple map of key/value strings.
Definition: metadata.h:22
A UI delegate tuned to be used with KIO Jobs.
Definition: jobuidelegate.h:33
ConfirmationType
ForceConfirmation: always ask the user for confirmation DefaultConfirmation: don&#39;t ask the user if he...
An abstract class defining interaction with users from KIO jobs:
RenameDialog_Result
The result of a rename or skip dialog.
The base class for all jobs.
Definition: job_base.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Aug 1 2021 23:00:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.