File indexing completed on 2024-07-21 12:11:55

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2014 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef PASTEJOB_P_H
0009 #define PASTEJOB_P_H
0010 
0011 #include "pastejob.h"
0012 #include <job_p.h>
0013 
0014 #include <QMimeData>
0015 
0016 namespace KIO
0017 {
0018 class DropJobPrivate;
0019 
0020 class PasteJobPrivate : public KIO::JobPrivate
0021 {
0022 public:
0023     // Used by KIO::PasteJob (clipboard=true) and KIO::DropJob (clipboard=false)
0024     PasteJobPrivate(const QMimeData *mimeData, const QUrl &destDir, JobFlags flags, bool clipboard)
0025         : JobPrivate()
0026         , m_mimeData(mimeData)
0027         , m_destDir(destDir)
0028         , m_flags(flags)
0029         , m_clipboard(clipboard)
0030     {
0031     }
0032 
0033     friend class KIO::DropJobPrivate;
0034 
0035     QPointer<const QMimeData> m_mimeData;
0036     QUrl m_destDir;
0037     JobFlags m_flags;
0038     bool m_clipboard;
0039 
0040     Q_DECLARE_PUBLIC(PasteJob)
0041 
0042     void slotStart();
0043     void slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to)
0044     {
0045         Q_EMIT q_func()->itemCreated(to);
0046     }
0047     void slotCopyingLinkDone(KIO::Job *, const QUrl &, const QString &, const QUrl &to)
0048     {
0049         Q_EMIT q_func()->itemCreated(to);
0050     }
0051 
0052     static inline PasteJob *newJob(const QMimeData *mimeData, const QUrl &destDir, JobFlags flags, bool clipboard)
0053     {
0054         PasteJob *job = new PasteJob(*new PasteJobPrivate(mimeData, destDir, flags, clipboard));
0055         job->setUiDelegate(KIO::createDefaultJobUiDelegate());
0056         // Note: never KIO::getJobTracker()->registerJob here
0057         // The progress information comes from the underlying job (so we don't have to forward it here).
0058         return job;
0059     }
0060 };
0061 
0062 }
0063 
0064 #endif