/** * Finding function : returns all components whom classname equals argument className. */ QList<ModItem*> ModItemsTree::findCompOfClassInDescendants(QString className,ModItem* parent) { if(parent==NULL) parent = _rootElement; ModItem* curComponent; QList<ModItem*> curComponents; int iChild; int curDepth = parent->depth(); // then check children are readen if(!parent->childrenReaden()) { // if not, check in its direction readFromOMCWThread(parent,curDepth+1,QString(),curDepth); } int nbCompChild = parent->compChildCount(); int nbModelChild = parent->modelChildCount(); int nbPackageChild = parent->packageChildCount(); // looking if one child corresponds for(iChild=0;iChild<nbCompChild;iChild++) { curComponent = parent->compChild(iChild); if(curComponent->getFieldValue(ModComponent::CLASSNAME)==className) curComponents.push_back(curComponent); } //look deeper in components children iChild=0; while(iChild<nbCompChild) { curComponents << findCompOfClassInDescendants(className,parent->compChild(iChild)); iChild++; } //look deeper in models children iChild=0; while(iChild<nbModelChild) { curComponents << findCompOfClassInDescendants(className,parent->modelChild(iChild)); iChild++; } //look deeper in packages children iChild=0; while(iChild<nbPackageChild) { curComponents << findCompOfClassInDescendants(className,parent->packageChild(iChild)); iChild++; } return curComponents; }
/** * Finding function : returns all components whom classname equals argument className. */ QList<ModItem*> ModItemsTree::findCompOfClassInDescendants(QString className,ModItem* parent) { if(parent==NULL) parent = _rootElement; ModItem* curComponent; QList<ModItem*> curComponents; int iChild; int nbCompChild = parent->compChildCount(); int nbModelChild = parent->modelChildCount(); int nbPackageChild = parent->packageChildCount(); // looking if one child corresponds for(iChild=0; iChild<nbCompChild; iChild++) { curComponent = parent->compChild(iChild); if(curComponent->getFieldValue(ModComponent::CLASSNAME)==className) curComponents.push_back(curComponent); } //look deeper in components children iChild=0; while(iChild<nbCompChild) { curComponents << findCompOfClassInDescendants(className,parent->compChild(iChild)); iChild++; } //look deeper in models children iChild=0; while(iChild<nbModelChild) { curComponents << findCompOfClassInDescendants(className,parent->modelChild(iChild)); iChild++; } //look deeper in packages children iChild=0; while(iChild<nbPackageChild) { curComponents << findCompOfClassInDescendants(className,parent->packageChild(iChild)); iChild++; } return curComponents; }