Commit 605bd87b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Save rules

parent 398798b2
Pipeline #68251 canceled with stage
......@@ -46,9 +46,14 @@ void ConfirmBeforeDeletingManager::loadRules()
}
}
QString defaultGroupName()
{
return QStringLiteral("Confirm Deleting Rule");
}
QStringList ConfirmBeforeDeletingManager::ruleGroups(const KSharedConfig::Ptr &config) const
{
return config->groupList().filter(QRegularExpression(QStringLiteral("Confirm Deleting Rule #\\d+")));
return config->groupList().filter(QRegularExpression(defaultGroupName() + QStringLiteral(" #\\d+")));
}
void ConfirmBeforeDeletingManager::saveRules()
......@@ -60,10 +65,10 @@ void ConfirmBeforeDeletingManager::saveRules()
config->deleteGroup(group);
}
for (int i = 0, total = mRules.count(); i < total; ++i) {
const QString groupName = QStringLiteral("DKIM Rule #%1").arg(i);
const QString groupName = defaultGroupName() + QStringLiteral(" #%1").arg(i);
KConfigGroup group = config->group(groupName);
const ConfirmBeforeDeletingRule &rule = mRules.at(i);
rule.save(); // TODO
rule.save(group); // TODO
}
}
......
......@@ -48,9 +48,10 @@ bool ConfirmBeforeDeletingRule::isValid() const
return !mPattern.isEmpty() && (mRuleType != Unknown);
}
void ConfirmBeforeDeletingRule::save() const
void ConfirmBeforeDeletingRule::save(KConfigGroup &group) const
{
// TODO
group.writeEntry(QStringLiteral("Pattern"), mPattern);
group.writeEntry(QStringLiteral("Type"), ruleTypeToString());
}
ConfirmBeforeDeletingRule::RuleType ConfirmBeforeDeletingRule::stringToRuleType(const QString &str) const
......
......@@ -34,7 +34,7 @@ public:
Q_REQUIRED_RESULT bool deletingNeedToConfirm(const Akonadi::Item &item) const;
void save() const;
void save(KConfigGroup &group) const;
void load(const KConfigGroup &group);
Q_REQUIRED_RESULT bool isValid() const;
......
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