void Settings::writeSettingsValues(const QString &path, ConfigOptionGroup *group) { ConfigOption *option; m_storage.beginGroup(path); for (ConfigOptionGroup::size_type i = 0, size = group->size(); i < size; ++i) if ((option = group->at(i))->type() == ConfigOption::Value) m_storage.setValue(option->title(), static_cast<ConfigOptionValue*>(option)->editorValue()); else { m_storage.endGroup(); writeSettingsValues(QString(path).append(QChar(L'.')).append(option->title()), static_cast<ConfigOptionGroup*>(option)); m_storage.beginGroup(path); } m_storage.endGroup(); }
void Settings::makeSettingsCache(const QString &groupPath, GroupPathCache &groupPathCache, ConfigOptionGroup *group) { ConfigOption *option; for (ConfigOptionGroup::size_type i = 0, size = group->size(); i < size; ++i) if ((option = group->at(i))->type() == ConfigOption::Value) { Q_ASSERT_X(!m_cache.contains(static_cast<ConfigOptionValue*>(option)->id()), "Settings::makeSettingsCache", "Settings can not have same id"); m_cache[static_cast<ConfigOptionValue*>(option)->id()] = CacheEntry(static_cast<ConfigOptionValue*>(option), groupPath); } else makeSettingsCache(QString(groupPath).append(QChar(L'.')).append(option->title()), groupPathCache, static_cast<ConfigOptionGroup*>(option)); }
void Settings::readSettingsValues(const QString &path, ConfigOptionGroup *group) { QVariant value; ConfigOption *option; m_storage.beginGroup(path); for (ConfigOptionGroup::size_type i = 0, size = group->size(); i < size; ++i) if ((option = group->at(i))->type() == ConfigOption::Value) { if ((value = m_storage.value(option->title())).isNull()) m_storage.setValue(option->title(), value = static_cast<ConfigOptionValue*>(option)->defaultValue()); static_cast<ConfigOptionValue*>(option)->setLoadedEditorValue(value); } else { m_storage.endGroup(); readSettingsValues(QString(path).append(QChar(L'.')).append(option->title()), static_cast<ConfigOptionGroup*>(option)); m_storage.beginGroup(path); } m_storage.endGroup(); }