Commit 57f05b7c authored by Laurent Montel's avatar Laurent Montel 😁

Clean up

parent 71cf45c4
......@@ -141,16 +141,6 @@ QString AutoCreateScriptUtil::strValue(QXmlStreamReader &node)
}
}
#ifdef REMOVE_QDOMELEMENT
node = node.nextSibling();
QDomElement textElement = node.toElement();
if (!textElement.isNull()) {
const QString textElementTagName = textElement.tagName();
if (textElementTagName == QLatin1String("str")) {
return textElement.text();
}
}
#endif
return QString();
}
......@@ -171,22 +161,6 @@ QStringList AutoCreateScriptUtil::listValue(QXmlStreamReader &element)
}
}
return lst;
#ifdef REMOVE_QDOMELEMENT
QStringList lst;
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("str")) {
lst << e.text();
}
}
node = node.nextSibling();
}
return lst;
#endif
return {};
}
QString AutoCreateScriptUtil::fixListValue(QString valueStr)
......
......@@ -65,30 +65,6 @@ bool SieveActionAbstractFlags::setParamWidgetValue(QXmlStreamReader &element, QW
qCDebug(LIBKSIEVE_LOG) << " SieveActionAbstractFlags::setParamWidgetValue unknown tag :" << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("list")) {
SelectFlagsWidget *flagsWidget = w->findChild<SelectFlagsWidget *>(QStringLiteral("flagswidget"));
flagsWidget->setFlags(AutoCreateScriptUtil::listValue(e));
} else if (tagName == QLatin1String("str")) {
SelectFlagsWidget *flagsWidget = w->findChild<SelectFlagsWidget *>(QStringLiteral("flagswidget"));
flagsWidget->setFlags(QStringList() << e.text());
} 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;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -99,40 +99,6 @@ bool SieveActionAddHeader::setParamWidgetValue(QXmlStreamReader &element, QWidge
}
}
#ifdef REMOVE_QDOMELEMENT
int index = 0;
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("tag")) {
SelectAddHeaderPositionCombobox *combo = w->findChild<SelectAddHeaderPositionCombobox *>(QStringLiteral("selectposition"));
combo->setCode(AutoCreateScriptUtil::tagValue(e.text()), name(), error);
} else if (tagName == QLatin1String("str")) {
if (index == 0) {
QLineEdit *edit = w->findChild<QLineEdit *>(QStringLiteral("headeredit"));
edit->setText(e.text());
} else if (index == 1) {
QLineEdit *value = w->findChild<QLineEdit *>(QStringLiteral("valueedit"));
value->setText(AutoCreateScriptUtil::quoteStr(e.text()));
} else {
tooManyArgument(tagName, index, 2, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionAddHeader::setParamWidgetValue too many argument :" << index;
}
++index;
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionAddHeader::setParamWidgetValue unknown tag " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -79,35 +79,6 @@ bool SieveActionBreak::setParamWidgetValue(QXmlStreamReader &element, QWidget *w
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("tag")) {
const QString tagValue = e.text();
if (tagValue == QLatin1String("name")) {
QLineEdit *name = w->findChild<QLineEdit *>(QStringLiteral("name"));
name->setText(AutoCreateScriptUtil::strValue(e));
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionBreak::setParamWidgetValue unknown tagValue " << tagValue;
}
} else if (tagName == QLatin1String("str")) {
//Nothing
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionBreak::setParamWidgetValue unknown tag " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -100,40 +100,6 @@ bool SieveActionConvert::setParamWidgetValue(QXmlStreamReader &element, QWidget
}
}
#ifdef REMOVE_QDOMELEMENT
int index = 0;
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("str")) {
if (index == 0) {
SelectMimeTypeComboBox *fromMimeType = w->findChild<SelectMimeTypeComboBox *>(QStringLiteral("from"));
fromMimeType->setCode(e.text(), name(), error);
} else if (index == 1) {
SelectMimeTypeComboBox *toMimeType = w->findChild<SelectMimeTypeComboBox *>(QStringLiteral("to"));
toMimeType->setCode(e.text(), name(), error);
} else {
tooManyArgument(tagName, index, 2, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionConvert::setParamWidgetValue too many argument :" << index;
}
++index;
} else if (tagName == QLatin1String("list")) {
SelectConvertParameterWidget *params = w->findChild<SelectConvertParameterWidget *>(QStringLiteral("params"));
params->setCode(AutoCreateScriptUtil::listValue(e), error);
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionConvert::setParamWidgetValue unknown tag " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -108,45 +108,6 @@ bool SieveActionDeleteHeader::parseValue(QXmlStreamReader &element, QWidget *w,
}
}
#ifdef REMOVE_QDOMELEMENT
int index = 0;
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("test")) {
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::tagValueWithCondition(e.text(), isNegative), name(), error);
} else if (tagName == QLatin1String("str")) {
if (index == 0) {
QLineEdit *edit = w->findChild<QLineEdit *>(QStringLiteral("headeredit"));
edit->setText(e.text());
} else if (index == 1) {
QLineEdit *value = w->findChild<QLineEdit *>(QStringLiteral("valueedit"));
value->setText(e.text());
} else {
tooManyArgument(tagName, index, 2, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionAddHeader::setParamWidgetValue too many argument :" << index;
}
++index;
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionAddHeader::setParamWidgetValue unknown tag " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -106,45 +106,6 @@ bool SieveActionEnclose::setParamWidgetValue(QXmlStreamReader &element, QWidget
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("tag")) {
const QString tagValue = e.text();
if (tagValue == QLatin1String("headers")) {
const QString strValue = AutoCreateScriptUtil::strValue(node);
if (!strValue.isEmpty()) {
QLineEdit *subject = w->findChild<QLineEdit *>(QStringLiteral("headers"));
subject->setText(strValue);
}
} else if (tagValue == QLatin1String("subject")) {
const QString strValue = AutoCreateScriptUtil::strValue(node);
if (!strValue.isEmpty()) {
QLineEdit *headers = w->findChild<QLineEdit *>(QStringLiteral("subject"));
headers->setText(strValue);
}
} else {
unknowTagValue(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionEnclose::setParamWidgetValue unknown tag value:" << tagValue;
}
} else if (tagName == QLatin1String("str")) {
MultiLineEdit *edit = w->findChild<MultiLineEdit *>(QStringLiteral("text"));
edit->setPlainText(e.text());
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionEnclose::setParamWidgetValue unknown tagName " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -69,28 +69,6 @@ bool SieveActionEReject::setParamWidgetValue(QXmlStreamReader &element, QWidget
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("str")) {
const QString tagValue = e.text();
MultiLineEdit *edit = w->findChild<MultiLineEdit *>(QStringLiteral("rejectmessage"));
edit->setPlainText(AutoCreateScriptUtil::quoteStr(tagValue));
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionEReject::setParamWidgetValue unknown tagName " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -87,32 +87,6 @@ bool SieveActionExtractText::setParamWidgetValue(QXmlStreamReader &element, QWid
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("tag")) {
//TODO ?
} else if (tagName == QLatin1String("num")) {
QSpinBox *numberOfCharacters = w->findChild<QSpinBox *>(QStringLiteral("numberOfCharacters"));
numberOfCharacters->setValue(e.text().toInt());
} else if (tagName == QLatin1String("str")) {
QLineEdit *variableName = w->findChild<QLineEdit *>(QStringLiteral("variablename"));
variableName->setText(e.text());
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionExtractText::setParamWidgetValue unknown tagName " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -100,50 +100,6 @@ bool SieveActionFileInto::setParamWidgetValue(QXmlStreamReader &element, QWidget
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("tag")) {
const QString tagValue = e.text();
if (tagValue == QLatin1String("copy")) {
if (mHasCopySupport) {
QCheckBox *copy = w->findChild<QCheckBox *>(QStringLiteral("copy"));
copy->setChecked(true);
} else {
error += i18n("Action \"fileinto\" has \"copy\" argument but current server does not support it") + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << "SieveActionFileInto::setParamWidgetValue has not copy support ";
}
} else if (tagValue == QLatin1String("create")) {
if (mHasMailBoxSupport) {
QCheckBox *create = w->findChild<QCheckBox *>(QStringLiteral("create"));
create->setChecked(true);
} else {
serverDoesNotSupportFeatures(QStringLiteral("create"), error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionFileInto::setParamWidgetValue server has not create support ";
}
} else {
serverDoesNotSupportFeatures(tagValue, error);
qCDebug(LIBKSIEVE_LOG) << "SieveActionFileInto::setParamWidgetValue server has not flags support ";
}
} else if (tagName == QLatin1String("str")) {
const QString tagValue = e.text();
KSieveUi::AbstractMoveImapFolderWidget *edit = w->findChild<KSieveUi::AbstractMoveImapFolderWidget *>(QStringLiteral("fileintolineedit"));
edit->setText(AutoCreateScriptUtil::protectSlash(tagValue));
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionFileInto::setParamWidgetValue unknown tagName " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -104,36 +104,6 @@ bool SieveActionKeep::setParamWidgetValue(QXmlStreamReader &element, QWidget *w,
qCDebug(LIBKSIEVE_LOG) << " Server doesn't support imapflags";
}
#ifdef REMOVE_QDOMELEMENT
if (mHasFlagSupport) {
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("list")) {
SelectFlagsWidget *flagsWidget = w->findChild<SelectFlagsWidget *>(QStringLiteral("flagswidget"));
flagsWidget->setFlags(AutoCreateScriptUtil::listValue(e));
} else if (tagName == QLatin1String("str")) {
SelectFlagsWidget *flagsWidget = w->findChild<SelectFlagsWidget *>(QStringLiteral("flagswidget"));
flagsWidget->setFlags(QStringList() << e.text());
} else if (tagName == QLatin1String("tag") && e.text() == 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;
}
}
node = node.nextSibling();
}
} else {
qCDebug(LIBKSIEVE_LOG) << " Server doesn't support imapflags";
}
#endif
return true;
}
......
......@@ -103,45 +103,6 @@ bool SieveActionNotify::setParamWidgetValue(QXmlStreamReader &element, QWidget *
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("tag")) {
const QString tagValue = e.text();
if (tagValue == QLatin1String("message")) {
const QString strValue = AutoCreateScriptUtil::strValue(node);
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(node);
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(e.text()));
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionNotify::setParamWidgetValue unknown tagName " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -104,49 +104,6 @@ bool SieveActionRedirect::setParamWidgetValue(QXmlStreamReader &element, QWidget
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("str")) {
QLineEdit *edit = w->findChild<AddressLineEdit *>(QStringLiteral("RedirectEdit"));
const QString tagValue = e.text();
edit->setText(AutoCreateScriptUtil::quoteStr(tagValue));
} else if (tagName == QLatin1String("tag")) {
const QString tagValue = e.text();
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(e.text());
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionRedirect::setParamWidgetValue unknown tagName " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -68,28 +68,6 @@ bool SieveActionReject::setParamWidgetValue(QXmlStreamReader &element, QWidget *
qCDebug(LIBKSIEVE_LOG) << " SieveActionReject::setParamWidgetValue unknown tagName " << tagName;
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();
if (tagName == QLatin1String("str")) {
const QString tagValue = e.text();
MultiLineEdit *edit = w->findChild<MultiLineEdit *>(QStringLiteral("rejectmessage"));
edit->setPlainText(AutoCreateScriptUtil::quoteStr(tagValue));
} else if (tagName == QLatin1String("crlf")) {
//nothing
} else if (tagName == QLatin1String("comment")) {
//implement in the future ?
} else {
unknownTag(tagName, error);
qCDebug(LIBKSIEVE_LOG) << " SieveActionReject::setParamWidgetValue unknown tagName " << tagName;
}
}
node = node.nextSibling();
}
#endif
return true;
}
......
......@@ -105,45 +105,6 @@ bool SieveActionReplace::setParamWidgetValue(QXmlStreamReader &element, QWidget
}
}
#ifdef REMOVE_QDOMELEMENT
QDomNode node = element.firstChild();
while (!node.isNull()) {
QDomElement e = node.toElement();
if (!e.isNull()) {
const QString tagName = e.tagName();