]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/applyviewpropsjob.h
KItemListView: Don't allow starting role editing when animation is running
[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 #include <KIO/UDSEntry>
15
16 #include <QUrl>
17
18 class ViewProperties;
19
20 /**
21 * @brief Applies view properties recursively to directories.
22 *
23 * Usage:
24 * \code
25 * KJob* job = new ApplyViewPropsJob(dir, viewProps);
26 * connect(job, SIGNAL(result(KJob*)),
27 * this, SLOT(slotResult(KJob*)));
28 * \endcode
29 *
30 * To be able to show a progress of the operation, the following steps
31 * are recommended:
32 * - Use a DirectorySizeJob to count the number of directories.
33 * - Use a timer to show the current count of directories by invoking
34 * DirectorySizeJob::totalSubdirs() until the result signal is emitted.
35 * - Use the ApplyViewPropsJob.
36 * - Use a timer to show the progress by invoking ApplyViwePropsJob::progress().
37 * In combination with the total directory count it is possible to show a
38 * progress bar now.
39 */
40 class ApplyViewPropsJob : public KIO::Job
41 {
42 Q_OBJECT
43
44 public:
45 /**
46 * @param dir Directory where the view properties should be applied to
47 * (including sub directories).
48 * @param viewProps View properties for the directory \a dir including its
49 * sub directories.
50 */
51 ApplyViewPropsJob(const QUrl &dir, const ViewProperties &viewProps);
52 ~ApplyViewPropsJob() override;
53 int progress() const;
54
55 private Q_SLOTS:
56 void slotResult(KJob *job) override;
57 void slotEntries(KIO::Job *, const KIO::UDSEntryList &);
58
59 private:
60 ViewProperties *m_viewProps;
61 int m_progress;
62 QUrl m_dir;
63 };
64
65 inline int ApplyViewPropsJob::progress() const
66 {
67 return m_progress;
68 }
69
70 #endif