Skip to content

Commit

Permalink
Removed dead code based on QDomDocument
Browse files Browse the repository at this point in the history
Removed qSetGlobalQHashSeed which was introduced in DomDocument handling for getting a reproducable XML attribute order (did not work)
  • Loading branch information
s-t-e-f-a-n committed Jul 11, 2024
1 parent f7e1456 commit 7b9384b
Showing 1 changed file with 0 additions and 96 deletions.
96 changes: 0 additions & 96 deletions src/internal/TsBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <QXmlStreamWriter>
#include <QtDebug>

#undef QDOMONLY

TsBuilder::TsBuilder(InOutParameter parameter) : Builder{ std::move(parameter) }
{
if (!m_ioParameter.outputFile.endsWith("ts")) {
Expand All @@ -16,97 +14,6 @@ TsBuilder::TsBuilder(InOutParameter parameter) : Builder{ std::move(parameter) }

auto TsBuilder::build(const Result &res) const -> bool
{
#ifdef QDOMONLY
qSetGlobalQHashSeed(0);

QDomDocument doc;
QDomProcessingInstruction h = doc.createProcessingInstruction(
"xml", "version=\"1.0\" encoding=\"utf-8\"");
doc.appendChild(h);

QDomElement elem = doc.createElement("!DOCTYPE TS");
doc.appendChild(elem);

QDomElement root = doc.createElement("TS");
if (res.root.tsVersion != "") {
root.setAttribute("version", res.root.tsVersion);
}
if (res.root.sourcelanguage != "") {
root.setAttribute("sourcelanguage", res.root.sourcelanguage);
}
if (res.root.language != "") {
root.setAttribute("language", res.root.language);
}
doc.appendChild(root);

for (const auto &ctxs : res.translantions) {
QDomElement context = doc.createElement("context");
root.appendChild(context);

elem = doc.createElement("name");
context.appendChild(elem);
QDomText text = doc.createTextNode(ctxs.name);
elem.appendChild(text);

for (const auto &msg : ctxs.messages) {
QDomElement message = doc.createElement("message");
if (msg.identifier != "") {
message.setAttribute("id", msg.identifier);
}
context.appendChild(message);

for (const auto &loc : msg.locations) {
elem = doc.createElement("location");
elem.setAttribute("filename", loc.first);
elem.setAttribute("line", QString::number(loc.second));
message.appendChild(elem);
}

elem = doc.createElement("source");
message.appendChild(elem);
text = doc.createTextNode(msg.source);
elem.appendChild(text);

if (msg.comment != "") {
elem = doc.createElement("comment");
message.appendChild(elem);
text = doc.createTextNode(msg.comment);
elem.appendChild(text);
}

if (msg.extracomment != "") {
elem = doc.createElement("extracomment");
message.appendChild(elem);
text = doc.createTextNode(msg.extracomment);
elem.appendChild(text);
}

if (msg.translatorcomment != "") {
elem = doc.createElement("translatorcomment");
message.appendChild(elem);
text = doc.createTextNode(msg.translatorcomment);
elem.appendChild(text);
}

elem = doc.createElement("translation");
if (msg.translationtype != "") {
elem.setAttribute("type", msg.translationtype);
}
message.appendChild(elem);
text = doc.createTextNode(msg.translation);
elem.appendChild(text);
}
}

QFile output(m_ioParameter.outputFile);
if (!output.open(QFile::WriteOnly | QFile::Truncate)) {
qWarning() << "can't open file" << output.fileName();
return false;
} else {
QTextStream stream(&output);
stream << doc.toString();
}
#else
QFile output(m_ioParameter.outputFile);
if (!output.open(QFile::WriteOnly | QFile::Truncate)) {
qWarning() << "can't open file" << output.fileName();
Expand Down Expand Up @@ -171,13 +78,10 @@ auto TsBuilder::build(const Result &res) const -> bool
}

s.writeEndDocument();
#endif

output.close();
removeSlashInDoctype(&output);

qSetGlobalQHashSeed(-1);

return true;
}

Expand Down

0 comments on commit 7b9384b

Please sign in to comment.