Indenters: Move style setup into the QtStyleCodeFormatter constructors.

This makes sure styles are consistent for the editor and the quick fix
engine.
This commit is contained in:
Christian Kamm
2010-08-12 14:00:15 +02:00
parent 0355e37e53
commit 538f611503
9 changed files with 50 additions and 38 deletions

View File

@@ -33,6 +33,7 @@
#include <Lexer.h>
#include <texteditor/basetextdocumentlayout.h>
#include <texteditor/tabsettings.h>
#include <QtCore/QDebug>
#include <QtGui/QTextDocument>
@@ -914,6 +915,32 @@ QtStyleCodeFormatter::QtStyleCodeFormatter()
{
}
QtStyleCodeFormatter::QtStyleCodeFormatter(const TextEditor::TabSettings &tabSettings)
: m_indentSize(tabSettings.m_indentSize)
, m_indentSubstatementBraces(false)
, m_indentSubstatementStatements(true)
, m_indentDeclarationBraces(false)
, m_indentDeclarationMembers(true)
{
setTabSize(tabSettings.m_tabSize);
if (tabSettings.m_indentBraces && tabSettings.m_doubleIndentBlocks) { // gnu style
setIndentSubstatementBraces(true);
setIndentSubstatementStatements(true);
setIndentDeclarationBraces(false);
setIndentDeclarationMembers(true);
} else if (tabSettings.m_indentBraces) { // whitesmiths style
setIndentSubstatementBraces(true);
setIndentSubstatementStatements(false);
setIndentDeclarationBraces(true);
setIndentDeclarationMembers(false);
} else { // default Qt style
setIndentSubstatementBraces(false);
setIndentSubstatementStatements(true);
setIndentDeclarationBraces(false);
setIndentDeclarationMembers(true);
}
}
void QtStyleCodeFormatter::setIndentSize(int size)
{
m_indentSize = size;

View File

@@ -46,6 +46,10 @@ class QTextDocument;
class QTextBlock;
QT_END_NAMESPACE
namespace TextEditor {
class TabSettings;
}
namespace CppTools {
namespace Internal {
class CppCodeFormatterData;
@@ -241,6 +245,7 @@ class CPPTOOLS_EXPORT QtStyleCodeFormatter : public CodeFormatter
{
public:
QtStyleCodeFormatter();
explicit QtStyleCodeFormatter(const TextEditor::TabSettings &tabSettings);
void setIndentSize(int size);