Commit 24a83838 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(App): svg parser in progress

parent 6c8a198c
...@@ -42,40 +42,45 @@ QImage ImageProvider::requestImage (const QString &id, QSize *, const QSize &) { ...@@ -42,40 +42,45 @@ QImage ImageProvider::requestImage (const QString &id, QSize *, const QSize &) {
const QString path = QStringLiteral(":/assets/images/%1").arg(id); const QString path = QStringLiteral(":/assets/images/%1").arg(id);
// 1. Read and update XML content. // 1. Read and update XML content.
QFile file(path); QFile file(path); // TODO: Check file size.
if (!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))
return QImage(); // Invalid file. return QImage(); // Invalid file.
QString content; QString content;
QXmlStreamReader reader(&file); QXmlStreamReader reader(&file);
bool soFarSoGood = true; while (!reader.atEnd())
while (soFarSoGood && !reader.atEnd())
switch (reader.readNext()) { switch (reader.readNext()) {
case QXmlStreamReader::NoToken: case QXmlStreamReader::Comment:
case QXmlStreamReader::DTD:
case QXmlStreamReader::EndDocument:
case QXmlStreamReader::EntityReference:
case QXmlStreamReader::Invalid: case QXmlStreamReader::Invalid:
case QXmlStreamReader::NoToken:
case QXmlStreamReader::ProcessingInstruction:
case QXmlStreamReader::StartDocument:
break; break;
case QXmlStreamReader::StartDocument:
case QXmlStreamReader::EndDocument:
case QXmlStreamReader::StartElement: { case QXmlStreamReader::StartElement: {
QXmlStreamNamespaceDeclarations declarations = reader.namespaceDeclarations();
QXmlStreamAttributes attributes = reader.attributes(); QXmlStreamAttributes attributes = reader.attributes();
} break;
for (const auto &declaration : declarations) {
qDebug() << "toto" << declaration.namespaceUri() << declaration.prefix();
}
} break; // TODO.
case QXmlStreamReader::EndElement: case QXmlStreamReader::EndElement:
content.append(QStringLiteral("</%1>").arg(reader.name().toString())); content.append(QStringLiteral("</%1>").arg(reader.name().toString()));
break; break;
case QXmlStreamReader::Characters: case QXmlStreamReader::Characters:
case QXmlStreamReader::Comment: content.append(reader.text());
case QXmlStreamReader::DTD:
case QXmlStreamReader::EntityReference:
case QXmlStreamReader::ProcessingInstruction:
break; break;
} }
qDebug() << content; qDebug() << content;
if (!soFarSoGood || reader.hasError()) if (reader.hasError())
return QImage(); // Invalid file. return QImage(); // Invalid file.
// 2. Build svg renderer. // 2. Build svg renderer.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment