1// Copyright (C) 2024 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 QQUICKITEMGENERATOR_P_H
5#define QQUICKITEMGENERATOR_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 "qquickgenerator_p.h"
19#include <QStack>
20
21QT_BEGIN_NAMESPACE
22
23class Q_QUICKVECTORIMAGEGENERATOR_EXPORT QQuickItemGenerator : public QQuickGenerator
24{
25public:
26 QQuickItemGenerator(const QString fileName, QQuickVectorImageGenerator::GeneratorFlags flags, QQuickItem *parentItem);
27 ~QQuickItemGenerator();
28
29protected:
30 void generateNodeBase(const NodeInfo &info) override;
31 bool generateDefsNode(const NodeInfo &info) override;
32 void generateImageNode(const ImageNodeInfo &info) override;
33 void generatePath(const PathNodeInfo &info, const QRectF &overrideBoundingRect) override;
34 void generateNode(const NodeInfo &info) override;
35 void generateTextNode(const TextNodeInfo &info) override;
36 void generateUseNode(const UseNodeInfo &info) override;
37 bool generateStructureNode(const StructureNodeInfo &info) override;
38 bool generateRootNode(const StructureNodeInfo &info) override;
39 void outputShapePath(const PathNodeInfo &info, const QPainterPath *path, const QQuadPath *quadPath, QQuickVectorImageGenerator::PathSelector pathSelector, const QRectF &boundingRect) override;
40
41private:
42 void generateGradient(const QGradient *grad, QQuickShapePath *shapePath);
43 void generatePathContainer(const StructureNodeInfo &info);
44 QQuickItem *currentItem();
45 void addCurrentItem(QQuickItem *item, const NodeInfo &info);
46
47 bool m_inShapeItem = false;
48 QQuickShape *m_parentShapeItem = nullptr;
49
50 QStack<QQuickItem *> m_items;
51
52 QQuickItem *m_parentItem = nullptr;
53};
54
55QT_END_NAMESPACE
56
57#endif // QQUICKITEMGENERATOR_P_H
58

source code of qtdeclarative/src/quickvectorimage/generator/qquickitemgenerator_p.h