本文整理汇总了C++中BaseNode::getPathName方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseNode::getPathName方法的具体用法?C++ BaseNode::getPathName怎么用?C++ BaseNode::getPathName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseNode
的用法示例。
在下文中一共展示了BaseNode::getPathName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateStringPath
std::string BaseLink::CreateStringPath(Base* dest, Base* from)
{
if (!dest || dest == from) return std::string("[]");
BaseObject* o = dest->toBaseObject();
BaseObject* f = from->toBaseObject();
BaseContext* ctx = from->toBaseContext();
if (!ctx && f) ctx = f->getContext();
if (o)
{
std::string objectPath = o->getName();
BaseObject* master = o->getMaster();
while (master)
{
objectPath = master->getName() + std::string("/") + objectPath;
master = master->getMaster();
}
BaseNode* n = o->getContext()->toBaseNode();
if (f && o->getContext() == ctx)
return objectPath;
else if (n)
return n->getPathName() + std::string("/") + objectPath; // TODO: compute relative path
else
return objectPath; // we could not determine destination path, specifying simply its name might be enough to find it back
}
else // dest is a context
{
if (f && ctx == dest)
return std::string("./");
BaseNode* n = dest->toBaseNode();
if (n) return n->getPathName(); // TODO: compute relative path
else return dest->getName(); // we could not determine destination path, specifying simply its name might be enough to find it back
}
}
示例2: getExpandedNodes
/// Traverse the item tree and retrive the item that are expanded. The path of the node
/// that are expanded are stored in the the pathes std::vector::std::string>.
void QSofaListView::getExpandedNodes(QTreeWidgetItem* item, std::vector<std::string>& pathes)
{
if(!item)
return;
/// We have reached a leaf of the hierarchy or it is closed...so we save the path
if( !item->isExpanded() && graphListener_->findObject(item)->toBaseNode() != nullptr )
return;
BaseNode* parentNode = graphListener_->findObject(item)->toBaseNode() ;
if(parentNode == nullptr)
return;
std::string path = parentNode->getPathName();
pathes.push_back(path);
for(int i=0 ; i<item->childCount() ; i++)
{
QTreeWidgetItem* child = item->child(i);
BaseNode* childNode = graphListener_->findObject(child)->toBaseNode() ;
if(childNode==nullptr)
continue;
if( childNode->getParents()[0] == parentNode )
getExpandedNodes(child, pathes) ;
}
return ;
}