diff options
Diffstat (limited to 'PySide/QtCore')
-rw-r--r-- | PySide/QtCore/glue/qobject_findchild.cpp | 21 | ||||
-rw-r--r-- | PySide/QtCore/typesystem_core.xml | 12 |
2 files changed, 27 insertions, 6 deletions
diff --git a/PySide/QtCore/glue/qobject_findchild.cpp b/PySide/QtCore/glue/qobject_findchild.cpp index 351aa69ab..669beac45 100644 --- a/PySide/QtCore/glue/qobject_findchild.cpp +++ b/PySide/QtCore/glue/qobject_findchild.cpp @@ -17,14 +17,23 @@ static QObject* _findChildHelper(const QObject* parent, const QString& name, PyT return 0; } -static void _findChildrenHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType, PyObject* result) +static inline bool _findChildrenComparator(const QObject*& child, const QRegExp& name) { - foreach(QObject* child, parent->children()) { + return name.indexIn(child->objectName()) != -1; +} + +static inline bool _findChildrenComparator(const QObject*& child, const QString& name) +{ + return name.isNull() || name == child->objectName(); +} + +template<typename T> +static void _findChildrenHelper(const QObject* parent, const T& name, PyTypeObject* desiredType, PyObject* result) +{ + foreach(const QObject* child, parent->children()) { Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child)); - if (PyType_IsSubtype(pyChild->ob_type, desiredType) - && (name.isNull() || name == child->objectName())) { + if (PyType_IsSubtype(pyChild->ob_type, desiredType) && _findChildrenComparator(child, name)) PyList_Append(result, pyChild); - } _findChildrenHelper(child, name, desiredType, result); } -}
\ No newline at end of file +} diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index b261a2ad1..7d2655e3b 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1317,6 +1317,18 @@ <modify-argument index="return"> <parent index="this" action="add"/> </modify-argument> + <modify-argument index="2"> + <replace-default-expression with="QString()" /> + </modify-argument> + </add-function> + <add-function signature="findChildren(PyTypeObject*, const QRegExp&)" return-type="PySequence*" > + <inject-code class="target" position="beginning"> + %PYARG_0 = PyList_New(0); + _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0); + </inject-code> + <modify-argument index="return"> + <parent index="this" action="add"/> + </modify-argument> </add-function> <add-function signature="tr(const char *, const char *, int)" return-type="QString"> |