aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtCore/glue/qobject_findchild.cpp
blob: 351aa69ab9a6daebc1bb5c42b4ebf3d26ac65208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
static QObject* _findChildHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType)
{
    foreach(QObject* child, parent->children()) {
        Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
        if (PyType_IsSubtype(pyChild->ob_type, desiredType)
            && (name.isNull() || name == child->objectName())) {
            return child;
        }
    }

    QObject* obj;
    foreach(QObject* child, parent->children()) {
        obj = _findChildHelper(child, name, desiredType);
        if (obj)
            return obj;
    }
    return 0;
}

static void _findChildrenHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType, PyObject* result)
{
    foreach(QObject* child, parent->children()) {
        Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
        if (PyType_IsSubtype(pyChild->ob_type, desiredType)
            && (name.isNull() || name == child->objectName())) {
            PyList_Append(result, pyChild);
        }
        _findChildrenHelper(child, name, desiredType, result);
    }
}