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


C++ HierarchyTreeNode::IsHasChild方法代码示例

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


在下文中一共展示了HierarchyTreeNode::IsHasChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnDeleteControlAction

void HierarchyTreeWidget::OnDeleteControlAction()
{
	QList<QTreeWidgetItem*> items = ui->treeWidget->selectedItems();
	if (!items.size())
		return;

	bool needConfirm = false;
	bool needDeleteFiles = false;

	// DF-1273 - Remove all child nodes. We don't have to remove them here.
	QList<QTreeWidgetItem*> parentItems(items);
	for (QList<QTreeWidgetItem*>::iterator iter = items.begin(); iter != items.end(); ++iter)
	{
		HierarchyTreeNode* node = GetNodeFromTreeItem(*iter);
		
		if (!node)
			continue;
				
		for (QList<QTreeWidgetItem*>::iterator innerIter = items.begin(); innerIter != items.end(); ++innerIter)
		{
			HierarchyTreeNode* innerNode = GetNodeFromTreeItem(*innerIter);
				
			if (node->IsHasChild(innerNode))
			{
				parentItems.removeOne(*innerIter);
			}
		}
	}	

	HierarchyTreeNode::HIERARCHYTREENODESLIST nodes;
	for (QList<QTreeWidgetItem*>::iterator iter = parentItems.begin(); iter != parentItems.end(); ++iter)
	{
		HierarchyTreeNode* node = GetNodeFromTreeItem(*iter);
		
		HierarchyTreeAggregatorNode* aggregatorNode = dynamic_cast<HierarchyTreeAggregatorNode*>(node);
		if (aggregatorNode)
		{
			const HierarchyTreeAggregatorNode::CHILDS& childs = aggregatorNode->GetChilds();
			needConfirm |= (childs.size() > 0);
			for (HierarchyTreeAggregatorNode::CHILDS::const_iterator iter = childs.begin(); iter != childs.end(); ++iter)
			{
				nodes.push_back((*iter));
			}
		}

		if (aggregatorNode ||
			dynamic_cast<HierarchyTreeScreenNode*>(node) ||
			dynamic_cast<HierarchyTreePlatformNode*>(node))
		{
			QMessageBox messageBox;
			messageBox.setText(tr("Delete nodes"));
			messageBox.setInformativeText(tr("Do you want to remove selected nodes only from project, or delete their files from disk?"));
			QAbstractButton* removeFromProjectButton = (QAbstractButton*)messageBox.addButton(tr("Remove from project"),
																							  QMessageBox::YesRole);
			QAbstractButton* deleteFromProjectButton = (QAbstractButton*)messageBox.addButton(tr("Delete from disk"),
																							  QMessageBox::YesRole);
			QAbstractButton* cancelButton = (QAbstractButton*)messageBox.addButton(tr("Cancel"),
																				   QMessageBox::RejectRole);
			messageBox.setDefaultButton((QPushButton*)removeFromProjectButton);
			messageBox.setIcon(QMessageBox::Question);
			messageBox.exec();

			if (messageBox.clickedButton() == removeFromProjectButton)
			{
				Logger::Debug("removeFromProjectButton");
			}
			if (messageBox.clickedButton() == deleteFromProjectButton)
			{
				needDeleteFiles = true;
				Logger::Debug("deleteFromProjectButton");
			}
			if (messageBox.clickedButton() == cancelButton)
			{
				Logger::Debug("cancelButton");
				return;
			}
		}
		
		nodes.push_front(node);
	}
	
	if (needConfirm)
	{
		if (QMessageBox::No == QMessageBox::information(this,
								 "",
								 "Selected aggregator control has child controls. Do you want delete aggregator with all child controls?",
								 QMessageBox::Yes | QMessageBox::No))
			return;
	}
	
	DeleteSelectedNodeCommand* cmd = new DeleteSelectedNodeCommand(nodes, needDeleteFiles);
	CommandsController::Instance()->ExecuteCommand(cmd);
	SafeRelease(cmd);
}
开发者ID:,项目名称:,代码行数:94,代码来源:


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