Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickpositioners_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count |
---|---|---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - |
4 | ** Contact: https://www.qt.io/licensing/ | - |
5 | ** | - |
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and The Qt Company. For licensing terms | - |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - |
15 | ** information use the contact form at https://www.qt.io/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 3 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - |
24 | ** | - |
25 | ** GNU General Public License Usage | - |
26 | ** Alternatively, this file may be used under the terms of the GNU | - |
27 | ** General Public License version 2.0 or (at your option) the GNU General | - |
28 | ** Public license version 3 or any later version approved by the KDE Free | - |
29 | ** Qt Foundation. The licenses are as published by the Free Software | - |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - |
31 | ** included in the packaging of this file. Please review the following | - |
32 | ** information to ensure the GNU General Public License requirements will | - |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - |
35 | ** | - |
36 | ** $QT_END_LICENSE$ | - |
37 | ** | - |
38 | ****************************************************************************/ | - |
39 | - | |
40 | #ifndef QQUICKPOSITIONERS_P_H | - |
41 | #define QQUICKPOSITIONERS_P_H | - |
42 | - | |
43 | // | - |
44 | // W A R N I N G | - |
45 | // ------------- | - |
46 | // | - |
47 | // This file is not part of the Qt API. It exists purely as an | - |
48 | // implementation detail. This header file may change from version to | - |
49 | // version without notice, or even be removed. | - |
50 | // | - |
51 | // We mean it. | - |
52 | // | - |
53 | - | |
54 | #include <QtQuick/private/qtquickglobal_p.h> | - |
55 | - | |
56 | QT_REQUIRE_CONFIG(quick_positioners); | - |
57 | - | |
58 | #include "qquickimplicitsizeitem_p.h" | - |
59 | #include "qquickitemviewtransition_p.h" | - |
60 | - | |
61 | #include <private/qpodvector_p.h> | - |
62 | - | |
63 | #include <QtCore/qobject.h> | - |
64 | #include <QtCore/qstring.h> | - |
65 | - | |
66 | QT_BEGIN_NAMESPACE | - |
67 | - | |
68 | class QQuickBasePositionerPrivate; | - |
69 | - | |
70 | class QQuickPositionerAttached : public QObject | - |
71 | { | - |
72 | Q_OBJECT | - |
73 | - | |
74 | public: | - |
75 | QQuickPositionerAttached(QObject *parent); | - |
76 | - | |
77 | Q_PROPERTY(int index READ index NOTIFY indexChanged) | - |
78 | Q_PROPERTY(bool isFirstItem READ isFirstItem NOTIFY isFirstItemChanged) | - |
79 | Q_PROPERTY(bool isLastItem READ isLastItem NOTIFY isLastItemChanged) | - |
80 | - | |
81 | int index() const { return m_index; } executed 36 times by 1 test: return m_index; Executed by:
| 36 |
82 | void setIndex(int index); | - |
83 | - | |
84 | bool isFirstItem() const { return m_isFirstItem; } executed 32 times by 1 test: return m_isFirstItem; Executed by:
| 32 |
85 | void setIsFirstItem(bool isFirstItem); | - |
86 | - | |
87 | bool isLastItem() const { return m_isLastItem; } executed 62 times by 1 test: return m_isLastItem; Executed by:
| 62 |
88 | void setIsLastItem(bool isLastItem); | - |
89 | - | |
90 | Q_SIGNALS: | - |
91 | void indexChanged(); | - |
92 | void isFirstItemChanged(); | - |
93 | void isLastItemChanged(); | - |
94 | - | |
95 | private: | - |
96 | int m_index; | - |
97 | bool m_isFirstItem; | - |
98 | bool m_isLastItem; | - |
99 | }; | - |
100 | - | |
101 | class Q_QUICK_PRIVATE_EXPORT QQuickBasePositioner : public QQuickImplicitSizeItem | - |
102 | { | - |
103 | Q_OBJECT | - |
104 | - | |
105 | Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) | - |
106 | Q_PROPERTY(QQuickTransition *populate READ populate WRITE setPopulate NOTIFY populateChanged) | - |
107 | Q_PROPERTY(QQuickTransition *move READ move WRITE setMove NOTIFY moveChanged) | - |
108 | Q_PROPERTY(QQuickTransition *add READ add WRITE setAdd NOTIFY addChanged) | - |
109 | - | |
110 | Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION 6) | - |
111 | Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION 6) | - |
112 | Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6) | - |
113 | Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6) | - |
114 | Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6) | - |
115 | public: | - |
116 | enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 }; | - |
117 | - | |
118 | QQuickBasePositioner(PositionerType, QQuickItem *parent); | - |
119 | ~QQuickBasePositioner(); | - |
120 | - | |
121 | qreal spacing() const; | - |
122 | void setSpacing(qreal); | - |
123 | - | |
124 | QQuickTransition *populate() const; | - |
125 | void setPopulate(QQuickTransition *); | - |
126 | - | |
127 | QQuickTransition *move() const; | - |
128 | void setMove(QQuickTransition *); | - |
129 | - | |
130 | QQuickTransition *add() const; | - |
131 | void setAdd(QQuickTransition *); | - |
132 | - | |
133 | static QQuickPositionerAttached *qmlAttachedProperties(QObject *obj); | - |
134 | - | |
135 | void updateAttachedProperties(QQuickPositionerAttached *specificProperty = nullptr, QQuickItem *specificPropertyOwner = nullptr) const; | - |
136 | - | |
137 | qreal padding() const; | - |
138 | void setPadding(qreal padding); | - |
139 | void resetPadding(); | - |
140 | - | |
141 | qreal topPadding() const; | - |
142 | void setTopPadding(qreal padding); | - |
143 | void resetTopPadding(); | - |
144 | - | |
145 | qreal leftPadding() const; | - |
146 | void setLeftPadding(qreal padding); | - |
147 | void resetLeftPadding(); | - |
148 | - | |
149 | qreal rightPadding() const; | - |
150 | void setRightPadding(qreal padding); | - |
151 | void resetRightPadding(); | - |
152 | - | |
153 | qreal bottomPadding() const; | - |
154 | void setBottomPadding(qreal padding); | - |
155 | void resetBottomPadding(); | - |
156 | - | |
157 | Q_REVISION(9) Q_INVOKABLE void forceLayout(); | - |
158 | - | |
159 | protected: | - |
160 | QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent); | - |
161 | void componentComplete() override; | - |
162 | void itemChange(ItemChange, const ItemChangeData &) override; | - |
163 | - | |
164 | void updatePolish() override; | - |
165 | - | |
166 | Q_SIGNALS: | - |
167 | void spacingChanged(); | - |
168 | void populateChanged(); | - |
169 | void moveChanged(); | - |
170 | void addChanged(); | - |
171 | Q_REVISION(6) void paddingChanged(); | - |
172 | Q_REVISION(6) void topPaddingChanged(); | - |
173 | Q_REVISION(6) void leftPaddingChanged(); | - |
174 | Q_REVISION(6) void rightPaddingChanged(); | - |
175 | Q_REVISION(6) void bottomPaddingChanged(); | - |
176 | Q_REVISION(9) void positioningComplete(); | - |
177 | - | |
178 | protected Q_SLOTS: | - |
179 | void prePositioning(); | - |
180 | - | |
181 | protected: | - |
182 | virtual void doPositioning(QSizeF *contentSize)=0; | - |
183 | virtual void reportConflictingAnchors()=0; | - |
184 | - | |
185 | class PositionedItem | - |
186 | { | - |
187 | public : | - |
188 | PositionedItem(QQuickItem *i); | - |
189 | ~PositionedItem(); | - |
190 | bool operator==(const PositionedItem &other) const { return other.item == item; } executed 203823 times by 10 tests: return other.item == item; Executed by:
| 203823 |
191 | - | |
192 | qreal itemX() const; | - |
193 | qreal itemY() const; | - |
194 | - | |
195 | void moveTo(const QPointF &pos); | - |
196 | - | |
197 | void transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget); | - |
198 | bool prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds); | - |
199 | void startTransition(QQuickItemViewTransitioner *transitioner); | - |
200 | - | |
201 | void updatePadding(qreal lp, qreal tp, qreal rp, qreal bp); | - |
202 | - | |
203 | QQuickItem *item; | - |
204 | QQuickItemViewTransitionableItem *transitionableItem; | - |
205 | int index; | - |
206 | bool isNew; | - |
207 | bool isVisible; | - |
208 | - | |
209 | qreal topPadding; | - |
210 | qreal leftPadding; | - |
211 | qreal rightPadding; | - |
212 | qreal bottomPadding; | - |
213 | }; | - |
214 | - | |
215 | QPODVector<PositionedItem,8> positionedItems; | - |
216 | QPODVector<PositionedItem,8> unpositionedItems;//Still 'in' the positioner, just not positioned | - |
217 | - | |
218 | void positionItem(qreal x, qreal y, PositionedItem *target); | - |
219 | void positionItemX(qreal, PositionedItem *target); | - |
220 | void positionItemY(qreal, PositionedItem *target); | - |
221 | - | |
222 | void removePositionedItem(QPODVector<PositionedItem,8> *items, int index); | - |
223 | void clearPositionedItems(QPODVector<PositionedItem,8> *items); | - |
224 | - | |
225 | private: | - |
226 | Q_DISABLE_COPY(QQuickBasePositioner) | - |
227 | Q_DECLARE_PRIVATE(QQuickBasePositioner) executed 205579 times by 23 tests: return reinterpret_cast<QQuickBasePositionerPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
executed 967968 times by 23 tests: return reinterpret_cast<const QQuickBasePositionerPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
| 205579-967968 |
228 | }; | - |
229 | - | |
230 | class Q_AUTOTEST_EXPORT QQuickColumn : public QQuickBasePositioner | - |
231 | { | - |
232 | Q_OBJECT | - |
233 | public: | - |
234 | QQuickColumn(QQuickItem *parent=nullptr); | - |
235 | - | |
236 | protected: | - |
237 | void doPositioning(QSizeF *contentSize) override; | - |
238 | void reportConflictingAnchors() override; | - |
239 | private: | - |
240 | Q_DISABLE_COPY(QQuickColumn) | - |
241 | }; | - |
242 | - | |
243 | class QQuickRowPrivate; | - |
244 | class Q_AUTOTEST_EXPORT QQuickRow: public QQuickBasePositioner | - |
245 | { | - |
246 | Q_OBJECT | - |
247 | Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged) | - |
248 | Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged) | - |
249 | public: | - |
250 | QQuickRow(QQuickItem *parent=nullptr); | - |
251 | - | |
252 | Qt::LayoutDirection layoutDirection() const; | - |
253 | void setLayoutDirection (Qt::LayoutDirection); | - |
254 | Qt::LayoutDirection effectiveLayoutDirection() const; | - |
255 | - | |
256 | Q_SIGNALS: | - |
257 | void layoutDirectionChanged(); | - |
258 | void effectiveLayoutDirectionChanged(); | - |
259 | - | |
260 | protected: | - |
261 | void doPositioning(QSizeF *contentSize) override; | - |
262 | void reportConflictingAnchors() override; | - |
263 | private: | - |
264 | Q_DISABLE_COPY(QQuickRow) | - |
265 | Q_DECLARE_PRIVATE(QQuickRow) never executed: return reinterpret_cast<QQuickRowPrivate *>(qGetPtrHelper(d_ptr)); never executed: return reinterpret_cast<const QQuickRowPrivate *>(qGetPtrHelper(d_ptr)); | 0 |
266 | }; | - |
267 | - | |
268 | class QQuickGridPrivate; | - |
269 | class Q_AUTOTEST_EXPORT QQuickGrid : public QQuickBasePositioner | - |
270 | { | - |
271 | Q_OBJECT | - |
272 | Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged) | - |
273 | Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged) | - |
274 | Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged RESET resetRowSpacing) | - |
275 | Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged RESET resetColumnSpacing) | - |
276 | Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) | - |
277 | Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged) | - |
278 | Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged) | - |
279 | Q_PROPERTY(HAlignment horizontalItemAlignment READ hItemAlign WRITE setHItemAlign NOTIFY horizontalAlignmentChanged REVISION 1) | - |
280 | Q_PROPERTY(HAlignment effectiveHorizontalItemAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged REVISION 1) | - |
281 | Q_PROPERTY(VAlignment verticalItemAlignment READ vItemAlign WRITE setVItemAlign NOTIFY verticalAlignmentChanged REVISION 1) | - |
282 | - | |
283 | public: | - |
284 | QQuickGrid(QQuickItem *parent=nullptr); | - |
285 | - | |
286 | int rows() const { return m_rows; } executed 12 times by 2 tests: return m_rows; Executed by:
| 12 |
287 | void setRows(const int rows); | - |
288 | - | |
289 | int columns() const { return m_columns; } executed 12 times by 2 tests: return m_columns; Executed by:
| 12 |
290 | void setColumns(const int columns); | - |
291 | - | |
292 | qreal rowSpacing() const { return m_rowSpacing; } executed 4 times by 1 test: return m_rowSpacing; Executed by:
| 4 |
293 | void setRowSpacing(qreal); | - |
294 | void resetRowSpacing() { m_useRowSpacing = false; } never executed: end of block | 0 |
295 | - | |
296 | qreal columnSpacing() const { return m_columnSpacing; } executed 4 times by 1 test: return m_columnSpacing; Executed by:
| 4 |
297 | void setColumnSpacing(qreal); | - |
298 | void resetColumnSpacing() { m_useColumnSpacing = false; } never executed: end of block | 0 |
299 | - | |
300 | enum Flow { LeftToRight, TopToBottom }; | - |
301 | Q_ENUM(Flow) | - |
302 | Flow flow() const; | - |
303 | void setFlow(Flow); | - |
304 | - | |
305 | Qt::LayoutDirection layoutDirection() const; | - |
306 | void setLayoutDirection (Qt::LayoutDirection); | - |
307 | Qt::LayoutDirection effectiveLayoutDirection() const; | - |
308 | - | |
309 | enum HAlignment { AlignLeft = Qt::AlignLeft, | - |
310 | AlignRight = Qt::AlignRight, | - |
311 | AlignHCenter = Qt::AlignHCenter}; | - |
312 | Q_ENUM(HAlignment) | - |
313 | enum VAlignment { AlignTop = Qt::AlignTop, | - |
314 | AlignBottom = Qt::AlignBottom, | - |
315 | AlignVCenter = Qt::AlignVCenter }; | - |
316 | Q_ENUM(VAlignment) | - |
317 | - | |
318 | HAlignment hItemAlign() const; | - |
319 | void setHItemAlign(HAlignment align); | - |
320 | HAlignment effectiveHAlign() const; | - |
321 | - | |
322 | VAlignment vItemAlign() const; | - |
323 | void setVItemAlign(VAlignment align); | - |
324 | - | |
325 | Q_SIGNALS: | - |
326 | void rowsChanged(); | - |
327 | void columnsChanged(); | - |
328 | void flowChanged(); | - |
329 | void layoutDirectionChanged(); | - |
330 | void effectiveLayoutDirectionChanged(); | - |
331 | void rowSpacingChanged(); | - |
332 | void columnSpacingChanged(); | - |
333 | Q_REVISION(1) void horizontalAlignmentChanged(HAlignment alignment); | - |
334 | Q_REVISION(1) void effectiveHorizontalAlignmentChanged(HAlignment alignment); | - |
335 | Q_REVISION(1) void verticalAlignmentChanged(VAlignment alignment); | - |
336 | - | |
337 | protected: | - |
338 | void doPositioning(QSizeF *contentSize) override; | - |
339 | void reportConflictingAnchors() override; | - |
340 | - | |
341 | private: | - |
342 | int m_rows; | - |
343 | int m_columns; | - |
344 | qreal m_rowSpacing; | - |
345 | qreal m_columnSpacing; | - |
346 | bool m_useRowSpacing; | - |
347 | bool m_useColumnSpacing; | - |
348 | Flow m_flow; | - |
349 | HAlignment m_hItemAlign; | - |
350 | VAlignment m_vItemAlign; | - |
351 | Q_DISABLE_COPY(QQuickGrid) | - |
352 | Q_DECLARE_PRIVATE(QQuickGrid) never executed: return reinterpret_cast<QQuickGridPrivate *>(qGetPtrHelper(d_ptr)); never executed: return reinterpret_cast<const QQuickGridPrivate *>(qGetPtrHelper(d_ptr)); | 0 |
353 | }; | - |
354 | - | |
355 | class QQuickFlowPrivate; | - |
356 | class Q_AUTOTEST_EXPORT QQuickFlow: public QQuickBasePositioner | - |
357 | { | - |
358 | Q_OBJECT | - |
359 | Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) | - |
360 | Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged) | - |
361 | Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged) | - |
362 | public: | - |
363 | QQuickFlow(QQuickItem *parent=nullptr); | - |
364 | - | |
365 | enum Flow { LeftToRight, TopToBottom }; | - |
366 | Q_ENUM(Flow) | - |
367 | Flow flow() const; | - |
368 | void setFlow(Flow); | - |
369 | - | |
370 | Qt::LayoutDirection layoutDirection() const; | - |
371 | void setLayoutDirection (Qt::LayoutDirection); | - |
372 | Qt::LayoutDirection effectiveLayoutDirection() const; | - |
373 | - | |
374 | Q_SIGNALS: | - |
375 | void flowChanged(); | - |
376 | void layoutDirectionChanged(); | - |
377 | void effectiveLayoutDirectionChanged(); | - |
378 | - | |
379 | protected: | - |
380 | void doPositioning(QSizeF *contentSize) override; | - |
381 | void reportConflictingAnchors() override; | - |
382 | protected: | - |
383 | QQuickFlow(QQuickFlowPrivate &dd, QQuickItem *parent); | - |
384 | private: | - |
385 | Q_DISABLE_COPY(QQuickFlow) | - |
386 | Q_DECLARE_PRIVATE(QQuickFlow) executed 1580 times by 3 tests: return reinterpret_cast<QQuickFlowPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
executed 12 times by 1 test: return reinterpret_cast<const QQuickFlowPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
| 12-1580 |
387 | }; | - |
388 | - | |
389 | - | |
390 | QT_END_NAMESPACE | - |
391 | - | |
392 | QML_DECLARE_TYPE(QQuickColumn) | - |
393 | QML_DECLARE_TYPE(QQuickRow) | - |
394 | QML_DECLARE_TYPE(QQuickGrid) | - |
395 | QML_DECLARE_TYPE(QQuickFlow) | - |
396 | - | |
397 | QML_DECLARE_TYPE(QQuickBasePositioner) | - |
398 | QML_DECLARE_TYPEINFO(QQuickBasePositioner, QML_HAS_ATTACHED_PROPERTIES) | - |
399 | - | |
400 | #endif // QQUICKPOSITIONERS_P_H | - |
Source code | Switch to Preprocessed file |