Commit 29fe78c0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add support for priority

parent 19c7ee21
......@@ -60,3 +60,5 @@ void DKIMManagerRulesTest::shouldClearRules()
r.clear();
QVERIFY(r.isEmpty());
}
//TODO add save/load support
......@@ -66,4 +66,9 @@ void DKIMRuleWidgetTest::shouldHaveDefaultValues()
MessageViewer::DKIMManageRulesComboBox *mRuleType = w.findChild<MessageViewer::DKIMManageRulesComboBox *>(QStringLiteral("ruletype"));
QVERIFY(mRuleType);
QLineEdit *mPriority = w.findChild<QLineEdit *>(QStringLiteral("priority"));
QVERIFY(mPriority);
QVERIFY(mPriority->text().isEmpty());
QVERIFY(mPriority->isClearButtonEnabled());
}
......@@ -81,6 +81,7 @@ int DKIMManagerRules::loadRules(const QString &fileName)
const bool enabled = group.readEntry(QLatin1String("Enabled"), true);
const int ruleType = group.readEntry(QLatin1String("RuleType"), 0);
const QString listId = group.readEntry(QLatin1String("List-Id"), QString());
const int priority = group.readEntry(QLatin1String("Priority"), 1000);
DKIMRule rule;
rule.setEnabled(enabled);
rule.setDomain(domain);
......@@ -88,6 +89,7 @@ int DKIMManagerRules::loadRules(const QString &fileName)
rule.setListId(listId);
rule.setSignedDomainIdentifier(signedDomainIdentifier);
rule.setRuleType(static_cast<DKIMRule::RuleType>(ruleType));
rule.setPriority(priority);
if (rule.isValid()) {
numberOfRulesAdded++;
mRules.append(rule);
......@@ -137,5 +139,6 @@ void DKIMManagerRules::save(const QString &fileName)
group.writeEntry(QLatin1String("Enabled"), rule.enabled());
group.writeEntry(QLatin1String("RuleType"), static_cast<int>(rule.ruleType()));
group.writeEntry(QLatin1String("List-Id"), rule.listId());
group.writeEntry(QLatin1String("Priority"), rule.priority());
}
}
......@@ -23,6 +23,8 @@
#include <QCheckBox>
#include <QFormLayout>
#include <QLineEdit>
#include <QIntValidator>
using namespace MessageViewer;
DKIMRuleWidget::DKIMRuleWidget(QWidget *parent)
: QWidget(parent)
......@@ -60,6 +62,13 @@ DKIMRuleWidget::DKIMRuleWidget(QWidget *parent)
mRuleType = new DKIMManageRulesComboBox(this);
mRuleType->setObjectName(QStringLiteral("ruletype"));
layout->addRow(i18n("Rule:"), mRuleType);
QIntValidator *validator = new QIntValidator(1, 9999, this);
mPriority = new QLineEdit(this);
mPriority->setObjectName(QStringLiteral("priority"));
mPriority->setValidator(validator);
mPriority->setClearButtonEnabled(true);
layout->addRow(i18n("Priority:"), mPriority);
}
DKIMRuleWidget::~DKIMRuleWidget()
......@@ -74,6 +83,7 @@ void DKIMRuleWidget::loadRule(const MessageViewer::DKIMRule &rule)
mFrom->setText(rule.from());
mListId->setText(rule.listId());
mRuleType->setRuleType(rule.ruleType());
mPriority->setText(QString::number(rule.priority()));
}
MessageViewer::DKIMRule DKIMRuleWidget::rule() const
......@@ -85,5 +95,6 @@ MessageViewer::DKIMRule DKIMRuleWidget::rule() const
rule.setFrom(mFrom->text());
rule.setListId(mListId->text());
rule.setRuleType(mRuleType->ruleType());
rule.setPriority(mPriority->text().toInt());
return rule;
}
......@@ -40,6 +40,7 @@ private:
QLineEdit *mSignatureDomainIdentifier = nullptr;
QLineEdit *mFrom = nullptr;
QLineEdit *mListId = nullptr;
QLineEdit *mPriority = nullptr;
DKIMManageRulesComboBox *mRuleType = nullptr;
};
}
......
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