]> cloud.milkyroute.net Git - dolphin.git/blob - src/iconmanager.h
Move KCategorizedView to kdelibs. Use that one.
[dolphin.git] / src / iconmanager.h
1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef ICONMANAGER_H
21 #define ICONMANAGER_H
22
23 #include <kurl.h>
24
25 #include <QList>
26 #include <QObject>
27 #include <QPixmap>
28
29 class DolphinModel;
30 class KFileItem;
31 class KFileItemList;
32 class KJob;
33
34 /**
35 * @brief Manages the icon state of a directory model.
36 *
37 * Per default a preview is generated for each item.
38 * Additionally the clipboard is checked for cut items.
39 * The icon state for cut items gets dimmed automatically.
40 */
41 class IconManager : public QObject
42 {
43 Q_OBJECT
44
45 public:
46 IconManager(QObject* parent, DolphinModel* model);
47 virtual ~IconManager();
48 void setShowPreview(bool show);
49 bool showPreview() const;
50
51 private slots:
52 /**
53 * Generates a preview image for each file item in \a items.
54 * The current preview settings (maximum size, 'Show Preview' menu)
55 * are respected.
56 */
57 void generatePreviews(const KFileItemList& items);
58
59 /**
60 * Replaces the icon of the item \a item by the preview pixmap
61 * \a pixmap.
62 */
63 void replaceIcon(const KFileItem& item, const QPixmap& pixmap);
64
65 /**
66 * Is invoked when the preview job has been finished and
67 * set m_previewJob to 0.
68 */
69 void slotPreviewJobFinished(KJob* job);
70
71 /** Synchronizes the item icon with the clipboard of cut items. */
72 void updateCutItems();
73
74 private:
75 /**
76 * Returns true, if the item \a item has been cut into
77 * the clipboard.
78 */
79 bool isCutItem(const KFileItem& item) const;
80
81 /** Applies an item effect to all cut items. */
82 void applyCutItemEffect();
83
84 private:
85 /**
86 * Remembers the original pixmap for an item before
87 * the cut effect is applied.
88 */
89 struct CutItem
90 {
91 KUrl url;
92 QPixmap pixmap;
93 };
94
95 bool m_showPreview;
96 QList<KJob*> m_previewJobs;
97 DolphinModel* m_dolphinModel;
98
99 QList<CutItem> m_cutItemsCache;
100 };
101
102 inline bool IconManager::showPreview() const
103 {
104 return m_showPreview;
105 }
106
107 #endif