1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
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 DOLPHINFILEITEMDELEGATE_H
21 #define DOLPHINFILEITEMDELEGATE_H
23 #include <kfileitemdelegate.h>
26 * Extends KFileItemDelegate by the ability to show the hover effect
27 * and the selection in a minimized way for the name column of
30 * Note that this is a workaround, as Qt does not support having custom
31 * shapes within the visual rect of an item view. The visual part of
32 * workaround is handled inside DolphinFileItemDelegate, the behavior
33 * changes are handled in DolphinDetailsView.
35 class DolphinFileItemDelegate
: public KFileItemDelegate
38 explicit DolphinFileItemDelegate(QObject
* parent
= 0);
39 virtual ~DolphinFileItemDelegate();
42 * If \a minimized is true, the hover effect and the selection are
43 * only drawn above the icon and text of an item. Per default
44 * \a minimized is false, which means that the whole visual rect is
45 * used like in KFileItemDelegate.
47 void setMinimizedNameColumn(bool minimized
);
48 bool hasMinimizedNameColumn() const;
50 virtual void paint(QPainter
* painter
,
51 const QStyleOptionViewItem
& option
,
52 const QModelIndex
& index
) const;
55 * Returns the minimized width of the name column for the name \a name. This method
56 * is also used in DolphinDetailsView to handle the selection of items correctly.
58 static int nameColumnWidth(const QString
& name
, const QStyleOptionViewItem
& option
);
61 bool m_hasMinimizedNameColumn
;
64 inline void DolphinFileItemDelegate::setMinimizedNameColumn(bool minimized
)
66 m_hasMinimizedNameColumn
= minimized
;
69 inline bool DolphinFileItemDelegate::hasMinimizedNameColumn() const
71 return m_hasMinimizedNameColumn
;