Commit 3a1cf666 authored by Andi Clemens's avatar Andi Clemens
Browse files

Read pattern history before writing the new values.

The pattern history will not be saved correctly when the AdvancedRename tool is used, but the pattern history in the BQM is not updated.
Therefore closing digiKam will result in an empty pattern history in the config file because the BQM is the last instance that will be destroyed when closing the main application.

This does not fix the problem described in this bugreport, but it is somehow related.

CCBUG:312332
parent ad8f2767
......@@ -255,8 +255,6 @@ public:
const int maxVisibleItems;
const int maxHistoryItems;
QStringList patternHistory;
AdvancedRenameLineEdit* lineEdit;
Highlighter* highlighter;
};
......@@ -396,9 +394,9 @@ void AdvancedRenameInput::readSettings()
KSharedConfig::Ptr config = KGlobal::config();
KConfigGroup group = config->group(d->configGroupName);
d->patternHistory = group.readEntry(d->configPatternHistoryListEntry, QStringList());
d->patternHistory.removeAll(QString(""));
addItems(d->patternHistory);
QStringList patternHistory = group.readEntry(d->configPatternHistoryListEntry, QStringList());
patternHistory.removeAll(QString(""));
addItems(patternHistory);
d->lineEdit->clear();
}
......@@ -407,12 +405,14 @@ void AdvancedRenameInput::writeSettings()
KSharedConfig::Ptr config = KGlobal::config();
KConfigGroup group = config->group(d->configGroupName);
QStringList patternHistory = group.readEntry(d->configPatternHistoryListEntry, QStringList());
// remove duplicate entries and save pattern history, omit empty strings
QString pattern = d->lineEdit->toPlainText();
d->patternHistory.removeAll(pattern);
d->patternHistory.removeAll(QString(""));
d->patternHistory.prepend(pattern);
group.writeEntry(d->configPatternHistoryListEntry, d->patternHistory);
patternHistory.removeAll(pattern);
patternHistory.removeAll(QString(""));
patternHistory.prepend(pattern);
group.writeEntry(d->configPatternHistoryListEntry, patternHistory);
}
} // namespace Digikam
Supports Markdown
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