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>
This commit is contained in:
J-P Nurmi 2013-09-01 17:58:52 +02:00 committed by The Qt Project
parent 770532d058
commit 7e7d1f5a79
2 changed files with 19 additions and 0 deletions

View File

@ -436,6 +436,24 @@ void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *compo
d->handlers.insert(objectType, h);
}
/*!
\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.
*/

View File

@ -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: