Commit 398798b2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement load rule

parent 09ba0534
Pipeline #68249 passed with stage
in 53 minutes and 42 seconds
......@@ -40,7 +40,9 @@ void ConfirmBeforeDeletingManager::loadRules()
ConfirmBeforeDeletingRule r;
KConfigGroup group = config->group(groupName);
r.load(group);
mRules.append(r);
if (r.isValid()) {
mRules.append(r);
}
}
}
......@@ -63,10 +65,6 @@ void ConfirmBeforeDeletingManager::saveRules()
const ConfirmBeforeDeletingRule &rule = mRules.at(i);
rule.save(); // TODO
}
for (const auto &r : qAsConst(mRules)) {
// TODO
// r.save();
}
}
bool ConfirmBeforeDeletingManager::deletingNeedToConfirm(const Akonadi::Item &item) const
......
......@@ -40,7 +40,12 @@ void ConfirmBeforeDeletingRule::load(const KConfigGroup &group)
const QString pattern = group.readEntry(QStringLiteral("Pattern"), QString());
const QString checkType = group.readEntry(QStringLiteral("Type"), QString());
setPattern(pattern);
// TODO setRuleType();
setRuleType(stringToRuleType(checkType));
}
bool ConfirmBeforeDeletingRule::isValid() const
{
return !mPattern.isEmpty() && (mRuleType != Unknown);
}
void ConfirmBeforeDeletingRule::save() const
......@@ -48,6 +53,42 @@ void ConfirmBeforeDeletingRule::save() const
// TODO
}
ConfirmBeforeDeletingRule::RuleType ConfirmBeforeDeletingRule::stringToRuleType(const QString &str) const
{
if (str == QLatin1String("body")) {
return Body;
} else if (str == QLatin1String("subject")) {
return Subject;
} else if (str == QLatin1String("to")) {
return To;
} else if (str == QLatin1String("cc")) {
return Cc;
}
return Unknown;
}
QString ConfirmBeforeDeletingRule::ruleTypeToString() const
{
QString tmp;
switch (mRuleType) {
case Unknown:
break;
case Body:
tmp = QStringLiteral("body");
break;
case Subject:
tmp = QStringLiteral("subject");
break;
case To:
tmp = QStringLiteral("to");
break;
case Cc:
tmp = QStringLiteral("cc");
break;
}
return tmp;
}
bool ConfirmBeforeDeletingRule::deletingNeedToConfirm(const Akonadi::Item &item) const
{
bool needToConfirm = false;
......
/*
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
......@@ -37,7 +37,11 @@ public:
void save() const;
void load(const KConfigGroup &group);
Q_REQUIRED_RESULT bool isValid() const;
private:
Q_REQUIRED_RESULT QString ruleTypeToString() const;
Q_REQUIRED_RESULT ConfirmBeforeDeletingRule::RuleType stringToRuleType(const QString &str) const;
QString mPattern;
RuleType mRuleType = RuleType::Unknown;
};
......
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