]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/applyviewpropsjob.h
Modernize: Use override where possible
[dolphin.git] / src / settings / applyviewpropsjob.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * The code is based on kdelibs/kio/kio/directorysizejob.* *
5 * (C) 2006 by David Faure <faure@kde.org> *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
21 ***************************************************************************/
22
23 #ifndef APPLYVIEWPROPSJOB_H
24 #define APPLYVIEWPROPSJOB_H
25
26 #include <KIO/Job>
27 #include <QUrl>
28
29 class ViewProperties;
30
31 /**
32 * @brief Applies view properties recursively to directories.
33 *
34 * Usage:
35 * \code
36 * KJob* job = new ApplyViewPropsJob(dir, viewProps);
37 * connect(job, SIGNAL(result(KJob*)),
38 * this, SLOT(slotResult(KJob*)));
39 * \endcode
40 *
41 * To be able to show a progress of the operation, the following steps
42 * are recommended:
43 * - Use a DirectorySizeJob to count the number of directories.
44 * - Use a timer to show the current count of directories by invoking
45 * DirectorySizeJob::totalSubdirs() until the result signal is emitted.
46 * - Use the ApplyViewPropsJob.
47 * - Use a timer to show the progress by invoking ApplyViwePropsJob::progress().
48 * In combination with the total directory count it is possible to show a
49 * progress bar now.
50 */
51 class ApplyViewPropsJob : public KIO::Job
52 {
53 Q_OBJECT
54
55 public:
56 /**
57 * @param dir Directory where the view properties should be applied to
58 * (including sub directories).
59 * @param viewProps View properties for the directory \a dir including its
60 * sub directories.
61 */
62 ApplyViewPropsJob(const QUrl& dir, const ViewProperties& viewProps);
63 ~ApplyViewPropsJob() override;
64 int progress() const;
65
66 private slots:
67 void slotResult(KJob* job) override;
68 void slotEntries(KIO::Job*, const KIO::UDSEntryList&);
69
70 private:
71 ViewProperties* m_viewProps;
72 int m_currentItem;
73 int m_progress;
74 QUrl m_dir;
75 };
76
77 inline int ApplyViewPropsJob::progress() const
78 {
79 return m_progress;
80 }
81
82 #endif