summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2016-06-27 09:44:05 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-06-27 09:44:05 +0000
commitab30724b00adb76879f4c5865ae4eb1ba828453f (patch)
treeff11836debb28f13ce9440259edf272c0a6f6178 /src/plugins/cpptools
parentff66f5c62f20e55375852c353bdf21509377a9cf (diff)
parent07fccfe9f1e25a8b3e45788f754b83206a590044 (diff)
downloadqt-creator-ab30724b00adb76879f4c5865ae4eb1ba828453f.tar.gz
Merge "Merge remote-tracking branch 'origin/master' into 4.1" into 4.1
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/cppcodestylesettings.cpp64
-rw-r--r--src/plugins/cpptools/cppcodestylesettings.h5
-rw-r--r--src/plugins/cpptools/cppcodestylesettingspage.cpp4
-rw-r--r--src/plugins/cpptools/cppcodestylesettingspage.ui27
4 files changed, 74 insertions, 26 deletions
diff --git a/src/plugins/cpptools/cppcodestylesettings.cpp b/src/plugins/cpptools/cppcodestylesettings.cpp
index a0d618225c..06d396e59c 100644
--- a/src/plugins/cpptools/cppcodestylesettings.cpp
+++ b/src/plugins/cpptools/cppcodestylesettings.cpp
@@ -59,6 +59,7 @@ static const char bindStarToLeftSpecifierKey[] = "BindStarToLeftSpecifier";
static const char bindStarToRightSpecifierKey[] = "BindStarToRightSpecifier";
static const char extraPaddingForConditionsIfConfusingAlignKey[] = "ExtraPaddingForConditionsIfConfusingAlign";
static const char alignAssignmentsKey[] = "AlignAssignments";
+static const char shortGetterNameKey[] = "ShortGetterName";
using namespace CppTools;
@@ -85,6 +86,7 @@ CppCodeStyleSettings::CppCodeStyleSettings() :
, bindStarToRightSpecifier(false)
, extraPaddingForConditionsIfConfusingAlign(true)
, alignAssignments(false)
+ , preferGetterNameWithoutGetPrefix(true)
{
}
@@ -121,6 +123,7 @@ void CppCodeStyleSettings::toMap(const QString &prefix, QVariantMap *map) const
map->insert(prefix + QLatin1String(bindStarToRightSpecifierKey), bindStarToRightSpecifier);
map->insert(prefix + QLatin1String(extraPaddingForConditionsIfConfusingAlignKey), extraPaddingForConditionsIfConfusingAlign);
map->insert(prefix + QLatin1String(alignAssignmentsKey), alignAssignments);
+ map->insert(prefix + QLatin1String(shortGetterNameKey), preferGetterNameWithoutGetPrefix);
}
void CppCodeStyleSettings::fromMap(const QString &prefix, const QVariantMap &map)
@@ -165,6 +168,8 @@ void CppCodeStyleSettings::fromMap(const QString &prefix, const QVariantMap &map
extraPaddingForConditionsIfConfusingAlign).toBool();
alignAssignments = map.value(prefix + QLatin1String(alignAssignmentsKey),
alignAssignments).toBool();
+ preferGetterNameWithoutGetPrefix = map.value(prefix + QLatin1String(shortGetterNameKey),
+ preferGetterNameWithoutGetPrefix).toBool();
}
bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const
@@ -188,7 +193,37 @@ bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const
&& bindStarToLeftSpecifier == rhs.bindStarToLeftSpecifier
&& bindStarToRightSpecifier == rhs.bindStarToRightSpecifier
&& extraPaddingForConditionsIfConfusingAlign == rhs.extraPaddingForConditionsIfConfusingAlign
- && alignAssignments == rhs.alignAssignments;
+ && alignAssignments == rhs.alignAssignments
+ && preferGetterNameWithoutGetPrefix == rhs.preferGetterNameWithoutGetPrefix
+ ;
+}
+
+CppCodeStyleSettings CppCodeStyleSettings::currentProjectCodeStyle()
+{
+ ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
+ if (!project)
+ return currentGlobalCodeStyle();
+
+ ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
+ QTC_ASSERT(editorConfiguration, return currentGlobalCodeStyle());
+
+ TextEditor::ICodeStylePreferences *codeStylePreferences
+ = editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
+ QTC_ASSERT(codeStylePreferences, return currentGlobalCodeStyle());
+
+ CppCodeStylePreferences *cppCodeStylePreferences
+ = dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences);
+ QTC_ASSERT(cppCodeStylePreferences, return currentGlobalCodeStyle());
+
+ return cppCodeStylePreferences->currentCodeStyleSettings();
+}
+
+CppCodeStyleSettings CppCodeStyleSettings::currentGlobalCodeStyle()
+{
+ CppCodeStylePreferences *cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
+ QTC_ASSERT(cppCodeStylePreferences, return CppCodeStyleSettings());
+
+ return cppCodeStylePreferences->currentCodeStyleSettings();
}
static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview,
@@ -207,37 +242,14 @@ static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview
CPlusPlus::Overview CppCodeStyleSettings::currentProjectCodeStyleOverview()
{
- ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
- if (!project)
- return currentGlobalCodeStyleOverview();
-
- ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
- QTC_ASSERT(editorConfiguration, return currentGlobalCodeStyleOverview());
-
- TextEditor::ICodeStylePreferences *codeStylePreferences
- = editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
- QTC_ASSERT(codeStylePreferences, return currentGlobalCodeStyleOverview());
-
- CppCodeStylePreferences *cppCodeStylePreferences
- = dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences);
- QTC_ASSERT(cppCodeStylePreferences, return currentGlobalCodeStyleOverview());
-
- CppCodeStyleSettings settings = cppCodeStylePreferences->currentCodeStyleSettings();
-
CPlusPlus::Overview overview;
- configureOverviewWithCodeStyleSettings(overview, settings);
+ configureOverviewWithCodeStyleSettings(overview, currentProjectCodeStyle());
return overview;
}
CPlusPlus::Overview CppCodeStyleSettings::currentGlobalCodeStyleOverview()
{
CPlusPlus::Overview overview;
-
- CppCodeStylePreferences *cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
- QTC_ASSERT(cppCodeStylePreferences, return overview);
-
- CppCodeStyleSettings settings = cppCodeStylePreferences->currentCodeStyleSettings();
-
- configureOverviewWithCodeStyleSettings(overview, settings);
+ configureOverviewWithCodeStyleSettings(overview, currentGlobalCodeStyle());
return overview;
}
diff --git a/src/plugins/cpptools/cppcodestylesettings.h b/src/plugins/cpptools/cppcodestylesettings.h
index 60dcc2fbf6..f69d72d0ab 100644
--- a/src/plugins/cpptools/cppcodestylesettings.h
+++ b/src/plugins/cpptools/cppcodestylesettings.h
@@ -80,6 +80,8 @@ public:
// b
bool alignAssignments;
+ bool preferGetterNameWithoutGetPrefix;
+
void toSettings(const QString &category, QSettings *s) const;
void fromSettings(const QString &category, const QSettings *s);
@@ -90,6 +92,9 @@ public:
bool operator==(const CppCodeStyleSettings &s) const { return equals(s); }
bool operator!=(const CppCodeStyleSettings &s) const { return !equals(s); }
+ static CppCodeStyleSettings currentProjectCodeStyle();
+ static CppCodeStyleSettings currentGlobalCodeStyle();
+
/*! Returns an Overview configured by the current project's code style.
If no current project is available or an error occurs when getting the
diff --git a/src/plugins/cpptools/cppcodestylesettingspage.cpp b/src/plugins/cpptools/cppcodestylesettingspage.cpp
index 8af93ff100..46d6ee6985 100644
--- a/src/plugins/cpptools/cppcodestylesettingspage.cpp
+++ b/src/plugins/cpptools/cppcodestylesettingspage.cpp
@@ -321,6 +321,8 @@ CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
connect(m_ui->bindStarToRightSpecifier, &QCheckBox::toggled,
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
+ connect(m_ui->preferGetterNamesWithoutGet, &QCheckBox::toggled,
+ this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
m_ui->categoryTab->setCurrentIndex(0);
@@ -380,6 +382,7 @@ CppCodeStyleSettings CppCodeStylePreferencesWidget::cppCodeStyleSettings() const
set.bindStarToRightSpecifier = m_ui->bindStarToRightSpecifier->isChecked();
set.extraPaddingForConditionsIfConfusingAlign = m_ui->extraPaddingConditions->isChecked();
set.alignAssignments = m_ui->alignAssignments->isChecked();
+ set.preferGetterNameWithoutGetPrefix = m_ui->preferGetterNamesWithoutGet->isChecked();
return set;
}
@@ -413,6 +416,7 @@ void CppCodeStylePreferencesWidget::setCodeStyleSettings(const CppCodeStyleSetti
m_ui->bindStarToRightSpecifier->setChecked(s.bindStarToRightSpecifier);
m_ui->extraPaddingConditions->setChecked(s.extraPaddingForConditionsIfConfusingAlign);
m_ui->alignAssignments->setChecked(s.alignAssignments);
+ m_ui->preferGetterNamesWithoutGet->setChecked(s.preferGetterNameWithoutGetPrefix);
m_blockUpdates = wasBlocked;
if (preview)
updatePreview();
diff --git a/src/plugins/cpptools/cppcodestylesettingspage.ui b/src/plugins/cpptools/cppcodestylesettingspage.ui
index 0206b96549..9934259608 100644
--- a/src/plugins/cpptools/cppcodestylesettingspage.ui
+++ b/src/plugins/cpptools/cppcodestylesettingspage.ui
@@ -484,6 +484,33 @@ if they would align to the next line</string>
</item>
</layout>
</widget>
+ <widget class="QWidget" name="getterSetterTab">
+ <attribute name="title">
+ <string>Getter and Setter</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_7">
+ <item>
+ <widget class="QCheckBox" name="preferGetterNamesWithoutGet">
+ <property name="text">
+ <string>Prefer getter names without &quot;get&quot;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>