Ejemplo n.º 1
0
void populateMenu(QSet<ActionInterface* > &actionInterfaces,
                  const QByteArray &category,
                  QMenu* menu,
                  const SelectionContext &selectionContext)
{
    QSet<ActionInterface* > matchingFactories = findMembers(actionInterfaces, category);

    actionInterfaces.subtract(matchingFactories);

    QList<ActionInterface* > matchingFactoriesList = matchingFactories.toList();
    Utils::sort(matchingFactoriesList, [](ActionInterface *l, ActionInterface *r) {
        return l->priority() > r->priority();
    });

    foreach (ActionInterface* actionInterface, matchingFactoriesList) {
        if (actionInterface->type() == ActionInterface::ContextMenu) {
            actionInterface->currentContextChanged(selectionContext);
            QMenu *newMenu = actionInterface->action()->menu();
            if (newMenu && !newMenu->title().isEmpty())
                menu->addMenu(newMenu);

            //recurse

            populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext);
       } else if (actionInterface->type() == ActionInterface::ContextMenuAction
                  || actionInterface->type() == ActionInterface::Action) {
           QAction* action = actionInterface->action();
           actionInterface->currentContextChanged(selectionContext);
           action->setIconVisibleInMenu(false);
           menu->addAction(action);
       }
    }
}
Ejemplo n.º 2
0
void Type::cache()
{
    if (baseType)
    {
        baseType->cache();
    }

    if (cached)
    {
        return;
    }

    cached = true;

    MemberTypes types;

    types.constructor = true;
    types.field       = true;
    types.method      = true;
    types.property    = true;

    utArray<MemberInfo *> allMembers;

    findMembers(types, allMembers, true, true);

    maxMemberOrdinal = 0;

    for (UTsize i = 0; i < allMembers.size(); i++)
    {
        MemberInfo *mi = allMembers.at(i);

        if (mi->ordinal > maxMemberOrdinal)
        {
            maxMemberOrdinal = mi->ordinal;
        }
    }

    maxMemberOrdinal++;

    memberInfoOrdinalLookup = (MemberInfo **)lmAlloc(NULL, sizeof(MemberInfo *) * maxMemberOrdinal);
    memset(memberInfoOrdinalLookup, 0, sizeof(MemberInfo *) * maxMemberOrdinal);

    for (int i = (int)(allMembers.size() - 1); i >= 0; i--)
    {
        MemberInfo *mi = allMembers.at(i);

        memberCache.insert(mi->getName(), mi);
        memberInfoOrdinalLookup[mi->getOrdinal()] = mi;
    }
}
Ejemplo n.º 3
0
PropertyInfo *Type::getPropertyInfo(int index)
{
    if (propertyMembersValid == false)
    {
        MemberTypes types;
        types.property = true;
        findMembers(types, propertyMembers, true);
        propertyMembersValid = true;
    }

    if ((index < 0) || (index >= (int)propertyMembers.size()))
    {
        LSError("Bad property info index");
    }

    return (PropertyInfo *)propertyMembers[index];
}
Ejemplo n.º 4
0
FieldInfo *Type::getFieldInfo(int index)
{
    if (fieldMembersValid == false)
    {
        MemberTypes types;
        types.field = true;
        findMembers(types, fieldMembers, true);
        fieldMembersValid = true;
    }

    if ((index < 0) || (index >= (int)fieldMembers.size()))
    {
        LSError("Bad field info index");
    }

    return (FieldInfo *)fieldMembers[index];
}
Ejemplo n.º 5
0
int Type::getFieldInfoCount()
{
    // Cache the result.
    if (fieldInfoCount != -1)
    {
        return fieldInfoCount;
    }

    MemberTypes types;
    types.field = true;
    utArray<MemberInfo *> members;

    findMembers(types, members, true);

    fieldInfoCount = (int)members.size();
    return fieldInfoCount;
}
Ejemplo n.º 6
0
int Type::getPropertyInfoCount()
{
    // Cache the result.
    if (propertyInfoCount != -1)
    {
        return propertyInfoCount;
    }

    MemberTypes types;
    types.property = true;
    utArray<MemberInfo *> members;

    findMembers(types, members, true);

    propertyInfoCount = (int)members.size();

    return propertyInfoCount;
}
Ejemplo n.º 7
0
void Type::assignOrdinals()
{
    if (baseType)
    {
        baseType->assignOrdinals();
    }

    // already assigned?
    if (members.size() && members.at(0)->ordinal)
    {
        return;
    }

    MemberTypes types;

    types.constructor = true;
    types.field       = true;
    types.method      = true;
    types.property    = true;

    utArray<MemberInfo *> allMembers;
    findMembers(types, allMembers, true, true);

    int maxOrdinal = 0;
    for (UTsize i = 0; i < allMembers.size(); i++)
    {
        MemberInfo *mi = allMembers.at(i);

        if (mi->getOrdinal() > maxOrdinal)
        {
            maxOrdinal = mi->getOrdinal();
        }
    }

    // and assign
    int start = maxOrdinal + 1;

    for (UTsize i = 0; i < allMembers.size(); i++)
    {
        MemberInfo *mi = allMembers.at(i);

        if (!mi->ordinal)
        {
            lmAssert(mi->getDeclaringType() == this, "ordinal being assigned to non-declared member");

            UTsize j;
            for (j = 0; j < allMembers.size(); j++)
            {
                MemberInfo *other = allMembers.at(j);

                if (other->getDeclaringType() == this)
                {
                    continue;
                }

                if (strcmp(other->getName(), mi->getName()))
                {
                    continue;
                }

                break;
            }

            if (j == allMembers.size())
            {
                mi->setOrdinal(start++);
            }
            else
            {
                mi->setOrdinal(allMembers.at(j)->getOrdinal());
            }
        }
    }
}