Commit 651b85d8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Rename filter name

parent 031057ca
......@@ -116,3 +116,17 @@ void FilterSavedManager::removeFilter(const QString &identifier)
qDeleteAll(lst);
lst.clear();
}
void FilterSavedManager::renameFilter(const QString &identifier, const QString &newName)
{
KConfigGroup grp(KSharedConfig::openConfig(), "General");
const int numberFilter = grp.readEntry("NumberFilter").toInt();
for (int i = 0; i < numberFilter; ++i) {
KConfigGroup newGroup(KSharedConfig::openConfig(), QStringLiteral("Filter_%1").arg(i));
if (newGroup.readEntry("identifier") == identifier) {
newGroup.writeEntry("name", newName);
newGroup.sync();
break;
}
}
}
......@@ -30,6 +30,7 @@ public:
static FilterSavedManager *self();
void removeFilter(const QString &identifier);
void renameFilter(const QString &identifier, const QString &newName);
Q_REQUIRED_RESULT Filter *loadFilter(const QString &identifier);
Q_REQUIRED_RESULT QStringList existingFilterNames() const;
......
......@@ -51,7 +51,7 @@ void ConfigureFiltersWidget::slotCustomContextMenuRequested(const QPoint &pos)
QString newName = QInputDialog::getText(this, i18n("Rename Filter"), i18n("name"), QLineEdit::Normal, item->text());
newName = newName.trimmed();
if (!newName.isEmpty()) {
// TODO rename
renameFilterInfo(identifier, newName);
}
});
menu.addSeparator();
......@@ -72,6 +72,13 @@ void ConfigureFiltersWidget::removeFilterInfo(const QString &identifier)
}
}
void ConfigureFiltersWidget::renameFilterInfo(const QString &identifier, const QString &newName)
{
if (!identifier.isEmpty()) {
FilterSavedManager::self()->renameFilter(identifier, newName);
}
}
FilterListWidgetItem::FilterListWidgetItem(QListWidget *parent)
: QListWidgetItem(parent)
{
......
......@@ -35,6 +35,7 @@ public:
~ConfigureFiltersWidget() override;
private:
void renameFilterInfo(const QString &identifier, const QString &newName);
void slotCustomContextMenuRequested(const QPoint &pos);
void removeFilterInfo(const QString &identifier);
void init();
......
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