#include <qtextobject.h>
#include <qtextcursor.h>
#include <qdebug.h>
-#include <qtextedit.h>
#include <qtimer.h>
QT_BEGIN_NAMESPACE
/*!
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);
+ }
}
/*!
}
/*!
- 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()
class QFont;
class QColor;
class QTextBlockUserData;
-class QTextEdit;
class Q_GUI_EXPORT QSyntaxHighlighter : public QObject
{
public:
QSyntaxHighlighter(QObject *parent);
QSyntaxHighlighter(QTextDocument *parent);
- QSyntaxHighlighter(QTextEdit *parent);
virtual ~QSyntaxHighlighter();
void setDocument(QTextDocument *doc);
#include <qdebug.h>
#include <private/qtextengine_p.h>
#include <qpalette.h>
-#include <qtextbrowser.h>
#include <qthread.h>
QT_BEGIN_NAMESPACE
if (pm.isNull()) {
QString context;
-#ifndef QT_NO_TEXTBROWSER
+#if 0
+ // ### Qt5
QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent());
if (browser)
context = browser->source().toString();
if (image.isNull()) {
QString context;
-#ifndef QT_NO_TEXTBROWSER
+
+#if 0
+ // ### Qt5
QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent());
if (browser)
context = browser->source().toString();
Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+ Q_PROPERTY(QObject *document READ document)
public:
enum LineWrapMode {
NoWrap,