1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2013 Dawit Alemayehu <adawit@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KIO_CLIPBOARDUPDATER_P_H |
9 | #define KIO_CLIPBOARDUPDATER_P_H |
10 | |
11 | #include <QObject> |
12 | #include <jobuidelegateextension.h> |
13 | |
14 | class KJob; |
15 | class QUrl; |
16 | |
17 | namespace KIO |
18 | { |
19 | class Job; |
20 | class JobUiDelegate; |
21 | |
22 | /** |
23 | * Updates the clipboard when it is affected by KIO operations. |
24 | * |
25 | * UpdateContent updates clipboard urls that were modified. This mode should |
26 | * be the one preferred by default because it will not change the contents |
27 | * of the clipboard if the urls modified by the job are not found in the |
28 | * clipboard. |
29 | * |
30 | * OverwriteContent blindly replaces all urls in the clipboard with the ones |
31 | * from the job. This mode should not be used unless you are 100% certain that |
32 | * the urls in the clipboard are actually there for the purposes of carrying |
33 | * out the specified job. This mode for example is used by the KIO::pasteClipboard |
34 | * job when a user performs a cut+paste operation. |
35 | * |
36 | * This class also sets @ref job as its parent object. As such, when @ref job |
37 | * is deleted the instance of ClipboardUpdater you create will also be deleted |
38 | * as well. |
39 | */ |
40 | class ClipboardUpdater : public QObject |
41 | { |
42 | Q_OBJECT |
43 | |
44 | public: |
45 | /** |
46 | * Convenience function that allows renaming of a single url in the clipboard. |
47 | */ |
48 | static void update(const QUrl &srcUrl, const QUrl &destUrl); |
49 | |
50 | /** |
51 | * Sets the mode. |
52 | */ |
53 | void setMode(JobUiDelegateExtension::ClipboardUpdaterMode m); |
54 | |
55 | private Q_SLOTS: |
56 | void slotResult(KJob *job); |
57 | |
58 | private: |
59 | explicit ClipboardUpdater(Job *job, JobUiDelegateExtension::ClipboardUpdaterMode mode); |
60 | friend class JobUiDelegate; |
61 | JobUiDelegateExtension::ClipboardUpdaterMode m_mode; |
62 | }; |
63 | } |
64 | |
65 | #endif |
66 | |