aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/basetexteditor.cpp
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-08-27 11:57:32 +0200
committerhjk <hjk121@nokiamail.com>2014-08-27 15:00:36 +0200
commit2a5c602341dd07b146d755f3674fbfc054bce48a (patch)
treec4ef0044a8d52e0fd942ab0e79a31e9c182b8f4d /src/plugins/texteditor/basetexteditor.cpp
parentd2c243464ece44b27e8a03c73b45d9de424adcd8 (diff)
TextEditor: Introduce some convenience text accessors in the editor
And adjust users. Change-Id: I9329257cfa5f3298731deb07c2881bc37d9a051d Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/plugins/texteditor/basetexteditor.cpp')
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index c7bcbe5371..c43d8ea430 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -6590,7 +6590,7 @@ BaseTextEditor::~BaseTextEditor()
delete d;
}
-BaseTextDocument *BaseTextEditor::textDocument()
+BaseTextDocument *BaseTextEditor::textDocument() const
{
ensureDocument();
return editorWidget()->textDocument();
@@ -7081,6 +7081,31 @@ BaseTextEditorWidget *BaseTextEditor::editorWidget() const
return static_cast<BaseTextEditorWidget *>(m_widget.data());
}
+QTextDocument *BaseTextEditor::qdocument() const
+{
+ return textDocument()->document();
+}
+
+void BaseTextEditor::setTextCursor(const QTextCursor &cursor)
+{
+ editorWidget()->setTextCursor(cursor);
+}
+
+QTextCursor BaseTextEditor::textCursor() const
+{
+ return editorWidget()->textCursor();
+}
+
+QChar BaseTextEditor::characterAt(int pos) const
+{
+ return textDocument()->characterAt(pos);
+}
+
+QString BaseTextEditor::textAt(int from, int to) const
+{
+ return textDocument()->textAt(from, to);
+}
+
void BaseTextEditorWidget::configureMimeType(const QString &mimeType)
{
configureMimeType(MimeDatabase::findByType(mimeType));
@@ -7186,7 +7211,7 @@ BaseTextEditorWidget *BaseTextEditor::ensureWidget() const
return editorWidget();
}
-BaseTextDocumentPtr BaseTextEditor::ensureDocument()
+BaseTextDocumentPtr BaseTextEditor::ensureDocument() const
{
BaseTextEditorWidget *widget = ensureWidget();
if (widget->d->m_document.isNull()) {