diff options
author | Jarek Kobus <jkobus@trolltech.com> | 2011-08-04 11:19:25 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@nokia.com> | 2011-08-05 10:29:41 +0200 |
commit | 0c8df0597fd84068d535bc459e0694b1ccf87189 (patch) | |
tree | 0773109beeaf7edeb579be53c6426efcdbc74136 /src/plugins/cpptools/cppqtstyleindenter.cpp | |
parent | 55f0f64a5dbba40442efc34a1868d428a66298ff (diff) |
Refactor: Get rid of BaseTextEditorWidget from Indenter
Provide directly TabSettings instead.
This will be used for indenting a text for which
there is no editor instance.
Change-Id: Ia5f11a481f42464cf4820efdf2c7c4c32166f55e
Reviewed-on: http://codereview.qt.nokia.com/2622
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/plugins/cpptools/cppqtstyleindenter.cpp')
-rw-r--r-- | src/plugins/cpptools/cppqtstyleindenter.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/plugins/cpptools/cppqtstyleindenter.cpp b/src/plugins/cpptools/cppqtstyleindenter.cpp index 3bcbe813c2c..64ac333e967 100644 --- a/src/plugins/cpptools/cppqtstyleindenter.cpp +++ b/src/plugins/cpptools/cppqtstyleindenter.cpp @@ -36,7 +36,6 @@ #include "cpptoolssettings.h" #include "cppcodestylepreferences.h" #include "cpptoolsconstants.h" -#include <texteditor/basetexteditor.h> #include <texteditor/tabsettings.h> #include <texteditor/texteditorsettings.h> @@ -93,12 +92,11 @@ static bool colonIsElectric(const QString &text) void CppQtStyleIndenter::indentBlock(QTextDocument *doc, const QTextBlock &block, const QChar &typedChar, - TextEditor::BaseTextEditorWidget *editor) + const TextEditor::TabSettings &tabSettings) { Q_UNUSED(doc) - const TextEditor::TabSettings &ts = editor->tabSettings(); - CppTools::QtStyleCodeFormatter codeFormatter(ts, codeStyleSettings()); + CppTools::QtStyleCodeFormatter codeFormatter(tabSettings, codeStyleSettings()); codeFormatter.updateStateUntil(block); int indent; @@ -115,39 +113,38 @@ void CppQtStyleIndenter::indentBlock(QTextDocument *doc, int newlineIndent; int newlinePadding; codeFormatter.indentForNewLineAfter(block.previous(), &newlineIndent, &newlinePadding); - if (ts.indentationColumn(block.text()) != newlineIndent + newlinePadding) + if (tabSettings.indentationColumn(block.text()) != newlineIndent + newlinePadding) return; } - ts.indentLine(block, indent + padding, padding); + tabSettings.indentLine(block, indent + padding, padding); } void CppQtStyleIndenter::indent(QTextDocument *doc, const QTextCursor &cursor, const QChar &typedChar, - TextEditor::BaseTextEditorWidget *editor) + const TextEditor::TabSettings &tabSettings) { if (cursor.hasSelection()) { QTextBlock block = doc->findBlock(cursor.selectionStart()); const QTextBlock end = doc->findBlock(cursor.selectionEnd()).next(); - const TextEditor::TabSettings &ts = editor->tabSettings(); - CppTools::QtStyleCodeFormatter codeFormatter(ts, codeStyleSettings()); + CppTools::QtStyleCodeFormatter codeFormatter(tabSettings, codeStyleSettings()); codeFormatter.updateStateUntil(block); - QTextCursor tc = editor->textCursor(); + QTextCursor tc = cursor; tc.beginEditBlock(); do { int indent; int padding; codeFormatter.indentFor(block, &indent, &padding); - ts.indentLine(block, indent + padding, padding); + tabSettings.indentLine(block, indent + padding, padding); codeFormatter.updateLineStateChange(block); block = block.next(); } while (block.isValid() && block != end); tc.endEditBlock(); } else { - indentBlock(doc, cursor.block(), typedChar, editor); + indentBlock(doc, cursor.block(), typedChar, tabSettings); } } |