]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.h
SVN_SILENT: assure that the order of the methods match in the h + cpp file
[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 <QFont>
29 #include <QSize>
30 #include <QStyleOption>
31
32 #include <libdolphin_export.h>
33
34 class DolphinController;
35 class SelectionManager;
36 class DolphinCategoryDrawer;
37
38 /**
39 * @brief Represents the view, where each item is shown as an icon.
40 *
41 * It is also possible that instead of the icon a preview of the item
42 * content is shown.
43 */
44 class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
45 {
46 Q_OBJECT
47
48 public:
49 explicit DolphinIconsView(QWidget* parent, DolphinController* controller);
50 virtual ~DolphinIconsView();
51 virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
52
53 protected slots:
54 virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
55
56 protected:
57 virtual QStyleOptionViewItem viewOptions() const;
58 virtual void contextMenuEvent(QContextMenuEvent* event);
59 virtual void mousePressEvent(QMouseEvent* event);
60 virtual void startDrag(Qt::DropActions supportedActions);
61 virtual void dragEnterEvent(QDragEnterEvent* event);
62 virtual void dragLeaveEvent(QDragLeaveEvent* event);
63 virtual void dragMoveEvent(QDragMoveEvent* event);
64 virtual void dropEvent(QDropEvent* event);
65 virtual void keyPressEvent(QKeyEvent* event);
66 virtual void wheelEvent(QWheelEvent* event);
67 virtual void showEvent(QShowEvent* event);
68 virtual void leaveEvent(QEvent* event);
69
70 private slots:
71 void slotShowPreviewChanged();
72 void slotAdditionalInfoChanged();
73 void setZoomLevel(int level);
74 void requestActivation();
75 void updateFont();
76
77 private:
78 /**
79 * Updates the size of the grid depending on the state
80 * of \a showPreview and \a additionalInfoCount.
81 */
82 void updateGridSize(bool showPreview, int additionalInfoCount);
83
84 /**
85 * Returns the number of additional information lines that should
86 * be shown below the item name.
87 */
88 int additionalInfoCount() const;
89
90 private:
91 bool m_enableScrollTo;
92 DolphinController* m_controller;
93 SelectionManager* m_selectionManager;
94 DolphinCategoryDrawer* m_categoryDrawer;
95
96 QFont m_font;
97 QSize m_decorationSize;
98 QStyleOptionViewItem::Position m_decorationPosition;
99 Qt::Alignment m_displayAlignment;
100
101 QSize m_itemSize;
102 QRect m_dropRect;
103 };
104
105 #endif