diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-09-01 17:58:52 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-04 18:52:29 +0200 |
commit | 7e7d1f5a796d6dc2878a630252142ea191e57501 (patch) | |
tree | 1f4530541410937483d0faea205e52600d69dd7d /src/gui/text | |
parent | 770532d058b9667025c70abe0208589facd8d548 (diff) |
Introduce QAbstractTextDocumentLayout::unregisterHandler()
Required for QQuickText & friends to implement image resource handling
in a clean way - to get rid of QQuickTextDocumentWithImageResources and
eventually make QQuickTextEdit's document interchangeable.
Change-Id: I12305b68065a5990997ca4a47821fd29e0e17476
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qabstracttextdocumentlayout.cpp | 18 | ||||
-rw-r--r-- | src/gui/text/qabstracttextdocumentlayout.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index e051178a47..b8f5aa70a9 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -437,6 +437,24 @@ void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *compo } /*! + \since 5.2 + + Unregisters the given \a component as a handler for items of the given \a objectType, or + any handler if the \a component is not specified. +*/ +void QAbstractTextDocumentLayout::unregisterHandler(int objectType, QObject *component) +{ + Q_D(QAbstractTextDocumentLayout); + + HandlerHash::iterator it = d->handlers.find(objectType); + if (it != d->handlers.end() && (!component || component == it->component)) { + if (component) + disconnect(component, SIGNAL(destroyed(QObject*)), this, SLOT(_q_handlerDestroyed(QObject*))); + d->handlers.erase(it); + } +} + +/*! Returns a handler for objects of the given \a objectType. */ QTextObjectInterface *QAbstractTextDocumentLayout::handlerForObject(int objectType) const diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h index 95733f5da7..4bae631b9c 100644 --- a/src/gui/text/qabstracttextdocumentlayout.h +++ b/src/gui/text/qabstracttextdocumentlayout.h @@ -98,6 +98,7 @@ public: QTextDocument *document() const; void registerHandler(int objectType, QObject *component); + void unregisterHandler(int objectType, QObject *component = 0); QTextObjectInterface *handlerForObject(int objectType) const; Q_SIGNALS: |