1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef DOLPHINICONSVIEW_H
21 #define DOLPHINICONSVIEW_H
23 #include <KCategorizedView>
26 #include <KFileItemDelegate>
30 #include <QStyleOption>
32 #include <libdolphin_export.h>
34 class DolphinViewController
;
35 class DolphinCategoryDrawer
;
36 class DolphinSortFilterProxyModel
;
37 class ViewExtensionsFactory
;
38 class ViewModeController
;
41 * @brief Represents the view, where each item is shown as an icon.
43 * It is also possible that instead of the icon a preview of the item
46 class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView
: public KCategorizedView
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.
60 explicit DolphinIconsView(QWidget
* parent
,
61 DolphinViewController
* dolphinViewController
,
62 const ViewModeController
* viewModeController
,
63 DolphinSortFilterProxyModel
* proxyModel
);
64 virtual ~DolphinIconsView();
67 virtual void dataChanged(const QModelIndex
& topLeft
, const QModelIndex
& bottomRight
);
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
);
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
);
96 * Updates the size of the grid depending on the state
97 * of \a showPreview and \a additionalInfoCount.
99 void updateGridSize(bool showPreview
, int additionalInfoCount
);
102 * Returns the number of additional information lines that should
103 * be shown below the item name.
105 int additionalInfoCount() const;
108 DolphinViewController
* m_dolphinViewController
;
109 DolphinCategoryDrawer
* m_categoryDrawer
;
110 ViewExtensionsFactory
* m_extensionsFactory
;
113 QSize m_decorationSize
;
114 QStyleOptionViewItem::Position m_decorationPosition
;
115 Qt::Alignment m_displayAlignment
;