Commit 794258b1 authored by Laurent Montel's avatar Laurent Montel 😁

Fix deleteheaders

parent 09763543
require "editheader";
#Script name: delete headers
if true {
#SCRIPTNAME: Script part 0
#Script name: delete headers
if true
{
deleteheader :matches "header-str" "header-value";
deleteheader not :is "header-str" "header-value";
deleteheader not :matches "" "";
}
}
\ No newline at end of file
......@@ -92,7 +92,6 @@ void SieveEditorGraphicalModeWidgetTest::shouldLoadScripts()
QVERIFY(proc.waitForFinished());
QEXPECT_FAIL("test-current-date" , "Expected failure on delete-headers file", Continue);
QEXPECT_FAIL("delete-headers" , "Expected failure on delete-headers file", Continue);
QCOMPARE(proc.exitCode(), 0);
}
}
......
......@@ -67,7 +67,7 @@ QWidget *SieveActionDeleteHeader::createParamWidget(QWidget *parent) const
return w;
}
bool SieveActionDeleteHeader::setParamWidgetValue(const QDomElement &element, QWidget *w, QString &error)
bool SieveActionDeleteHeader::parseValue(const QDomElement &element, QWidget *w, QString &error, bool isNegative)
{
int index = 0;
QDomNode node = element.firstChild();
......@@ -76,11 +76,13 @@ bool SieveActionDeleteHeader::setParamWidgetValue(const QDomElement &element, QW
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("test")) {
QDomNode testNode = e.toElement();
return setParamWidgetValue(testNode.toElement(), w, error);
const QDomNode testNode = e.toElement();
const QString nameValue = e.attribute(QStringLiteral("name"), QString());
const bool isNegative = (nameValue == QLatin1String("not"));
return parseValue(testNode.toElement(), w, error, isNegative);
} else if (tagName == QLatin1String("tag")) {
SelectMatchTypeComboBox *combo = w->findChild<SelectMatchTypeComboBox *>(QStringLiteral("matchtype"));
combo->setCode(AutoCreateScriptUtil::tagValue(e.text()), name(), error);
combo->setCode(AutoCreateScriptUtil::tagValueWithCondition(e.text(), isNegative), name(), error);
} else if (tagName == QLatin1String("str")) {
if (index == 0) {
QLineEdit *edit = w->findChild<QLineEdit *>(QStringLiteral("headeredit"));
......@@ -107,6 +109,11 @@ bool SieveActionDeleteHeader::setParamWidgetValue(const QDomElement &element, QW
return true;
}
bool SieveActionDeleteHeader::setParamWidgetValue(const QDomElement &element, QWidget *w, QString &error)
{
return parseValue(element, w, error, false);
}
QString SieveActionDeleteHeader::code(QWidget *w) const
{
const SelectMatchTypeComboBox *combo = w->findChild<SelectMatchTypeComboBox *>(QStringLiteral("matchtype"));
......
......@@ -31,6 +31,8 @@ public:
bool setParamWidgetValue(const QDomElement &element, QWidget *parent, QString &error) Q_DECL_OVERRIDE;
QString help() const Q_DECL_OVERRIDE;
QUrl href() const Q_DECL_OVERRIDE;
private:
bool parseValue(const QDomElement &element, QWidget *w, QString &error, bool isNegative);
};
}
......
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