diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-04 08:52:19 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-06 09:06:16 (GMT) |
commit | 99160bb9f851bf02fe5345b5f52217b6c77a57c4 (patch) | |
tree | 16e29fe47c45e940145e24556d79aec500923aeb /src/corelib | |
parent | 5e06fcfa6139988cce2e88d604ba8e05d5e43dd0 (diff) | |
download | Qt-99160bb9f851bf02fe5345b5f52217b6c77a57c4.zip Qt-99160bb9f851bf02fe5345b5f52217b6c77a57c4.tar.gz Qt-99160bb9f851bf02fe5345b5f52217b6c77a57c4.tar.bz2 |
Deprecated qFindChild and qFindChildren
Rev-by: dev mailing list
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 6 | ||||
-rw-r--r-- | 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}<T>(\a name). @@ -1796,6 +1797,7 @@ QObjectList QObject::queryList(const char *inheritsClass, /*! \fn QList<T> qFindChildren(const QObject *obj, const QString &name) \relates QObject + \obsolete This function is equivalent to \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\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<QObject*> QObjectList; -template<typename T> inline T qFindChild(const QObject *, const QString & = QString()); -template<typename T> inline QList<T> qFindChildren(const QObject *, const QString & = QString()); -#ifndef QT_NO_REGEXP -template<typename T> inline QList<T> 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<void *> *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<typename T> inline T findChild(const QString &aName = QString()) const - { return qFindChild<T>(this, aName); } + { return static_cast<T>(qt_qFindChild_helper(this, aName, reinterpret_cast<T>(0)->staticMetaObject)); } template<typename T> inline QList<T> findChildren(const QString &aName = QString()) const - { return qFindChildren<T>(this, aName); } + { + QList<T> list; + union { + QList<T> *typedList; + QList<void *> *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(this, aName, 0, reinterpret_cast<T>(0)->staticMetaObject, u.voidList); + return list; + } #ifndef QT_NO_REGEXP template<typename T> inline QList<T> findChildren(const QRegExp &re) const - { return qFindChildren<T>(this, re); } + { + QList<T> list; + union { + QList<T> *typedList; + QList<void *> *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(this, QString(), &re, reinterpret_cast<T>(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<void *> *list); -Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); - +#ifdef QT_DEPRECATED template<typename T> -inline T qFindChild(const QObject *o, const QString &name) -{ return static_cast<T>(qt_qFindChild_helper(o, name, reinterpret_cast<T>(0)->staticMetaObject)); } +inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) +{ return o->findChild<T>(name); } template<typename T> -inline QList<T> qFindChildren(const QObject *o, const QString &name) +inline QList<T> qFindChildren(const QObject *o, const QString &name = QString()) { - QList<T> list; - union { - QList<T> *typedList; - QList<void *> *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, name, 0, reinterpret_cast<T>(0)->staticMetaObject, u.voidList); - return list; + return o->findChildren<T>(name); } #ifndef QT_NO_REGEXP template<typename T> -inline QList<T> qFindChildren(const QObject *o, const QRegExp &re) +inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QRegExp &re) { - QList<T> list; - union { - QList<T> *typedList; - QList<void *> *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, QString(), &re, reinterpret_cast<T>(0)->staticMetaObject, u.voidList); - return list; + return o->findChildren<T>(re); } #endif +#endif //QT_DEPRECATED + template <class T> inline T qobject_cast(QObject *object) { |