]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.h
SVN_SILENT: removed unnecessary include
[dolphin.git] / src / dolphiniconsview.h
1 /***************************************************************************
2 * Copyright (C) 2006-2009 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 <QFont>
29 #include <QSize>
30 #include <QStyleOption>
31
32 #include <libdolphin_export.h>
33
34 class DolphinController;
35 class DolphinCategoryDrawer;
36 class DolphinSortFilterProxyModel;
37 class ViewExtensionsFactory;
38
39 /**
40 * @brief Represents the view, where each item is shown as an icon.
41 *
42 * It is also possible that instead of the icon a preview of the item
43 * content is shown.
44 */
45 class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
46 {
47 Q_OBJECT
48
49 public:
50 explicit DolphinIconsView(QWidget* parent,
51 DolphinController* controller,
52 DolphinSortFilterProxyModel* proxyModel);
53 virtual ~DolphinIconsView();
54
55 protected slots:
56 virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
57
58 protected:
59 virtual QStyleOptionViewItem viewOptions() const;
60 virtual void contextMenuEvent(QContextMenuEvent* event);
61 virtual void mousePressEvent(QMouseEvent* event);
62 virtual void startDrag(Qt::DropActions supportedActions);
63 virtual void dragEnterEvent(QDragEnterEvent* event);
64 virtual void dragLeaveEvent(QDragLeaveEvent* event);
65 virtual void dragMoveEvent(QDragMoveEvent* event);
66 virtual void dropEvent(QDropEvent* event);
67 virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
68 virtual void keyPressEvent(QKeyEvent* event);
69 virtual void wheelEvent(QWheelEvent* event);
70 virtual void showEvent(QShowEvent* event);
71 virtual void leaveEvent(QEvent* event);
72 virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
73 virtual void resizeEvent(QResizeEvent* event);
74
75 private slots:
76 void slotShowPreviewChanged();
77 void slotAdditionalInfoChanged();
78 void setZoomLevel(int level);
79 void requestActivation();
80 void slotGlobalSettingsChanged(int category);
81
82 private:
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 /**
90 * Returns the number of additional information lines that should
91 * be shown below the item name.
92 */
93 int additionalInfoCount() const;
94
95 private:
96 DolphinController* m_controller;
97 DolphinCategoryDrawer* m_categoryDrawer;
98 ViewExtensionsFactory* m_extensionsFactory;
99
100 QFont m_font;
101 QSize m_decorationSize;
102 QStyleOptionViewItem::Position m_decorationPosition;
103 Qt::Alignment m_displayAlignment;
104
105 QSize m_itemSize;
106 QRect m_dropRect;
107 };
108
109 #endif