Ejemplo n.º 1
0
static QObject *qChildHelper(const char *objName, const char *inheritsClass,
                             bool recursiveSearch, const QObjectList &children)
{
    if (children.isEmpty())
        return 0;

    bool onlyWidgets = (inheritsClass
                        && qstrcmp(inheritsClass, "QWidget") == 0);
    const QLatin1String oName(objName);

    for (int i = 0; i < children.size(); ++i)
    {
        QObject *obj = children.at(i);

        if (onlyWidgets)
        {
            if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
                return obj;
        }
        else if ((!inheritsClass || obj->inherits(inheritsClass))
                 && (!objName || obj->objectName() == oName))
            return obj;

        if (recursiveSearch && (dynamic_cast<MythUIGroup *>(obj) != NULL)
            && (obj = qChildHelper(objName, inheritsClass,
                                   recursiveSearch,
                                   obj->children())))
            return obj;
    }

    return 0;
}
Ejemplo n.º 2
0
/**
 *  \brief Get a named child of this UIType
 *
 *  \param Name of child
 *  \return Pointer to child if found, or NULL
 */
MythUIType *MythUIType::GetChild(const QString &name) const
{
    QObject *ret = qChildHelper(name.toAscii().constData(), NULL, true, children());
    if (ret)
        return dynamic_cast<MythUIType *>(ret);

    return NULL;
}
Ejemplo n.º 3
0
/**
 *  \brief Get a named child of this UIType
 *
 *  \param name Name of child
 *  \return Pointer to child if found, or nullptr
 */
MythUIType *MythUIType::GetChild(const QString &name) const
{
    QObject *ret = qChildHelper(name.toLatin1().constData(), nullptr, true, children());

    if (ret)
        return dynamic_cast<MythUIType *>(ret);

    return nullptr;
}