本文整理汇总了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);
}