本文整理汇总了C++中ProjectTreeItem::getDataString方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectTreeItem::getDataString方法的具体用法?C++ ProjectTreeItem::getDataString怎么用?C++ ProjectTreeItem::getDataString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectTreeItem
的用法示例。
在下文中一共展示了ProjectTreeItem::getDataString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: projectActiveChanged
/**
* @brief ProjectManagerTreeModel::projectActiveChanged Call this method if active project was changed.
* @param newProject New active project.
* @param oldProject Old active project.
*/
void ProjectManagerTreeModel::projectActiveChanged(QString newProject, QString oldProject)
{
// new project is set
int rowNumber = root->getRowCount();
ProjectTreeItem* oldP = NULL;
ProjectTreeItem* newP = NULL;
int oldRow = 0;
int newRow = 0;
for(int i = 0; i < rowNumber; ++i)
{
ProjectTreeItem* item = root->getChild(i);
if(item->getDataString() == newProject)
{
newP = item;
newRow = i;
}
else if(item->getDataString() == oldProject)
{
oldP = item;
oldRow = i;
}
}
if(oldP != NULL)
{
QModelIndex index = createIndex(oldRow, 0, oldP);
dataChanged(index,index);
}
if(newP != NULL)
{
QModelIndex indexNew = createIndex(newRow, 0, newP);
dataChanged(indexNew,indexNew);
}
}
示例2: projectRemoved
/**
* @brief ProjectManagerTreeModel::projectRemoved Call this method if project with given name was removed.
* @param projName Name of the old project.
*/
void ProjectManagerTreeModel::projectRemoved(QString projName)
{
int row = root->getRowCount();
for(int i = 0; i < row; ++i)
{
ProjectTreeItem* item = root->getChild(i);
if(item->getDataString() == projName)
{
insertData = projName;
insertType = ProjectTreeItem::PROJECT;
removeRows(i, 1);
return;
}
}
}
示例3: 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();
}