Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / apps / dolphin / src / applyviewpropsjob.h
blob4ffc069a9d9ed4ce33f4dae97458f0779dac78b6
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 return m_progress;
70 private:
71 void startNextJob(const KUrl & url);
73 private slots:
74 virtual void slotResult(KJob* job);
75 void slotEntries(KIO::Job*, const KIO::UDSEntryList&);
76 void processNextItem();
78 private:
79 ViewProperties* m_viewProps;
80 int m_currentItem;
81 int m_progress;
82 KUrl m_dir;
85 #endif