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