Example #1
0
/**
  * Finding function : within parent, look for children whom fullname equals argument
  */
ModItem* ModItemsTree::findInDescendants(QString fullName,ModItem* parent)
{
    if(parent==NULL)
        parent = _rootElement;

    ModItem* curChild;
    QString curFullName = parent->name(ModItem::FULL);

    int curDepth = parent->depth();
    int lookingDepth = fullName.split(".").size()-1;

    // check if it is this component
    if(curFullName == fullName)
        return parent;

    //first check name compatibility
    if(fullName.indexOf(curFullName)!=0)
        return NULL;

    // then check children are readen
    if(!parent->childrenReaden())
    {
        // if not, check in its direction
        readFromOmc(parent,lookingDepth,fullName,curDepth);
    }

    //get child name to visit
    //QString childShortName = fullName.section(".",curDepth,curDepth);
    QString childShortName = fullName;
    // first remove parent name
    // A ajouter la une condition if not executable else childShortName = curFullName !!!!!!
    if(!fullName.endsWith(".exe"))
    {
        childShortName.remove(QRegExp("^"+curFullName+"\\."));
        // then take first section
        childShortName = childShortName.section(".",0,0);


        // looking in children
        for(int iChild=0;iChild<parent->childCount();iChild++)
        {
            curChild = parent->child(iChild);
            if(curChild->name(ModItem::SHORT)==childShortName)
                return findInDescendants(fullName,curChild);
        }
    }
    else
    {
        for(int iChild=0;iChild<parent->childCount();iChild++)
        {
            curChild = parent->child(iChild);
            if(curChild->name(ModItem::FULL)==childShortName)
                return findInDescendants(fullName,curChild);
        }


    }
    return NULL;
}
Example #2
0
// get all ports of component parent (not only those connected)
QList<ModItem*> ModItemsTree::getPorts(ModItem* parent)
{
    QList<ModItem*> ports;

    int curDepth = parent->depth();
    if(!parent->childrenReaden())
    {
        readFromOmc(parent,curDepth+1,QString(),curDepth);
    }

    int nbCompChild = parent->compChildCount();
    for(int i=0; i<nbCompChild; i++)
    {
        ModComponent* curComp = (ModComponent*)parent->compChild(i);
        if(_moomc->isConnector(curComp->getFieldValue(ModComponent::CLASSNAME).toString()))
            ports.push_back(curComp);
    }
    return ports;
}
Example #3
0
void ModItemsLoader::run()
{
    emit readFromOmc(_parent,_depthMax,_direction,_curDepth);
}