Commit 86ab2757 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix export rules

parent b03ec1c2
Pipeline #53018 passed with stage
in 41 minutes and 26 seconds
......@@ -104,7 +104,7 @@ int DKIMManagerRules::importRules(const QString &fileName)
void DKIMManagerRules::exportRules(const QString &fileName, const QVector<DKIMRule> &lst)
{
save(fileName);
save(fileName, lst);
}
void DKIMManagerRules::save(const QString &fileName, const QVector<DKIMRule> &lst)
......
......@@ -69,13 +69,14 @@ void DKIMManageRulesDialog::slotAccepted()
void DKIMManageRulesDialog::slotExport()
{
if (MessageViewer::DKIMManagerRules::self()->isEmpty()) {
const auto rules = mRulesWidget->rules();
if (rules.isEmpty()) {
KMessageBox::error(this, i18n("No rules found"), i18n("Export Rules"));
return;
}
const QString fileName = QFileDialog::getSaveFileName(this, i18n("Export Rules"));
if (!fileName.isEmpty()) {
MessageViewer::DKIMManagerRules::self()->exportRules(fileName);
MessageViewer::DKIMManagerRules::self()->exportRules(fileName, rules);
}
}
......
......@@ -104,7 +104,7 @@ void DKIMManageRulesWidget::loadSettings()
}
}
void DKIMManageRulesWidget::saveSettings()
QVector<MessageViewer::DKIMRule> DKIMManageRulesWidget::rules() const
{
QVector<MessageViewer::DKIMRule> rules;
const int total = mTreeWidget->topLevelItemCount();
......@@ -114,7 +114,12 @@ void DKIMManageRulesWidget::saveSettings()
auto ruleItem = static_cast<DKIMManageRulesWidgetItem *>(item);
rules.append(ruleItem->rule());
}
MessageViewer::DKIMManagerRules::self()->saveRules(rules);
return rules;
}
void DKIMManageRulesWidget::saveSettings()
{
MessageViewer::DKIMManagerRules::self()->saveRules(rules());
}
QByteArray DKIMManageRulesWidget::saveHeaders() const
......
......@@ -59,6 +59,7 @@ public:
void restoreHeaders(const QByteArray &header);
void addRule();
Q_REQUIRED_RESULT QVector<MessageViewer::DKIMRule> rules() const;
private:
void modifyRule(DKIMManageRulesWidgetItem *rulesItem);
......
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