From 3565aad630864ecdbe53fdaa501ea708555b3c7c Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sun, 30 Apr 2023 18:30:36 -0400 Subject: New upstream version 3.4.4+dfsg. --- SQLiteStudio3/guiSQLiteStudio/configmapper.cpp | 50 +++++++++++++++++++------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'SQLiteStudio3/guiSQLiteStudio/configmapper.cpp') diff --git a/SQLiteStudio3/guiSQLiteStudio/configmapper.cpp b/SQLiteStudio3/guiSQLiteStudio/configmapper.cpp index b36d985..704104b 100644 --- a/SQLiteStudio3/guiSQLiteStudio/configmapper.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/configmapper.cpp @@ -293,14 +293,14 @@ void ConfigMapper::applyConfigToWidget(QWidget* widget, const QHashgetFullKey()]; if (!configValue.isValid()) - configValue = cfgEntry->getDefultValue(); + configValue = cfgEntry->getDefaultValue(); } else if (cfgEntry->isPersistable()) { // In case this is a persistable config, we should have everything in the config hash, which is just one, initial database query. // If we don't, than we don't want to call get(), because it will cause one more query to the database for it. // We go with the default value. - configValue = cfgEntry->getDefultValue(); + configValue = cfgEntry->getDefaultValue(); } else { @@ -329,18 +329,36 @@ void ConfigMapper::applyConfigToWidget(QWidget* widget, CfgEntry* cfgEntry, cons void ConfigMapper::applyConfigDefaultValueToWidget(QWidget* widget) { - QString keyStr = widget->property(CFG_MODEL_PROPERTY).toString(); + CfgEntry* key = getConfigForWidget(widget); + if (!key) + { + qWarning() << "Asked to apply config value to widget" << widget + << "but it's config entry key was not found."; + return; + } + + applyConfigToWidget(widget, key, key->getDefaultValue()); +} + +CfgEntry* ConfigMapper::getConfigForWidget(QWidget* widget) +{ + QString keyStr = getConfigFullKeyForWidget(widget); QHash allConfigEntries = getAllConfigEntries(); if (!allConfigEntries.contains(keyStr)) { - qWarning() << "Asked to apply config value to widget" << widget << "but it's config entry key was not found:" << keyStr; - return; + qWarning() << "Config entry with key not found:" << keyStr; + return nullptr; } - CfgEntry* key = allConfigEntries[keyStr]; - applyConfigToWidget(widget, key, key->getDefultValue()); + return allConfigEntries[keyStr]; } +QString ConfigMapper::getConfigFullKeyForWidget(QWidget* widget) +{ + return widget->property(CFG_MODEL_PROPERTY).toString(); +} + + void ConfigMapper::handleSpecialWidgets(QWidget* widget, const QHash& allConfigEntries) { handleConfigComboBox(widget, allConfigEntries); @@ -372,7 +390,7 @@ bool ConfigMapper::applyCustomConfigToWidget(CfgEntry* key, QWidget* widget, con handlers += internalCustomConfigWidgets; handlers += PLUGINS->getLoadedPlugins(); - for (CustomConfigWidgetPlugin* handler : handlers) + for (CustomConfigWidgetPlugin*& handler : handlers) { if (handler->isConfigForWidget(key, widget)) { @@ -389,11 +407,11 @@ bool ConfigMapper::connectCustomNotifierToWidget(QWidget* widget, CfgEntry* cfgE handlers += internalCustomConfigWidgets; handlers += PLUGINS->getLoadedPlugins(); - for (CustomConfigWidgetPlugin* handler : handlers) + for (CustomConfigWidgetPlugin*& handler : handlers) { if (handler->isConfigForWidget(cfgEntry, widget)) { - connect(widget, handler->getModifiedNotifier(), this, SIGNAL(modified())); + connect(widget, handler->getModifiedNotifier(), this, SLOT(handleCustomModified())); if (widget->property(CFG_NOTIFY_PROPERTY).isValid() && widget->property(CFG_NOTIFY_PROPERTY).toBool()) connect(widget, handler->getModifiedNotifier(), this, SLOT(uiConfigEntryChanged())); @@ -430,7 +448,7 @@ bool ConfigMapper::saveCustomConfigFromWidget(QWidget* widget, CfgEntry* key) handlers += internalCustomConfigWidgets; handlers += PLUGINS->getLoadedPlugins(); - for (CustomConfigWidgetPlugin* plugin : handlers) + for (CustomConfigWidgetPlugin*& plugin : handlers) { if (plugin->isConfigForWidget(key, widget)) { @@ -470,7 +488,7 @@ QHash ConfigMapper::getAllConfigEntries() if (allEntries.isEmpty()) { QString key; - for (CfgMain* cfgMain : cfgMainList) + for (CfgMain*& cfgMain : cfgMainList) { QHashIterator catIt(cfgMain->getCategories()); while (catIt.hasNext()) @@ -627,7 +645,13 @@ void ConfigMapper::handleModified() handleDependencyChange(widget); - emit modified(); + emit modified(widget); +} + +void ConfigMapper::handleCustomModified() +{ + QWidget* widget = dynamic_cast(sender()); + emit modified(widget); } void ConfigMapper::entryChanged(const QVariant& newValue) -- cgit v1.2.3