1 /***************************************************************************
2 * Copyright (C) 2012 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 KITEMLISTHEADER_H
21 #define KITEMLISTHEADER_H
23 #include "dolphin_export.h"
27 class KItemListHeaderWidget
;
31 * @brief Provides access to the header of a KItemListView.
33 * Each column of the header represents a visible role
34 * accessible by KItemListView::visibleRoles().
36 class DOLPHIN_EXPORT KItemListHeader
: public QObject
41 virtual ~KItemListHeader();
44 * If set to true, KItemListView will automatically adjust the
45 * widths of the columns. If set to false, the size can be
46 * manually adjusted by KItemListHeader::setColumnWidth().
48 void setAutomaticColumnResizing(bool automatic
);
49 bool automaticColumnResizing() const;
52 * Sets the width of the column for the given role. Note that
53 * the width only gets applied if KItemListHeader::automaticColumnResizing()
54 * has been turned off.
56 void setColumnWidth(const QByteArray
& role
, qreal width
);
57 qreal
columnWidth(const QByteArray
& role
) const;
60 * Sets the widths of the columns for all roles. From a performance point of
61 * view calling this method should be preferred over several setColumnWidth()
62 * calls in case if the width of more than one column should be changed.
63 * Note that the widths only get applied if KItemListHeader::automaticColumnResizing()
64 * has been turned off.
66 void setColumnWidths(const QHash
<QByteArray
, qreal
>& columnWidths
);
69 * @return The column width that is required to show the role unclipped.
71 qreal
preferredColumnWidth(const QByteArray
& role
) const;
75 * Is emitted if the width of a column has been adjusted by the user with the mouse
76 * (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
78 void columnWidthChanged(const QByteArray
& role
,
83 KItemListHeader(KItemListView
* listView
);
86 KItemListView
* m_view
;
87 KItemListHeaderWidget
* m_headerWidget
;
89 friend class KItemListView
; // Constructs the KItemListHeader instance