]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.h
Rename KListView to KCategorizedView as decided
[dolphin.git] / src / dolphiniconsview.h
1 /***************************************************************************
2 * Copyright (C) 2006 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 DOLPHINICONSVIEW_H
21 #define DOLPHINICONSVIEW_H
22
23 #include <kcategorizedview.h>
24 #include <kitemcategorizer.h>
25 #include <QtGui/QStyleOption>
26 #include <libdolphin_export.h>
27
28 class DolphinController;
29
30 /**
31 * @brief Represents the view, where each item is shown as an icon.
32 *
33 * It is also possible that instead of the icon a preview of the item
34 * content is shown.
35 */
36 class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
37 {
38 Q_OBJECT
39
40 public:
41 explicit DolphinIconsView(QWidget* parent, DolphinController* controller);
42 virtual ~DolphinIconsView();
43
44 protected:
45 virtual QStyleOptionViewItem viewOptions() const;
46 virtual void contextMenuEvent(QContextMenuEvent* event);
47 virtual void mousePressEvent(QMouseEvent* event);
48 virtual void dragEnterEvent(QDragEnterEvent* event);
49 virtual void dragLeaveEvent(QDragLeaveEvent* event);
50 virtual void dragMoveEvent(QDragMoveEvent* event);
51 virtual void dropEvent(QDropEvent* event);
52 virtual void paintEvent(QPaintEvent* event);
53
54 private slots:
55 void slotShowPreviewChanged(bool show);
56 void slotShowAdditionalInfoChanged(bool show);
57 void zoomIn();
58 void zoomOut();
59
60 private:
61 bool isZoomInPossible() const;
62 bool isZoomOutPossible() const;
63
64 /** Returns the increased icon size for the size \a size. */
65 int increasedIconSize(int size) const;
66
67 /** Returns the decreased icon size for the size \a size. */
68 int decreasedIconSize(int size) const;
69
70 /**
71 * Updates the size of the grid depending on the state
72 * of \a showPreview and \a showAdditionalInfo.
73 */
74 void updateGridSize(bool showPreview, bool showAdditionalInfo);
75
76 private:
77 DolphinController* m_controller;
78 QStyleOptionViewItem m_viewOptions;
79
80 bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
81 QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
82 };
83
84 #endif