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 widths of the columns *before* the first column and *after* the last column.
63 * This is intended to facilitate an empty region for deselection in the main viewport.
65 void setSidePadding(qreal leftPaddingWidth
, qreal rightPaddingWidth
);
66 qreal
leftPadding() const;
67 qreal
rightPadding() const;
70 void sidePaddingChanged(qreal leftPaddingWidth
, qreal rightPaddingWidth
);
73 * Is emitted if the width of a column has been adjusted by the user with the mouse
74 * (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
76 void columnWidthChanged(const QByteArray
&role
, qreal currentWidth
, qreal previousWidth
);
79 * Is emitted if the user has released the mouse button after adjusting the
80 * width of a visible role.
82 void columnWidthChangeFinished(const QByteArray
&role
, qreal currentWidth
);
85 explicit KItemListHeader(KItemListView
*listView
);
88 KItemListView
*m_view
;
89 KItemListHeaderWidget
*m_headerWidget
;
91 friend class KItemListView
; // Constructs the KItemListHeader instance