1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Stephan Kulow <coolo@kde.org> |
3 | David Faure <faure@kde.org> |
4 | Copyright (C) 2006 Kevin Ottens <ervin@kde.org> |
5 | Copyright (C) 2013 Dawit Alemayehu <adawit@kde.org> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef KIO_JOBUIDELEGATE_H |
24 | #define KIO_JOBUIDELEGATE_H |
25 | |
26 | #include <kdialogjobuidelegate.h> |
27 | #include <kio/skipdialog.h> |
28 | #include <kio/renamedialog.h> |
29 | #include <kio/global.h> |
30 | |
31 | class KJob; |
32 | namespace KIO |
33 | { |
34 | class Job; |
35 | |
36 | /** |
37 | * A UI delegate tuned to be used with KIO Jobs. |
38 | */ |
39 | class KIO_EXPORT JobUiDelegate : public KDialogJobUiDelegate |
40 | { |
41 | Q_OBJECT |
42 | |
43 | public: |
44 | /** |
45 | * Constructs a new KIO Job UI delegate. |
46 | */ |
47 | JobUiDelegate(); |
48 | |
49 | /** |
50 | * Destroys the KIO Job UI delegate. |
51 | */ |
52 | virtual ~JobUiDelegate(); |
53 | |
54 | public: |
55 | |
56 | /** |
57 | * Associate this job with a window given by @p window. |
58 | * @param window the window to associate to |
59 | * @see window() |
60 | */ |
61 | virtual void setWindow(QWidget *window); |
62 | |
63 | /** |
64 | * \relates KIO::RenameDialog |
65 | * Construct a modal, parent-less "rename" dialog, and return |
66 | * a result code, as well as the new dest. Much easier to use than the |
67 | * class RenameDialog directly. |
68 | * |
69 | * @param caption the caption for the dialog box |
70 | * @param src the URL of the file/dir we're trying to copy, as it's part of the text message |
71 | * @param dest the URL of the destination file/dir, i.e. the one that already exists |
72 | * @param mode parameters for the dialog (which buttons to show...), |
73 | * see RenameDialog_Mode |
74 | * @param newDestPath the new destination path, valid if R_RENAME was returned. |
75 | * @param sizeSrc size of source file |
76 | * @param sizeDest size of destination file |
77 | * @param ctimeSrc creation time of source file |
78 | * @param ctimeDest creation time of destination file |
79 | * @param mtimeSrc modification time of source file |
80 | * @param mtimeDest modification time of destination file |
81 | * @return the result |
82 | */ |
83 | virtual RenameDialog_Result askFileRename(KJob * job, |
84 | const QString & caption, |
85 | const QString& src, |
86 | const QString & dest, |
87 | KIO::RenameDialog_Mode mode, |
88 | QString& newDest, |
89 | KIO::filesize_t sizeSrc = KIO::filesize_t(-1), |
90 | KIO::filesize_t sizeDest = KIO::filesize_t(-1), |
91 | time_t ctimeSrc = time_t(-1), |
92 | time_t ctimeDest = time_t(-1), |
93 | time_t mtimeSrc = time_t(-1), |
94 | time_t mtimeDest = time_t(-1)); |
95 | |
96 | /** |
97 | * @internal |
98 | * See skipdialog.h |
99 | */ |
100 | virtual SkipDialog_Result askSkip(KJob * job, |
101 | bool multi, |
102 | const QString & error_text); |
103 | |
104 | /** |
105 | * The type of deletion: real deletion, moving the files to the trash |
106 | * or emptying the trash |
107 | * Used by askDeleteConfirmation. |
108 | */ |
109 | enum DeletionType { Delete, Trash, EmptyTrash }; |
110 | /** |
111 | * ForceConfirmation: always ask the user for confirmation |
112 | * DefaultConfirmation: don't ask the user if he/she said "don't ask again". |
113 | * |
114 | * Used by askDeleteConfirmation. |
115 | */ |
116 | enum ConfirmationType { DefaultConfirmation, ForceConfirmation }; |
117 | /** |
118 | * Ask for confirmation before deleting/trashing @p urls. |
119 | * |
120 | * Note that this method is not called automatically by KIO jobs. It's the application's |
121 | * responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash(). |
122 | * |
123 | * @param urls the urls about to be deleted/trashed |
124 | * @param method the type of deletion (Delete for real deletion, Trash otherwise) |
125 | * @param confirmation see ConfirmationType. Normally set to DefaultConfirmation. |
126 | * Note: the window passed to setWindow is used as the parent for the message box. |
127 | * @return true if confirmed |
128 | */ |
129 | bool askDeleteConfirmation(const KUrl::List& urls, DeletionType deletionType, |
130 | ConfirmationType confirmationType); |
131 | |
132 | /** |
133 | * Message box types. |
134 | * |
135 | * Should be kept in sync with SlaveBase::MessageBoxType. |
136 | * |
137 | * @since 4.11 |
138 | * |
139 | * @internal |
140 | */ |
141 | enum MessageBoxType { |
142 | QuestionYesNo = 1, |
143 | WarningYesNo = 2, |
144 | WarningContinueCancel = 3, |
145 | WarningYesNoCancel = 4, |
146 | Information = 5, |
147 | SSLMessageBox = 6 |
148 | }; |
149 | /** |
150 | * This function allows for the delegation user prompts from the ioslaves. |
151 | * |
152 | * @param type the desired type of message box. |
153 | * @param text the message shown to the user. |
154 | * @param caption the caption of the message dialog box. |
155 | * @param buttonYes the text for the YES button. |
156 | * @param buttonNo the text for the NO button. |
157 | * @param iconYes the icon shown on the YES button. |
158 | * @param iconNo the icon shown on the NO button. |
159 | * @param dontAskAgainName the name used to store result from 'Do not ask again' checkbox. |
160 | * @param sslMetaData SSL information used by the SSLMessageBox. |
161 | * |
162 | * @since 4.11 |
163 | * |
164 | * @internal |
165 | */ |
166 | int requestMessageBox(MessageBoxType type, const QString& text, |
167 | const QString& caption, |
168 | const QString& buttonYes, |
169 | const QString& buttonNo, |
170 | const QString& iconYes = QString(), |
171 | const QString& iconNo = QString(), |
172 | const QString& dontAskAgainName = QString(), |
173 | const KIO::MetaData& sslMetaData = KIO::MetaData()); |
174 | private: |
175 | class Private; |
176 | Private * const d; |
177 | }; |
178 | } |
179 | |
180 | #endif |
181 | |