1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
4 SPDX-FileCopyrightText: 2000-2013 David Faure <faure@kde.org>
5 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef KIO_JOBUIDELEGATEEXTENSION_H
11#define KIO_JOBUIDELEGATEEXTENSION_H
12
13#include "kiocore_export.h"
14#include <QDateTime>
15#include <kio/global.h>
16
17class KJob;
18namespace KIO
19{
20class Job;
21class ClipboardUpdater;
22
23/*!
24 * \since 5.0
25 *
26 * \value RenameDialog_Overwrite We have an existing destination, show details about it and offer to overwrite it
27 * \value RenameDialog_OverwriteItself Warn that the current operation would overwrite a file with itself, which is not allowed
28 * \value RenameDialog_Skip Offer a "Skip" button, to skip other files too. Requires RenameDialog_MultipleItems
29 * \value RenameDialog_MultipleItems Set if the current operation concerns multiple files, so it makes sense to offer buttons that apply the user's choice to
30 * all files/folders
31 * \value RenameDialog_Resume Offer a "Resume" button (plus "Resume All" if RenameDialog_MultipleItems)
32 * \value RenameDialog_NoRename Don't offer a "Rename" button
33 * \value [since 5.78] RenameDialog_DestIsDirectory The destination is a directory, the dialog updates labels and tooltips accordingly
34 * \value [since 5.78] RenameDialog_SourceIsDirectory The source is a directory, the dialog updates labels and tooltips accordingly
35 */
36enum RenameDialog_Option {
37 RenameDialog_Overwrite = 1,
38 RenameDialog_OverwriteItself = 2,
39 RenameDialog_Skip = 4,
40 RenameDialog_MultipleItems = 8,
41 RenameDialog_Resume = 16,
42 RenameDialog_NoRename = 64,
43 RenameDialog_DestIsDirectory = 128,
44 RenameDialog_SourceIsDirectory = 256,
45};
46
47Q_DECLARE_FLAGS(RenameDialog_Options, RenameDialog_Option)
48Q_DECLARE_OPERATORS_FOR_FLAGS(RenameDialog_Options)
49
50/*!
51 * \since 5.0
52 *
53 * \value SkipDialog_MultipleItems Set if the current operation concerns multiple files, so it makes sense to offer buttons that apply the user's choice to all
54files/folders.
55 * \value [since 5.86] SkipDialog_Replace_Invalid_Chars Set if the current operation involves copying files/folders with certain characters in their names that
56are not supported by the destination filesystem (e.g.\ VFAT and NTFS disallow "*" in file/folder names). This will make the SkipDialog show a "Replace" button
57that can be used to instruct the underlying job to replace any problematic character with an underscore "_"
58 * \value [since 5.88] SkipDialog_Hide_Retry Set if the current operation cannot be retried. For example if there is an issue that involves the destination
59filesystem support, e.g. VFAT and ExFat don't support symlinks, then retrying doesn't make sense.
60*/
61enum SkipDialog_Option {
62 SkipDialog_MultipleItems = 8,
63 SkipDialog_Replace_Invalid_Chars = 16,
64 SkipDialog_Hide_Retry = 32,
65};
66Q_DECLARE_FLAGS(SkipDialog_Options, SkipDialog_Option)
67Q_DECLARE_OPERATORS_FOR_FLAGS(SkipDialog_Options)
68
69/*!
70 * The result of a rename or skip dialog
71 *
72 * \value Result_Cancel
73 * \value Result_Rename
74 * \value Result_Skip
75 * \value Result_AutoSkip
76 * \value Result_Overwrite
77 * \value Result_OverwriteAll
78 * \value Result_Resume
79 * \value Result_Rename
80 * \value Result_Retry
81 * \value Result_ResumeAll
82 * \value Result_AutoRename
83 * \value [since 5.77] Result_OverwriteWhenOlder Can be returned only when multiple files are passed, Option overwrite is passed and files modification times
84 * are valid
85 * \value [since 5.86] Result_ReplaceInvalidChars Can be returned if the user selects to replace any character disallowed by the destination filesystem with an
86 * underscore "_". See SkipDialog_Option::SkipDialog_Replace_Invalid_Chars
87 * \value [since 5.86] Result_ReplaceAllInvalidChars The same as Result_ReplaceInvalidChars, but the user selected to automatically replace any invalid
88 * character, without being asked about every file/folder
89 */
90enum RenameDialog_Result {
91 Result_Cancel = 0,
92 Result_Rename = 1,
93 Result_Skip = 2,
94 Result_AutoSkip = 3,
95 Result_Overwrite = 4,
96 Result_OverwriteAll = 5,
97 Result_Resume = 6,
98 Result_ResumeAll = 7,
99 Result_AutoRename = 8,
100 Result_Retry = 9,
101 Result_OverwriteWhenOlder = 10,
102 Result_ReplaceInvalidChars = 11,
103 Result_ReplaceAllInvalidChars = 12,
104};
105typedef RenameDialog_Result SkipDialog_Result;
106
107/*!
108 * \class KIO::JobUiDelegateExtension
109 * \inheaderfile KIO/JobUiDelegateExtension
110 * \inmodule KIOCore
111 *
112 * An abstract class defining interaction with users from KIO jobs:
113 * \list
114 * \li asking for confirmation before deleting files or directories
115 * \endlist
116 * \since 5.0
117 */
118class KIOCORE_EXPORT JobUiDelegateExtension
119{
120protected:
121 /*!
122 * Constructor
123 */
124 JobUiDelegateExtension();
125
126 virtual ~JobUiDelegateExtension();
127
128public:
129#if KIOCORE_BUILD_DEPRECATED_SINCE(6, 15)
130 /*!
131 * The type of deletion: real deletion, moving the files to the trash
132 * or emptying the trash
133 * Used by askDeleteConfirmation.
134 *
135 * \value Delete
136 * \value Trash
137 * \value EmptyTrash
138 */
139 enum DeletionType {
140 Delete,
141 Trash,
142 EmptyTrash
143 };
144
145 /*!
146 * ForceConfirmation: always ask the user for confirmation
147 * DefaultConfirmation: don't ask the user if he/she said "don't ask again".
148 *
149 * Used by askDeleteConfirmation.
150 *
151 * \value DefaultConfirmation
152 * \value ForceConfirmation
153 */
154 enum ConfirmationType {
155 DefaultConfirmation,
156 ForceConfirmation
157 };
158 /*!
159 * Ask for confirmation before deleting/trashing \a urls.
160 *
161 * Note that this method is not called automatically by KIO jobs. It's the application's
162 * responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash().
163 *
164 * \a urls the urls about to be deleted/trashed
165 *
166 * \a deletionType the type of deletion (Delete for real deletion, Trash otherwise)
167 *
168 * \a confirmationType see ConfirmationType. Normally set to DefaultConfirmation.
169 *
170 * \note the window passed to setWindow is used as the parent for the message box.
171 *
172 * Returns \c true if confirmed
173 */
174 KIOCORE_DEPRECATED_VERSION(6, 15, "Use AskUserActionInterface::askUserDelete instead")
175 virtual bool askDeleteConfirmation(const QList<QUrl> &urls, DeletionType deletionType, ConfirmationType confirmationType) = 0;
176#endif
177
178 /*!
179 * \value UpdateContent
180 * \value OverwriteContent
181 * \value RemoveContent
182 *
183 */
184 enum ClipboardUpdaterMode {
185 UpdateContent,
186 OverwriteContent,
187 RemoveContent,
188 };
189
190 /*!
191 * Creates a clipboard updater as a child of the given job.
192 */
193 virtual ClipboardUpdater *createClipboardUpdater(Job *job, ClipboardUpdaterMode mode);
194 /*!
195 * Update URL in clipboard, if present
196 */
197 virtual void updateUrlInClipboard(const QUrl &src, const QUrl &dest);
198
199 // TODO KF6: add virtual_hook
200
201private:
202 class Private;
203 Private *const d;
204};
205
206/*!
207 * \relates KIO::JobUiDelegateExtension
208 *
209 * Returns the default job UI delegate extension to be used by all KIO jobs (in which HideProgressInfo is not set)
210 * Can return nullptr, if no kio GUI library is loaded.
211 * \since 5.0
212 */
213KIOCORE_EXPORT JobUiDelegateExtension *defaultJobUiDelegateExtension();
214
215/*!
216 * \relates KIO::JobUiDelegateExtension
217 *
218 * Internal. Allows the KIO widgets library to register its widget-based job UI delegate extension
219 * automatically.
220 * \since 5.0
221 */
222KIOCORE_EXPORT void setDefaultJobUiDelegateExtension(JobUiDelegateExtension *extension);
223
224} // namespace KIO
225
226#endif
227

source code of kio/src/core/jobuidelegateextension.h