]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/applyviewpropsjob.h
Build with QT_NO_KEYWORDS
[dolphin.git] / src / settings / applyviewpropsjob.h
1 /*
2 * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
3 *
4 * The code is based on kdelibs/kio/directorysizejob:
5 * SPDX-FileCopyrightText: 2006 David Faure <faure@kde.org>
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10 #ifndef APPLYVIEWPROPSJOB_H
11 #define APPLYVIEWPROPSJOB_H
12
13 #include <KIO/Job>
14
15 #include <QUrl>
16
17 class ViewProperties;
18
19 /**
20 * @brief Applies view properties recursively to directories.
21 *
22 * Usage:
23 * \code
24 * KJob* job = new ApplyViewPropsJob(dir, viewProps);
25 * connect(job, SIGNAL(result(KJob*)),
26 * this, SLOT(slotResult(KJob*)));
27 * \endcode
28 *
29 * To be able to show a progress of the operation, the following steps
30 * are recommended:
31 * - Use a DirectorySizeJob to count the number of directories.
32 * - Use a timer to show the current count of directories by invoking
33 * DirectorySizeJob::totalSubdirs() until the result signal is emitted.
34 * - Use the ApplyViewPropsJob.
35 * - Use a timer to show the progress by invoking ApplyViwePropsJob::progress().
36 * In combination with the total directory count it is possible to show a
37 * progress bar now.
38 */
39 class ApplyViewPropsJob : public KIO::Job
40 {
41 Q_OBJECT
42
43 public:
44 /**
45 * @param dir Directory where the view properties should be applied to
46 * (including sub directories).
47 * @param viewProps View properties for the directory \a dir including its
48 * sub directories.
49 */
50 ApplyViewPropsJob(const QUrl& dir, const ViewProperties& viewProps);
51 ~ApplyViewPropsJob() override;
52 int progress() const;
53
54 private Q_SLOTS:
55 void slotResult(KJob* job) override;
56 void slotEntries(KIO::Job*, const KIO::UDSEntryList&);
57
58 private:
59 ViewProperties* m_viewProps;
60 int m_progress;
61 QUrl m_dir;
62 };
63
64 inline int ApplyViewPropsJob::progress() const
65 {
66 return m_progress;
67 }
68
69 #endif