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;
62 * Sets the width of the column *before* the first column.
63 * This is intended to facilitate an empty region for deselection in the main viewport.
65 void setSidePadding(qreal width
);
66 qreal
sidePadding() const;
69 void sidePaddingChanged(qreal width
);
72 * Is emitted if the width of a column has been adjusted by the user with the mouse
73 * (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
75 void columnWidthChanged(const QByteArray
&role
, qreal currentWidth
, qreal previousWidth
);
78 * Is emitted if the user has released the mouse button after adjusting the
79 * width of a visible role.
81 void columnWidthChangeFinished(const QByteArray
&role
, qreal currentWidth
);
84 explicit KItemListHeader(KItemListView
*listView
);
87 KItemListView
*m_view
;
88 KItemListHeaderWidget
*m_headerWidget
;
90 friend class KItemListView
; // Constructs the KItemListHeader instance