Fix bug 685 - "The second arg. of QObject.findChildren doesn't have a default value and doesn't support regexes."
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
c1f507f87a
commit
e360a53087
3 changed files with 37 additions and 7 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue