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 QSVGVISITORIMPL_P_H |
5 | #define QSVGVISITORIMPL_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 <QtSvg/private/qsvgvisitor_p.h> |
19 | #include "qquickgenerator_p.h" |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QTextStream; |
24 | class QSvgTinyDocument; |
25 | class QString; |
26 | class QQuickItem; |
27 | |
28 | class QSvgVisitorImpl : public QSvgVisitor |
29 | { |
30 | public: |
31 | QSvgVisitorImpl(const QString svgFileName, QQuickGenerator *generator); |
32 | bool traverse(); |
33 | |
34 | protected: |
35 | void visitNode(const QSvgNode *node) override; |
36 | void visitImageNode(const QSvgImage *node) override; |
37 | void visitRectNode(const QSvgRect *node) override; |
38 | void visitEllipseNode(const QSvgEllipse *node) override; |
39 | void visitPathNode(const QSvgPath *node) override; |
40 | void visitLineNode(const QSvgLine *node) override; |
41 | void visitPolygonNode(const QSvgPolygon *node) override; |
42 | void visitPolylineNode(const QSvgPolyline *node) override; |
43 | void visitTextNode(const QSvgText *node) override; |
44 | void visitUseNode(const QSvgUse *node) override; |
45 | bool visitDefsNodeStart(const QSvgDefs *node) override; |
46 | bool visitStructureNodeStart(const QSvgStructureNode *node) override; |
47 | void visitStructureNodeEnd(const QSvgStructureNode *node) override; |
48 | |
49 | bool visitDocumentNodeStart(const QSvgTinyDocument *node) override; |
50 | void visitDocumentNodeEnd(const QSvgTinyDocument *node) override; |
51 | |
52 | bool visitSwitchNodeStart(const QSvgSwitch *node) override; |
53 | void visitSwitchNodeEnd(const QSvgSwitch *node) override; |
54 | |
55 | private: |
56 | void fillCommonNodeInfo(const QSvgNode *node, NodeInfo &info); |
57 | void handleBaseNodeSetup(const QSvgNode *node); |
58 | void handleBaseNode(const QSvgNode *node); |
59 | void handleBaseNodeEnd(const QSvgNode *node); |
60 | void handlePathNode(const QSvgNode *node, const QPainterPath &path); |
61 | void outputShapePath(QPainterPath pathCopy, const PathNodeInfo &info); |
62 | static QString gradientCssDescription(const QGradient *gradient); |
63 | static QString colorCssDescription(QColor color); |
64 | |
65 | private: |
66 | QString m_svgFileName; |
67 | QQuickGenerator *m_generator; |
68 | }; |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | #endif // QSVGVISITORIMPL_P_H |
73 | |