summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-05-13 18:15:54 +0200
committerMontel Laurent <[email protected]>2017-05-13 18:15:54 +0200
commit794258b1d82c69152bf58efcaeb209912682b24c (patch)
tree51cf2548728dbc90cfec5825aa3c31bdff15c387
parent097635433a5421d9505f2119f0358c45ec522625 (diff)
Fix deleteheaders
-rw-r--r--src/ksieveui/autocreatescripts/autotests/data/delete-headers-ref.siv9
-rw-r--r--src/ksieveui/autocreatescripts/autotests/sieveeditorgraphicalmodewidgettest.cpp1
-rw-r--r--src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.cpp15
-rw-r--r--src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.h2
4 files changed, 18 insertions, 9 deletions
diff --git a/src/ksieveui/autocreatescripts/autotests/data/delete-headers-ref.siv b/src/ksieveui/autocreatescripts/autotests/data/delete-headers-ref.siv
index 1ff68bd..297b2ac 100644
--- a/src/ksieveui/autocreatescripts/autotests/data/delete-headers-ref.siv
+++ b/src/ksieveui/autocreatescripts/autotests/data/delete-headers-ref.siv
@@ -1,9 +1,10 @@
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
diff --git a/src/ksieveui/autocreatescripts/autotests/sieveeditorgraphicalmodewidgettest.cpp b/src/ksieveui/autocreatescripts/autotests/sieveeditorgraphicalmodewidgettest.cpp
index f36d49b..e38d532 100644
--- a/src/ksieveui/autocreatescripts/autotests/sieveeditorgraphicalmodewidgettest.cpp
+++ b/src/ksieveui/autocreatescripts/autotests/sieveeditorgraphicalmodewidgettest.cpp
@@ -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);
}
}
diff --git a/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.cpp b/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.cpp
index a287000..917aba5 100644
--- a/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.cpp
+++ b/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.cpp
@@ -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"));
diff --git a/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.h b/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.h
index af7d7dc..7a9aca0 100644
--- a/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.h
+++ b/src/ksieveui/autocreatescripts/sieveactions/sieveactiondeleteheader.h
@@ -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);
};
}