forked from qt-creator/qt-creator
Cpp: Use new settings API
Avoid writing defaults to the settings. Task-number: QTCREATORBUG-24430 Change-Id: I8e1d5a5b8ca21ef96a68a4d71a7d97d138bd186b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -447,16 +447,18 @@ void CppIncludeHierarchyWidget::perform()
|
||||
showIncludeHierarchy();
|
||||
}
|
||||
|
||||
const bool kSyncDefault = false;
|
||||
|
||||
void CppIncludeHierarchyWidget::saveSettings(QSettings *settings, int position)
|
||||
{
|
||||
const QString key = QString("IncludeHierarchy.%1.SyncWithEditor").arg(position);
|
||||
settings->setValue(key, m_toggleSync->isChecked());
|
||||
QtcSettings::setValueWithDefault(settings, key, m_toggleSync->isChecked(), kSyncDefault);
|
||||
}
|
||||
|
||||
void CppIncludeHierarchyWidget::restoreSettings(QSettings *settings, int position)
|
||||
{
|
||||
const QString key = QString("IncludeHierarchy.%1.SyncWithEditor").arg(position);
|
||||
m_toggleSync->setChecked(settings->value(key).toBool());
|
||||
m_toggleSync->setChecked(settings->value(key, kSyncDefault).toBool());
|
||||
}
|
||||
|
||||
void CppIncludeHierarchyWidget::onItemActivated(const QModelIndex &index)
|
||||
|
@@ -297,6 +297,13 @@ QStringList sortedAndTrimmedStringListWithoutEmptyElements(const QStringList &li
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
const bool kInsertVirtualKeywordDefault = false;
|
||||
const bool kHideReimplementedFunctionsDefault = false;
|
||||
const bool kInsertOVerrideReplacementDefault = false;
|
||||
const int kOverrideReplacementIndexDefault = 0;
|
||||
const InsertVirtualMethodsDialog::ImplementationMode kImplementationModeDefault
|
||||
= InsertVirtualMethodsDialog::ModeOnlyDeclarations;
|
||||
|
||||
class VirtualMethodsSettings
|
||||
{
|
||||
public:
|
||||
@@ -304,37 +311,50 @@ public:
|
||||
{
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(group());
|
||||
insertVirtualKeyword = s->value(insertVirtualKeywordKey(), false).toBool();
|
||||
hideReimplementedFunctions = s->value(hideReimplementedFunctionsKey(), false).toBool();
|
||||
insertOverrideReplacement = s->value(insertOverrideReplacementKey(), false).toBool();
|
||||
overrideReplacementIndex = s->value(overrideReplacementIndexKey(), 0).toInt();
|
||||
insertVirtualKeyword = s->value(insertVirtualKeywordKey(), kInsertVirtualKeywordDefault)
|
||||
.toBool();
|
||||
hideReimplementedFunctions
|
||||
= s->value(hideReimplementedFunctionsKey(), kHideReimplementedFunctionsDefault).toBool();
|
||||
insertOverrideReplacement
|
||||
= s->value(insertOverrideReplacementKey(), kInsertOVerrideReplacementDefault).toBool();
|
||||
overrideReplacementIndex
|
||||
= s->value(overrideReplacementIndexKey(), kOverrideReplacementIndexDefault).toInt();
|
||||
userAddedOverrideReplacements = s->value(userAddedOverrideReplacementsKey()).toStringList();
|
||||
implementationMode = static_cast<InsertVirtualMethodsDialog::ImplementationMode>(
|
||||
s->value(implementationModeKey(), 1).toInt());
|
||||
s->value(implementationModeKey(), int(kImplementationModeDefault)).toInt());
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void write() const
|
||||
{
|
||||
QSettings *s = Core::ICore::settings();
|
||||
Utils::QtcSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(group());
|
||||
s->setValue(insertVirtualKeywordKey(), insertVirtualKeyword);
|
||||
s->setValue(hideReimplementedFunctionsKey(), hideReimplementedFunctions);
|
||||
s->setValue(insertOverrideReplacementKey(), insertOverrideReplacement);
|
||||
s->setValue(overrideReplacementIndexKey(), overrideReplacementIndex);
|
||||
s->setValue(userAddedOverrideReplacementsKey(), userAddedOverrideReplacements);
|
||||
s->setValue(implementationModeKey(), implementationMode);
|
||||
s->setValueWithDefault(insertVirtualKeywordKey(),
|
||||
insertVirtualKeyword,
|
||||
kInsertVirtualKeywordDefault);
|
||||
s->setValueWithDefault(hideReimplementedFunctionsKey(),
|
||||
hideReimplementedFunctions,
|
||||
kHideReimplementedFunctionsDefault);
|
||||
s->setValueWithDefault(insertOverrideReplacementKey(),
|
||||
insertOverrideReplacement,
|
||||
kInsertOVerrideReplacementDefault);
|
||||
s->setValueWithDefault(overrideReplacementIndexKey(),
|
||||
overrideReplacementIndex,
|
||||
kOverrideReplacementIndexDefault);
|
||||
s->setValueWithDefault(userAddedOverrideReplacementsKey(), userAddedOverrideReplacements);
|
||||
s->setValueWithDefault(implementationModeKey(),
|
||||
int(implementationMode),
|
||||
int(kImplementationModeDefault));
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
QString overrideReplacement; // internal
|
||||
QStringList userAddedOverrideReplacements;
|
||||
InsertVirtualMethodsDialog::ImplementationMode implementationMode =
|
||||
InsertVirtualMethodsDialog::ModeOnlyDeclarations;
|
||||
int overrideReplacementIndex = 0;
|
||||
bool insertVirtualKeyword = false;
|
||||
bool hideReimplementedFunctions = false;
|
||||
bool insertOverrideReplacement = false;
|
||||
InsertVirtualMethodsDialog::ImplementationMode implementationMode = kImplementationModeDefault;
|
||||
int overrideReplacementIndex = kOverrideReplacementIndexDefault;
|
||||
bool insertVirtualKeyword = kInsertVirtualKeywordDefault;
|
||||
bool hideReimplementedFunctions = kHideReimplementedFunctionsDefault;
|
||||
bool insertOverrideReplacement = kInsertOVerrideReplacementDefault;
|
||||
|
||||
private:
|
||||
using _ = QLatin1String;
|
||||
|
@@ -25,8 +25,11 @@
|
||||
|
||||
#include "cppquickfixsettings.h"
|
||||
#include "cppeditorconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cpptools/cppcodestylesettings.h>
|
||||
#include <utils/qtcsettings.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace CppEditor {
|
||||
@@ -54,81 +57,66 @@ void CppQuickFixSettings::loadGlobalSettings()
|
||||
|
||||
void CppQuickFixSettings::loadSettingsFrom(QSettings *s)
|
||||
{
|
||||
s->beginGroup(QLatin1String(Constants::QUICK_FIX_SETTINGS_ID));
|
||||
getterOutsideClassFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_GETTER_OUTSIDE_CLASS_FROM),
|
||||
getterOutsideClassFrom)
|
||||
CppQuickFixSettings def;
|
||||
s->beginGroup(Constants::QUICK_FIX_SETTINGS_ID);
|
||||
getterOutsideClassFrom = s->value(Constants::QUICK_FIX_SETTING_GETTER_OUTSIDE_CLASS_FROM,
|
||||
def.getterOutsideClassFrom)
|
||||
.toInt();
|
||||
getterInCppFileFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_GETTER_IN_CPP_FILE_FROM),
|
||||
getterInCppFileFrom)
|
||||
getterInCppFileFrom = s->value(Constants::QUICK_FIX_SETTING_GETTER_IN_CPP_FILE_FROM,
|
||||
def.getterInCppFileFrom)
|
||||
.toInt();
|
||||
setterOutsideClassFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_SETTER_OUTSIDE_CLASS_FROM),
|
||||
setterOutsideClassFrom)
|
||||
setterOutsideClassFrom = s->value(Constants::QUICK_FIX_SETTING_SETTER_OUTSIDE_CLASS_FROM,
|
||||
def.setterOutsideClassFrom)
|
||||
.toInt();
|
||||
setterInCppFileFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_SETTER_IN_CPP_FILE_FROM),
|
||||
setterInCppFileFrom)
|
||||
setterInCppFileFrom = s->value(Constants::QUICK_FIX_SETTING_SETTER_IN_CPP_FILE_FROM,
|
||||
def.setterInCppFileFrom)
|
||||
.toInt();
|
||||
getterAttributes = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_ATTRIBUTES),
|
||||
getterAttributes)
|
||||
.toString();
|
||||
getterNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_NAME_TEMPLATE),
|
||||
getterNameTemplate)
|
||||
getterAttributes
|
||||
= s->value(Constants::QUICK_FIX_SETTING_GETTER_ATTRIBUTES, def.getterAttributes).toString();
|
||||
getterNameTemplate = s->value(Constants::QUICK_FIX_SETTING_GETTER_NAME_TEMPLATE,
|
||||
def.getterNameTemplate)
|
||||
.toString();
|
||||
setterNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_NAME_TEMPLATE),
|
||||
setterNameTemplate)
|
||||
setterNameTemplate = s->value(Constants::QUICK_FIX_SETTING_SETTER_NAME_TEMPLATE,
|
||||
def.setterNameTemplate)
|
||||
.toString();
|
||||
setterParameterNameTemplate = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_SETTER_PARAMETER_NAME),
|
||||
setterParameterNameTemplate)
|
||||
setterParameterNameTemplate = s->value(Constants::QUICK_FIX_SETTING_SETTER_PARAMETER_NAME,
|
||||
def.setterParameterNameTemplate)
|
||||
.toString();
|
||||
resetNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_RESET_NAME_TEMPLATE),
|
||||
resetNameTemplate)
|
||||
resetNameTemplate = s->value(Constants::QUICK_FIX_SETTING_RESET_NAME_TEMPLATE,
|
||||
def.resetNameTemplate)
|
||||
.toString();
|
||||
signalNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_NAME_TEMPLATE),
|
||||
signalNameTemplate)
|
||||
signalNameTemplate = s->value(Constants::QUICK_FIX_SETTING_SIGNAL_NAME_TEMPLATE,
|
||||
def.signalNameTemplate)
|
||||
.toString();
|
||||
signalWithNewValue = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_WITH_NEW_VALUE),
|
||||
signalWithNewValue)
|
||||
signalWithNewValue = s->value(Constants::QUICK_FIX_SETTING_SIGNAL_WITH_NEW_VALUE,
|
||||
def.signalWithNewValue)
|
||||
.toBool();
|
||||
setterAsSlot = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_AS_SLOT), setterAsSlot)
|
||||
.toBool();
|
||||
setterAsSlot = s->value(Constants::QUICK_FIX_SETTING_SETTER_AS_SLOT, def.setterAsSlot).toBool();
|
||||
cppFileNamespaceHandling = static_cast<MissingNamespaceHandling>(
|
||||
s->value(QLatin1String(Constants::QUICK_FIX_SETTING_CPP_FILE_NAMESPACE_HANDLING),
|
||||
static_cast<int>(cppFileNamespaceHandling))
|
||||
s->value(Constants::QUICK_FIX_SETTING_CPP_FILE_NAMESPACE_HANDLING,
|
||||
static_cast<int>(def.cppFileNamespaceHandling))
|
||||
.toInt());
|
||||
memberVariableNameTemplate
|
||||
= s->value(QLatin1String(Constants::QUICK_FIX_SETTING_MEMBER_VARIABEL_NAME_TEMPLATE),
|
||||
memberVariableNameTemplate)
|
||||
.toString();
|
||||
valueTypes = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_VALUE_TYPES), valueTypes)
|
||||
.toStringList();
|
||||
int size = s->beginReadArray(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATES));
|
||||
memberVariableNameTemplate = s->value(Constants::QUICK_FIX_SETTING_MEMBER_VARIABEL_NAME_TEMPLATE,
|
||||
def.memberVariableNameTemplate)
|
||||
.toString();
|
||||
valueTypes = s->value(Constants::QUICK_FIX_SETTING_VALUE_TYPES, def.valueTypes).toStringList();
|
||||
customTemplates = def.customTemplates;
|
||||
int size = s->beginReadArray(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATES);
|
||||
if (size > 0)
|
||||
customTemplates.clear();
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
s->setArrayIndex(i);
|
||||
CustomTemplate c;
|
||||
c.types = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_TYPES))
|
||||
.toStringList();
|
||||
c.types = s->value(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_TYPES).toStringList();
|
||||
if (c.types.isEmpty())
|
||||
continue;
|
||||
c.equalComparison = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_COMPARISON))
|
||||
c.equalComparison = s->value(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_COMPARISON)
|
||||
.toString();
|
||||
c.returnType = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_TYPE))
|
||||
.toString();
|
||||
c.returnType = s->value(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_TYPE).toString();
|
||||
c.returnExpression
|
||||
= s->value(
|
||||
QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_EXPRESSION))
|
||||
.toString();
|
||||
c.assignment = s->value(
|
||||
QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_ASSIGNMENT))
|
||||
.toString();
|
||||
= s->value(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_EXPRESSION).toString();
|
||||
c.assignment = s->value(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_ASSIGNMENT).toString();
|
||||
if (c.assignment.isEmpty() && c.returnType.isEmpty() && c.equalComparison.isEmpty())
|
||||
continue; // nothing custom here
|
||||
|
||||
@@ -140,45 +128,86 @@ void CppQuickFixSettings::loadSettingsFrom(QSettings *s)
|
||||
|
||||
void CppQuickFixSettings::saveSettingsTo(QSettings *s)
|
||||
{
|
||||
s->beginGroup(QLatin1String(Constants::QUICK_FIX_SETTINGS_ID));
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_OUTSIDE_CLASS_FROM),
|
||||
getterOutsideClassFrom);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_IN_CPP_FILE_FROM),
|
||||
getterInCppFileFrom);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_OUTSIDE_CLASS_FROM),
|
||||
setterOutsideClassFrom);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_IN_CPP_FILE_FROM),
|
||||
setterInCppFileFrom);
|
||||
using Utils::QtcSettings;
|
||||
CppQuickFixSettings def;
|
||||
s->beginGroup(Constants::QUICK_FIX_SETTINGS_ID);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_GETTER_OUTSIDE_CLASS_FROM,
|
||||
getterOutsideClassFrom,
|
||||
def.getterOutsideClassFrom);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_GETTER_IN_CPP_FILE_FROM,
|
||||
getterInCppFileFrom,
|
||||
def.getterInCppFileFrom);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_SETTER_OUTSIDE_CLASS_FROM,
|
||||
setterOutsideClassFrom,
|
||||
def.setterOutsideClassFrom);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_SETTER_IN_CPP_FILE_FROM,
|
||||
setterInCppFileFrom,
|
||||
def.setterInCppFileFrom);
|
||||
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_ATTRIBUTES), getterAttributes);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_NAME_TEMPLATE), getterNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_NAME_TEMPLATE), setterNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_RESET_NAME_TEMPLATE), resetNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_NAME_TEMPLATE), signalNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_WITH_NEW_VALUE), signalWithNewValue);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CPP_FILE_NAMESPACE_HANDLING),
|
||||
static_cast<int>(cppFileNamespaceHandling));
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_MEMBER_VARIABEL_NAME_TEMPLATE),
|
||||
memberVariableNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_PARAMETER_NAME),
|
||||
setterParameterNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_AS_SLOT), setterAsSlot);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_VALUE_TYPES), valueTypes);
|
||||
s->beginWriteArray(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATES));
|
||||
for (int i = 0; i < static_cast<int>(customTemplates.size()); ++i) {
|
||||
const auto &c = customTemplates[i];
|
||||
s->setArrayIndex(i);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_TYPES), c.types);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_COMPARISON),
|
||||
c.equalComparison);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_TYPE),
|
||||
c.returnType);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_EXPRESSION),
|
||||
c.returnExpression);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_ASSIGNMENT),
|
||||
c.assignment);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_GETTER_ATTRIBUTES,
|
||||
getterAttributes,
|
||||
def.getterAttributes);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_GETTER_NAME_TEMPLATE,
|
||||
getterNameTemplate,
|
||||
def.getterNameTemplate);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_SETTER_NAME_TEMPLATE,
|
||||
setterNameTemplate,
|
||||
def.setterNameTemplate);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_RESET_NAME_TEMPLATE,
|
||||
resetNameTemplate,
|
||||
def.resetNameTemplate);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_SIGNAL_NAME_TEMPLATE,
|
||||
signalNameTemplate,
|
||||
def.signalNameTemplate);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_SIGNAL_WITH_NEW_VALUE,
|
||||
signalWithNewValue,
|
||||
def.signalWithNewValue);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_CPP_FILE_NAMESPACE_HANDLING,
|
||||
int(cppFileNamespaceHandling),
|
||||
int(def.cppFileNamespaceHandling));
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_MEMBER_VARIABEL_NAME_TEMPLATE,
|
||||
memberVariableNameTemplate,
|
||||
def.memberVariableNameTemplate);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_SETTER_PARAMETER_NAME,
|
||||
setterParameterNameTemplate,
|
||||
def.setterParameterNameTemplate);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_SETTER_AS_SLOT,
|
||||
setterAsSlot,
|
||||
def.setterAsSlot);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::QUICK_FIX_SETTING_VALUE_TYPES,
|
||||
valueTypes,
|
||||
def.valueTypes);
|
||||
if (customTemplates == def.customTemplates) {
|
||||
s->remove(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATES);
|
||||
} else {
|
||||
s->beginWriteArray(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATES);
|
||||
for (int i = 0; i < static_cast<int>(customTemplates.size()); ++i) {
|
||||
const auto &c = customTemplates[i];
|
||||
s->setArrayIndex(i);
|
||||
s->setValue(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_TYPES, c.types);
|
||||
s->setValue(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_COMPARISON, c.equalComparison);
|
||||
s->setValue(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_TYPE, c.returnType);
|
||||
s->setValue(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_EXPRESSION,
|
||||
c.returnExpression);
|
||||
s->setValue(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_ASSIGNMENT, c.assignment);
|
||||
}
|
||||
s->endArray();
|
||||
}
|
||||
s->endArray();
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
|
@@ -48,6 +48,14 @@ public:
|
||||
}
|
||||
struct CustomTemplate
|
||||
{
|
||||
bool operator==(const CustomTemplate &b) const
|
||||
{
|
||||
return types == b.types
|
||||
&& equalComparison == b.equalComparison
|
||||
&& returnExpression == b.returnExpression
|
||||
&& returnType == b.returnType
|
||||
&& assignment == b.assignment;
|
||||
}
|
||||
QStringList types;
|
||||
QString equalComparison;
|
||||
QString returnExpression;
|
||||
|
@@ -73,40 +73,46 @@ const char *licenseTemplateTemplate = QT_TRANSLATE_NOOP("CppTools::Internal::Cpp
|
||||
|
||||
void CppFileSettings::toSettings(QSettings *s) const
|
||||
{
|
||||
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
|
||||
s->setValue(QLatin1String(headerPrefixesKeyC), headerPrefixes);
|
||||
s->setValue(QLatin1String(sourcePrefixesKeyC), sourcePrefixes);
|
||||
s->setValue(QLatin1String(headerSuffixKeyC), headerSuffix);
|
||||
s->setValue(QLatin1String(sourceSuffixKeyC), sourceSuffix);
|
||||
s->setValue(QLatin1String(headerSearchPathsKeyC), headerSearchPaths);
|
||||
s->setValue(QLatin1String(sourceSearchPathsKeyC), sourceSearchPaths);
|
||||
s->setValue(QLatin1String(Constants::LOWERCASE_CPPFILES_KEY), lowerCaseFiles);
|
||||
s->setValue(QLatin1String(headerPragmaOnceC), headerPragmaOnce);
|
||||
s->setValue(QLatin1String(licenseTemplatePathKeyC), licenseTemplatePath);
|
||||
using Utils::QtcSettings;
|
||||
const CppFileSettings def;
|
||||
s->beginGroup(Constants::CPPTOOLS_SETTINGSGROUP);
|
||||
QtcSettings::setValueWithDefault(s, headerPrefixesKeyC, headerPrefixes, def.headerPrefixes);
|
||||
QtcSettings::setValueWithDefault(s, sourcePrefixesKeyC, sourcePrefixes, def.sourcePrefixes);
|
||||
QtcSettings::setValueWithDefault(s, headerSuffixKeyC, headerSuffix, def.headerSuffix);
|
||||
QtcSettings::setValueWithDefault(s, sourceSuffixKeyC, sourceSuffix, def.sourceSuffix);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
headerSearchPathsKeyC,
|
||||
headerSearchPaths,
|
||||
def.headerSearchPaths);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
sourceSearchPathsKeyC,
|
||||
sourceSearchPaths,
|
||||
def.sourceSearchPaths);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
Constants::LOWERCASE_CPPFILES_KEY,
|
||||
lowerCaseFiles,
|
||||
def.lowerCaseFiles);
|
||||
QtcSettings::setValueWithDefault(s, headerPragmaOnceC, headerPragmaOnce, def.headerPragmaOnce);
|
||||
QtcSettings::setValueWithDefault(s,
|
||||
licenseTemplatePathKeyC,
|
||||
licenseTemplatePath,
|
||||
def.licenseTemplatePath);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void CppFileSettings::fromSettings(QSettings *s)
|
||||
{
|
||||
const QStringList defaultHeaderSearchPaths
|
||||
= QStringList({"include", "Include", QDir::toNativeSeparators("../include"),
|
||||
QDir::toNativeSeparators("../Include")});
|
||||
const QStringList defaultSourceSearchPaths
|
||||
= QStringList({QDir::toNativeSeparators("../src"), QDir::toNativeSeparators("../Src"),
|
||||
".."});
|
||||
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
|
||||
headerPrefixes = s->value(QLatin1String(headerPrefixesKeyC)).toStringList();
|
||||
sourcePrefixes = s->value(QLatin1String(sourcePrefixesKeyC)).toStringList();
|
||||
headerSuffix = s->value(QLatin1String(headerSuffixKeyC), QLatin1String("h")).toString();
|
||||
sourceSuffix = s->value(QLatin1String(sourceSuffixKeyC), QLatin1String("cpp")).toString();
|
||||
headerSearchPaths = s->value(QLatin1String(headerSearchPathsKeyC), defaultHeaderSearchPaths)
|
||||
.toStringList();
|
||||
sourceSearchPaths = s->value(QLatin1String(sourceSearchPathsKeyC), defaultSourceSearchPaths)
|
||||
.toStringList();
|
||||
const bool lowerCaseDefault = Constants::lowerCaseFilesDefault;
|
||||
lowerCaseFiles = s->value(QLatin1String(Constants::LOWERCASE_CPPFILES_KEY), QVariant(lowerCaseDefault)).toBool();
|
||||
headerPragmaOnce = s->value(headerPragmaOnceC, headerPragmaOnce).toBool();
|
||||
licenseTemplatePath = s->value(QLatin1String(licenseTemplatePathKeyC), QString()).toString();
|
||||
const CppFileSettings def;
|
||||
s->beginGroup(Constants::CPPTOOLS_SETTINGSGROUP);
|
||||
headerPrefixes = s->value(headerPrefixesKeyC, def.headerPrefixes).toStringList();
|
||||
sourcePrefixes = s->value(sourcePrefixesKeyC, def.sourcePrefixes).toStringList();
|
||||
headerSuffix = s->value(headerSuffixKeyC, def.headerSuffix).toString();
|
||||
sourceSuffix = s->value(sourceSuffixKeyC, def.sourceSuffix).toString();
|
||||
headerSearchPaths = s->value(headerSearchPathsKeyC, def.headerSearchPaths).toStringList();
|
||||
sourceSearchPaths = s->value(sourceSearchPathsKeyC, def.sourceSearchPaths).toStringList();
|
||||
lowerCaseFiles = s->value(Constants::LOWERCASE_CPPFILES_KEY, def.lowerCaseFiles).toBool();
|
||||
headerPragmaOnce = s->value(headerPragmaOnceC, def.headerPragmaOnce).toBool();
|
||||
licenseTemplatePath = s->value(licenseTemplatePathKeyC, def.licenseTemplatePath).toString();
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpptoolsconstants.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
@@ -37,14 +41,19 @@ namespace Internal {
|
||||
struct CppFileSettings
|
||||
{
|
||||
QStringList headerPrefixes;
|
||||
QString headerSuffix;
|
||||
QStringList headerSearchPaths;
|
||||
QString headerSuffix = "h";
|
||||
QStringList headerSearchPaths = {"include",
|
||||
"Include",
|
||||
QDir::toNativeSeparators("../include"),
|
||||
QDir::toNativeSeparators("../Include")};
|
||||
QStringList sourcePrefixes;
|
||||
QString sourceSuffix;
|
||||
QStringList sourceSearchPaths;
|
||||
QString sourceSuffix = "cpp";
|
||||
QStringList sourceSearchPaths = {QDir::toNativeSeparators("../src"),
|
||||
QDir::toNativeSeparators("../Src"),
|
||||
".."};
|
||||
QString licenseTemplatePath;
|
||||
bool headerPragmaOnce = false;
|
||||
bool lowerCaseFiles = false;
|
||||
bool lowerCaseFiles = Constants::LOWERCASE_CPPFILES_DEFAULT;
|
||||
|
||||
void toSettings(QSettings *) const;
|
||||
void fromSettings(QSettings *);
|
||||
|
@@ -49,7 +49,7 @@ const char AMBIGUOUS_HEADER_MIMETYPE[] = "application/vnd.qtc.ambiguousheader";
|
||||
// QSettings keys for use by the "New Class" wizards.
|
||||
const char CPPTOOLS_SETTINGSGROUP[] = "CppTools";
|
||||
const char LOWERCASE_CPPFILES_KEY[] = "LowerCaseFiles";
|
||||
enum { lowerCaseFilesDefault = 1 };
|
||||
const bool LOWERCASE_CPPFILES_DEFAULT = true;
|
||||
const char CPPTOOLS_SORT_EDITOR_DOCUMENT_OUTLINE[] = "SortedMethodOverview";
|
||||
const char CPPTOOLS_SHOW_INFO_BAR_FOR_HEADER_ERRORS[] = "ShowInfoBarForHeaderErrors";
|
||||
const char CPPTOOLS_SHOW_INFO_BAR_FOR_FOR_NO_PROJECT[] = "ShowInfoBarForNoProject";
|
||||
|
@@ -43,6 +43,9 @@
|
||||
#include <QSettings>
|
||||
|
||||
static const char idKey[] = "CppGlobal";
|
||||
const bool kSortEditorDocumentOutlineDefault = true;
|
||||
const bool kShowHeaderErrorInfoBarDefault = true;
|
||||
const bool kShowNoProjectInfoBarDefault = true;
|
||||
|
||||
using namespace Core;
|
||||
using namespace CppTools;
|
||||
@@ -254,12 +257,16 @@ static QString sortEditorDocumentOutlineKey()
|
||||
|
||||
bool CppToolsSettings::sortedEditorDocumentOutline() const
|
||||
{
|
||||
return ICore::settings()->value(sortEditorDocumentOutlineKey(), true).toBool();
|
||||
return ICore::settings()
|
||||
->value(sortEditorDocumentOutlineKey(), kSortEditorDocumentOutlineDefault)
|
||||
.toBool();
|
||||
}
|
||||
|
||||
void CppToolsSettings::setSortedEditorDocumentOutline(bool sorted)
|
||||
{
|
||||
ICore::settings()->setValue(sortEditorDocumentOutlineKey(), sorted);
|
||||
ICore::settings()->setValueWithDefault(sortEditorDocumentOutlineKey(),
|
||||
sorted,
|
||||
kSortEditorDocumentOutlineDefault);
|
||||
emit editorDocumentOutlineSortingChanged(sorted);
|
||||
}
|
||||
|
||||
@@ -272,12 +279,16 @@ static QString showHeaderErrorInfoBarKey()
|
||||
|
||||
bool CppToolsSettings::showHeaderErrorInfoBar() const
|
||||
{
|
||||
return ICore::settings()->value(showHeaderErrorInfoBarKey(), true).toBool();
|
||||
return ICore::settings()
|
||||
->value(showHeaderErrorInfoBarKey(), kShowHeaderErrorInfoBarDefault)
|
||||
.toBool();
|
||||
}
|
||||
|
||||
void CppToolsSettings::setShowHeaderErrorInfoBar(bool show)
|
||||
{
|
||||
ICore::settings()->setValue(showHeaderErrorInfoBarKey(), show);
|
||||
ICore::settings()->setValueWithDefault(showHeaderErrorInfoBarKey(),
|
||||
show,
|
||||
kShowHeaderErrorInfoBarDefault);
|
||||
emit showHeaderErrorInfoBarChanged(show);
|
||||
}
|
||||
|
||||
@@ -290,11 +301,13 @@ static QString showNoProjectInfoBarKey()
|
||||
|
||||
bool CppToolsSettings::showNoProjectInfoBar() const
|
||||
{
|
||||
return ICore::settings()->value(showNoProjectInfoBarKey(), true).toBool();
|
||||
return ICore::settings()->value(showNoProjectInfoBarKey(), kShowNoProjectInfoBarDefault).toBool();
|
||||
}
|
||||
|
||||
void CppToolsSettings::setShowNoProjectInfoBar(bool show)
|
||||
{
|
||||
ICore::settings()->setValue(showNoProjectInfoBarKey(), show);
|
||||
ICore::settings()->setValueWithDefault(showNoProjectInfoBarKey(),
|
||||
show,
|
||||
kShowNoProjectInfoBarDefault);
|
||||
emit showNoProjectInfoBarChanged(show);
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ bool FormClassWizardPage::lowercaseHeaderFiles()
|
||||
QString lowerCaseSettingsKey = CppTools::Constants::CPPTOOLS_SETTINGSGROUP;
|
||||
lowerCaseSettingsKey += '/';
|
||||
lowerCaseSettingsKey += CppTools::Constants::LOWERCASE_CPPFILES_KEY;
|
||||
const bool lowerCaseDefault = CppTools::Constants::lowerCaseFilesDefault;
|
||||
const bool lowerCaseDefault = CppTools::Constants::LOWERCASE_CPPFILES_DEFAULT;
|
||||
return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool();
|
||||
}
|
||||
|
||||
|
@@ -112,7 +112,7 @@ bool QtWizard::lowerCaseFiles()
|
||||
QString lowerCaseSettingsKey = QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP);
|
||||
lowerCaseSettingsKey += QLatin1Char('/');
|
||||
lowerCaseSettingsKey += QLatin1String(CppTools::Constants::LOWERCASE_CPPFILES_KEY);
|
||||
const bool lowerCaseDefault = CppTools::Constants::lowerCaseFilesDefault;
|
||||
const bool lowerCaseDefault = CppTools::Constants::LOWERCASE_CPPFILES_DEFAULT;
|
||||
return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user