KIO

copyjob.h
1 // -*- c++ -*-
2 /* This file is part of the KDE libraries
3  Copyright 2000 Stephan Kulow <[email protected]>
4  Copyright 2000-2006 David Faure <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef KIO_COPYJOB_H
23 #define KIO_COPYJOB_H
24 
25 #include <QObject>
26 #include <QStringList>
27 #include <QDateTime>
28 #include <QUrl>
29 
30 #include "kiocore_export.h"
31 #include <kio/global.h> // filesize_t
32 #include "job_base.h"
33 
34 class QTimer;
35 
36 namespace KIO
37 {
38 
41 struct CopyInfo {
42  QUrl uSource;
43  QUrl uDest;
44  QString linkDest; // for symlinks only
45  int permissions;
46  QDateTime ctime;
47  QDateTime mtime;
48  KIO::filesize_t size; // 0 for dirs
49 };
50 
51 class CopyJobPrivate;
66 class KIOCORE_EXPORT CopyJob : public Job
67 {
68 
69  Q_OBJECT
70 
71 public:
75  enum CopyMode { Copy, Move, Link };
76 
77  ~CopyJob() override;
78 
83  CopyMode operationMode() const;
84 
89  QList<QUrl> srcUrls() const;
90 
95  QUrl destUrl() const;
96 
104  void setDefaultPermissions(bool b);
105 
113  void setAutoSkip(bool autoSkip);
114 
122  void setAutoRename(bool autoRename);
123 
130  void setWriteIntoExistingDirectories(bool overwriteAllDirs);
131 
135  bool doSuspend() override;
136 
140  bool doResume() override;
141 
142 Q_SIGNALS:
143 
144 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 72)
145 
150  KIOCORE_DEPRECATED_VERSION(5, 72, "Use KJob::totalAmount instead. This one is not emitted")
151  QT_MOC_COMPAT void totalFiles(KJob *job, unsigned long files);
152 #endif
153 
154 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 72)
155 
160  KIOCORE_DEPRECATED_VERSION(5, 72, "Use KJob::totalAmount instead. This one is not emitted")
161  QT_MOC_COMPAT void totalDirs(KJob *job, unsigned long dirs);
162 #endif
163 
164 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 2)
165 
173  KIOCORE_DEPRECATED_VERSION(5, 2, "To be removed due to no known users")
174  QT_MOC_COMPAT void aboutToCreate(KIO::Job *job, const QList<KIO::CopyInfo> &files);
175 #endif
176 
182  void processedFiles(KIO::Job *job, unsigned long files);
188  void processedDirs(KIO::Job *job, unsigned long dirs);
189 
201  void copying(KIO::Job *job, const QUrl &src, const QUrl &dest);
213  void linking(KIO::Job *job, const QString &target, const QUrl &to);
225  void moving(KIO::Job *job, const QUrl &from, const QUrl &to);
234  void creatingDir(KIO::Job *job, const QUrl &dir);
242  void renamed(KIO::Job *job, const QUrl &from, const QUrl &to);
243 
259  void copyingDone(KIO::Job *job, const QUrl &from, const QUrl &to, const QDateTime &mtime, bool directory, bool renamed);
269  void copyingLinkDone(KIO::Job *job, const QUrl &from, const QString &target, const QUrl &to);
270 protected Q_SLOTS:
271  void slotResult(KJob *job) override;
272 
273 protected:
274  CopyJob(CopyJobPrivate &dd);
275  void emitResult();
276 
277 private:
278  Q_PRIVATE_SLOT(d_func(), void sourceStated(const KIO::UDSEntry &entry, const QUrl &sourceUrl))
279 
280  Q_DECLARE_PRIVATE(CopyJob)
281 };
282 
300 KIOCORE_EXPORT CopyJob *copy(const QUrl &src, const QUrl &dest, JobFlags flags = DefaultFlags);
301 
319 KIOCORE_EXPORT CopyJob *copyAs(const QUrl &src, const QUrl &dest, JobFlags flags = DefaultFlags);
320 
332 KIOCORE_EXPORT CopyJob *copy(const QList<QUrl> &src, const QUrl &dest, JobFlags flags = DefaultFlags);
333 
347 KIOCORE_EXPORT CopyJob *move(const QUrl &src, const QUrl &dest, JobFlags flags = DefaultFlags);
361 KIOCORE_EXPORT CopyJob *moveAs(const QUrl &src, const QUrl &dest, JobFlags flags = DefaultFlags);
374 KIOCORE_EXPORT CopyJob *move(const QList<QUrl> &src, const QUrl &dest, JobFlags flags = DefaultFlags);
375 
386 KIOCORE_EXPORT CopyJob *link(const QUrl &src, const QUrl &destDir, JobFlags flags = DefaultFlags);
387 
399 KIOCORE_EXPORT CopyJob *link(const QList<QUrl> &src, const QUrl &destDir, JobFlags flags = DefaultFlags);
400 
414 KIOCORE_EXPORT CopyJob *linkAs(const QUrl &src, const QUrl &dest, JobFlags flags = DefaultFlags);
415 
425 KIOCORE_EXPORT CopyJob *trash(const QUrl &src, JobFlags flags = DefaultFlags);
426 
435 KIOCORE_EXPORT CopyJob *trash(const QList<QUrl> &src, JobFlags flags = DefaultFlags);
436 
437 }
438 
439 #endif
qulonglong filesize_t
64-bit file size
Definition: global.h:51
Universal Directory Service.
Definition: udsentry.h:88
A namespace for KIO globals.
Definition: authinfo.h:34
KIOCORE_EXPORT CopyJob * linkAs(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
Create a link.
Definition: copyjob.cpp:2301
Show the progress info GUI, no Resume and no Overwrite.
Definition: job_base.h:282
KIOCORE_EXPORT CopyJob * copy(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
Copy a file or directory src into the destination dest, which can be a file (including the final file...
Definition: copyjob.cpp:2233
CopyMode
Defines the mode of the operation.
Definition: copyjob.h:75
KIOCORE_EXPORT CopyJob * link(const QUrl &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
Create a link.
Definition: copyjob.cpp:2289
The base class for all jobs.
Definition: job_base.h:57
KIOCORE_EXPORT CopyJob * trash(const QUrl &src, JobFlags flags=DefaultFlags)
Trash a file or directory.
Definition: copyjob.cpp:2308
KIOCORE_EXPORT CopyJob * move(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
Moves a file or directory src to the given destination dest.
Definition: copyjob.cpp:2255
KIOCORE_EXPORT CopyJob * moveAs(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
Moves a file or directory src to the given destination dest.
Definition: copyjob.cpp:2267
KIOCORE_EXPORT CopyJob * copyAs(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
Copy a file or directory src into the destination dest, which is the destination name in any case...
Definition: copyjob.cpp:2241
CopyJob is used to move, copy or symlink files and directories.
Definition: copyjob.h:66
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jul 9 2020 23:00:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.