KIO

pastejob.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2014 David Faure <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef PASTEJOB_H
9 #define PASTEJOB_H
10 
11 #include <QUrl>
12 
13 #include "kiowidgets_export.h"
14 #include <kio/job_base.h>
15 
16 class QMimeData;
17 
18 namespace KIO
19 {
20 class PasteJobPrivate;
21 /**
22  * @class KIO::PasteJob pastejob.h <KIO/PasteJob>
23  *
24  * A KIO job that handles pasting the clipboard contents.
25  *
26  * If the clipboard contains URLs, they are copied to the destination URL.
27  * If the clipboard contains data, it is saved into a file after asking
28  * the user to choose a filename and the preferred data format.
29  *
30  * @see KIO::pasteClipboard
31  * @since 5.4
32  */
33 class KIOWIDGETS_EXPORT PasteJob : public Job
34 {
35  Q_OBJECT
36 
37 public:
38  ~PasteJob() override;
39 
40 Q_SIGNALS:
41  /**
42  * Signals that a file or directory was created.
43  */
44  void itemCreated(const QUrl &url);
45 
46 protected Q_SLOTS:
47  void slotResult(KJob *job) override;
48 
49 protected:
50  KIOWIDGETS_NO_EXPORT explicit PasteJob(PasteJobPrivate &dd);
51 
52 private:
53  Q_DECLARE_PRIVATE(PasteJob)
54 };
55 
56 /**
57  * Pastes the clipboard contents.
58  *
59  * If the clipboard contains URLs, they are copied (or moved) to the destination URL,
60  * using a KIO::CopyJob subjob.
61  * Otherwise, the data from the clipboard is saved into a file using KIO::storedPut,
62  * after asking the user to choose a filename and the preferred data format.
63  *
64  * This takes care of recording the subjob in the FileUndoManager, and emits
65  * itemCreated for every file or directory being created, so that the view can select
66  * these items.
67  *
68  * @param mimeData the MIME data to paste, usually QApplication::clipboard()->mimeData()
69  * @param destDir The URL of the target directory
70  * @param flags passed to the sub job
71  *
72  * @return A pointer to the job handling the operation.
73  * @since 5.4
74  */
75 KIOWIDGETS_EXPORT PasteJob *paste(const QMimeData *mimeData, const QUrl &destDir, JobFlags flags = DefaultFlags);
76 
77 }
78 
79 #endif
@ DefaultFlags
Show the progress info GUI, no Resume and no Overwrite.
Definition: job_base.h:270
A namespace for KIO globals.
KIOWIDGETS_EXPORT PasteJob * paste(const QMimeData *mimeData, const QUrl &destDir, JobFlags flags=DefaultFlags)
Pastes the clipboard contents.
Definition: pastejob.cpp:100
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:53:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.