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 QQUICKPATH_P_H
5#define QQUICKPATH_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qtquickglobal_p.h>
19
20QT_REQUIRE_CONFIG(quick_path);
21
22#include "qquickpath_p.h"
23
24#include <qqml.h>
25#include <QtCore/QStringList>
26
27#include <private/qobject_p.h>
28
29QT_BEGIN_NAMESPACE
30
31class Q_QUICK_EXPORT QQuickPathPrivate : public QObjectPrivate
32{
33 Q_DECLARE_PUBLIC(QQuickPath)
34
35public:
36 static QQuickPathPrivate* get(QQuickPath *path) { return path->d_func(); }
37 static const QQuickPathPrivate* get(const QQuickPath *path) { return path->d_func(); }
38
39 QQuickPathPrivate()
40 : componentComplete(true), isShapePath(false), simplify(false)
41 , processPending(false), asynchronous(false), useCustomPath(false)
42 {}
43
44 void appendPathElement(QQuickPathElement *pathElement)
45 {
46 if (pathElement && componentComplete) {
47 enablePathElement(pathElement);
48 _pathElements.append(t: pathElement);
49 q_func()->processPath();
50 } else {
51 _pathElements.append(t: pathElement);
52 }
53 }
54
55 void removeLastPathElement()
56 {
57 QQuickPathElement *pathElement = _pathElements.takeLast();
58 if (pathElement && componentComplete) {
59 disablePathElement(pathElement);
60 q_func()->processPath();
61 }
62 }
63
64 void replacePathElement(qsizetype position, QQuickPathElement *pathElement)
65 {
66 if (position >= _pathElements.length())
67 _pathElements.resize(size: position + 1, c: nullptr);
68
69 if (!componentComplete) {
70 _pathElements[position] = pathElement;
71 return;
72 }
73
74 bool changed = false;
75
76 QQuickPathElement *oldElement = _pathElements.at(i: position);
77 if (oldElement == pathElement)
78 return;
79
80 if (oldElement) {
81 disablePathElement(pathElement: oldElement);
82 changed = true;
83 }
84
85 if (pathElement) {
86 enablePathElement(pathElement);
87 changed = true;
88 }
89
90 _pathElements[position] = pathElement;
91
92 if (changed)
93 q_func()->processPath();
94 }
95
96 QPainterPath _path;
97 QList<QQuickPathElement*> _pathElements;
98 mutable QVector<QPointF> _pointCache;
99 QList<QQuickPath::AttributePoint> _attributePoints;
100 QStringList _attributes;
101 QList<QQuickCurve*> _pathCurves;
102 QList<QQuickPathText*> _pathTexts;
103 mutable QQuickCachedBezier prevBez;
104 QQmlNullableValue<qreal> startX;
105 QQmlNullableValue<qreal> startY;
106 qreal pathLength = 0;
107 QSizeF scale = QSizeF(1, 1);
108 bool closed = false;
109 bool componentComplete : 1;
110 bool isShapePath : 1;
111 bool simplify : 1;
112 bool processPending : 1;
113 bool asynchronous : 1;
114 bool useCustomPath : 1;
115
116private:
117 void enablePathElement(QQuickPathElement *pathElement);
118 void disablePathElement(QQuickPathElement *pathElement);
119};
120
121QT_END_NAMESPACE
122
123#endif
124

source code of qtdeclarative/src/quick/util/qquickpath_p_p.h