KIO

filecopyjob.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
4 SPDX-FileCopyrightText: 2000-2009 David Faure <faure@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KIO_FILECOPYJOB_H
10#define KIO_FILECOPYJOB_H
11
12#include "job_base.h"
13#include <kio/global.h> // filesize_t
14
15namespace KIO
16{
17class FileCopyJobPrivate;
18/**
19 * @class KIO::FileCopyJob filecopyjob.h <KIO/FileCopyJob>
20 *
21 * The FileCopyJob copies data from one place to another.
22 * @see KIO::file_copy()
23 * @see KIO::file_move()
24 */
25class KIOCORE_EXPORT FileCopyJob : public Job
26{
27 Q_OBJECT
28
29public:
30 ~FileCopyJob() override;
31 /**
32 * If you know the size of the source file, call this method
33 * to inform this job. It will be displayed in the "resume" dialog.
34 * @param size the size of the source file
35 */
36 void setSourceSize(KIO::filesize_t size);
37
38 /**
39 * Sets the modification time of the file
40 *
41 * Note that this is ignored if a direct copy (WorkerBase::copy) can be done,
42 * in which case the mtime of the source is applied to the destination (if the protocol
43 * supports the concept).
44 */
45 void setModificationTime(const QDateTime &mtime);
46
47 /**
48 * Returns the source URL.
49 * @return the source URL
50 */
51 QUrl srcUrl() const;
52
53 /**
54 * Returns the destination URL.
55 * @return the destination URL
56 */
57 QUrl destUrl() const;
58
59 bool doSuspend() override;
60 bool doResume() override;
61 bool doKill() override;
62
63Q_SIGNALS:
64 /**
65 * MIME type determined during a file copy.
66 * This is never emitted during a move, and might not be emitted during
67 * a file copy, depending on the worker. But when a get and a put are
68 * being used (which is the common case), this signal forwards the
69 * MIME type information from the get job.
70 *
71 * @param job the job that emitted this signal
72 * @param mimeType the MIME type
73 * @since 5.78
74 */
75 void mimeTypeFound(KIO::Job *job, const QString &mimeType);
76
77protected Q_SLOTS:
78 /**
79 * Called whenever a subjob finishes.
80 * @param job the job that emitted this signal
81 */
82 void slotResult(KJob *job) override;
83
84protected:
85 KIOCORE_NO_EXPORT explicit FileCopyJob(FileCopyJobPrivate &dd);
86
87private:
88 Q_DECLARE_PRIVATE(FileCopyJob)
89};
90
91/**
92 * Copy a single file.
93 *
94 * Uses either WorkerBase::copy() if the worker supports that
95 * or get() and put() otherwise.
96 *
97 * @param src Where to get the file
98 * @param dest Where to put the file
99 * @param permissions the file mode permissions to set on @p dest; if this is -1
100 * (the default) no special permissions will be set on @p dest, i.e. it'll have
101 * the default system permissions for newly created files, and the owner and group
102 * permissions are not preserved.
103 * @param flags Can be @ref JobFlag::HideProgressInfo, Overwrite and Resume here
104 * WARNING: Setting @ref JobFlag::Resume means that the data will be appended to
105 * @p dest if @p dest exists
106 * @return the job handling the operation
107 */
108KIOCORE_EXPORT FileCopyJob *file_copy(const QUrl &src, const QUrl &dest, int permissions = -1, JobFlags flags = DefaultFlags);
109
110/**
111 * Overload for catching code mistakes. Do NOT call this method (it is not implemented),
112 * insert a value for permissions (-1 by default) before the JobFlags.
113 */
114FileCopyJob *file_copy(const QUrl &src, const QUrl &dest, JobFlags flags) Q_DECL_EQ_DELETE; // not implemented - on purpose.
115
116/**
117 * Move a single file.
118 *
119 * Use either WorkerBase::rename() if the worker supports that,
120 * or copy() and del() otherwise, or eventually get() & put() & del()
121 *
122 * @param src Where to get the file
123 * @param dest Where to put the file
124 * @param permissions the file mode permissions to set on @p dest; if this is -1
125 * (the default), no special permissions are set on @p dest, i.e. it'll have
126 * the default system permissions for newly created files, and the owner and group
127 * permissions are not preserved.
128 * @param flags Can be HideProgressInfo, Overwrite and Resume here
129 * WARNING: Setting @ref JobFlag::Resume means that the data will be appended to
130 * @p dest if @p dest exists
131 * @return the job handling the operation
132 */
133KIOCORE_EXPORT FileCopyJob *file_move(const QUrl &src, const QUrl &dest, int permissions = -1, JobFlags flags = DefaultFlags);
134
135/**
136 * Overload for catching code mistakes. Do NOT call this method (it is not implemented),
137 * insert a value for permissions (-1 by default) before the JobFlags.
138 */
139FileCopyJob *file_move(const QUrl &src, const QUrl &dest, JobFlags flags) Q_DECL_EQ_DELETE; // not implemented - on purpose.
140
141}
142
143#endif
The FileCopyJob copies data from one place to another.
void mimeTypeFound(KIO::Job *job, const QString &mimeType)
MIME type determined during a file copy.
The base class for all jobs.
A namespace for KIO globals.
KIOCORE_EXPORT SimpleJob * setModificationTime(const QUrl &url, const QDateTime &mtime)
Changes the modification time on a file or directory.
KIOCORE_EXPORT FileCopyJob * file_move(const QUrl &src, const QUrl &dest, int permissions=-1, JobFlags flags=DefaultFlags)
Move a single file.
KIOCORE_EXPORT FileCopyJob * file_copy(const QUrl &src, const QUrl &dest, int permissions=-1, JobFlags flags=DefaultFlags)
Copy a single file.
@ DefaultFlags
Show the progress info GUI, no Resume and no Overwrite.
Definition job_base.h:246
qulonglong filesize_t
64-bit file size
Definition global.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.