// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // Qt-Security score:significant reason:default #ifndef QQUICKPATH_P_H #define QQUICKPATH_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include QT_REQUIRE_CONFIG(quick_path); #include "qquickpath_p.h" #include #include #include QT_BEGIN_NAMESPACE class Q_QUICK_EXPORT QQuickPathPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QQuickPath) public: static QQuickPathPrivate* get(QQuickPath *path) { return path->d_func(); } static const QQuickPathPrivate* get(const QQuickPath *path) { return path->d_func(); } QQuickPathPrivate() : componentComplete(true), isShapePath(false), simplify(false) , processPending(false), asynchronous(false), useCustomPath(false) {} enum class ProcessPathPolicy { DontProcess, Process }; void appendPathElement(QQuickPathElement *pathElement, ProcessPathPolicy processPathPolicy = ProcessPathPolicy::Process) { if (pathElement && componentComplete) { enablePathElement(pathElement); _pathElements.append(pathElement); if (processPathPolicy == ProcessPathPolicy::Process) q_func()->processPath(); } else { _pathElements.append(pathElement); } } void removeLastPathElement() { QQuickPathElement *pathElement = _pathElements.takeLast(); if (pathElement && componentComplete) { disablePathElement(pathElement); q_func()->processPath(); } } void replacePathElement(qsizetype position, QQuickPathElement *pathElement) { if (position >= _pathElements.length()) _pathElements.resize(position + 1, nullptr); if (!componentComplete) { _pathElements[position] = pathElement; return; } bool changed = false; QQuickPathElement *oldElement = _pathElements.at(position); if (oldElement == pathElement) return; if (oldElement) { disablePathElement(oldElement); changed = true; } if (pathElement) { enablePathElement(pathElement); changed = true; } _pathElements[position] = pathElement; if (changed) q_func()->processPath(); } enum class DeleteElementPolicy { DontDelete, Delete }; void clearPathElements(DeleteElementPolicy deleteElementPolicy = QQuickPathPrivate::DeleteElementPolicy::DontDelete) { Q_Q(QQuickPath); q->disconnectPathElements(); if (deleteElementPolicy == DeleteElementPolicy::Delete) qDeleteAll(_pathElements); _pathElements.clear(); _pathCurves.clear(); _pointCache.clear(); _pathTexts.clear(); _path.clear(); emit q->changed(); } QPainterPath _path; QList _pathElements; mutable QVector _pointCache; QList _attributePoints; QStringList _attributes; QList _pathCurves; QList _pathTexts; mutable QQuickCachedBezier prevBez; QQmlNullableValue startX; QQmlNullableValue startY; qreal pathLength = 0; QSizeF scale = QSizeF(1, 1); bool closed = false; bool componentComplete : 1; bool isShapePath : 1; bool simplify : 1; bool processPending : 1; bool asynchronous : 1; bool useCustomPath : 1; private: void enablePathElement(QQuickPathElement *pathElement); void disablePathElement(QQuickPathElement *pathElement); }; QT_END_NAMESPACE #endif