]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemlistheader.h
Build with QT_NO_KEYWORDS
[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 Q_SIGNALS:
62 /**
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).
65 */
66 void columnWidthChanged(const QByteArray& role,
67 qreal currentWidth,
68 qreal previousWidth);
69
70 /**
71 * Is emitted if the user has released the mouse button after adjusting the
72 * width of a visible role.
73 */
74 void columnWidthChangeFinished(const QByteArray& role,
75 qreal currentWidth);
76
77 private:
78 explicit KItemListHeader(KItemListView* listView);
79
80 private:
81 KItemListView* m_view;
82 KItemListHeaderWidget* m_headerWidget;
83
84 friend class KItemListView; // Constructs the KItemListHeader instance
85 };
86
87 #endif
88
89