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>
This commit is contained in:
Jarek Kobus
2011-08-04 11:19:25 +02:00
committed by Jarek Kobus
parent 55f0f64a5d
commit 0c8df0597f
12 changed files with 53 additions and 67 deletions

View File

@@ -33,7 +33,6 @@
#include "qmljsindenter.h"
#include <qmljstools/qmljsqtstylecodeformatter.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/tabsettings.h>
#include <QtCore/QChar>
@@ -63,13 +62,11 @@ bool Indenter::isElectricCharacter(const QChar &ch) const
void Indenter::indentBlock(QTextDocument *doc,
const QTextBlock &block,
const QChar &typedChar,
TextEditor::BaseTextEditorWidget *editor)
const TextEditor::TabSettings &tabSettings)
{
Q_UNUSED(doc)
Q_UNUSED(editor)
const TextEditor::TabSettings &ts = editor->tabSettings();
QmlJSTools::QtStyleCodeFormatter codeFormatter(ts);
QmlJSTools::QtStyleCodeFormatter codeFormatter(tabSettings);
codeFormatter.updateStateUntil(block);
const int depth = codeFormatter.indentFor(block);
@@ -78,9 +75,9 @@ void Indenter::indentBlock(QTextDocument *doc,
// only reindent the current line when typing electric characters if the
// indent is the same it would be if the line were empty
const int newlineIndent = codeFormatter.indentForNewLineAfter(block.previous());
if (ts.indentationColumn(block.text()) != newlineIndent)
if (tabSettings.indentationColumn(block.text()) != newlineIndent)
return;
}
ts.indentLine(block, depth);
tabSettings.indentLine(block, depth);
}