本文整理汇总了C++中FolderNode::parentFolderNode方法的典型用法代码示例。如果您正苦于以下问题:C++ FolderNode::parentFolderNode方法的具体用法?C++ FolderNode::parentFolderNode怎么用?C++ FolderNode::parentFolderNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FolderNode
的用法示例。
在下文中一共展示了FolderNode::parentFolderNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findOrDefault
Project *ProjectTree::projectForNode(Node *node)
{
if (!node)
return 0;
FolderNode *rootProjectNode = node->asFolderNode();
if (!rootProjectNode)
rootProjectNode = node->parentFolderNode();
while (rootProjectNode && rootProjectNode->parentFolderNode() != SessionManager::sessionNode())
rootProjectNode = rootProjectNode->parentFolderNode();
Q_ASSERT(rootProjectNode);
return Utils::findOrDefault(SessionManager::projects(), Utils::equal(&Project::rootProjectNode, rootProjectNode));
}
示例2: parent
QModelIndex FlatModel::parent(const QModelIndex &idx) const
{
QModelIndex parentIndex;
if (Node *node = nodeForIndex(idx)) {
FolderNode *parentNode = visibleFolderNode(node->parentFolderNode());
if (parentNode) {
FolderNode *grandParentNode = visibleFolderNode(parentNode->parentFolderNode());
if (grandParentNode) {
QHash<FolderNode*, QList<Node*> >::const_iterator it = m_childNodes.constFind(grandParentNode);
if (it == m_childNodes.constEnd()) {
fetchMore(grandParentNode);
it = m_childNodes.constFind(grandParentNode);
}
Q_ASSERT(it != m_childNodes.constEnd());
const int row = it.value().indexOf(parentNode);
Q_ASSERT(row >= 0);
parentIndex = createIndex(row, 0, parentNode);
} else {
// top level node, parent is session
parentIndex = index(0, 0, QModelIndex());
}
}
}
// qDebug() << "parent of " << idx.data(Project::FilePathRole) << " is " << parentIndex.data(Project::FilePathRole);
return parentIndex;
}