本文整理汇总了C++中ProjectViewItem::setFolder方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectViewItem::setFolder方法的具体用法?C++ ProjectViewItem::setFolder怎么用?C++ ProjectViewItem::setFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectViewItem
的用法示例。
在下文中一共展示了ProjectViewItem::setFolder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: folder
ProjectViewItem* ProjectView::folder(const KileProjectItem *pi, ProjectViewItem *item)
{
ProjectViewItem *parent = parentFor(pi, item);
if(!parent) {
kError() << "no parent for " << pi->url().toLocalFile();
return NULL;
}
// we have already found the parent folder
if(parent->type() == KileType::Folder) {
return parent;
}
// we are looking at the children, if there is an existing folder for this type
ProjectViewItem *folder;
// determine the foldername for this type
QString foldername;
switch(pi->type()) {
case (KileProjectItem::ProjectFile):
foldername = i18n("projectfile");
break;
case (KileProjectItem::Package):
foldername = i18n("packages");
break;
case (KileProjectItem::Image):
foldername = i18n("images");
break;
case (KileProjectItem::Other):
default :
foldername = i18n("other");
break;
}
// if there already a folder for this type on this level?
bool found = false;
QTreeWidgetItemIterator it(parent);
++it; // skip 'parent'
while(*it) {
folder = dynamic_cast<ProjectViewItem*>(*it);
if(folder && folder->text(0) == foldername) {
found = true;
break;
}
++it;
}
// if no folder was found, we must create a new one
if(!found) {
folder = new ProjectViewItem(parent, foldername);
KILE_DEBUG() << "new folder: parent=" << parent->url().url()
<< ", foldername=" << foldername;
folder->setFolder(pi->type());
folder->setType(KileType::Folder);
}
return folder;
}