本文整理汇总了C++中ProjectTreeItem::isActiveProject方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectTreeItem::isActiveProject方法的具体用法?C++ ProjectTreeItem::isActiveProject怎么用?C++ ProjectTreeItem::isActiveProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectTreeItem
的用法示例。
在下文中一共展示了ProjectTreeItem::isActiveProject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
/**
* @brief ProjectManagerTreeModel::data Get data of this item on index with given role.
* @param index Index what item we want.
* @param role What data role we want to get.
* @return QVariant data.
*/
QVariant ProjectManagerTreeModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid())
return QVariant();
ProjectTreeItem* item = static_cast<ProjectTreeItem*>(index.internalPointer());
// Display role
if(role == Qt::DisplayRole) // get name string
return QVariant(item->getDataString());
else if(role == Qt::UserRole) // get type of this item - User roles
return QVariant(item->getType());
else if(role == Qt::UserRole + 1) // get name of item (program name, so shader relative path for shader, name of project etc.
{
ProjectTreeItem::TYPE type = item->getType();
if(type == ProjectTreeItem::SHADER)
{
MetaShader* sh = static_cast<MetaShader*>(item->getData());
return QVariant(sh->getShader());
}
else if(type == ProjectTreeItem::PROJECT)
{
MetaProject* proj = static_cast<MetaProject*>(item->getData());
return QVariant(proj->getName());
}
}
else if(role == Qt::UserRole + 2 && item->getType() == ProjectTreeItem::SHADER) // get project of this shader item
{
MetaProject* proj = static_cast<MetaProject*>(item->findProject());
return QVariant(proj->getName());
}
// font role
else if(role == Qt::FontRole)
{
if(item->isActiveProject())
{
QFont font;
font.setBold(true);
return QVariant(font);
}
else
return QVariant();
}
else if(role == Qt::DecorationRole) // return icons for items
{
QIcon icon;
MetaShader* sh;
switch(item->getType())
{
case ProjectTreeItem::DIRECTORY:
icon.addFile(":/folder_blue.png");
break;
case ProjectTreeItem::SHADER:
sh = static_cast<MetaShader*>(item->getData());
if(sh->getType() == MetaShader::FRAGMENT)
{
icon.addFile(":/document_frag.png");
}
else if(sh->getType() == MetaShader::VERTEX)
{
icon.addFile(":/document_vert.png");
}
else
return QVariant();
break;
default:
return QVariant();
}
return QVariant(icon);
}
return QVariant();
}