Commit 46b23630 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to duplicate rule

parent 48e569b9
......@@ -145,6 +145,20 @@ void DKIMManageRulesWidget::addRule()
delete dlg;
}
void DKIMManageRulesWidget::duplicateRule(DKIMManageRulesWidgetItem *rulesItem)
{
QPointer<DKIMRuleDialog> dlg = new DKIMRuleDialog(this);
dlg->loadRule(rulesItem->rule());
if (dlg->exec()) {
const MessageViewer::DKIMRule rule = dlg->rule();
if (rule.isValid()) {
DKIMManageRulesWidgetItem *item = new DKIMManageRulesWidgetItem(mTreeWidget);
item->setRule(rule);
}
}
delete dlg;
}
void DKIMManageRulesWidget::modifyRule(DKIMManageRulesWidgetItem *rulesItem)
{
QPointer<DKIMRuleDialog> dlg = new DKIMRuleDialog(this);
......@@ -172,6 +186,10 @@ void DKIMManageRulesWidget::customContextMenuRequested(const QPoint &pos)
modifyRule(rulesItem);
});
menu.addSeparator();
menu.addAction(QIcon::fromTheme(QStringLiteral("edit-duplicate")), i18n("Duplicate Rule"), this, [this, rulesItem]() {
duplicateRule(rulesItem);
});
menu.addSeparator();
menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Remove Rule"), this, [this, item]() {
if (KMessageBox::Yes == KMessageBox::warningYesNo(this, i18n("Do you want to delete this rule?"), i18n("Delete Rule"))) {
delete item;
......
......@@ -74,6 +74,7 @@ public:
private:
void modifyRule(DKIMManageRulesWidgetItem *rulesItem);
void customContextMenuRequested(const QPoint &);
void duplicateRule(DKIMManageRulesWidgetItem *rulesItem);
QTreeWidget *mTreeWidget = 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