Editors: Refactor indenters out of the editors for better reusability.

Reviewed-by: ckamm
This commit is contained in:
Leandro Melo
2010-11-05 14:27:16 +01:00
parent 1afea78c7d
commit 3a684586fa
19 changed files with 455 additions and 170 deletions

View File

@@ -38,6 +38,7 @@
#include "qmloutlinemodel.h"
#include "qmljsfindreferences.h"
#include "qmljssemantichighlighter.h"
#include "qmljsindenter.h"
#include <qmljs/qmljsbind.h>
#include <qmljs/qmljsdocument.h>
@@ -645,6 +646,7 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
setMarksVisible(true);
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
setIndenter(new Indenter);
m_updateDocumentTimer = new QTimer(this);
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
@@ -1262,15 +1264,6 @@ QString QmlJSTextEditor::wordUnderCursor() const
return word;
}
bool QmlJSTextEditor::isElectricCharacter(QChar ch) const
{
if (ch == QLatin1Char('}')
|| ch == QLatin1Char(']')
|| ch == QLatin1Char(':'))
return true;
return false;
}
bool QmlJSTextEditor::isClosingBrace(const QList<Token> &tokens) const
{
@@ -1283,19 +1276,6 @@ bool QmlJSTextEditor::isClosingBrace(const QList<Token> &tokens) const
return false;
}
void QmlJSTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
{
Q_UNUSED(doc)
Q_UNUSED(typedChar)
const TextEditor::TabSettings &ts = tabSettings();
QmlJSEditor::QtStyleCodeFormatter codeFormatter(ts);
codeFormatter.updateStateUntil(block);
const int depth = codeFormatter.indentFor(block);
ts.indentLine(block, depth);
}
TextEditor::BaseTextEditorEditable *QmlJSTextEditor::createEditableInterface()
{
QmlJSEditorEditable *editable = new QmlJSEditorEditable(this);