summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor/indenter.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jkobus@trolltech.com>2011-08-04 11:19:25 +0200
committerJarek Kobus <jaroslaw.kobus@nokia.com>2011-08-05 10:29:41 +0200
commit0c8df0597fd84068d535bc459e0694b1ccf87189 (patch)
tree0773109beeaf7edeb579be53c6426efcdbc74136 /src/plugins/texteditor/indenter.cpp
parent55f0f64a5dbba40442efc34a1868d428a66298ff (diff)
downloadqt-creator-0c8df0597fd84068d535bc459e0694b1ccf87189.tar.gz
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/texteditor/indenter.cpp')
-rw-r--r--src/plugins/texteditor/indenter.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/plugins/texteditor/indenter.cpp b/src/plugins/texteditor/indenter.cpp
index 02e24e390e..cb85c6a4d5 100644
--- a/src/plugins/texteditor/indenter.cpp
+++ b/src/plugins/texteditor/indenter.cpp
@@ -31,9 +31,11 @@
**************************************************************************/
#include "indenter.h"
-#include "basetexteditor.h"
#include "tabsettings.h"
+#include <QtGui/QTextDocument>
+#include <QtGui/QTextCursor>
+
using namespace TextEditor;
Indenter::Indenter()
@@ -50,60 +52,58 @@ bool Indenter::isElectricCharacter(const QChar &) const
void Indenter::indentBlock(QTextDocument *doc,
const QTextBlock &block,
const QChar &typedChar,
- BaseTextEditorWidget *editor)
+ const TextEditor::TabSettings &tabSettings)
{
Q_UNUSED(doc);
Q_UNUSED(block);
Q_UNUSED(typedChar);
- Q_UNUSED(editor);
+ Q_UNUSED(tabSettings);
}
void Indenter::indent(QTextDocument *doc,
const QTextCursor &cursor,
const QChar &typedChar,
- BaseTextEditorWidget *editor)
+ const TextEditor::TabSettings &tabSettings)
{
if (cursor.hasSelection()) {
QTextBlock block = doc->findBlock(cursor.selectionStart());
const QTextBlock end = doc->findBlock(cursor.selectionEnd()).next();
do {
- indentBlock(doc, block, typedChar, editor);
+ indentBlock(doc, block, typedChar, tabSettings);
block = block.next();
} while (block.isValid() && block != end);
} else {
- indentBlock(doc, cursor.block(), typedChar, editor);
+ indentBlock(doc, cursor.block(), typedChar, tabSettings);
}
}
-void Indenter::reindent(QTextDocument *doc, const QTextCursor &cursor, BaseTextEditorWidget *editor)
+void Indenter::reindent(QTextDocument *doc, const QTextCursor &cursor, const TextEditor::TabSettings &tabSettings)
{
if (cursor.hasSelection()) {
QTextBlock block = doc->findBlock(cursor.selectionStart());
const QTextBlock end = doc->findBlock(cursor.selectionEnd()).next();
- const TabSettings &ts = editor->tabSettings();
-
// skip empty blocks
while (block.isValid() && block != end) {
QString bt = block.text();
- if (ts.firstNonSpace(bt) < bt.size())
+ if (tabSettings.firstNonSpace(bt) < bt.size())
break;
- indentBlock(doc, block, QChar::Null, editor);
+ indentBlock(doc, block, QChar::Null, tabSettings);
block = block.next();
}
- int previousIndentation = ts.indentationColumn(block.text());
- indentBlock(doc, block, QChar::Null, editor);
- int currentIndentation = ts.indentationColumn(block.text());
+ int previousIndentation = tabSettings.indentationColumn(block.text());
+ indentBlock(doc, block, QChar::Null, tabSettings);
+ int currentIndentation = tabSettings.indentationColumn(block.text());
int delta = currentIndentation - previousIndentation;
block = block.next();
while (block.isValid() && block != end) {
- ts.reindentLine(block, delta);
+ tabSettings.reindentLine(block, delta);
block = block.next();
}
} else {
- indentBlock(doc, cursor.block(), QChar::Null, editor);
+ indentBlock(doc, cursor.block(), QChar::Null, tabSettings);
}
}