summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper K. Pedersen <jesper.pedersen@kdab.com>2013-05-20 16:11:08 +0200
committerJesper K. Pedersen <jesper.pedersen@kdab.com>2013-05-21 15:38:02 +0200
commitebb0cc770f509e53968f3329ce27a723e748665f (patch)
tree23ffd5c8b5e8a9d3c244e14b8f2b6e519995fd74
parent28f72e5b31b7cb32dc7b23164f701dc739cea9a3 (diff)
added goto start/end of document
Change-Id: Id1376e6507074ecca67e4d34357ae6bff0c6b41d Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
-rw-r--r--objects/basetexteditor.cpp18
-rw-r--r--objects/basetexteditor.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/objects/basetexteditor.cpp b/objects/basetexteditor.cpp
index 4e53304..58a427c 100644
--- a/objects/basetexteditor.cpp
+++ b/objects/basetexteditor.cpp
@@ -498,6 +498,24 @@ void BaseTextEditor::deleteRegion(const Position &from, const Position &to)
gotoMark(start);
}
+void BaseTextEditor::gotoDocumentStart()
+{
+ gotoLine(1,0);
+}
+
+void BaseTextEditor::gotoDocumentEnd()
+{
+ gotoLine(lineCount());
+ gotoLineEnd();
+}
+
+int BaseTextEditor::lineCount()
+{
+ if (textEditorWidget())
+ return textEditorWidget()->document()->blockCount();
+ return 0;
+}
+
void BaseTextEditor::indent()
{
if (textEditorWidget())
diff --git a/objects/basetexteditor.h b/objects/basetexteditor.h
index 983e6b0..31b9866 100644
--- a/objects/basetexteditor.h
+++ b/objects/basetexteditor.h
@@ -47,6 +47,7 @@ class Mark;
class BaseTextEditor : public TextEditor
{
Q_OBJECT
+ Q_PROPERTY(int lineCount READ lineCount)
public:
explicit BaseTextEditor(QObject *parent=0);
::TextEditor::BaseTextEditorWidget *textEditorWidget();
@@ -123,6 +124,9 @@ public slots:
bool findRegexp(const QString& regexp, bool backward = false, bool caseSensitively = false, bool wholeWords = false);
void indent();
void deleteRegion( const Position& from, const Position& to);
+ void gotoDocumentStart();
+ void gotoDocumentEnd();
+ int lineCount();
private:
QTextDocument::FindFlags flags(bool backward, bool caseSensitively, bool wholeWords) const;