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.bb10
parent
7351a43560
commit
b220fcb1a8
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -328,17 +336,6 @@ QSyntaxHighlighter::QSyntaxHighlighter(QTextDocument *parent)
|
|||
setDocument(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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue