当前位置: 首页>>代码示例>>C++>>正文


C++ ProjectViewItem::setType方法代码示例

本文整理汇总了C++中ProjectViewItem::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectViewItem::setType方法的具体用法?C++ ProjectViewItem::setType怎么用?C++ ProjectViewItem::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectViewItem的用法示例。


在下文中一共展示了ProjectViewItem::setType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:60,代码来源:projectview.cpp

示例2: add

ProjectViewItem* ProjectView::add(KileProjectItem *projitem, ProjectViewItem *projvi /* = NULL */)
{
	KILE_DEBUG() << "\tprojectitem=" << projitem->path()
	             << " projvi=" << projvi;
	const KileProject *project = projitem->project();

	if (!projvi) {
		projvi = projectViewItemFor(project->url());
	}

	KILE_DEBUG() << "\tparent projectviewitem " << projvi->url().fileName();

	ProjectViewItem *item = NULL, *parent = NULL;

	switch (projitem->type()) {
	case (KileProjectItem::Source):
		item = new ProjectViewItem(projvi, projitem);
		item->setType(KileType::ProjectItem);
		item->setIcon(0, KIcon("projectitem"));
	break;
	case (KileProjectItem::Package):
		parent = folder(projitem, projvi);
		item = new ProjectViewItem(parent, projitem);
		item->setType(KileType::ProjectItem);
		item->setIcon(0, KIcon("projectitem"));
	break;
	case (KileProjectItem::ProjectFile):
	default:
		parent = folder(projitem, projvi);
		item = new ProjectViewItem(parent, projitem);
		item->setType(KileType::ProjectExtra);
		item->setIcon(0, KIcon((projitem->type()==KileProjectItem::ProjectFile) ? "kile" : "file"));
	break;
	}
	
	item->setArchiveState(projitem->archive());
	item->setURL(projitem->url());
	makeTheConnection(item, projitem->getInfo());

	projvi->sortChildren(0, Qt::AscendingOrder);
	// seems to be necessary to get a correct refreh (Qt 4.4.3)
	bool expanded = projvi->isExpanded();
	projvi->setExpanded(!expanded);
	projvi->setExpanded(expanded);
	
	return item;
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:47,代码来源:projectview.cpp

示例3: removeItem

void ProjectView::removeItem(const KileProjectItem *projitem, bool open)
{
	QTreeWidgetItemIterator it(this);
	ProjectViewItem *item;
	while(*it) {
		item = dynamic_cast<ProjectViewItem*>(*it);
		if(item && (item->type() == KileType::ProjectItem) && (item->projectItem() == projitem)) {
			KILE_DEBUG() << "removing projectviewitem";
			static_cast<QTreeWidgetItem*>(item->parent())->removeChild(item);
			delete item;
		}
		++it;
	}

	if(open) {
		item = new ProjectViewItem(this, projitem->url().fileName());
		item->setType(KileType::File);
		item->setURL(projitem->url());
		makeTheConnection(item);
	}

}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:22,代码来源:projectview.cpp


注:本文中的ProjectViewItem::setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。