summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-06-21 13:51:09 +0200
committerMontel Laurent <[email protected]>2017-06-21 14:04:15 +0200
commit31b0ee01a9b64408223ac342cbd812382d448d2b (patch)
treef8d4f70e0f3b77ffadd86441eb60eeb2bacd4cce
parentb95c20da2e68bed91667c95667b3282e23cf6dc4 (diff)
Clean up code
-rw-r--r--src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.cpp22
-rw-r--r--src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.h2
2 files changed, 16 insertions, 8 deletions
diff --git a/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.cpp b/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.cpp
index 662c097..92f68d1 100644
--- a/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.cpp
+++ b/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.cpp
@@ -25,7 +25,7 @@ using KSieve::Parser;
#include "libksieve_debug.h"
#include <QXmlStreamWriter>
-#define USE_QXMLSTREAMWRITER 1
+//#define USE_QXMLSTREAMWRITER 1
using namespace KSieveUi;
XMLPrintingScriptBuilder::XMLPrintingScriptBuilder()
: KSieve::ScriptBuilder(),
@@ -55,12 +55,20 @@ void XMLPrintingScriptBuilder::taggedArgument(const QString &tag)
void XMLPrintingScriptBuilder::stringArgument(const QString &string, bool multiLine, const QString & /*fixme*/)
{
- write(QStringLiteral("str"), multiLine ? QStringLiteral("type=\"multiline\"") : QStringLiteral("type=\"quoted\""), string);
+ if (multiLine) {
+ write(QStringLiteral("str"), QStringLiteral("type"), QStringLiteral("multiline"), string);
+ } else {
+ write(QStringLiteral("str"), QStringLiteral("type"), QStringLiteral("quoted"), string);
+ }
}
void XMLPrintingScriptBuilder::numberArgument(unsigned long number, char quantifier)
{
- write(QStringLiteral("num"), (quantifier ? QStringLiteral("quantifier=\"%1\"").arg(quantifier) : QString()), QString::number(number));
+ if (quantifier) {
+ write(QStringLiteral("num"), QStringLiteral("quantifier"), QStringLiteral("%1").arg(quantifier), QString::number(number));
+ } else {
+ write(QStringLiteral("num"), QString(), QString(), QString::number(number));
+ }
}
void XMLPrintingScriptBuilder::commandStart(const QString &identifier, int lineNumber)
@@ -187,12 +195,12 @@ void XMLPrintingScriptBuilder::stringListEntry(const QString &string, bool multi
void XMLPrintingScriptBuilder::hashComment(const QString &comment)
{
- write(QStringLiteral("comment"), QStringLiteral("type=\"hash\""), comment);
+ write(QStringLiteral("comment"), QStringLiteral("type"), QStringLiteral("hash"), comment);
}
void XMLPrintingScriptBuilder::bracketComment(const QString &comment)
{
- write(QStringLiteral("comment"), QStringLiteral("type=\"bracket\""), comment);
+ write(QStringLiteral("comment"), QStringLiteral("type"), QStringLiteral("bracket"), comment);
}
void XMLPrintingScriptBuilder::lineFeed()
@@ -245,7 +253,7 @@ void XMLPrintingScriptBuilder::write(const QString &key, const QString &value)
#endif
}
-void XMLPrintingScriptBuilder::write(const QString &key, const QString &attribute, const QString &value)
+void XMLPrintingScriptBuilder::write(const QString &key, const QString &qualifiedName, const QString &attribute, const QString &value)
{
if (value.isEmpty()) {
#ifdef USE_QXMLSTREAMWRITER
@@ -267,7 +275,7 @@ void XMLPrintingScriptBuilder::write(const QString &key, const QString &attribut
if (attribute.isEmpty()) {
write(QStringLiteral("<%1>").arg(key));
} else {
- write(QStringLiteral("<%1 %2>").arg(key, attribute));
+ write(QStringLiteral("<%1 %2=\"%3\">").arg(key, qualifiedName, attribute));
}
QString tmpValue = value;
tmpValue.replace(QLatin1Char('<'), QLatin1String("&lt;"));
diff --git a/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.h b/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.h
index 6871c84..68e590d 100644
--- a/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.h
+++ b/src/ksieveui/scriptsparsing/xmlprintingscriptbuilder.h
@@ -64,7 +64,7 @@ public:
private:
void write(const QString &msg);
void write(const QString &key, const QString &value);
- void write(const QString &key, const QString &attribute, const QString &value);
+ void write(const QString &key, const QString &qualifiedName, const QString &attribute, const QString &value);
QXmlStreamWriter *mStream;
QString mResult;