bool ModItemsTree::hasChildren ( const QModelIndex & parent ) const { bool hasChildren; bool triedToFind; if(!_enabled) return false; ModItem *parentElement; if (parent.column() > 0) return false; if (!parent.isValid()) parentElement = rootElement(); else parentElement = static_cast<ModItem*>(parent.internalPointer()); if(parentElement->childrenReaden()) { if(_showComponents) return (parentElement->childCount()>0); else return (parentElement->childCount()-parentElement->compChildCount()>0); } else { triedToFind = true; hasChildren = false; QStringList children = _moomc->getClassNames(parentElement->name()); children.removeAll(QString()); if(!children.isEmpty()) hasChildren = true; else if(parentElement->getClassRestr()==Modelica::MODEL) { if(!_showComponents) { hasChildren = false; triedToFind = false; } else { // look if has component children QStringList compNames; QStringList compClasses; _moomc->getContainedComponents(parentElement->getModClassName(),compNames,compClasses,true); hasChildren = (!compNames.isEmpty()); } } if(triedToFind && !hasChildren) parentElement->setChildrenReaden(true); // avoid re-reading return hasChildren; } }
void ModItemsTree::fetchMore ( const QModelIndex & parent ) { if(!_enabled) return; if (!parent.isValid()) return; ModItem *item = static_cast<ModItem*>(parent.internalPointer()); if(item) { if(!item->childrenReaden()) readFromOMCWThread(item,_modLoader->getDepthMax()); } }
bool ModItemsTree::canFetchMore ( const QModelIndex & parent ) const { ModItem *item = static_cast<ModItem*>(parent.internalPointer()); if(!_enabled) return false; if (!parent.isValid()) return false; if(parent.column()<0 || parent.column()>=ModItem::nbFields) return false; // ModItem *item = static_cast<ModItem*>(parent.internalPointer()); if(item && !item->childrenReaden()) return true; else return false; }