]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.h
fixed most regressions due to the previous column-view refactoring
[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
25 #include <kfileitem.h>
26
27 #include <QSize>
28 #include <QStyleOption>
29
30 #include <libdolphin_export.h>
31
32 class DolphinController;
33 class DolphinCategoryDrawer;
34
35 /**
36 * @brief Represents the view, where each item is shown as an icon.
37 *
38 * It is also possible that instead of the icon a preview of the item
39 * content is shown.
40 */
41 class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
42 {
43 Q_OBJECT
44
45 public:
46 explicit DolphinIconsView(QWidget* parent, DolphinController* controller);
47 virtual ~DolphinIconsView();
48
49 /** @see QAbstractItemView::visualRect() */
50 virtual QRect visualRect(const QModelIndex& index) const;
51
52 protected:
53 virtual QStyleOptionViewItem viewOptions() const;
54 virtual void contextMenuEvent(QContextMenuEvent* event);
55 virtual void mousePressEvent(QMouseEvent* event);
56 virtual void dragEnterEvent(QDragEnterEvent* event);
57 virtual void dragLeaveEvent(QDragLeaveEvent* event);
58 virtual void dragMoveEvent(QDragMoveEvent* event);
59 virtual void dropEvent(QDropEvent* event);
60 virtual void paintEvent(QPaintEvent* event);
61 virtual void keyPressEvent(QKeyEvent* event);
62
63 private slots:
64 void triggerItem(const QModelIndex& index);
65 void slotEntered(const QModelIndex& index);
66 void slotShowPreviewChanged(bool show);
67 void slotAdditionalInfoCountChanged(int count);
68 void zoomIn();
69 void zoomOut();
70
71 private:
72 bool isZoomInPossible() const;
73 bool isZoomOutPossible() const;
74
75 /** Returns the increased icon size for the size \a size. */
76 int increasedIconSize(int size) const;
77
78 /** Returns the decreased icon size for the size \a size. */
79 int decreasedIconSize(int size) const;
80
81 /**
82 * Updates the size of the grid depending on the state
83 * of \a showPreview and \a additionalInfoCount.
84 */
85 void updateGridSize(bool showPreview, int additionalInfoCount);
86
87 KFileItem itemForIndex(const QModelIndex& index) const;
88
89 private:
90 DolphinController* m_controller;
91 DolphinCategoryDrawer* m_categoryDrawer;
92 QStyleOptionViewItem m_viewOptions;
93
94 QSize m_itemSize;
95
96 bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
97 QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
98 };
99
100 #endif