forked from qt-creator/qt-creator
Utils: Simplify from/toSettings API
Change-Id: I591b6f833342ba9bd1a282332de5bb620d7f8c76 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
64ac719ff8
commit
ef30831213
@@ -35,19 +35,16 @@ namespace Utils {
|
|||||||
template <class SettingsClassT>
|
template <class SettingsClassT>
|
||||||
void fromSettings(const QString &postFix,
|
void fromSettings(const QString &postFix,
|
||||||
const QString &category,
|
const QString &category,
|
||||||
const QSettings *s,
|
QSettings *s,
|
||||||
SettingsClassT *obj)
|
SettingsClassT *obj)
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
|
s->beginGroup(category + postFix);
|
||||||
const QStringList keys = s->allKeys();
|
const QStringList keys = s->allKeys();
|
||||||
for (const QString &key : keys)
|
for (const QString &key : keys)
|
||||||
map.insert(key, s->value(key));
|
map.insert(key, s->value(key));
|
||||||
|
s->endGroup();
|
||||||
QString group = postFix;
|
obj->fromMap(map);
|
||||||
if (!category.isEmpty())
|
|
||||||
group.insert(0, category);
|
|
||||||
group += QLatin1Char('/');
|
|
||||||
obj->fromMap(group, map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class SettingsClassT>
|
template <class SettingsClassT>
|
||||||
@@ -59,13 +56,12 @@ void toSettings(const QString &postFix,
|
|||||||
QString group = postFix;
|
QString group = postFix;
|
||||||
if (!category.isEmpty())
|
if (!category.isEmpty())
|
||||||
group.insert(0, category);
|
group.insert(0, category);
|
||||||
group += QLatin1Char('/');
|
const QVariantMap map = obj->toMap();
|
||||||
|
|
||||||
QVariantMap map;
|
s->beginGroup(group);
|
||||||
obj->toMap(group, &map);
|
for (auto it = map.constBegin(), end = map.constEnd(); it != end; ++it)
|
||||||
QVariantMap::const_iterator it = map.constBegin();
|
|
||||||
for (; it != map.constEnd(); ++it)
|
|
||||||
s->setValue(it.key(), it.value());
|
s->setValue(it.key(), it.value());
|
||||||
|
s->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
@@ -89,22 +89,19 @@ void CppCodeStylePreferences::slotCurrentValueChanged(const QVariant &value)
|
|||||||
emit currentCodeStyleSettingsChanged(value.value<CppCodeStyleSettings>());
|
emit currentCodeStyleSettingsChanged(value.value<CppCodeStyleSettings>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCodeStylePreferences::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap CppCodeStylePreferences::toMap() const
|
||||||
{
|
{
|
||||||
ICodeStylePreferences::toMap(prefix, map);
|
QVariantMap map = ICodeStylePreferences::toMap();
|
||||||
if (currentDelegate())
|
if (!currentDelegate())
|
||||||
return;
|
map.insert(m_data.toMap());
|
||||||
|
return map;
|
||||||
m_data.toMap(prefix, map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCodeStylePreferences::fromMap(const QString &prefix, const QVariantMap &map)
|
void CppCodeStylePreferences::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
ICodeStylePreferences::fromMap(prefix, map);
|
ICodeStylePreferences::fromMap(map);
|
||||||
if (currentDelegate())
|
if (!currentDelegate())
|
||||||
return;
|
m_data.fromMap(map);
|
||||||
|
|
||||||
m_data.fromMap(prefix, map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // namespace CppEditor
|
||||||
|
@@ -47,8 +47,8 @@ public:
|
|||||||
// tracks parent hierarchy until currentParentSettings is null
|
// tracks parent hierarchy until currentParentSettings is null
|
||||||
CppCodeStyleSettings currentCodeStyleSettings() const;
|
CppCodeStyleSettings currentCodeStyleSettings() const;
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const override;
|
QVariantMap toMap() const override;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map) override;
|
void fromMap(const QVariantMap &map) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCodeStyleSettings(const CppCodeStyleSettings &data);
|
void setCodeStyleSettings(const CppCodeStyleSettings &data);
|
||||||
|
@@ -74,80 +74,68 @@ void CppCodeStyleSettings::toSettings(const QString &category, QSettings *s) con
|
|||||||
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCodeStyleSettings::fromSettings(const QString &category, const QSettings *s)
|
void CppCodeStyleSettings::fromSettings(const QString &category, QSettings *s)
|
||||||
{
|
{
|
||||||
*this = CppCodeStyleSettings(); // Assign defaults
|
*this = CppCodeStyleSettings(); // Assign defaults
|
||||||
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCodeStyleSettings::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap CppCodeStyleSettings::toMap() const
|
||||||
{
|
{
|
||||||
map->insert(prefix + QLatin1String(indentBlockBracesKey), indentBlockBraces);
|
return {
|
||||||
map->insert(prefix + QLatin1String(indentBlockBodyKey), indentBlockBody);
|
{indentBlockBracesKey, indentBlockBraces},
|
||||||
map->insert(prefix + QLatin1String(indentClassBracesKey), indentClassBraces);
|
{indentBlockBodyKey, indentBlockBody},
|
||||||
map->insert(prefix + QLatin1String(indentEnumBracesKey), indentEnumBraces);
|
{indentClassBracesKey, indentClassBraces},
|
||||||
map->insert(prefix + QLatin1String(indentNamespaceBracesKey), indentNamespaceBraces);
|
{indentEnumBracesKey, indentEnumBraces},
|
||||||
map->insert(prefix + QLatin1String(indentNamespaceBodyKey), indentNamespaceBody);
|
{indentNamespaceBracesKey, indentNamespaceBraces},
|
||||||
map->insert(prefix + QLatin1String(indentAccessSpecifiersKey), indentAccessSpecifiers);
|
{indentNamespaceBodyKey, indentNamespaceBody},
|
||||||
map->insert(prefix + QLatin1String(indentDeclarationsRelativeToAccessSpecifiersKey), indentDeclarationsRelativeToAccessSpecifiers);
|
{indentAccessSpecifiersKey, indentAccessSpecifiers},
|
||||||
map->insert(prefix + QLatin1String(indentFunctionBodyKey), indentFunctionBody);
|
{indentDeclarationsRelativeToAccessSpecifiersKey, indentDeclarationsRelativeToAccessSpecifiers},
|
||||||
map->insert(prefix + QLatin1String(indentFunctionBracesKey), indentFunctionBraces);
|
{indentFunctionBodyKey, indentFunctionBody},
|
||||||
map->insert(prefix + QLatin1String(indentSwitchLabelsKey), indentSwitchLabels);
|
{indentFunctionBracesKey, indentFunctionBraces},
|
||||||
map->insert(prefix + QLatin1String(indentStatementsRelativeToSwitchLabelsKey), indentStatementsRelativeToSwitchLabels);
|
{indentSwitchLabelsKey, indentSwitchLabels},
|
||||||
map->insert(prefix + QLatin1String(indentBlocksRelativeToSwitchLabelsKey), indentBlocksRelativeToSwitchLabels);
|
{indentStatementsRelativeToSwitchLabelsKey, indentStatementsRelativeToSwitchLabels},
|
||||||
map->insert(prefix + QLatin1String(indentControlFlowRelativeToSwitchLabelsKey), indentControlFlowRelativeToSwitchLabels);
|
{indentBlocksRelativeToSwitchLabelsKey, indentBlocksRelativeToSwitchLabels},
|
||||||
map->insert(prefix + QLatin1String(bindStarToIdentifierKey), bindStarToIdentifier);
|
{indentControlFlowRelativeToSwitchLabelsKey, indentControlFlowRelativeToSwitchLabels},
|
||||||
map->insert(prefix + QLatin1String(bindStarToTypeNameKey), bindStarToTypeName);
|
{bindStarToIdentifierKey, bindStarToIdentifier},
|
||||||
map->insert(prefix + QLatin1String(bindStarToLeftSpecifierKey), bindStarToLeftSpecifier);
|
{bindStarToTypeNameKey, bindStarToTypeName},
|
||||||
map->insert(prefix + QLatin1String(bindStarToRightSpecifierKey), bindStarToRightSpecifier);
|
{bindStarToLeftSpecifierKey, bindStarToLeftSpecifier},
|
||||||
map->insert(prefix + QLatin1String(extraPaddingForConditionsIfConfusingAlignKey), extraPaddingForConditionsIfConfusingAlign);
|
{bindStarToRightSpecifierKey, bindStarToRightSpecifier},
|
||||||
map->insert(prefix + QLatin1String(alignAssignmentsKey), alignAssignments);
|
{extraPaddingForConditionsIfConfusingAlignKey, extraPaddingForConditionsIfConfusingAlign},
|
||||||
map->insert(prefix + QLatin1String(shortGetterNameKey), preferGetterNameWithoutGetPrefix);
|
{alignAssignmentsKey, alignAssignments},
|
||||||
|
{shortGetterNameKey, preferGetterNameWithoutGetPrefix}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCodeStyleSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
void CppCodeStyleSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
indentBlockBraces = map.value(prefix + QLatin1String(indentBlockBracesKey),
|
indentBlockBraces = map.value(indentBlockBracesKey, indentBlockBraces).toBool();
|
||||||
indentBlockBraces).toBool();
|
indentBlockBody = map.value(indentBlockBodyKey, indentBlockBody).toBool();
|
||||||
indentBlockBody = map.value(prefix + QLatin1String(indentBlockBodyKey),
|
indentClassBraces = map.value(indentClassBracesKey, indentClassBraces).toBool();
|
||||||
indentBlockBody).toBool();
|
indentEnumBraces = map.value(indentEnumBracesKey, indentEnumBraces).toBool();
|
||||||
indentClassBraces = map.value(prefix + QLatin1String(indentClassBracesKey),
|
indentNamespaceBraces = map.value(indentNamespaceBracesKey, indentNamespaceBraces).toBool();
|
||||||
indentClassBraces).toBool();
|
indentNamespaceBody = map.value(indentNamespaceBodyKey, indentNamespaceBody).toBool();
|
||||||
indentEnumBraces = map.value(prefix + QLatin1String(indentEnumBracesKey),
|
indentAccessSpecifiers = map.value(indentAccessSpecifiersKey, indentAccessSpecifiers).toBool();
|
||||||
indentEnumBraces).toBool();
|
indentDeclarationsRelativeToAccessSpecifiers =
|
||||||
indentNamespaceBraces = map.value(prefix + QLatin1String(indentNamespaceBracesKey),
|
map.value(indentDeclarationsRelativeToAccessSpecifiersKey,
|
||||||
indentNamespaceBraces).toBool();
|
indentDeclarationsRelativeToAccessSpecifiers).toBool();
|
||||||
indentNamespaceBody = map.value(prefix + QLatin1String(indentNamespaceBodyKey),
|
indentFunctionBody = map.value(indentFunctionBodyKey, indentFunctionBody).toBool();
|
||||||
indentNamespaceBody).toBool();
|
indentFunctionBraces = map.value(indentFunctionBracesKey, indentFunctionBraces).toBool();
|
||||||
indentAccessSpecifiers = map.value(prefix + QLatin1String(indentAccessSpecifiersKey),
|
indentSwitchLabels = map.value(indentSwitchLabelsKey, indentSwitchLabels).toBool();
|
||||||
indentAccessSpecifiers).toBool();
|
indentStatementsRelativeToSwitchLabels = map.value(indentStatementsRelativeToSwitchLabelsKey,
|
||||||
indentDeclarationsRelativeToAccessSpecifiers = map.value(prefix + QLatin1String(indentDeclarationsRelativeToAccessSpecifiersKey),
|
|
||||||
indentDeclarationsRelativeToAccessSpecifiers).toBool();
|
|
||||||
indentFunctionBody = map.value(prefix + QLatin1String(indentFunctionBodyKey),
|
|
||||||
indentFunctionBody).toBool();
|
|
||||||
indentFunctionBraces = map.value(prefix + QLatin1String(indentFunctionBracesKey),
|
|
||||||
indentFunctionBraces).toBool();
|
|
||||||
indentSwitchLabels = map.value(prefix + QLatin1String(indentSwitchLabelsKey),
|
|
||||||
indentSwitchLabels).toBool();
|
|
||||||
indentStatementsRelativeToSwitchLabels = map.value(prefix + QLatin1String(indentStatementsRelativeToSwitchLabelsKey),
|
|
||||||
indentStatementsRelativeToSwitchLabels).toBool();
|
indentStatementsRelativeToSwitchLabels).toBool();
|
||||||
indentBlocksRelativeToSwitchLabels = map.value(prefix + QLatin1String(indentBlocksRelativeToSwitchLabelsKey),
|
indentBlocksRelativeToSwitchLabels = map.value(indentBlocksRelativeToSwitchLabelsKey,
|
||||||
indentBlocksRelativeToSwitchLabels).toBool();
|
indentBlocksRelativeToSwitchLabels).toBool();
|
||||||
indentControlFlowRelativeToSwitchLabels = map.value(prefix + QLatin1String(indentControlFlowRelativeToSwitchLabelsKey),
|
indentControlFlowRelativeToSwitchLabels = map.value(indentControlFlowRelativeToSwitchLabelsKey,
|
||||||
indentControlFlowRelativeToSwitchLabels).toBool();
|
indentControlFlowRelativeToSwitchLabels).toBool();
|
||||||
bindStarToIdentifier = map.value(prefix + QLatin1String(bindStarToIdentifierKey),
|
bindStarToIdentifier = map.value(bindStarToIdentifierKey, bindStarToIdentifier).toBool();
|
||||||
bindStarToIdentifier).toBool();
|
bindStarToTypeName = map.value(bindStarToTypeNameKey, bindStarToTypeName).toBool();
|
||||||
bindStarToTypeName = map.value(prefix + QLatin1String(bindStarToTypeNameKey),
|
bindStarToLeftSpecifier = map.value(bindStarToLeftSpecifierKey, bindStarToLeftSpecifier).toBool();
|
||||||
bindStarToTypeName).toBool();
|
bindStarToRightSpecifier = map.value(bindStarToRightSpecifierKey, bindStarToRightSpecifier).toBool();
|
||||||
bindStarToLeftSpecifier = map.value(prefix + QLatin1String(bindStarToLeftSpecifierKey),
|
extraPaddingForConditionsIfConfusingAlign = map.value(extraPaddingForConditionsIfConfusingAlignKey,
|
||||||
bindStarToLeftSpecifier).toBool();
|
|
||||||
bindStarToRightSpecifier = map.value(prefix + QLatin1String(bindStarToRightSpecifierKey),
|
|
||||||
bindStarToRightSpecifier).toBool();
|
|
||||||
extraPaddingForConditionsIfConfusingAlign = map.value(prefix + QLatin1String(extraPaddingForConditionsIfConfusingAlignKey),
|
|
||||||
extraPaddingForConditionsIfConfusingAlign).toBool();
|
extraPaddingForConditionsIfConfusingAlign).toBool();
|
||||||
alignAssignments = map.value(prefix + QLatin1String(alignAssignmentsKey),
|
alignAssignments = map.value(alignAssignmentsKey, alignAssignments).toBool();
|
||||||
alignAssignments).toBool();
|
preferGetterNameWithoutGetPrefix = map.value(shortGetterNameKey,
|
||||||
preferGetterNameWithoutGetPrefix = map.value(prefix + QLatin1String(shortGetterNameKey),
|
|
||||||
preferGetterNameWithoutGetPrefix).toBool();
|
preferGetterNameWithoutGetPrefix).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,10 +89,10 @@ public:
|
|||||||
bool preferGetterNameWithoutGetPrefix = true;
|
bool preferGetterNameWithoutGetPrefix = true;
|
||||||
|
|
||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, QSettings *s);
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const;
|
QVariantMap toMap() const;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
bool equals(const CppCodeStyleSettings &rhs) const;
|
bool equals(const CppCodeStyleSettings &rhs) const;
|
||||||
bool operator==(const CppCodeStyleSettings &s) const { return equals(s); }
|
bool operator==(const CppCodeStyleSettings &s) const { return equals(s); }
|
||||||
|
@@ -180,33 +180,38 @@ QMap<Utils::Id, ICodeStylePreferences *> EditorConfiguration::codeStyles() const
|
|||||||
return d->m_languageCodeStylePreferences;
|
return d->m_languageCodeStylePreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void toMapWithPrefix(QVariantMap *map, const QVariantMap &source)
|
||||||
|
{
|
||||||
|
for (auto it = source.constBegin(), end = source.constEnd(); it != end; ++it)
|
||||||
|
map->insert(kPrefix + it.key(), it.value());
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap EditorConfiguration::toMap() const
|
QVariantMap EditorConfiguration::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map = {
|
||||||
map.insert(kUseGlobal, d->m_useGlobal);
|
{kUseGlobal, d->m_useGlobal},
|
||||||
map.insert(kCodec, d->m_textCodec->name());
|
{kCodec, d->m_textCodec->name()},
|
||||||
|
{kCodeStyleCount, d->m_languageCodeStylePreferences.count()}
|
||||||
map.insert(kCodeStyleCount, d->m_languageCodeStylePreferences.count());
|
};
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto itCodeStyle = d->m_languageCodeStylePreferences.cbegin(),
|
for (auto itCodeStyle = d->m_languageCodeStylePreferences.cbegin(),
|
||||||
end = d->m_languageCodeStylePreferences.cend();
|
end = d->m_languageCodeStylePreferences.cend();
|
||||||
itCodeStyle != end; ++itCodeStyle) {
|
itCodeStyle != end; ++itCodeStyle) {
|
||||||
QVariantMap settingsIdMap;
|
const QVariantMap settingsIdMap = {
|
||||||
settingsIdMap.insert(QLatin1String("language"), itCodeStyle.key().toSetting());
|
{"language", itCodeStyle.key().toSetting()},
|
||||||
QVariantMap value;
|
{"value", itCodeStyle.value()->toMap()}
|
||||||
itCodeStyle.value()->toMap(QString(), &value);
|
};
|
||||||
settingsIdMap.insert(QLatin1String("value"), value);
|
|
||||||
map.insert(kCodeStylePrefix + QString::number(i), settingsIdMap);
|
map.insert(kCodeStylePrefix + QString::number(i), settingsIdMap);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_defaultCodeStyle->tabSettings().toMap(kPrefix, &map);
|
toMapWithPrefix(&map, d->m_defaultCodeStyle->tabSettings().toMap());
|
||||||
d->m_typingSettings.toMap(kPrefix, &map);
|
toMapWithPrefix(&map, d->m_typingSettings.toMap());
|
||||||
d->m_storageSettings.toMap(kPrefix, &map);
|
toMapWithPrefix(&map, d->m_storageSettings.toMap());
|
||||||
d->m_behaviorSettings.toMap(kPrefix, &map);
|
toMapWithPrefix(&map, d->m_behaviorSettings.toMap());
|
||||||
d->m_extraEncodingSettings.toMap(kPrefix, &map);
|
toMapWithPrefix(&map, d->m_extraEncodingSettings.toMap());
|
||||||
d->m_marginSettings.toMap(kPrefix, &map);
|
toMapWithPrefix(&map, d->m_marginSettings.toMap());
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -229,15 +234,20 @@ void EditorConfiguration::fromMap(const QVariantMap &map)
|
|||||||
QVariantMap value = settingsIdMap.value(QLatin1String("value")).toMap();
|
QVariantMap value = settingsIdMap.value(QLatin1String("value")).toMap();
|
||||||
ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId);
|
ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId);
|
||||||
if (preferences)
|
if (preferences)
|
||||||
preferences->fromMap(QString(), value);
|
preferences->fromMap(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_defaultCodeStyle->fromMap(kPrefix, map);
|
QVariantMap submap;
|
||||||
d->m_typingSettings.fromMap(kPrefix, map);
|
for (auto it = map.constBegin(), end = map.constEnd(); it != end; ++it) {
|
||||||
d->m_storageSettings.fromMap(kPrefix, map);
|
if (it.key().startsWith(kPrefix))
|
||||||
d->m_behaviorSettings.fromMap(kPrefix, map);
|
submap.insert(it.key().mid(kPrefix.size()), it.value());
|
||||||
d->m_extraEncodingSettings.fromMap(kPrefix, map);
|
}
|
||||||
d->m_marginSettings.fromMap(kPrefix, map);
|
d->m_defaultCodeStyle->fromMap(submap);
|
||||||
|
d->m_typingSettings.fromMap(submap);
|
||||||
|
d->m_storageSettings.fromMap(submap);
|
||||||
|
d->m_behaviorSettings.fromMap(submap);
|
||||||
|
d->m_extraEncodingSettings.fromMap(submap);
|
||||||
|
d->m_marginSettings.fromMap(submap);
|
||||||
setUseGlobalSettings(map.value(kUseGlobal, d->m_useGlobal).toBool());
|
setUseGlobalSettings(map.value(kUseGlobal, d->m_useGlobal).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,40 +57,34 @@ void BehaviorSettings::toSettings(const QString &category, QSettings *s) const
|
|||||||
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorSettings::fromSettings(const QString &category, const QSettings *s)
|
void BehaviorSettings::fromSettings(const QString &category, QSettings *s)
|
||||||
{
|
{
|
||||||
*this = BehaviorSettings();
|
*this = BehaviorSettings();
|
||||||
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorSettings::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap BehaviorSettings::toMap() const
|
||||||
{
|
{
|
||||||
map->insert(prefix + QLatin1String(mouseHidingKey), m_mouseHiding);
|
return {
|
||||||
map->insert(prefix + QLatin1String(mouseNavigationKey), m_mouseNavigation);
|
{mouseHidingKey, m_mouseHiding},
|
||||||
map->insert(prefix + QLatin1String(scrollWheelZoomingKey), m_scrollWheelZooming);
|
{mouseNavigationKey, m_mouseNavigation},
|
||||||
map->insert(prefix + QLatin1String(constrainTooltips), m_constrainHoverTooltips);
|
{scrollWheelZoomingKey, m_scrollWheelZooming},
|
||||||
map->insert(prefix + QLatin1String(camelCaseNavigationKey), m_camelCaseNavigation);
|
{constrainTooltips, m_constrainHoverTooltips},
|
||||||
map->insert(prefix + QLatin1String(keyboardTooltips), m_keyboardTooltips);
|
{camelCaseNavigationKey, m_camelCaseNavigation},
|
||||||
map->insert(prefix + QLatin1String(smartSelectionChanging), m_smartSelectionChanging);
|
{keyboardTooltips, m_keyboardTooltips},
|
||||||
|
{smartSelectionChanging, m_smartSelectionChanging}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
void BehaviorSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_mouseHiding =
|
m_mouseHiding = map.value(mouseHidingKey, m_mouseHiding).toBool();
|
||||||
map.value(prefix + QLatin1String(mouseHidingKey), m_mouseHiding).toBool();
|
m_mouseNavigation = map.value(mouseNavigationKey, m_mouseNavigation).toBool();
|
||||||
m_mouseNavigation =
|
m_scrollWheelZooming = map.value(scrollWheelZoomingKey, m_scrollWheelZooming).toBool();
|
||||||
map.value(prefix + QLatin1String(mouseNavigationKey), m_mouseNavigation).toBool();
|
m_constrainHoverTooltips = map.value(constrainTooltips, m_constrainHoverTooltips).toBool();
|
||||||
m_scrollWheelZooming =
|
m_camelCaseNavigation = map.value(camelCaseNavigationKey, m_camelCaseNavigation).toBool();
|
||||||
map.value(prefix + QLatin1String(scrollWheelZoomingKey), m_scrollWheelZooming).toBool();
|
m_keyboardTooltips = map.value(keyboardTooltips, m_keyboardTooltips).toBool();
|
||||||
m_constrainHoverTooltips =
|
m_smartSelectionChanging = map.value(smartSelectionChanging, m_smartSelectionChanging).toBool();
|
||||||
map.value(prefix + QLatin1String(constrainTooltips), m_constrainHoverTooltips).toBool();
|
|
||||||
m_camelCaseNavigation =
|
|
||||||
map.value(prefix + QLatin1String(camelCaseNavigationKey), m_camelCaseNavigation).toBool();
|
|
||||||
m_keyboardTooltips =
|
|
||||||
map.value(prefix + QLatin1String(keyboardTooltips), m_keyboardTooltips).toBool();
|
|
||||||
m_smartSelectionChanging =
|
|
||||||
map.value(prefix + QLatin1String(smartSelectionChanging), m_smartSelectionChanging)
|
|
||||||
.toBool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BehaviorSettings::equals(const BehaviorSettings &ds) const
|
bool BehaviorSettings::equals(const BehaviorSettings &ds) const
|
||||||
|
@@ -45,10 +45,10 @@ public:
|
|||||||
BehaviorSettings();
|
BehaviorSettings();
|
||||||
|
|
||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, QSettings *s);
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const;
|
QVariantMap toMap() const;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
bool equals(const BehaviorSettings &bs) const;
|
bool equals(const BehaviorSettings &bs) const;
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@ BehaviorSettingsPage::BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate()
|
|||||||
m_defaultCodeStylePool = new CodeStylePool(nullptr, this); // Any language
|
m_defaultCodeStylePool = new CodeStylePool(nullptr, this); // Any language
|
||||||
m_defaultCodeStylePool->addCodeStyle(m_codeStyle);
|
m_defaultCodeStylePool->addCodeStyle(m_codeStyle);
|
||||||
|
|
||||||
const QSettings *s = Core::ICore::settings();
|
QSettings * const s = Core::ICore::settings();
|
||||||
m_codeStyle->fromSettings(m_settingsPrefix, s);
|
m_codeStyle->fromSettings(m_settingsPrefix, s);
|
||||||
m_typingSettings.fromSettings(m_settingsPrefix, s);
|
m_typingSettings.fromSettings(m_settingsPrefix, s);
|
||||||
m_storageSettings.fromSettings(m_settingsPrefix, s);
|
m_storageSettings.fromSettings(m_settingsPrefix, s);
|
||||||
|
@@ -242,7 +242,7 @@ ICodeStylePreferences *CodeStylePool::loadCodeStyle(const Utils::FilePath &fileN
|
|||||||
codeStyle = d->m_factory->createCodeStyle();
|
codeStyle = d->m_factory->createCodeStyle();
|
||||||
codeStyle->setId(id);
|
codeStyle->setId(id);
|
||||||
codeStyle->setDisplayName(displayName);
|
codeStyle->setDisplayName(displayName);
|
||||||
codeStyle->fromMap(QString(), map);
|
codeStyle->fromMap(map);
|
||||||
|
|
||||||
addCodeStyle(codeStyle);
|
addCodeStyle(codeStyle);
|
||||||
}
|
}
|
||||||
@@ -280,12 +280,11 @@ void CodeStylePool::saveCodeStyle(ICodeStylePreferences *codeStyle) const
|
|||||||
|
|
||||||
void CodeStylePool::exportCodeStyle(const Utils::FilePath &fileName, ICodeStylePreferences *codeStyle) const
|
void CodeStylePool::exportCodeStyle(const Utils::FilePath &fileName, ICodeStylePreferences *codeStyle) const
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
const QVariantMap map = codeStyle->toMap();
|
||||||
codeStyle->toMap(QString(), &map);
|
const QVariantMap tmp = {
|
||||||
|
{displayNameKey, codeStyle->displayName()},
|
||||||
QVariantMap tmp;
|
{codeStyleDataKey, map}
|
||||||
tmp.insert(QLatin1String(displayNameKey), codeStyle->displayName());
|
};
|
||||||
tmp.insert(QLatin1String(codeStyleDataKey), map);
|
|
||||||
Utils::PersistentSettingsWriter writer(fileName, QLatin1String(codeStyleDocKey));
|
Utils::PersistentSettingsWriter writer(fileName, QLatin1String(codeStyleDocKey));
|
||||||
writer.save(tmp, Core::ICore::dialogParent());
|
writer.save(tmp, Core::ICore::dialogParent());
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ void ExtraEncodingSettings::toSettings(const QString &category, QSettings *s) co
|
|||||||
Utils::toSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
Utils::toSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtraEncodingSettings::fromSettings(const QString &category, const QSettings *s)
|
void ExtraEncodingSettings::fromSettings(const QString &category, QSettings *s)
|
||||||
{
|
{
|
||||||
Q_UNUSED(category)
|
Q_UNUSED(category)
|
||||||
|
|
||||||
@@ -57,15 +57,16 @@ void ExtraEncodingSettings::fromSettings(const QString &category, const QSetting
|
|||||||
Utils::fromSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
Utils::fromSettings(QLatin1String(kGroupPostfix), QString(), s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtraEncodingSettings::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap ExtraEncodingSettings::toMap() const
|
||||||
{
|
{
|
||||||
map->insert(prefix + QLatin1String(kUtf8BomBehaviorKey), m_utf8BomSetting);
|
return {
|
||||||
|
{kUtf8BomBehaviorKey, m_utf8BomSetting}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtraEncodingSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
void ExtraEncodingSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_utf8BomSetting = (Utf8BomSetting)
|
m_utf8BomSetting = (Utf8BomSetting)map.value(kUtf8BomBehaviorKey, m_utf8BomSetting).toInt();
|
||||||
map.value(prefix + QLatin1String(kUtf8BomBehaviorKey), m_utf8BomSetting).toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExtraEncodingSettings::equals(const ExtraEncodingSettings &s) const
|
bool ExtraEncodingSettings::equals(const ExtraEncodingSettings &s) const
|
||||||
|
@@ -42,10 +42,10 @@ public:
|
|||||||
~ExtraEncodingSettings();
|
~ExtraEncodingSettings();
|
||||||
|
|
||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, QSettings *s);
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const;
|
QVariantMap toMap() const;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
bool equals(const ExtraEncodingSettings &s) const;
|
bool equals(const ExtraEncodingSettings &s) const;
|
||||||
|
|
||||||
|
@@ -216,23 +216,25 @@ void ICodeStylePreferences::toSettings(const QString &category, QSettings *s) co
|
|||||||
Utils::toSettings(d->m_settingsSuffix, category, s, this);
|
Utils::toSettings(d->m_settingsSuffix, category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICodeStylePreferences::fromSettings(const QString &category, const QSettings *s)
|
void ICodeStylePreferences::fromSettings(const QString &category, QSettings *s)
|
||||||
{
|
{
|
||||||
Utils::fromSettings(d->m_settingsSuffix, category, s, this);
|
Utils::fromSettings(d->m_settingsSuffix, category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICodeStylePreferences::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap ICodeStylePreferences::toMap() const
|
||||||
{
|
{
|
||||||
|
QVariantMap map;
|
||||||
if (!currentDelegate())
|
if (!currentDelegate())
|
||||||
d->m_tabSettings.toMap(prefix, map);
|
return d->m_tabSettings.toMap();
|
||||||
else
|
return {
|
||||||
map->insert(prefix + QLatin1String(currentPreferencesKey), currentDelegateId());
|
{currentPreferencesKey, currentDelegateId()}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICodeStylePreferences::fromMap(const QString &prefix, const QVariantMap &map)
|
void ICodeStylePreferences::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
d->m_tabSettings.fromMap(prefix, map);
|
d->m_tabSettings.fromMap(map);
|
||||||
const QByteArray delegateId = map.value(prefix + QLatin1String(currentPreferencesKey)).toByteArray();
|
const QByteArray delegateId = map.value(currentPreferencesKey).toByteArray();
|
||||||
if (delegatingPool()) {
|
if (delegatingPool()) {
|
||||||
ICodeStylePreferences *delegate = delegatingPool()->codeStyle(delegateId);
|
ICodeStylePreferences *delegate = delegatingPool()->codeStyle(delegateId);
|
||||||
if (!delegateId.isEmpty() && delegate)
|
if (!delegateId.isEmpty() && delegate)
|
||||||
|
@@ -81,11 +81,11 @@ public:
|
|||||||
|
|
||||||
void setSettingsSuffix(const QString &suffix);
|
void setSettingsSuffix(const QString &suffix);
|
||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, QSettings *s);
|
||||||
|
|
||||||
// make below 2 protected?
|
// make below 2 protected?
|
||||||
virtual void toMap(const QString &prefix, QVariantMap *map) const;
|
virtual QVariantMap toMap() const;
|
||||||
virtual void fromMap(const QString &prefix, const QVariantMap &map);
|
virtual void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tabSettingsChanged(const TextEditor::TabSettings &settings);
|
void tabSettingsChanged(const TextEditor::TabSettings &settings);
|
||||||
|
@@ -69,18 +69,20 @@ void MarginSettings::fromSettings(const QString &category, const QSettings *s)
|
|||||||
m_marginColumn = s->value(group + QLatin1String(wrapColumnKey), m_marginColumn).toInt();
|
m_marginColumn = s->value(group + QLatin1String(wrapColumnKey), m_marginColumn).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarginSettings::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap MarginSettings::toMap() const
|
||||||
{
|
{
|
||||||
map->insert(prefix + QLatin1String(showWrapColumnKey), m_showMargin);
|
return {
|
||||||
map->insert(prefix + QLatin1String(useIndenterColumnKey), m_useIndenter);
|
{showWrapColumnKey, m_showMargin},
|
||||||
map->insert(prefix + QLatin1String(wrapColumnKey), m_marginColumn);
|
{useIndenterColumnKey, m_useIndenter},
|
||||||
|
{wrapColumnKey, m_marginColumn}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarginSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
void MarginSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_showMargin = map.value(prefix + QLatin1String(showWrapColumnKey), m_showMargin).toBool();
|
m_showMargin = map.value(showWrapColumnKey, m_showMargin).toBool();
|
||||||
m_useIndenter = map.value(prefix + QLatin1String(useIndenterColumnKey), m_useIndenter).toBool();
|
m_useIndenter = map.value(useIndenterColumnKey, m_useIndenter).toBool();
|
||||||
m_marginColumn = map.value(prefix + QLatin1String(wrapColumnKey), m_marginColumn).toInt();
|
m_marginColumn = map.value(wrapColumnKey, m_marginColumn).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MarginSettings::equals(const MarginSettings &other) const
|
bool MarginSettings::equals(const MarginSettings &other) const
|
||||||
|
@@ -43,8 +43,8 @@ public:
|
|||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, const QSettings *s);
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const;
|
QVariantMap toMap() const;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
bool equals(const MarginSettings &other) const;
|
bool equals(const MarginSettings &other) const;
|
||||||
|
|
||||||
|
@@ -58,36 +58,32 @@ void StorageSettings::toSettings(const QString &category, QSettings *s) const
|
|||||||
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageSettings::fromSettings(const QString &category, const QSettings *s)
|
void StorageSettings::fromSettings(const QString &category, QSettings *s)
|
||||||
{
|
{
|
||||||
*this = StorageSettings();
|
*this = StorageSettings();
|
||||||
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageSettings::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap StorageSettings::toMap() const
|
||||||
{
|
{
|
||||||
map->insert(prefix + QLatin1String(cleanWhitespaceKey), m_cleanWhitespace);
|
return {
|
||||||
map->insert(prefix + QLatin1String(inEntireDocumentKey), m_inEntireDocument);
|
{cleanWhitespaceKey, m_cleanWhitespace},
|
||||||
map->insert(prefix + QLatin1String(addFinalNewLineKey), m_addFinalNewLine);
|
{inEntireDocumentKey, m_inEntireDocument},
|
||||||
map->insert(prefix + QLatin1String(cleanIndentationKey), m_cleanIndentation);
|
{addFinalNewLineKey, m_addFinalNewLine},
|
||||||
map->insert(prefix + QLatin1String(skipTrailingWhitespaceKey), m_skipTrailingWhitespace);
|
{cleanIndentationKey, m_cleanIndentation},
|
||||||
map->insert(prefix + QLatin1String(ignoreFileTypesKey), m_ignoreFileTypes.toLatin1().data());
|
{skipTrailingWhitespaceKey, m_skipTrailingWhitespace},
|
||||||
|
{ignoreFileTypesKey, m_ignoreFileTypes.toLatin1().data()}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
void StorageSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_cleanWhitespace =
|
m_cleanWhitespace = map.value(cleanWhitespaceKey, m_cleanWhitespace).toBool();
|
||||||
map.value(prefix + QLatin1String(cleanWhitespaceKey), m_cleanWhitespace).toBool();
|
m_inEntireDocument = map.value(inEntireDocumentKey, m_inEntireDocument).toBool();
|
||||||
m_inEntireDocument =
|
m_addFinalNewLine = map.value(addFinalNewLineKey, m_addFinalNewLine).toBool();
|
||||||
map.value(prefix + QLatin1String(inEntireDocumentKey), m_inEntireDocument).toBool();
|
m_cleanIndentation = map.value(cleanIndentationKey, m_cleanIndentation).toBool();
|
||||||
m_addFinalNewLine =
|
m_skipTrailingWhitespace = map.value(skipTrailingWhitespaceKey, m_skipTrailingWhitespace).toBool();
|
||||||
map.value(prefix + QLatin1String(addFinalNewLineKey), m_addFinalNewLine).toBool();
|
m_ignoreFileTypes = map.value(ignoreFileTypesKey, m_ignoreFileTypes).toString();
|
||||||
m_cleanIndentation =
|
|
||||||
map.value(prefix + QLatin1String(cleanIndentationKey), m_cleanIndentation).toBool();
|
|
||||||
m_skipTrailingWhitespace =
|
|
||||||
map.value(prefix + QLatin1String(skipTrailingWhitespaceKey), m_skipTrailingWhitespace).toBool();
|
|
||||||
m_ignoreFileTypes =
|
|
||||||
map.value(prefix + QLatin1String(ignoreFileTypesKey), m_ignoreFileTypes).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StorageSettings::removeTrailingWhitespace(const QString &fileName) const
|
bool StorageSettings::removeTrailingWhitespace(const QString &fileName) const
|
||||||
|
@@ -41,10 +41,10 @@ public:
|
|||||||
StorageSettings();
|
StorageSettings();
|
||||||
|
|
||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, QSettings *s);
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const;
|
QVariantMap toMap() const;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
// calculated based on boolean setting plus file type blacklist examination
|
// calculated based on boolean setting plus file type blacklist examination
|
||||||
bool removeTrailingWhitespace(const QString &filePattern) const;
|
bool removeTrailingWhitespace(const QString &filePattern) const;
|
||||||
|
@@ -60,32 +60,32 @@ void TabSettings::toSettings(const QString &category, QSettings *s) const
|
|||||||
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSettings::fromSettings(const QString &category, const QSettings *s)
|
void TabSettings::fromSettings(const QString &category, QSettings *s)
|
||||||
{
|
{
|
||||||
*this = TabSettings(); // Assign defaults
|
*this = TabSettings(); // Assign defaults
|
||||||
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSettings::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap TabSettings::toMap() const
|
||||||
{
|
{
|
||||||
map->insert(prefix + QLatin1String(spacesForTabsKey), m_tabPolicy != TabsOnlyTabPolicy);
|
return {
|
||||||
map->insert(prefix + QLatin1String(autoSpacesForTabsKey), m_tabPolicy == MixedTabPolicy);
|
{spacesForTabsKey, m_tabPolicy != TabsOnlyTabPolicy},
|
||||||
map->insert(prefix + QLatin1String(tabSizeKey), m_tabSize);
|
{autoSpacesForTabsKey, m_tabPolicy == MixedTabPolicy},
|
||||||
map->insert(prefix + QLatin1String(indentSizeKey), m_indentSize);
|
{tabSizeKey, m_tabSize},
|
||||||
map->insert(prefix + QLatin1String(paddingModeKey), m_continuationAlignBehavior);
|
{indentSizeKey, m_indentSize},
|
||||||
|
{paddingModeKey, m_continuationAlignBehavior}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
void TabSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
const bool spacesForTabs =
|
const bool spacesForTabs = map.value(spacesForTabsKey, true).toBool();
|
||||||
map.value(prefix + QLatin1String(spacesForTabsKey), true).toBool();
|
const bool autoSpacesForTabs = map.value(autoSpacesForTabsKey, false).toBool();
|
||||||
const bool autoSpacesForTabs =
|
|
||||||
map.value(prefix + QLatin1String(autoSpacesForTabsKey), false).toBool();
|
|
||||||
m_tabPolicy = spacesForTabs ? (autoSpacesForTabs ? MixedTabPolicy : SpacesOnlyTabPolicy) : TabsOnlyTabPolicy;
|
m_tabPolicy = spacesForTabs ? (autoSpacesForTabs ? MixedTabPolicy : SpacesOnlyTabPolicy) : TabsOnlyTabPolicy;
|
||||||
m_tabSize = map.value(prefix + QLatin1String(tabSizeKey), m_tabSize).toInt();
|
m_tabSize = map.value(tabSizeKey, m_tabSize).toInt();
|
||||||
m_indentSize = map.value(prefix + QLatin1String(indentSizeKey), m_indentSize).toInt();
|
m_indentSize = map.value(indentSizeKey, m_indentSize).toInt();
|
||||||
m_continuationAlignBehavior = (ContinuationAlignBehavior)
|
m_continuationAlignBehavior = (ContinuationAlignBehavior)
|
||||||
map.value(prefix + QLatin1String(paddingModeKey), m_continuationAlignBehavior).toInt();
|
map.value(paddingModeKey, m_continuationAlignBehavior).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabSettings::cursorIsAtBeginningOfLine(const QTextCursor &cursor)
|
bool TabSettings::cursorIsAtBeginningOfLine(const QTextCursor &cursor)
|
||||||
|
@@ -59,10 +59,10 @@ public:
|
|||||||
int indentSize, ContinuationAlignBehavior continuationAlignBehavior);
|
int indentSize, ContinuationAlignBehavior continuationAlignBehavior);
|
||||||
|
|
||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, QSettings *s);
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const;
|
QVariantMap toMap() const;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
int lineIndentPosition(const QString &text) const;
|
int lineIndentPosition(const QString &text) const;
|
||||||
int columnAt(const QString &text, int position) const;
|
int columnAt(const QString &text, int position) const;
|
||||||
|
@@ -51,34 +51,30 @@ void TypingSettings::toSettings(const QString &category, QSettings *s) const
|
|||||||
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypingSettings::fromSettings(const QString &category, const QSettings *s)
|
void TypingSettings::fromSettings(const QString &category, QSettings *s)
|
||||||
{
|
{
|
||||||
*this = TypingSettings(); // Assign defaults
|
*this = TypingSettings(); // Assign defaults
|
||||||
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypingSettings::toMap(const QString &prefix, QVariantMap *map) const
|
QVariantMap TypingSettings::toMap() const
|
||||||
{
|
{
|
||||||
map->insert(prefix + QLatin1String(autoIndentKey), m_autoIndent);
|
return {
|
||||||
map->insert(prefix + QLatin1String(tabKeyBehaviorKey), m_tabKeyBehavior);
|
{autoIndentKey, m_autoIndent},
|
||||||
map->insert(prefix + QLatin1String(smartBackspaceBehaviorKey), m_smartBackspaceBehavior);
|
{tabKeyBehaviorKey, m_tabKeyBehavior},
|
||||||
|
{smartBackspaceBehaviorKey, m_smartBackspaceBehavior},
|
||||||
map->insert(prefix + QLatin1String(preferSingleLineCommentsKey), m_preferSingleLineComments);
|
{preferSingleLineCommentsKey, m_preferSingleLineComments}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypingSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
void TypingSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_autoIndent =
|
m_autoIndent = map.value(autoIndentKey, m_autoIndent).toBool();
|
||||||
map.value(prefix + QLatin1String(autoIndentKey), m_autoIndent).toBool();
|
m_tabKeyBehavior = (TabKeyBehavior) map.value(tabKeyBehaviorKey, m_tabKeyBehavior).toInt();
|
||||||
m_tabKeyBehavior = (TabKeyBehavior)
|
m_smartBackspaceBehavior = (SmartBackspaceBehavior)map.value(
|
||||||
map.value(prefix + QLatin1String(tabKeyBehaviorKey), m_tabKeyBehavior).toInt();
|
smartBackspaceBehaviorKey, m_smartBackspaceBehavior).toInt();
|
||||||
m_smartBackspaceBehavior = (SmartBackspaceBehavior)
|
|
||||||
map.value(prefix + QLatin1String(smartBackspaceBehaviorKey),
|
|
||||||
m_smartBackspaceBehavior).toInt();
|
|
||||||
|
|
||||||
m_preferSingleLineComments =
|
m_preferSingleLineComments =
|
||||||
map.value(prefix + QLatin1String(preferSingleLineCommentsKey), m_preferSingleLineComments).toBool();
|
map.value(preferSingleLineCommentsKey, m_preferSingleLineComments).toBool();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TypingSettings::equals(const TypingSettings &ts) const
|
bool TypingSettings::equals(const TypingSettings &ts) const
|
||||||
|
@@ -59,10 +59,10 @@ public:
|
|||||||
bool tabShouldIndent(const QTextDocument *document, const QTextCursor &cursor, int *suggestedPosition) const;
|
bool tabShouldIndent(const QTextDocument *document, const QTextCursor &cursor, int *suggestedPosition) const;
|
||||||
|
|
||||||
void toSettings(const QString &category, QSettings *s) const;
|
void toSettings(const QString &category, QSettings *s) const;
|
||||||
void fromSettings(const QString &category, const QSettings *s);
|
void fromSettings(const QString &category, QSettings *s);
|
||||||
|
|
||||||
void toMap(const QString &prefix, QVariantMap *map) const;
|
QVariantMap toMap() const;
|
||||||
void fromMap(const QString &prefix, const QVariantMap &map);
|
void fromMap(const QVariantMap &map);
|
||||||
|
|
||||||
bool equals(const TypingSettings &ts) const;
|
bool equals(const TypingSettings &ts) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user