C++: Add settings dialog for pointer declaration formatting

The dialog is at Tools > Options > C++ > Code Style > Edit... > Pointers
and References.

Currently the settings are referenced when applying the following
QuickFixes:
 - Adapting function signature in declaration/definition
   (FunctionDeclDefLink)
 - Inserting declaration from definition (InsertDeclOperation)
 - Inserting definition from declaration (InsertDefOperation)
 - Extracting a function (ExtractFunctionOperation)
 - Add Local Declaration (AddLocalDeclarationOp::Operation)

In these cases the code style of the current project is used. If there
is no current project open, the current global code style is used.

Task-number: QTCREATORBUG-6169

Change-Id: I3e4e502b3103f7f754ac9b39594ad461d89d9304
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-01-15 14:26:24 +01:00
parent 138066792e
commit 8fe25d0a4a
7 changed files with 309 additions and 31 deletions

View File

@@ -32,6 +32,8 @@
#include "cpptools_global.h"
#include <cplusplus/Overview.h>
#include <QMetaType>
#include <QVariant>
@@ -61,6 +63,12 @@ public:
bool indentBlocksRelativeToSwitchLabels;
bool indentControlFlowRelativeToSwitchLabels;
// Formatting of pointer and reference declarations, see Overview::StarBindFlag.
bool bindStarToIdentifier;
bool bindStarToTypeName;
bool bindStarToLeftSpecifier;
bool bindStarToRightSpecifier;
// false: if (a &&
// b)
// c;
@@ -87,6 +95,21 @@ public:
bool equals(const CppCodeStyleSettings &rhs) const;
bool operator==(const CppCodeStyleSettings &s) const { return equals(s); }
bool operator!=(const CppCodeStyleSettings &s) const { return !equals(s); }
/*! Returns an Overview configured by the current project's code style.
If no current project is available or an error occurs when getting the
current project's code style, the current global code style settings
are applied.
*/
static CPlusPlus::Overview currentProjectCodeStyleOverview();
/*! Returns an Overview configured by the current global code style.
If there occurred an error getting the current global code style, a
default constructed Overview is returned.
*/
static CPlusPlus::Overview currentGlobalCodeStyleOverview();
};
} // namespace CppTools