24 : m_lastInput(
std::move(lastInput)), m_previousDirectory(
std::move(previousDirectory)) {}
36 : m_lastInput(), m_previousDirectory(
""), m_algorithmsGroup(settingsGroup), m_dirKey(
"LastDirectory") {
58 m_lastInput[algName][
property.first] =
property.second;
106 if (!prefix.isEmpty() && !prefix.endsWith(
'/'))
110 QString previousDirectory;
111 for (
auto const &qualifiedName : storage.allKeys()) {
112 if (!qualifiedName.startsWith(prefix))
114 auto const relativeName = qualifiedName.mid(prefix.size());
116 previousDirectory = storage.value(qualifiedName).toString();
119 auto const separator = relativeName.indexOf(
'/');
120 if (separator <= 0 || relativeName.indexOf(
'/', separator + 1) >= 0)
122 auto const value = storage.value(qualifiedName).toString();
123 if (!
value.isEmpty())
124 inputHistory[relativeName.left(separator)].insert(relativeName.mid(separator + 1),
value);
142 if (!prefix.isEmpty() && !prefix.endsWith(
'/'))
144 QHashIterator<QString, QHash<QString, QString>> inputHistory(settings.
lastInput());
145 while (inputHistory.hasNext()) {
147 auto const algorithmName = prefix + inputHistory.key();
148 auto const algorithmPrefix = algorithmName +
'/';
149 auto const &algorithmSettings = inputHistory.value();
150 for (
auto const &storedKey : storage.allKeys()) {
151 auto const settingName = storedKey.mid(algorithmPrefix.size());
152 if (storedKey == algorithmName ||
153 (storedKey.startsWith(algorithmPrefix) && !algorithmSettings.contains(settingName)))
156 for (
auto itr = algorithmSettings.cbegin(); itr != algorithmSettings.cend(); ++itr)
157 writer.
setValue(algorithmPrefix + itr.key(), itr.value());
double value
The value of the point.
void save() const
Save the values stored here to persistent storage.
void initializeSettings()
Load any values that are available from persistent storage.
void setPreviousDirectory(const QString &lastdir)
Set the directory that was accessed when the previous open file dialog was used.
virtual ~AbstractAlgorithmInputHistory() override=0
Abstract destructor.
AlgorithmInputHistorySettings captureSettings() const override
Capture current history without persistent I/O.
QHash< QString, QHash< QString, QString > > m_lastInput
A map indexing the algorithm name and a list of property name:value pairs.
QString m_previousDirectory
The directory that last used by an open file dialog.
void restoreSettings(const AlgorithmInputHistorySettings &settings) override
Apply an already-read snapshot without persistent I/O.
QString m_algorithmsGroup
The string denoting the group (in the QSettings) where the algorithm properties are stored.
QString m_dirKey
The string denoting the key for the previous dir storage.
const QString & getPreviousDirectory() const
Get the directory that was accessed when the previous open file dialog was used.
void clearAlgorithmInput(const QString &algName)
Clear values for a particular algorithm.
void saveSettings(QSettings &storage, const AlgorithmInputHistorySettings &settings) const
Persist an explicit snapshot.
void storeNewValue(const QString &algName, const std::pair< QString, QString > &property)
Update the old values that are stored here.
AbstractAlgorithmInputHistory(const AbstractAlgorithmInputHistory &)=delete
QString previousInput(const QString &algName, const QString &propName) const
Retrieve an old parameter value.
AlgorithmInputHistorySettings readSettings(const QSettings &storage) const
Query persistent storage without changing the history.
QString const & previousDirectory() const
InputHistory const & lastInput() const
AlgorithmInputHistorySettings(InputHistory lastInput={}, QString previousDirectory={})
QString m_previousDirectory