diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-08-11 21:31:29 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-08-12 10:51:18 +0000 |
commit | b36652f9065b6ef892f121f4b29fe90853747fe9 (patch) | |
tree | 37588e41b96524dbd4c22a5bd705a7c4b839774a /examples/quickcontrols2/texteditor/documenthandler.cpp | |
parent | 14f46dc10166e618bef8ed0f33fea30b862cd951 (diff) |
texteditor: fix, unify and cleanup the setters
- setCursorPosition() was missing cursorPositionChanged()
- setAlignment() does not need to check for doc, it's done in textCursor()
- remove the unnecessary cursor.isNull() checks to gain shorter code
Change-Id: I4448224ab02fc22f43ef10749200aca80eed537c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/quickcontrols2/texteditor/documenthandler.cpp')
-rw-r--r-- | examples/quickcontrols2/texteditor/documenthandler.cpp | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp index 7e631085..9b8113c8 100644 --- a/examples/quickcontrols2/texteditor/documenthandler.cpp +++ b/examples/quickcontrols2/texteditor/documenthandler.cpp @@ -94,6 +94,7 @@ void DocumentHandler::setCursorPosition(int position) m_cursorPosition = position; reset(); + emit cursorPositionChanged(); } int DocumentHandler::selectionStart() const @@ -135,9 +136,6 @@ QString DocumentHandler::fontFamily() const void DocumentHandler::setFontFamily(const QString &family) { - QTextCursor cursor = textCursor(); - if (cursor.isNull()) - return; QTextCharFormat format; format.setFontFamily(family); mergeFormatOnWordOrSelection(format); @@ -155,9 +153,6 @@ QColor DocumentHandler::textColor() const void DocumentHandler::setTextColor(const QColor &color) { - QTextCursor cursor = textCursor(); - if (cursor.isNull()) - return; QTextCharFormat format; format.setForeground(QBrush(color)); mergeFormatOnWordOrSelection(format); @@ -174,9 +169,6 @@ Qt::Alignment DocumentHandler::alignment() const void DocumentHandler::setAlignment(Qt::Alignment alignment) { - if (!m_document) - return; - QTextBlockFormat format; format.setAlignment(alignment); QTextCursor cursor = textCursor(); |