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