Commit cd26efb0 authored by Laurent Montel's avatar Laurent Montel 😁

Port two conditions

parent 075e1f9d
......@@ -106,6 +106,46 @@ QString SieveConditionDate::help() const
bool SieveConditionDate::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, bool notCondition, QString &error)
{
int index = 0;
QString type;
QString value;
QString headerStr;
QString commentStr;
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("str")) {
if (index == 0) {
headerStr = element.readElementText();
} else if (index == 1) {
type = element.readElementText();
} else if (index == 2) {
value = element.readElementText();
} else {
tooManyArgument(tagName, index, 3, error);
qCDebug(LIBKSIEVE_LOG) << " SieveConditionDate::setParamWidgetValue too many argument :" << index;
}
++index;
} else if (tagName == QLatin1String("tag")) {
SelectMatchTypeComboBox *selectMatchCombobox = w->findChild<SelectMatchTypeComboBox *>(QStringLiteral("matchtype"));
selectMatchCombobox->setCode(AutoCreateScriptUtil::tagValueWithCondition(element.readElementText(), notCondition), name(), error);
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
commentStr = AutoCreateScriptUtil::loadConditionComment(commentStr, element.readElementText());
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveConditionDate::setParamWidgetValue unknown tag " << tagName;
}
}
if (!commentStr.isEmpty()) {
setComment(commentStr);
}
SelectDateWidget *dateWidget = w->findChild<SelectDateWidget *>(QStringLiteral("datewidget"));
dateWidget->setCode(type, value);
QLineEdit *header = w->findChild<QLineEdit *>(QStringLiteral("header"));
header->setText(headerStr);
#ifdef REMOVE_QDOMELEMENT
int index = 0;
QString type;
......
......@@ -105,6 +105,56 @@ QString SieveConditionVirusTest::help() const
bool SieveConditionVirusTest::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, bool /*notCondition*/, QString &error)
{
QString commentStr;
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
#ifdef QDOMELEMENT_FIXME
if (tagValue == QLatin1String("count") || tagValue == QLatin1String("value")) {
node = node.nextSibling();
if (!node.isNull()) {
QDomElement relationalElement = node.toElement();
if (!relationalElement.isNull()) {
if (relationalElement.tagName() == QLatin1String("str")) {
SelectRelationalMatchType *relation = w->findChild<SelectRelationalMatchType *>(QStringLiteral("relation"));
relation->setCode(AutoCreateScriptUtil::tagValue(tagValue), relationalElement.text(), name(), error);
}
}
}
} else if (tagValue == QLatin1String("comparator")) {
node = node.nextSibling();
if (!node.isNull()) {
QDomElement comparatorElement = node.toElement();
if (!comparatorElement.isNull()) {
if (comparatorElement.tagName() == QLatin1String("str")) {
SelectComparatorComboBox *comparator = w->findChild<SelectComparatorComboBox *>(QStringLiteral("comparator"));
comparator->setCode(comparatorElement.text(), name(), error);
}
}
}
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << " SieveConditionVirusTest::setParamWidgetValue unknown tagValue " << tagValue;
}
#endif
} else if (tagName == QLatin1String("str")) {
QSpinBox *spinbox = w->findChild<QSpinBox *>(QStringLiteral("value"));
spinbox->setValue(element.readElementText().toInt());
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
commentStr = AutoCreateScriptUtil::loadConditionComment(commentStr, element.readElementText());
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveConditionVirusTest::setParamWidgetValue unknown tagName " << tagName;
}
}
if (!commentStr.isEmpty()) {
setComment(commentStr);
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
QString commentStr;
......
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