Commit c8abe150 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Verify that list we don't use same filtername

parent 8390b4eb
Pipeline #65967 passed with stage
in 40 minutes and 49 seconds
......@@ -26,6 +26,19 @@ FilterSavedManager *FilterSavedManager::self()
return &s_self;
}
QStringList FilterSavedManager::existingFilterNames() const
{
QStringList lst;
KConfigGroup grp(KSharedConfig::openConfig(), "General");
const int numberFilter = grp.readEntry("NumberFilter").toInt();
lst.reserve(numberFilter);
for (int i = 0; i < numberFilter; ++i) {
KConfigGroup newGroup(KSharedConfig::openConfig(), QStringLiteral("Filter_%1").arg(i));
lst << newGroup.readEntry(QStringLiteral("name"));
}
return lst;
}
void FilterSavedManager::saveFilter(MessageList::Core::Filter *filter, const QString &filtername)
{
filter->save(KSharedConfig::openConfig(), filtername);
......
......@@ -31,6 +31,8 @@ public:
void removeFilter(const QString &identifier);
Q_REQUIRED_RESULT Filter *loadFilter(const QString &identifier);
Q_REQUIRED_RESULT QStringList existingFilterNames() const;
Q_SIGNALS:
void activateFilter(const QString &identifier);
};
......
......@@ -142,6 +142,7 @@ void SearchLineStatus::slotConfigureFilters()
void SearchLineStatus::slotSaveFilter()
{
QPointer<FilterNameDialog> dlg = new FilterNameDialog(this);
dlg->setExistingFilterNames(FilterSavedManager::self()->existingFilterNames());
if (dlg->exec()) {
Q_EMIT saveFilter(dlg->filterName());
}
......
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