Commit 075e1f9d authored by Laurent Montel's avatar Laurent Montel 😁

Continue to port action

parent b8118efa
...@@ -79,6 +79,30 @@ QWidget *SieveActionKeep::createParamWidget(QWidget *parent) const ...@@ -79,6 +79,30 @@ QWidget *SieveActionKeep::createParamWidget(QWidget *parent) const
bool SieveActionKeep::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionKeep::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
if (mHasFlagSupport) {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("list")) {
SelectFlagsWidget *flagsWidget = w->findChild<SelectFlagsWidget *>(QStringLiteral("flagswidget"));
flagsWidget->setFlags(AutoCreateScriptUtil::listValue(element));
} else if (tagName == QLatin1String("str")) {
SelectFlagsWidget *flagsWidget = w->findChild<SelectFlagsWidget *>(QStringLiteral("flagswidget"));
flagsWidget->setFlags(QStringList() << element.readElementText());
} else if (tagName == QLatin1String("tag") && element.readElementText() == QLatin1String("flags")) {
//nothing :)
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionAbstractFlags::setParamWidgetValue unknown tag :" << tagName;
}
}
} else {
qCDebug(LIBKSIEVE_LOG) << " Server doesn't support imapflags";
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
if (mHasFlagSupport) { if (mHasFlagSupport) {
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
......
...@@ -69,6 +69,39 @@ QWidget *SieveActionNotify::createParamWidget(QWidget *parent) const ...@@ -69,6 +69,39 @@ QWidget *SieveActionNotify::createParamWidget(QWidget *parent) const
bool SieveActionNotify::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionNotify::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("message")) {
const QString strValue = AutoCreateScriptUtil::strValue(element);
if (!strValue.isEmpty()) {
QLineEdit *message = w->findChild<QLineEdit *>(QStringLiteral("message"));
message->setText(AutoCreateScriptUtil::quoteStr(strValue));
}
} else if (tagValue == QLatin1String("importance")) {
const QString strValue = AutoCreateScriptUtil::strValue(element);
if (!strValue.isEmpty()) {
SelectImportanceCombobox *importance = w->findChild<SelectImportanceCombobox *>(QStringLiteral("importancecombo"));
importance->setCode(strValue, name(), error);
}
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionNotify::setParamWidgetValue unknown tagValue" << tagValue;
}
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else if (tagName == QLatin1String("str")) {
QLineEdit *method = w->findChild<QLineEdit *>(QStringLiteral("method"));
method->setText(AutoCreateScriptUtil::quoteStr(element.readElementText()));
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionNotify::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
...@@ -66,6 +66,43 @@ QWidget *SieveActionRedirect::createParamWidget(QWidget *parent) const ...@@ -66,6 +66,43 @@ QWidget *SieveActionRedirect::createParamWidget(QWidget *parent) const
bool SieveActionRedirect::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionRedirect::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("str")) {
QLineEdit *edit = w->findChild<AddressLineEdit *>(QStringLiteral("RedirectEdit"));
const QString tagValue = element.readElementText();
edit->setText(AutoCreateScriptUtil::quoteStr(tagValue));
} else if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("copy")) {
if (mHasCopySupport) {
QCheckBox *copy = w->findChild<QCheckBox *>(QStringLiteral("copy"));
copy->setChecked(true);
} else {
serverDoesNotSupportFeatures(QStringLiteral("copy"), error);
}
} else if (tagValue == QLatin1String("list")) {
if (mHasListSupport) {
QCheckBox *list = w->findChild<QCheckBox *>(QStringLiteral("list"));
list->setChecked(true);
} else {
serverDoesNotSupportFeatures(QStringLiteral("list"), error);
}
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionRedirect::setParamWidgetValue tagValue unknown" << tagValue;
}
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
setComment(element.readElementText());
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionRedirect::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
...@@ -71,6 +71,39 @@ QWidget *SieveActionReplace::createParamWidget(QWidget *parent) const ...@@ -71,6 +71,39 @@ QWidget *SieveActionReplace::createParamWidget(QWidget *parent) const
bool SieveActionReplace::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionReplace::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("str")) {
MultiLineEdit *edit = w->findChild<MultiLineEdit *>(QStringLiteral("text"));
edit->setPlainText(element.readElementText());
} else if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("subject")) {
const QString strValue = AutoCreateScriptUtil::strValue(element);
if (!strValue.isEmpty()) {
QLineEdit *subject = w->findChild<QLineEdit *>(QStringLiteral("subject"));
subject->setText(strValue);
}
} else if (tagValue == QLatin1String("from")) {
const QString strValue = AutoCreateScriptUtil::strValue(element);
if (!strValue.isEmpty()) {
QLineEdit *headers = w->findChild<QLineEdit *>(QStringLiteral("from"));
headers->setText(strValue);
}
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionReplace::setParamWidgetValue unknown tagValue " << tagValue;
}
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionReplace::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
...@@ -83,6 +83,48 @@ QUrl SieveActionSetVariable::href() const ...@@ -83,6 +83,48 @@ QUrl SieveActionSetVariable::href() const
bool SieveActionSetVariable::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionSetVariable::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("str")) {
const QString tagValue = element.readElementText();
QLineEdit *value = w->findChild<QLineEdit *>(QStringLiteral("value"));
value->setText(tagValue);
#ifdef QDOMELEMENT_FIXME
node = node.nextSibling();
QDomElement variableElement = node.toElement();
if (!variableElement.isNull()) {
const QString variableTagName = variableElement.tagName();
if (variableTagName == QLatin1String("str")) {
QLineEdit *variable = w->findChild<QLineEdit *>(QStringLiteral("variable"));
variable->setText(AutoCreateScriptUtil::protectSlash(variableElement.text()));
}
} else {
return false;
}
#endif
} else if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("quoteregex")) {
if (mHasRegexCapability) {
QCheckBox *protectAgainstUseRegexp = w->findChild<QCheckBox *>(QStringLiteral("regexprotect"));
protectAgainstUseRegexp->setChecked(true);
} else {
error += i18n("Script needs regex support, but server does not have it.") + QLatin1Char('\n');
}
} else {
SelectVariableModifierComboBox *modifier = w->findChild<SelectVariableModifierComboBox *>(QStringLiteral("modifier"));
modifier->setCode(AutoCreateScriptUtil::tagValue(tagValue), name(), error);
}
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionSetVariable::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
...@@ -94,6 +94,48 @@ QWidget *SieveActionVacation::createParamWidget(QWidget *parent) const ...@@ -94,6 +94,48 @@ QWidget *SieveActionVacation::createParamWidget(QWidget *parent) const
bool SieveActionVacation::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error) bool SieveActionVacation::setParamWidgetValue(QXmlStreamReader &element, QWidget *w, QString &error)
{ {
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("seconds")) {
if (mHasVacationSecondsSupport) {
SelectVacationComboBox *vacationcombobox = w->findChild<SelectVacationComboBox *>(QStringLiteral("vacationcombobox"));
vacationcombobox->setCode(AutoCreateScriptUtil::tagValue(tagValue), name(), error);
} else {
serverDoesNotSupportFeatures(QStringLiteral("seconds"), error);
}
} else if (tagValue == QLatin1String("days")) {
//Nothing wait num tag for it.
} else if (tagValue == QLatin1String("addresses")) {
QLineEdit *addresses = w->findChild<QLineEdit *>(QStringLiteral("addresses"));
addresses->setText(AutoCreateScriptUtil::strValue(element));
} else if (tagValue == QLatin1String("subject")) {
QLineEdit *subject = w->findChild<QLineEdit *>(QStringLiteral("subject"));
subject->setText(AutoCreateScriptUtil::strValue(element));
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionVacation::setParamWidgetValue unknown tagValue :" << tagValue;
}
} else if (tagName == QLatin1String("num")) {
QSpinBox *day = w->findChild<QSpinBox *>(QStringLiteral("day"));
day->setValue(element.readElementText().toInt());
} else if (tagName == QLatin1String("str")) {
MultiLineEdit *text = w->findChild<MultiLineEdit *>(QStringLiteral("text"));
text->setPlainText(element.readElementText());
} else if (tagName == QLatin1String("list")) {
QLineEdit *addresses = w->findChild<QLineEdit *>(QStringLiteral("addresses"));
addresses->setText(AutoCreateScriptUtil::listValueToStr(element));
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionVacation::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT #ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild(); QDomNode node = element.firstChild();
while (!node.isNull()) { while (!node.isNull()) {
......
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