]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemlistheader.h
GIT_SILENT Update Appstream for new release
[dolphin.git] / src / kitemviews / kitemlistheader.h
1 /*
2 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef KITEMLISTHEADER_H
8 #define KITEMLISTHEADER_H
9
10 #include "dolphin_export.h"
11
12 #include <QHash>
13 #include <QObject>
14
15 class KItemListHeaderWidget;
16 class KItemListView;
17
18 /**
19 * @brief Provides access to the header of a KItemListView.
20 *
21 * Each column of the header represents a visible role
22 * accessible by KItemListView::visibleRoles().
23 */
24 class DOLPHIN_EXPORT KItemListHeader : public QObject
25 {
26 Q_OBJECT
27
28 public:
29 ~KItemListHeader() override;
30
31 /**
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().
35 */
36 void setAutomaticColumnResizing(bool automatic);
37 bool automaticColumnResizing() const;
38
39 /**
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.
43 */
44 void setColumnWidth(const QByteArray &role, qreal width);
45 qreal columnWidth(const QByteArray &role) const;
46
47 /**
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.
53 */
54 void setColumnWidths(const QHash<QByteArray, qreal> &columnWidths);
55
56 /**
57 * @return The column width that is required to show the role unclipped.
58 */
59 qreal preferredColumnWidth(const QByteArray &role) const;
60
61 /**
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.
64 */
65 void setSidePadding(qreal leftPaddingWidth, qreal rightPaddingWidth);
66 qreal leftPadding() const;
67 qreal rightPadding() const;
68
69 Q_SIGNALS:
70 void sidePaddingChanged(qreal leftPaddingWidth, qreal rightPaddingWidth);
71
72 /**
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).
75 */
76 void columnWidthChanged(const QByteArray &role, qreal currentWidth, qreal previousWidth);
77
78 /**
79 * Is emitted if the user has released the mouse button after adjusting the
80 * width of a visible role.
81 */
82 void columnWidthChangeFinished(const QByteArray &role, qreal currentWidth);
83
84 private:
85 explicit KItemListHeader(KItemListView *listView);
86
87 private:
88 KItemListView *m_view;
89 KItemListHeaderWidget *m_headerWidget;
90
91 friend class KItemListView; // Constructs the KItemListHeader instance
92 };
93
94 #endif