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