diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-09-13 08:54:45 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-09-13 08:54:45 +0200 |
commit | b62bd0584a7872b6917917009b707785b3abd077 (patch) | |
tree | 9981f274712c098cabbff0c4667672a3934e5393 /src/gui/text/qsyntaxhighlighter.cpp | |
parent | 5e10745dca1d10025404a9f268f03ae697fb10cc (diff) | |
parent | 97baad65f65783d2b5ff938f6217aec9434f2e5f (diff) |
Merge branch 'refactor'
Conflicts:
mkspecs/qws/linux-lsb-g++/qmake.conf
src/gui/image/qpixmap_mac.cpp
src/gui/painting/qpaintengine_x11.cpp
src/gui/painting/qtessellator.cpp
src/gui/text/qfontengine_qws.cpp
src/gui/text/qfontengine_x11.cpp
src/gui/widgets/qlinecontrol.cpp
src/opengl/qgl.h
src/opengl/qgl_x11egl.cpp
src/plugins/plugins.pro
Change-Id: If52dcd55cd55f2983a756c2f843967702b60a310
Diffstat (limited to 'src/gui/text/qsyntaxhighlighter.cpp')
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 5d6c0052f4..5f1a53b556 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -50,7 +50,6 @@ #include <qtextobject.h> #include <qtextcursor.h> #include <qdebug.h> -#include <qtextedit.h> #include <qtimer.h> QT_BEGIN_NAMESPACE @@ -311,10 +310,19 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) /*! Constructs a QSyntaxHighlighter with the given \a parent. + + If the parent is a QTextEdit, it installs the syntaxhighlighter on the + parents document. The specified QTextEdit also becomes the owner of + the QSyntaxHighlighter. */ QSyntaxHighlighter::QSyntaxHighlighter(QObject *parent) : QObject(*new QSyntaxHighlighterPrivate, parent) { + if (parent->inherits("QTextEdit")) { + QTextDocument *doc = qobject_cast<QTextDocument *>(parent->property("document").value<QObject *>()); + if (doc) + setDocument(doc); + } } /*! @@ -329,17 +337,6 @@ QSyntaxHighlighter::QSyntaxHighlighter(QTextDocument *parent) } /*! - Constructs a QSyntaxHighlighter and installs it on \a parent 's - QTextDocument. The specified QTextEdit also becomes the owner of - the QSyntaxHighlighter. -*/ -QSyntaxHighlighter::QSyntaxHighlighter(QTextEdit *parent) - : QObject(*new QSyntaxHighlighterPrivate, parent) -{ - setDocument(parent->document()); -} - -/*! Destructor. Uninstalls this syntax highlighter from the text document. */ QSyntaxHighlighter::~QSyntaxHighlighter() |