KIO

listjob.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2000 Stephan Kulow <[email protected]>
4  SPDX-FileCopyrightText: 2000-2009 David Faure <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef KIO_LISTJOB_H
10 #define KIO_LISTJOB_H
11 
12 #include "simplejob.h"
13 #include <kio/udsentry.h>
14 
15 namespace KIO
16 {
17 class ListJobPrivate;
18 /**
19  * @class KIO::ListJob listjob.h <KIO/ListJob>
20  *
21  * A ListJob is allows you to get the get the content of a directory.
22  * Don't create the job directly, but use KIO::listRecursive() or
23  * KIO::listDir() instead.
24  * @see KIO::listRecursive()
25  * @see KIO::listDir()
26  */
27 class KIOCORE_EXPORT ListJob : public SimpleJob
28 {
29  Q_OBJECT
30 
31 public:
32  ~ListJob() override;
33 
34  /**
35  * Returns the ListJob's redirection URL. This will be invalid if there
36  * was no redirection.
37  * @return the redirection url
38  */
39  const QUrl &redirectionUrl() const;
40 
41  /**
42  * Do not apply any KIOSK restrictions to this job.
43  */
44  void setUnrestricted(bool unrestricted);
45 
46 Q_SIGNALS:
47  /**
48  * This signal emits the entry found by the job while listing.
49  * The progress signals aren't specific to ListJob. It simply
50  * uses SimpleJob's processedSize (number of entries listed) and
51  * totalSize (total number of entries, if known),
52  * as well as percent.
53  * @param job the job that emitted this signal
54  * @param list the list of UDSEntries
55  */
56  void entries(KIO::Job *job, const KIO::UDSEntryList &list); // TODO KDE5: use KIO::ListJob* argument to avoid casting
57 
58  /**
59  * This signal is emitted when a sub-directory could not be listed.
60  * The job keeps going, thus doesn't result in an overall error.
61  * @param job the job that emitted the signal
62  * @param subJob the job listing a sub-directory, which failed. Use
63  * url(), error() and errorText() on that job to find
64  * out more.
65  */
66  void subError(KIO::ListJob *job, KIO::ListJob *subJob);
67 
68  /**
69  * Signals a redirection.
70  * Use to update the URL shown to the user.
71  * The redirection itself is handled internally.
72  * @param job the job that is redirected
73  * @param url the new url
74  */
75  void redirection(KIO::Job *job, const QUrl &url);
76 
77  /**
78  * Signals a permanent redirection.
79  * The redirection itself is handled internally.
80  * @param job the job that emitted this signal
81  * @param fromUrl the original URL
82  * @param toUrl the new URL
83  */
84  void permanentRedirection(KIO::Job *job, const QUrl &fromUrl, const QUrl &toUrl);
85 
86 protected Q_SLOTS:
87  void slotFinished() override;
88 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 101) // override no longer needed
89  void slotMetaData(const KIO::MetaData &_metaData) override;
90 #endif
91  void slotResult(KJob *job) override;
92 
93 protected:
94  KIOCORE_NO_EXPORT explicit ListJob(ListJobPrivate &dd);
95 
96  Q_DECLARE_PRIVATE(ListJob)
97  friend class ListJobPrivate;
98 };
99 
100 /**
101  * List the contents of @p url, which is assumed to be a directory.
102  *
103  * "." and ".." are returned, filter them out if you don't want them.
104  *
105  *
106  * @param url the url of the directory
107  * @param flags Can be HideProgressInfo here
108  * @param includeHidden true for all files, false to cull out UNIX hidden
109  * files/dirs (whose names start with dot)
110  * @return the job handling the operation.
111  */
112 KIOCORE_EXPORT ListJob *listDir(const QUrl &url, JobFlags flags = DefaultFlags, bool includeHidden = true);
113 
114 /**
115  * The same as the previous method, but recurses subdirectories.
116  * Directory links are not followed.
117  *
118  * "." and ".." are returned but only for the toplevel directory.
119  * Filter them out if you don't want them.
120  *
121  * @param url the url of the directory
122  * @param flags Can be HideProgressInfo here
123  * @param includeHidden true for all files, false to cull out UNIX hidden
124  * files/dirs (whose names start with dot)
125  * @return the job handling the operation.
126  */
127 KIOCORE_EXPORT ListJob *listRecursive(const QUrl &url, JobFlags flags = DefaultFlags, bool includeHidden = true);
128 
129 }
130 
131 #endif
@ DefaultFlags
Show the progress info GUI, no Resume and no Overwrite.
Definition: job_base.h:270
KIOCORE_EXPORT ListJob * listRecursive(const QUrl &url, JobFlags flags=DefaultFlags, bool includeHidden=true)
The same as the previous method, but recurses subdirectories.
Definition: listjob.cpp:248
A namespace for KIO globals.
KIOCORE_EXPORT ListJob * listDir(const QUrl &url, JobFlags flags=DefaultFlags, bool includeHidden=true)
List the contents of url, which is assumed to be a directory.
Definition: listjob.cpp:243
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 03:58:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.