]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphiniconsview.h
Update e-mail address from peter.penz@gmx.at to peter.penz19@gmail.com
[dolphin.git] / src / views / dolphiniconsview.h
1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
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>
24
25 #include <KFileItem>
26 #include <KFileItemDelegate>
27
28 #include <QFont>
29 #include <QSize>
30 #include <QStyleOption>
31
32 #include <libdolphin_export.h>
33
34 class DolphinViewController;
35 class DolphinCategoryDrawer;
36 class DolphinSortFilterProxyModel;
37 class ViewExtensionsFactory;
38 class ViewModeController;
39
40 /**
41 * @brief Represents the view, where each item is shown as an icon.
42 *
43 * It is also possible that instead of the icon a preview of the item
44 * content is shown.
45 */
46 class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
47 {
48 Q_OBJECT
49
50 public:
51 /**
52 * @param parent Parent widget.
53 * @param dolphinViewController Allows the DolphinIconsView to control the
54 * DolphinView in a limited way.
55 * @param viewModeController Controller that is used by the DolphinView
56 * to control the DolphinIconsView. The DolphinIconsView
57 * only has read access to the controller.
58 * @param model Directory that is shown.
59 */
60 explicit DolphinIconsView(QWidget* parent,
61 DolphinViewController* dolphinViewController,
62 const ViewModeController* viewModeController,
63 DolphinSortFilterProxyModel* proxyModel);
64 virtual ~DolphinIconsView();
65
66 protected slots:
67 virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
68
69 protected:
70 virtual QStyleOptionViewItem viewOptions() const;
71 virtual void contextMenuEvent(QContextMenuEvent* event);
72 virtual void mousePressEvent(QMouseEvent* event);
73 virtual void startDrag(Qt::DropActions supportedActions);
74 virtual void dragEnterEvent(QDragEnterEvent* event);
75 virtual void dragLeaveEvent(QDragLeaveEvent* event);
76 virtual void dragMoveEvent(QDragMoveEvent* event);
77 virtual void dropEvent(QDropEvent* event);
78 virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
79 virtual void keyPressEvent(QKeyEvent* event);
80 virtual void wheelEvent(QWheelEvent* event);
81 virtual void showEvent(QShowEvent* event);
82 virtual void leaveEvent(QEvent* event);
83 virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
84 virtual void resizeEvent(QResizeEvent* event);
85
86 private slots:
87 void slotShowPreviewChanged();
88 void slotAdditionalInfoChanged();
89 void setZoomLevel(int level);
90 void requestActivation();
91 void slotGlobalSettingsChanged(int category);
92 void categoryDrawerActionRequested(int action, const QModelIndex &index);
93
94 private:
95 /**
96 * Updates the size of the grid depending on the state
97 * of \a showPreview and \a additionalInfoCount.
98 */
99 void updateGridSize(bool showPreview, int additionalInfoCount);
100
101 /**
102 * Returns the number of additional information lines that should
103 * be shown below the item name.
104 */
105 int additionalInfoCount() const;
106
107 private:
108 DolphinViewController* m_dolphinViewController;
109 DolphinCategoryDrawer* m_categoryDrawer;
110 ViewExtensionsFactory* m_extensionsFactory;
111
112 QFont m_font;
113 QSize m_decorationSize;
114 QStyleOptionViewItem::Position m_decorationPosition;
115 Qt::Alignment m_displayAlignment;
116
117 QSize m_itemSize;
118 QRect m_dropRect;
119 };
120
121 #endif