summaryrefslogtreecommitdiffstats
path: root/src/svg/qsvgstructure.cpp
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-09-14 15:50:30 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-09-14 15:57:15 (GMT)
commitab35f0f8b0d872bc2e963c6ef869fade71b83e3f (patch)
treeaf58509d936d6656fd6340c5f5da04aec85e912f /src/svg/qsvgstructure.cpp
parent886feff55f48ebdff0440278e611f822e6326c91 (diff)
downloadQt-ab35f0f8b0d872bc2e963c6ef869fade71b83e3f.zip
Qt-ab35f0f8b0d872bc2e963c6ef869fade71b83e3f.tar.gz
Qt-ab35f0f8b0d872bc2e963c6ef869fade71b83e3f.tar.bz2
Fixed gradient referencing in SVGs.
An SVG element can now reference a gradient or solid-color defined anywhere in the same SVG file. Task-number: 245602 Reviewed-by: Trond
Diffstat (limited to 'src/svg/qsvgstructure.cpp')
-rw-r--r--src/svg/qsvgstructure.cpp50
1 files changed, 8 insertions, 42 deletions
diff --git a/src/svg/qsvgstructure.cpp b/src/svg/qsvgstructure.cpp
index 47a544f..82c800d 100644
--- a/src/svg/qsvgstructure.cpp
+++ b/src/svg/qsvgstructure.cpp
@@ -45,6 +45,7 @@
#include "qsvgnode_p.h"
#include "qsvgstyle_p.h"
+#include "qsvgtinydocument_p.h"
#include "qpainter.h"
#include "qlocale.h"
@@ -90,35 +91,20 @@ QSvgStructureNode::QSvgStructureNode(QSvgNode *parent)
QSvgNode * QSvgStructureNode::scopeNode(const QString &id) const
{
- const QSvgStructureNode *group = this;
- while (group && group->type() != QSvgNode::DOC) {
- group = static_cast<QSvgStructureNode*>(group->parent());
- }
- if (group)
- return group->m_scope[id];
- return 0;
+ QSvgTinyDocument *doc = document();
+ return doc ? doc->namedNode(id) : 0;
}
-void QSvgStructureNode::addChild(QSvgNode *child, const QString &id, bool def)
+void QSvgStructureNode::addChild(QSvgNode *child, const QString &id)
{
- if (!def)
- m_renderers.append(child);
-
- if (child->type() == QSvgNode::DEFS) {
- QSvgDefs *defs =
- static_cast<QSvgDefs*>(child);
- m_linkedScopes.append(defs);
- }
+ m_renderers.append(child);
if (id.isEmpty())
return; //we can't add it to scope without id
- QSvgStructureNode *group = this;
- while (group && group->type() != QSvgNode::DOC) {
- group = static_cast<QSvgStructureNode*>(group->parent());
- }
- if (group)
- group->m_scope.insert(id, child);
+ QSvgTinyDocument *doc = document();
+ if (doc)
+ doc->addNamedNode(id, child);
}
QSvgDefs::QSvgDefs(QSvgNode *parent)
@@ -136,26 +122,6 @@ QSvgNode::Type QSvgDefs::type() const
return DEFS;
}
-QSvgStyleProperty * QSvgStructureNode::scopeStyle(const QString &id) const
-{
- const QSvgStructureNode *group = this;
- while (group) {
- QSvgStyleProperty *prop = group->styleProperty(id);
- if (prop)
- return prop;
- QList<QSvgStructureNode*>::const_iterator itr = group->m_linkedScopes.constBegin();
- while (itr != group->m_linkedScopes.constEnd()) {
- prop = (*itr)->styleProperty(id);
- if (prop)
- return prop;
- ++itr;
- }
- group = static_cast<QSvgStructureNode*>(group->parent());
- }
- return 0;
-}
-
-
/*
Below is a lookup function based on the gperf output using the following set: