add more spacing
[personal-kdebase.git] / apps / dolphin / src / settings / applyviewpropsjob.h
blobda18af966d28968d9fc9dc334ac4ed1c53abb518
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
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 ***************************************************************************/
23 #ifndef APPLYVIEWPROPSJOB_H
24 #define APPLYVIEWPROPSJOB_H
26 #include <kio/job.h>
27 #include <kfileitem.h>
28 #include <kurl.h>
30 class ViewProperties;
32 /**
33 * @brief Applies view properties recursively to directories.
35 * Usage:
36 * \code
37 * KJob* job = new ApplyViewPropsJob(dir, viewProps);
38 * connect(job, SIGNAL(result(KJob*)),
39 * this, SLOT(slotResult(KJob*)));
40 * \endcode
42 * To be able to show a progress of the operation, the following steps
43 * are recommended:
44 * - Use a DirectorySizeJob to count the number of directories.
45 * - Use a timer to show the current count of directories by invoking
46 * DirectorySizeJob::totalSubdirs() until the result signal is emitted.
47 * - Use the ApplyViewPropsJob.
48 * - Use a timer to show the progress by invoking ApplyViwePropsJob::progress().
49 * In combination with the total directory count it is possible to show a
50 * progress bar now.
52 class ApplyViewPropsJob : public KIO::Job
54 Q_OBJECT
56 public:
57 /**
58 * @param dir Directory where the view properties should be applied to
59 * (including sub directories).
60 * @param viewProps View properties for the directory \a dir including its
61 * sub directories.
63 ApplyViewPropsJob(const KUrl& dir, const ViewProperties& viewProps);
64 virtual ~ApplyViewPropsJob();
65 int progress() const;
67 private slots:
68 virtual void slotResult(KJob* job);
69 void slotEntries(KIO::Job*, const KIO::UDSEntryList&);
71 private:
72 ViewProperties* m_viewProps;
73 int m_currentItem;
74 int m_progress;
75 KUrl m_dir;
78 inline int ApplyViewPropsJob::progress() const
80 return m_progress;
83 #endif