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