]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.h
Open the meta data configuration dialog modeless
[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 void categoryDrawerActionRequested(int action, const QModelIndex &index);
82
83 private:
84 /**
85 * Updates the size of the grid depending on the state
86 * of \a showPreview and \a additionalInfoCount.
87 */
88 void updateGridSize(bool showPreview, int additionalInfoCount);
89
90 /**
91 * Returns the number of additional information lines that should
92 * be shown below the item name.
93 */
94 int additionalInfoCount() const;
95
96 private:
97 DolphinController* m_controller;
98 DolphinCategoryDrawer* m_categoryDrawer;
99 ViewExtensionsFactory* m_extensionsFactory;
100
101 QFont m_font;
102 QSize m_decorationSize;
103 QStyleOptionViewItem::Position m_decorationPosition;
104 Qt::Alignment m_displayAlignment;
105
106 QSize m_itemSize;
107 QRect m_dropRect;
108 };
109
110 #endif