本文整理汇总了C++中ModItem::name方法的典型用法代码示例。如果您正苦于以下问题:C++ ModItem::name方法的具体用法?C++ ModItem::name怎么用?C++ ModItem::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModItem
的用法示例。
在下文中一共展示了ModItem::name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findInDescendants
/**
* 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;
}
示例2: hasChildren
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;
}
}
示例3: data
QVariant ModItemsTree::data(const QModelIndex &index, int role) const
{
if(_enabled)
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole && role !=Qt::ToolTipRole && role != Qt::DecorationRole)
return QVariant();
if(index.column()<0 || index.column()>=ModItem::nbFields)
return QVariant();
ModItem *item = static_cast<ModItem*>(index.internalPointer());
if(item)
{
if(role==Qt::DecorationRole)
return getModelicaNodeIcon(item);
// fullfiling is now done in ::fetchmore
// if(!item->childrenReaden())
// readFromOmcV2(item,1);
if (role == Qt::ToolTipRole)
{
QString tooltip = item->getStrToolTip();
return tooltip;
}
// if display, only display short name (since hierarchy is visible)
if((role == Qt::DisplayRole) && (index.column()==ModItem::NAME))
return item->name(ModItem::SHORT);
return item->getFieldValue(index.column(),role);
}
else
{
return QVariant();
}
}
else
return QVariant();
}
示例4: mimeData
QMimeData* ModItemsTree::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
QString csv;
// select only first column indexes (since selection is made by row)
QModelIndexList rowIndexes;
QList<ModItem*> items;
for(int i=0;i<indexes.size();i++)
{
if(indexes.at(i).column()==0)
{
rowIndexes.push_back(indexes.at(i));
items.push_back((ModItem*)indexes.at(i).internalPointer());
}
}
// Remove children of contained parents -> avoid twice copying
QList<ModItem*> uniqueItems;
for(int i=0;i<items.size();i++)
{
// if(!items.contains(items.at(i)->parent()) || (items.at(i)->parent()==_rootElement))
uniqueItems.push_back(items.at(i));
}
// create text data
for(int i=0;i<uniqueItems.size();i++)
{
ModItem* item = uniqueItems.at(i);
csv.push_back(item->name(ModItem::FULL)+"\n");
}
if(csv.size()>0)
csv.remove(csv.size()-QString("\n").size(),QString("\n").size());
mimeData->setText(csv);
mimeData->setData("application/ModItemName",csv.toAscii());
return mimeData;
}