2 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef KITEMLISTHEADER_H
8 #define KITEMLISTHEADER_H
10 #include "dolphin_export.h"
15 class KItemListHeaderWidget
;
19 * @brief Provides access to the header of a KItemListView.
21 * Each column of the header represents a visible role
22 * accessible by KItemListView::visibleRoles().
24 class DOLPHIN_EXPORT KItemListHeader
: public QObject
29 ~KItemListHeader() override
;
32 * If set to true, KItemListView will automatically adjust the
33 * widths of the columns. If set to false, the size can be
34 * manually adjusted by KItemListHeader::setColumnWidth().
36 void setAutomaticColumnResizing(bool automatic
);
37 bool automaticColumnResizing() const;
40 * Sets the width of the column for the given role. Note that
41 * the width only gets applied if KItemListHeader::automaticColumnResizing()
42 * has been turned off.
44 void setColumnWidth(const QByteArray
& role
, qreal width
);
45 qreal
columnWidth(const QByteArray
& role
) const;
48 * Sets the widths of the columns for all roles. From a performance point of
49 * view calling this method should be preferred over several setColumnWidth()
50 * calls in case if the width of more than one column should be changed.
51 * Note that the widths only get applied if KItemListHeader::automaticColumnResizing()
52 * has been turned off.
54 void setColumnWidths(const QHash
<QByteArray
, qreal
>& columnWidths
);
57 * @return The column width that is required to show the role unclipped.
59 qreal
preferredColumnWidth(const QByteArray
& role
) const;
63 * Is emitted if the width of a column has been adjusted by the user with the mouse
64 * (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
66 void columnWidthChanged(const QByteArray
& role
,
71 * Is emitted if the user has released the mouse button after adjusting the
72 * width of a visible role.
74 void columnWidthChangeFinished(const QByteArray
& role
,
78 explicit KItemListHeader(KItemListView
* listView
);
81 KItemListView
* m_view
;
82 KItemListHeaderWidget
* m_headerWidget
;
84 friend class KItemListView
; // Constructs the KItemListHeader instance