1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QHEADERVIEW_H |
5 | #define |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qabstractitemview.h> |
9 | |
10 | QT_REQUIRE_CONFIG(itemviews); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class ; |
15 | class ; |
16 | |
17 | class Q_WIDGETS_EXPORT : public QAbstractItemView |
18 | { |
19 | Q_OBJECT |
20 | Q_PROPERTY(bool firstSectionMovable READ isFirstSectionMovable WRITE setFirstSectionMovable) |
21 | Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown) |
22 | Q_PROPERTY(bool highlightSections READ highlightSections WRITE setHighlightSections) |
23 | Q_PROPERTY(bool stretchLastSection READ stretchLastSection WRITE setStretchLastSection) |
24 | Q_PROPERTY(bool cascadingSectionResizes READ cascadingSectionResizes |
25 | WRITE setCascadingSectionResizes) |
26 | Q_PROPERTY(int defaultSectionSize READ defaultSectionSize WRITE setDefaultSectionSize |
27 | RESET resetDefaultSectionSize) |
28 | Q_PROPERTY(int minimumSectionSize READ minimumSectionSize WRITE setMinimumSectionSize) |
29 | Q_PROPERTY(int maximumSectionSize READ maximumSectionSize WRITE setMaximumSectionSize) |
30 | Q_PROPERTY(Qt::Alignment defaultAlignment READ defaultAlignment WRITE setDefaultAlignment) |
31 | Q_PROPERTY(bool sortIndicatorClearable READ isSortIndicatorClearable |
32 | WRITE setSortIndicatorClearable NOTIFY sortIndicatorClearableChanged) |
33 | |
34 | public: |
35 | |
36 | enum |
37 | { |
38 | , |
39 | , |
40 | , |
41 | , |
42 | = Fixed |
43 | }; |
44 | Q_ENUM(ResizeMode) |
45 | |
46 | explicit (Qt::Orientation orientation, QWidget *parent = nullptr); |
47 | virtual (); |
48 | |
49 | void (QAbstractItemModel *model) override; |
50 | |
51 | Qt::Orientation () const; |
52 | int () const; |
53 | int () const; |
54 | QSize () const override; |
55 | void (bool v) override; |
56 | int (int logicalIndex) const; |
57 | |
58 | int (int position) const; |
59 | int (int position) const; |
60 | |
61 | inline int logicalIndexAt(int x, int y) const; |
62 | inline int logicalIndexAt(const QPoint &pos) const; |
63 | |
64 | int (int logicalIndex) const; |
65 | int (int logicalIndex) const; |
66 | int (int logicalIndex) const; |
67 | |
68 | void (int from, int to); |
69 | void (int first, int second); |
70 | void (int logicalIndex, int size); |
71 | void (QHeaderView::ResizeMode mode); |
72 | |
73 | bool (int logicalIndex) const; |
74 | void (int logicalIndex, bool hide); |
75 | int () const; |
76 | |
77 | inline void hideSection(int logicalIndex); |
78 | inline void showSection(int logicalIndex); |
79 | |
80 | int () const; |
81 | int (int logicalIndex) const; |
82 | int (int visualIndex) const; |
83 | |
84 | void (bool movable); |
85 | bool () const; |
86 | void (bool movable); |
87 | bool () const; |
88 | |
89 | void (bool clickable); |
90 | bool () const; |
91 | |
92 | void (bool highlight); |
93 | bool () const; |
94 | |
95 | ResizeMode (int logicalIndex) const; |
96 | void (ResizeMode mode); |
97 | void (int logicalIndex, ResizeMode mode); |
98 | |
99 | void (int precision); |
100 | int () const; |
101 | |
102 | int () const; |
103 | |
104 | void (bool show); |
105 | bool () const; |
106 | |
107 | void (int logicalIndex, Qt::SortOrder order); |
108 | int () const; |
109 | Qt::SortOrder () const; |
110 | |
111 | void (bool clearable); |
112 | bool () const; |
113 | |
114 | bool () const; |
115 | void (bool stretch); |
116 | |
117 | bool () const; |
118 | void (bool enable); |
119 | |
120 | int () const; |
121 | void (int size); |
122 | void (); |
123 | |
124 | int () const; |
125 | void (int size); |
126 | int () const; |
127 | void (int size); |
128 | |
129 | Qt::Alignment () const; |
130 | void (Qt::Alignment alignment); |
131 | |
132 | void () override; |
133 | bool () const; |
134 | bool () const; |
135 | |
136 | #ifndef QT_NO_DATASTREAM |
137 | QByteArray () const; |
138 | bool (const QByteArray &state); |
139 | #endif |
140 | |
141 | void () override; |
142 | |
143 | public Q_SLOTS: |
144 | void (int offset); |
145 | void (int visualIndex); |
146 | void (); |
147 | void (Qt::Orientation orientation, int logicalFirst, int logicalLast); |
148 | |
149 | Q_SIGNALS: |
150 | void (int logicalIndex, int oldVisualIndex, int newVisualIndex); |
151 | void (int logicalIndex, int oldSize, int newSize); |
152 | void (int logicalIndex); |
153 | void (int logicalIndex); |
154 | void (int logicalIndex); |
155 | void (int logicalIndex); |
156 | void (int oldCount, int newCount); |
157 | void sectionHandleDoubleClicked(int logicalIndex); |
158 | void (); |
159 | void (int logicalIndex, Qt::SortOrder order); |
160 | void (bool clearable); |
161 | |
162 | protected Q_SLOTS: |
163 | void (int logicalIndex); |
164 | void (); |
165 | void (const QModelIndex &parent, int logicalFirst, int logicalLast); |
166 | void (const QModelIndex &parent, int logicalFirst, int logicalLast); |
167 | |
168 | protected: |
169 | (QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = nullptr); |
170 | void (); |
171 | |
172 | void (); |
173 | void (int start, int end); |
174 | void (const QModelIndex ¤t, const QModelIndex &old) override; |
175 | |
176 | bool (QEvent *e) override; |
177 | void (QPaintEvent *e) override; |
178 | void (QMouseEvent *e) override; |
179 | void (QMouseEvent *e) override; |
180 | void (QMouseEvent *e) override; |
181 | void (QMouseEvent *e) override; |
182 | bool (QEvent *e) override; |
183 | |
184 | virtual void (QPainter *painter, const QRect &rect, int logicalIndex) const; |
185 | virtual QSize (int logicalIndex) const; |
186 | |
187 | int () const override; |
188 | int () const override; |
189 | void () override; |
190 | void (int dx, int dy) override; |
191 | |
192 | void (const QModelIndex &topLeft, const QModelIndex &bottomRight, |
193 | const QList<int> &roles = QList<int>()) override; |
194 | void (const QModelIndex &parent, int start, int end) override; |
195 | |
196 | QRect (const QModelIndex &index) const override; |
197 | void (const QModelIndex &index, ScrollHint hint) override; |
198 | |
199 | QModelIndex (const QPoint &p) const override; |
200 | bool (const QModelIndex &index) const override; |
201 | |
202 | QModelIndex (CursorAction, Qt::KeyboardModifiers) override; |
203 | void (const QRect& rect, QItemSelectionModel::SelectionFlags flags) override; |
204 | QRegion (const QItemSelection &selection) const override; |
205 | virtual void (QStyleOptionHeader *option, int logicalIndex) const; |
206 | virtual void (QStyleOptionHeader *option) const; |
207 | |
208 | friend class QTableView; |
209 | friend class QTreeView; |
210 | |
211 | private: |
212 | void (QStyleOptionFrame *option) const override; |
213 | |
214 | // ### Qt6: make them protected slots in QHeaderViewPrivate |
215 | Q_PRIVATE_SLOT(d_func(), void _q_sectionsRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast)) |
216 | Q_PRIVATE_SLOT(d_func(), void _q_sectionsAboutToBeMoved(const QModelIndex &sourceParent, int logicalStart, int logicalEnd, const QModelIndex &destinationParent, int logicalDestination)) |
217 | Q_PRIVATE_SLOT(d_func(), void _q_sectionsMoved(const QModelIndex &sourceParent, int logicalStart, int logicalEnd, const QModelIndex &destinationParent, int logicalDestination)) |
218 | Q_PRIVATE_SLOT(d_func(), void _q_sectionsAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), |
219 | QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint)) |
220 | Q_PRIVATE_SLOT(d_func(), void _q_sectionsChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), |
221 | QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint)) |
222 | Q_DECLARE_PRIVATE(QHeaderView) |
223 | Q_DISABLE_COPY() |
224 | }; |
225 | |
226 | inline int QHeaderView::(int ax, int ay) const |
227 | { return orientation() == Qt::Horizontal ? logicalIndexAt(position: ax) : logicalIndexAt(position: ay); } |
228 | inline int QHeaderView::(const QPoint &apos) const |
229 | { return logicalIndexAt(ax: apos.x(), ay: apos.y()); } |
230 | inline void QHeaderView::(int alogicalIndex) |
231 | { setSectionHidden(logicalIndex: alogicalIndex, hide: true); } |
232 | inline void QHeaderView::(int alogicalIndex) |
233 | { setSectionHidden(logicalIndex: alogicalIndex, hide: false); } |
234 | |
235 | QT_END_NAMESPACE |
236 | |
237 | #endif // QHEADERVIEW_H |
238 | |