File indexing completed on 2024-10-06 03:39:27
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org> 0004 SPDX-FileCopyrightText: 2000-2013 David Faure <faure@kde.org> 0005 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef KIO_JOBUIDELEGATEEXTENSION_H 0011 #define KIO_JOBUIDELEGATEEXTENSION_H 0012 0013 #include "kiocore_export.h" 0014 #include <QDateTime> 0015 #include <kio/global.h> 0016 0017 class KJob; 0018 namespace KIO 0019 { 0020 class Job; 0021 class ClipboardUpdater; 0022 0023 /** 0024 * @see RenameDialog_Options 0025 * @since 5.0 0026 */ 0027 enum RenameDialog_Option { 0028 RenameDialog_Overwrite = 1, ///< We have an existing destination, show details about it and offer to overwrite it. 0029 RenameDialog_OverwriteItself = 2, ///< Warn that the current operation would overwrite a file with itself, which is not allowed. 0030 RenameDialog_Skip = 4, ///< Offer a "Skip" button, to skip other files too. Requires RenameDialog_MultipleItems. 0031 RenameDialog_MultipleItems = 0032 8, ///< Set if the current operation concerns multiple files, so it makes sense to offer buttons that apply the user's choice to all files/folders. 0033 RenameDialog_Resume = 16, ///< Offer a "Resume" button (plus "Resume All" if RenameDialog_MultipleItems). 0034 RenameDialog_NoRename = 64, ///< Don't offer a "Rename" button. 0035 RenameDialog_DestIsDirectory = 128, ///< The destination is a directory, the dialog updates labels and tooltips accordingly. @since 5.78 0036 RenameDialog_SourceIsDirectory = 256, ///< The source is a directory, the dialog updates labels and tooltips accordingly. @since 5.78 0037 }; 0038 /** 0039 * Stores a combination of #RenameDialog_Option values. 0040 */ 0041 Q_DECLARE_FLAGS(RenameDialog_Options, RenameDialog_Option) 0042 Q_DECLARE_OPERATORS_FOR_FLAGS(RenameDialog_Options) 0043 0044 /** 0045 * @see SkipDialog_Options 0046 * @since 5.0 0047 */ 0048 enum SkipDialog_Option { 0049 /** 0050 * Set if the current operation concerns multiple files, so it makes sense 0051 * to offer buttons that apply the user's choice to all files/folders. 0052 */ 0053 SkipDialog_MultipleItems = 8, 0054 /** 0055 * Set if the current operation involves copying files/folders with certain 0056 * characters in their names that are not supported by the destination 0057 * filesystem (e.g.\ VFAT and NTFS disallow "*" in file/folder names). 0058 * 0059 * This will make the SkipDialog show a "Replace" button that can be used 0060 * to instruct the underlying job to replace any problematic character with 0061 * an underscore "_". 0062 * 0063 * @since 5.86 0064 */ 0065 SkipDialog_Replace_Invalid_Chars = 16, 0066 0067 /** 0068 * Set if the current operation @e cannot be retried. 0069 * 0070 * For example if there is an issue that involves the destination filesystem 0071 * support, e.g. VFAT and ExFat don't support symlinks, then retrying doesn't 0072 * make sense. 0073 * 0074 * @since 5.88 0075 */ 0076 SkipDialog_Hide_Retry = 32, 0077 }; 0078 /** 0079 * Stores a combination of #SkipDialog_Option values. 0080 */ 0081 Q_DECLARE_FLAGS(SkipDialog_Options, SkipDialog_Option) 0082 Q_DECLARE_OPERATORS_FOR_FLAGS(SkipDialog_Options) 0083 0084 /** 0085 * The result of a rename or skip dialog 0086 */ 0087 enum RenameDialog_Result { 0088 Result_Cancel = 0, 0089 Result_Rename = 1, 0090 Result_Skip = 2, 0091 Result_AutoSkip = 3, 0092 Result_Overwrite = 4, 0093 Result_OverwriteAll = 5, 0094 Result_Resume = 6, 0095 Result_ResumeAll = 7, 0096 Result_AutoRename = 8, 0097 Result_Retry = 9, 0098 /** 0099 * Can be returned only when multiple files are passed, Option overwrite is passed 0100 * And files modification times are valid 0101 * @since 5.77 0102 */ 0103 Result_OverwriteWhenOlder = 10, 0104 /** 0105 * Can be returned if the user selects to replace any character disallowed 0106 * by the destination filesystem with an underscore "_". 0107 * 0108 * See @ref SkipDialog_Option::SkipDialog_Replace_Invalid_Chars 0109 * 0110 * @since 5.86 0111 */ 0112 Result_ReplaceInvalidChars = 11, 0113 /** 0114 * The same as @c Result_ReplaceInvalidChars, but the user selected to 0115 * automatically replace any invalid character, without being asked about 0116 * every file/folder. 0117 * 0118 * @since 5.86 0119 */ 0120 Result_ReplaceAllInvalidChars = 12, 0121 }; 0122 typedef RenameDialog_Result SkipDialog_Result; 0123 0124 /** 0125 * @class KIO::JobUiDelegateExtension jobuidelegateextension.h <KIO/JobUiDelegateExtension> 0126 * 0127 * An abstract class defining interaction with users from KIO jobs: 0128 * \li asking for confirmation before deleting files or directories 0129 * @since 5.0 0130 */ 0131 class KIOCORE_EXPORT JobUiDelegateExtension 0132 { 0133 protected: 0134 /** 0135 * Constructor 0136 */ 0137 JobUiDelegateExtension(); 0138 0139 /** 0140 * Destructor 0141 */ 0142 virtual ~JobUiDelegateExtension(); 0143 0144 public: 0145 /** 0146 * The type of deletion: real deletion, moving the files to the trash 0147 * or emptying the trash 0148 * Used by askDeleteConfirmation. 0149 */ 0150 enum DeletionType { Delete, Trash, EmptyTrash }; 0151 /** 0152 * ForceConfirmation: always ask the user for confirmation 0153 * DefaultConfirmation: don't ask the user if he/she said "don't ask again". 0154 * 0155 * Used by askDeleteConfirmation. 0156 */ 0157 enum ConfirmationType { DefaultConfirmation, ForceConfirmation }; 0158 /** 0159 * Ask for confirmation before deleting/trashing @p urls. 0160 * 0161 * Note that this method is not called automatically by KIO jobs. It's the application's 0162 * responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash(). 0163 * 0164 * @param urls the urls about to be deleted/trashed 0165 * @param deletionType the type of deletion (Delete for real deletion, Trash otherwise) 0166 * @param confirmationType see ConfirmationType. Normally set to DefaultConfirmation. 0167 * Note: the window passed to setWindow is used as the parent for the message box. 0168 * @return true if confirmed 0169 */ 0170 virtual bool askDeleteConfirmation(const QList<QUrl> &urls, DeletionType deletionType, ConfirmationType confirmationType) = 0; 0171 0172 enum ClipboardUpdaterMode { 0173 UpdateContent, 0174 OverwriteContent, 0175 RemoveContent, 0176 }; 0177 0178 /** 0179 * Creates a clipboard updater as a child of the given job. 0180 */ 0181 virtual ClipboardUpdater *createClipboardUpdater(Job *job, ClipboardUpdaterMode mode); 0182 /** 0183 * Update URL in clipboard, if present 0184 */ 0185 virtual void updateUrlInClipboard(const QUrl &src, const QUrl &dest); 0186 0187 // TODO KF6: add virtual_hook 0188 0189 private: 0190 class Private; 0191 Private *const d; 0192 }; 0193 0194 /** 0195 * Returns the default job UI delegate extension to be used by all KIO jobs (in which HideProgressInfo is not set) 0196 * Can return nullptr, if no kio GUI library is loaded. 0197 * @since 5.0 0198 */ 0199 KIOCORE_EXPORT JobUiDelegateExtension *defaultJobUiDelegateExtension(); 0200 0201 /** 0202 * Internal. Allows the KIO widgets library to register its widget-based job UI delegate extension 0203 * automatically. 0204 * @since 5.0 0205 */ 0206 KIOCORE_EXPORT void setDefaultJobUiDelegateExtension(JobUiDelegateExtension *extension); 0207 0208 } // namespace KIO 0209 0210 #endif