summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-05-25 09:22:07 +0200
committerMontel Laurent <[email protected]>2017-05-25 09:22:07 +0200
commit34c2f63cc5f39d051170e5f7849131d90788c581 (patch)
treead13a6999bb604cf163dc443e7583278e02723cb
parentee057a4032005572a0a71d6dbd43409f6e5e98c3 (diff)
Add code for create new regexpeditorlineeditabstract. + add new autottest
-rw-r--r--src/ksieveui/autocreatescripts/autocreatescriptutil.cpp18
-rw-r--r--src/ksieveui/autocreatescripts/autocreatescriptutil_p.h2
-rw-r--r--src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted-ref.siv9
-rw-r--r--src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted.siv9
4 files changed, 38 insertions, 0 deletions
diff --git a/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp b/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp
index 857cf8b..d5629a8 100644
--- a/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp
+++ b/src/ksieveui/autocreatescripts/autocreatescriptutil.cpp
@@ -21,7 +21,12 @@
#include <KLocalizedString>
+#include <KPluginLoader>
+#include <KPluginFactory>
#include <QStringList>
+#include <QRegularExpression>
+
+#include "autocreatescripts/sieveconditions/widgets/regexpeditorlineedit.h"
using namespace KSieveUi;
QString AutoCreateScriptUtil::createMultiLine(const QString &str)
@@ -190,3 +195,16 @@ QString AutoCreateScriptUtil::indentation()
{
return QStringLiteral(" ");
}
+
+AbstractRegexpEditorLineEdit *AutoCreateScriptUtil::createRegexpEditorLineEdit(QWidget *parent)
+{
+ KSieveUi::AbstractRegexpEditorLineEdit *edit = nullptr;
+ KPluginLoader loader(QStringLiteral("libksieve/regexpeditorlineeditplugin"));
+ KPluginFactory *factory = loader.factory();
+ if (factory) {
+ edit = factory->create<KSieveUi::AbstractRegexpEditorLineEdit>(parent);
+ } else {
+ edit = new KSieveUi::RegexpEditorLineEdit(parent);
+ }
+ return edit;
+}
diff --git a/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h b/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h
index 4f16991..3e24a55 100644
--- a/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h
+++ b/src/ksieveui/autocreatescripts/autocreatescriptutil_p.h
@@ -23,6 +23,7 @@
#include <QString>
#include <QStringList>
#include <QDomNode>
+#include <KSieveUi/AbstractRegexpEditorLineEdit>
namespace KSieveUi {
namespace AutoCreateScriptUtil {
QString createMultiLine(const QString &str);
@@ -42,6 +43,7 @@ void comboboxItemNotFound(const QString &searchItem, const QString &name, QStrin
QString createFullWhatsThis(const QString &help, const QString &href);
QString protectSlash(QString str);
QString indentation();
+AbstractRegexpEditorLineEdit *createRegexpEditorLineEdit(QWidget *parent = nullptr);
}
}
#endif // AUTOCREATESCRIPTUTIL_H
diff --git a/src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted-ref.siv b/src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted-ref.siv
new file mode 100644
index 0000000..9f36a4a
--- /dev/null
+++ b/src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted-ref.siv
@@ -0,0 +1,9 @@
+if anyof (header :contains "Subject" "[kdepim-runtime]"
+, header :contains "Subject" "[akonadi"
+, header :contains "Subject" "[kmail2"
+, header :contains "Subject" "[pim-sieve-editor"
+, header :contains "Subject" "[pim-data-exporter"
+, header :contains "Subject" "[akonadi-search/")
+{
+ fileinto "bb";
+}
diff --git a/src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted.siv b/src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted.siv
new file mode 100644
index 0000000..9f36a4a
--- /dev/null
+++ b/src/ksieveui/autocreatescripts/autotests/data/test-value-as-list-quoted.siv
@@ -0,0 +1,9 @@
+if anyof (header :contains "Subject" "[kdepim-runtime]"
+, header :contains "Subject" "[akonadi"
+, header :contains "Subject" "[kmail2"
+, header :contains "Subject" "[pim-sieve-editor"
+, header :contains "Subject" "[pim-data-exporter"
+, header :contains "Subject" "[akonadi-search/")
+{
+ fileinto "bb";
+}