From 99160bb9f851bf02fe5345b5f52217b6c77a57c4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Aug 2010 10:52:19 +0200 Subject: Deprecated qFindChild and qFindChildren Rev-by: dev mailing list --- src/corelib/kernel/qobject.cpp | 6 ++-- src/corelib/kernel/qobject.h | 65 +++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index dc3a9c3..0b96bda 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1746,7 +1746,7 @@ QObjectList QObject::queryList(const char *inheritsClass, \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 11 - \sa findChildren(), qFindChild() + \sa findChildren() */ /*! @@ -1766,7 +1766,7 @@ QObjectList QObject::queryList(const char *inheritsClass, \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 13 - \sa findChild(), qFindChildren() + \sa findChild() */ /*! @@ -1782,6 +1782,7 @@ QObjectList QObject::queryList(const char *inheritsClass, /*! \fn T qFindChild(const QObject *obj, const QString &name) \relates QObject + \obsolete This function is equivalent to \a{obj}->\l{QObject::findChild()}{findChild}(\a name). @@ -1796,6 +1797,7 @@ QObjectList QObject::queryList(const char *inheritsClass, /*! \fn QList qFindChildren(const QObject *obj, const QString &name) \relates QObject + \obsolete This function is equivalent to \a{obj}->\l{QObject::findChildren()}{findChildren}(\a name). diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index c8aa2b5..21bad16 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -77,11 +77,9 @@ class QObjectUserData; typedef QList QObjectList; -template inline T qFindChild(const QObject *, const QString & = QString()); -template inline QList qFindChildren(const QObject *, const QString & = QString()); -#ifndef QT_NO_REGEXP -template inline QList qFindChildren(const QObject *, const QRegExp &); -#endif +Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, + const QMetaObject &mo, QList *list); +Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); class #if defined(__INTEL_COMPILER) && defined(Q_OS_WIN) @@ -158,16 +156,34 @@ public: template inline T findChild(const QString &aName = QString()) const - { return qFindChild(this, aName); } + { return static_cast(qt_qFindChild_helper(this, aName, reinterpret_cast(0)->staticMetaObject)); } template inline QList findChildren(const QString &aName = QString()) const - { return qFindChildren(this, aName); } + { + QList list; + union { + QList *typedList; + QList *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(this, aName, 0, reinterpret_cast(0)->staticMetaObject, u.voidList); + return list; + } #ifndef QT_NO_REGEXP template inline QList findChildren(const QRegExp &re) const - { return qFindChildren(this, re); } + { + QList list; + union { + QList *typedList; + QList *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(this, QString(), &re, reinterpret_cast(0)->staticMetaObject, u.voidList); + return list; + } #endif #ifdef QT3_SUPPORT @@ -328,42 +344,27 @@ public: }; #endif -Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, - const QMetaObject &mo, QList *list); -Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); - +#ifdef QT_DEPRECATED template -inline T qFindChild(const QObject *o, const QString &name) -{ return static_cast(qt_qFindChild_helper(o, name, reinterpret_cast(0)->staticMetaObject)); } +inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) +{ return o->findChild(name); } template -inline QList qFindChildren(const QObject *o, const QString &name) +inline QList qFindChildren(const QObject *o, const QString &name = QString()) { - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, name, 0, reinterpret_cast(0)->staticMetaObject, u.voidList); - return list; + return o->findChildren(name); } #ifndef QT_NO_REGEXP template -inline QList qFindChildren(const QObject *o, const QRegExp &re) +inline QT_DEPRECATED QList qFindChildren(const QObject *o, const QRegExp &re) { - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, QString(), &re, reinterpret_cast(0)->staticMetaObject, u.voidList); - return list; + return o->findChildren(re); } #endif +#endif //QT_DEPRECATED + template inline T qobject_cast(QObject *object) { -- cgit v0.12