diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2011-05-05 10:38:43 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2011-05-05 10:38:43 +0200 |
commit | b220fcb1a88cba554335e15588590a1cdbb20db9 (patch) | |
tree | 7a07edb8dfc4a1528925f813dad896986e190267 /src | |
parent | 7351a43560675def9aeab111aa5cd22891b74f72 (diff) |
remove some dependencies to QTextEdit
QSyntaxHighlighter is now free of dependencies to
QtWidgets.
QTextImageHandler still needs some work to get
the url resolving to work again.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.cpp | 21 | ||||
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextimagehandler.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/qtextedit.h | 1 |
4 files changed, 15 insertions, 17 deletions
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 6a3355b90d..5edd6375c9 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() diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h index 9cd5778074..33006cdd9e 100644 --- a/src/gui/text/qsyntaxhighlighter.h +++ b/src/gui/text/qsyntaxhighlighter.h @@ -61,7 +61,6 @@ class QTextCharFormat; class QFont; class QColor; class QTextBlockUserData; -class QTextEdit; class Q_GUI_EXPORT QSyntaxHighlighter : public QObject { @@ -70,7 +69,6 @@ class Q_GUI_EXPORT QSyntaxHighlighter : public QObject public: QSyntaxHighlighter(QObject *parent); QSyntaxHighlighter(QTextDocument *parent); - QSyntaxHighlighter(QTextEdit *parent); virtual ~QSyntaxHighlighter(); void setDocument(QTextDocument *doc); diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp index 7cfaa3c88c..d04b758bc9 100644 --- a/src/gui/text/qtextimagehandler.cpp +++ b/src/gui/text/qtextimagehandler.cpp @@ -48,7 +48,6 @@ #include <qdebug.h> #include <private/qtextengine_p.h> #include <qpalette.h> -#include <qtextbrowser.h> #include <qthread.h> QT_BEGIN_NAMESPACE @@ -73,7 +72,8 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format) 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(); @@ -150,7 +150,9 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format) 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(); diff --git a/src/gui/widgets/qtextedit.h b/src/gui/widgets/qtextedit.h index d2d86d5ed7..459f9bdd5e 100644 --- a/src/gui/widgets/qtextedit.h +++ b/src/gui/widgets/qtextedit.h @@ -90,6 +90,7 @@ class Q_GUI_EXPORT QTextEdit : public QAbstractScrollArea 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, |