1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2014 David Faure <faure@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef PASTEJOB_P_H |
9 | #define PASTEJOB_P_H |
10 | |
11 | #include "pastejob.h" |
12 | #include <job_p.h> |
13 | |
14 | #include <QMimeData> |
15 | |
16 | namespace KIO |
17 | { |
18 | class DropJobPrivate; |
19 | |
20 | class PasteJobPrivate : public KIO::JobPrivate |
21 | { |
22 | public: |
23 | // Used by KIO::PasteJob (clipboard=true) and KIO::DropJob (clipboard=false) |
24 | PasteJobPrivate(const QMimeData *mimeData, const QUrl &destDir, JobFlags flags, bool clipboard) |
25 | : JobPrivate() |
26 | , m_mimeData(mimeData) |
27 | , m_destDir(destDir) |
28 | , m_flags(flags) |
29 | , m_clipboard(clipboard) |
30 | { |
31 | } |
32 | |
33 | friend class KIO::DropJobPrivate; |
34 | |
35 | QPointer<const QMimeData> m_mimeData; |
36 | QUrl m_destDir; |
37 | JobFlags m_flags; |
38 | bool m_clipboard; |
39 | |
40 | Q_DECLARE_PUBLIC(PasteJob) |
41 | |
42 | void slotStart(); |
43 | void slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to) |
44 | { |
45 | Q_EMIT q_func()->itemCreated(url: to); |
46 | } |
47 | void slotCopyingLinkDone(KIO::Job *, const QUrl &, const QString &, const QUrl &to) |
48 | { |
49 | Q_EMIT q_func()->itemCreated(url: to); |
50 | } |
51 | |
52 | static inline PasteJob *newJob(const QMimeData *mimeData, const QUrl &destDir, JobFlags flags, bool clipboard) |
53 | { |
54 | PasteJob *job = new PasteJob(*new PasteJobPrivate(mimeData, destDir, flags, clipboard)); |
55 | job->setUiDelegate(KIO::createDefaultJobUiDelegate()); |
56 | // Note: never KIO::getJobTracker()->registerJob here |
57 | // The progress information comes from the underlying job (so we don't have to forward it here). |
58 | return job; |
59 | } |
60 | }; |
61 | |
62 | } |
63 | |
64 | #endif |
65 | |