Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsvgstyleselector.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 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
// Qt-Security score:significant reason:default
4
5
6
#
include
"qsvgstyleselector_p.h"
7
#
include
<
QtSvg
/
private
/
qsvgnode_p
.
h
>
8
#
include
<
QtSvg
/
private
/
qsvgstructure_p
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
QSvgStyleSelector::QSvgStyleSelector()
13
{
14
nameCaseSensitivity = Qt::CaseInsensitive;
15
}
16
17
QSvgStyleSelector
::~
QSvgStyleSelector
()
18
{
19
}
20
21
QSvgNode *
QSvgStyleSelector
::
svgNode
(NodePtr node)
const
22
{
23
return
(QSvgNode*)node.ptr;
24
}
25
26
QSvgStructureNode *
QSvgStyleSelector
::
nodeToStructure
(QSvgNode *n)
const
27
{
28
if
(n &&
29
(n->type() == QSvgNode::Doc ||
30
n->type() == QSvgNode::Group ||
31
n->type() == QSvgNode::Defs ||
32
n->type() == QSvgNode::Switch)) {
33
return
(QSvgStructureNode*)n;
34
}
35
return
0;
36
}
37
38
QSvgStructureNode *
QSvgStyleSelector
::
svgStructure
(NodePtr node)
const
39
{
40
QSvgNode *n = svgNode(node);
41
QSvgStructureNode *st =
nodeToStructure
(
n
)
;
42
return
st;
43
}
44
45
bool
QSvgStyleSelector
::
nodeNameEquals
(NodePtr node,
const
QString &nodeName)
const
46
{
47
QSvgNode *n = svgNode(node);
48
if
(!n)
49
return
false
;
50
return
QString::compare(n->typeName(), nodeName, Qt::CaseInsensitive) == 0;
51
}
52
53
QString
QSvgStyleSelector
::
attributeValue
(NodePtr node,
const
QCss::AttributeSelector &asel)
const
54
{
55
const
QString &name = asel.name;
56
QSvgNode *n = svgNode(node);
57
if
((!n->nodeId().isEmpty() && (name == QLatin1String(
"id"
) ||
58
name == QLatin1String(
"xml:id"
))))
59
return
n->nodeId();
60
if
(!n->xmlClass().isEmpty() && name == QLatin1String(
"class"
))
61
return
n->xmlClass();
62
return
QString();
63
}
64
65
bool
QSvgStyleSelector
::
hasAttributes
(NodePtr node)
const
66
{
67
QSvgNode *n = svgNode(node);
68
return
(n &&
69
(!n->nodeId().isEmpty() || !n->xmlClass().isEmpty()));
70
}
71
72
QStringList
QSvgStyleSelector
::
nodeIds
(NodePtr node)
const
73
{
74
QSvgNode *n = svgNode(node);
75
QString nid;
76
if
(n)
77
nid = n->nodeId();
78
QStringList lst; lst.append(nid);
79
return
lst;
80
}
81
82
QStringList
QSvgStyleSelector
::
nodeNames
(NodePtr node)
const
83
{
84
QSvgNode *n = svgNode(node);
85
if
(n)
86
return
QStringList(n->typeName());
87
return
QStringList();
88
}
89
90
bool
QSvgStyleSelector
::
isNullNode
(NodePtr node)
const
91
{
92
return
!node.ptr;
93
}
94
95
QCss
::
StyleSelector
::
NodePtr
QSvgStyleSelector
::
parentNode
(NodePtr node)
const
96
{
97
QSvgNode *n = svgNode(node);
98
NodePtr newNode;
99
newNode.ptr = 0;
100
newNode.id = 0;
101
if
(n) {
102
QSvgNode *svgParent = n->parent();
103
if
(svgParent) {
104
newNode.ptr = svgParent;
105
}
106
}
107
return
newNode;
108
}
109
110
QCss
::
StyleSelector
::
NodePtr
QSvgStyleSelector
::
previousSiblingNode
(NodePtr node)
const
111
{
112
NodePtr newNode;
113
newNode.ptr = 0;
114
newNode.id = 0;
115
116
QSvgNode *n = svgNode(node);
117
if
(!n)
118
return
newNode;
119
QSvgStructureNode *svgParent =
nodeToStructure
(
n->parent()
)
;
120
121
if
(svgParent) {
122
newNode.ptr = svgParent->previousSiblingNode(n);
123
}
124
return
newNode;
125
}
126
127
QCss
::
StyleSelector
::
NodePtr
QSvgStyleSelector
::
duplicateNode
(NodePtr node)
const
128
{
129
NodePtr n;
130
n.ptr = node.ptr;
131
n.id = node.id;
132
return
n;
133
}
134
135
void
QSvgStyleSelector
::
freeNode
(NodePtr node)
const
136
{
137
Q_UNUSED(node);
138
}
139
140
QT_END_NAMESPACE
QSvgStyleSelector
Definition
qsvgstyleselector_p.h:28
QSvgStyleSelector::nodeNames
QStringList nodeNames(NodePtr node) const override
Definition
qsvgstyleselector.cpp:82
QSvgStyleSelector::svgStructure
QSvgStructureNode * svgStructure(NodePtr node) const
Definition
qsvgstyleselector.cpp:38
QSvgStyleSelector::hasAttributes
bool hasAttributes(NodePtr node) const override
Definition
qsvgstyleselector.cpp:65
QSvgStyleSelector::attributeValue
QString attributeValue(NodePtr node, const QCss::AttributeSelector &asel) const override
Definition
qsvgstyleselector.cpp:53
QSvgStyleSelector::isNullNode
bool isNullNode(NodePtr node) const override
Definition
qsvgstyleselector.cpp:90
QSvgStyleSelector::nodeToStructure
QSvgStructureNode * nodeToStructure(QSvgNode *n) const
Definition
qsvgstyleselector.cpp:26
QSvgStyleSelector::freeNode
void freeNode(NodePtr node) const override
Definition
qsvgstyleselector.cpp:135
QSvgStyleSelector::duplicateNode
NodePtr duplicateNode(NodePtr node) const override
Definition
qsvgstyleselector.cpp:127
QSvgStyleSelector::svgNode
QSvgNode * svgNode(NodePtr node) const
Definition
qsvgstyleselector.cpp:21
QSvgStyleSelector::parentNode
NodePtr parentNode(NodePtr node) const override
Definition
qsvgstyleselector.cpp:95
QSvgStyleSelector::~QSvgStyleSelector
virtual ~QSvgStyleSelector()
Definition
qsvgstyleselector.cpp:17
QSvgStyleSelector::nodeIds
QStringList nodeIds(NodePtr node) const override
Definition
qsvgstyleselector.cpp:72
QSvgStyleSelector::previousSiblingNode
NodePtr previousSiblingNode(NodePtr node) const override
Definition
qsvgstyleselector.cpp:110
QSvgStyleSelector::nodeNameEquals
bool nodeNameEquals(NodePtr node, const QString &nodeName) const override
Definition
qsvgstyleselector.cpp:45
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtsvg
src
svg
css
qsvgstyleselector.cpp
Generated on
for Qt by
1.18.0