本文整理汇总了C++中ProjectTreeItem::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectTreeItem::getParent方法的具体用法?C++ ProjectTreeItem::getParent怎么用?C++ ProjectTreeItem::getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectTreeItem
的用法示例。
在下文中一共展示了ProjectTreeItem::getParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shaderRemoved
/**
* @brief ProjectManagerTreeModel::shaderRemoved Call this method when shader was removed.
* @param name Name of the removed shader.
*/
void ProjectManagerTreeModel::shaderRemoved(QString name, MetaShader::SHADERTYPE type)
{
ProjectTreeItem* item;
MetaProject* proj = dynamic_cast<MetaProject*>(sender());
if(proj == NULL)
return;
//convert path to -> projectName '/' path
QString projName = proj->getName();
name.insert(0,projName + '/');
if(type == MetaShader::FRAGMENT)
//item = root->findLastCreated(name.split(QDir::separator()),ProjectTreeItem::FRAGMENT);
item = root->findLastCreated(name.split('/'),ProjectTreeItem::FRAGMENT);
else
//item = root->findLastCreated(name.split(QDir::separator()),ProjectTreeItem::VERTEX);
item = root->findLastCreated(name.split('/'),ProjectTreeItem::VERTEX);
ProjectTreeItem* candidate = item->getRemoveCandidate();
int row = candidate->getRow();
insertData = name;
insertType = ProjectTreeItem::SHADER;
QModelIndex index = createIndex(candidate->getParent()->getRow(), 0, candidate->getParent());
removeRows(row,1,index);
emit dataChanged(index,index);
}
示例2: parent
/**
* @brief ProjectManagerTreeModel::parent Get parent of item with index.
* @param child Child where we want get parent item.
* @return Parent of given child.
*/
QModelIndex ProjectManagerTreeModel::parent(const QModelIndex &child) const
{
if(!child.isValid())
return QModelIndex();
ProjectTreeItem* cItem = static_cast<ProjectTreeItem*>(child.internalPointer());
ProjectTreeItem* pItem = cItem->getParent();
if(pItem == root)
return QModelIndex();
return createIndex(pItem->getRow(), 0, pItem);
}