コード例 #1
0
void HierarchyTreeWidget::on_treeWidget_itemSelectionChanged()
{
	QTreeWidgetItem* selectedItem = ui->treeWidget->currentItem();
	if (!selectedItem)
	{
		return;
	}

	if (internalSelectionChanged)
	{
		return;
	}

	QVariant data = selectedItem->data(ITEM_ID);
	HierarchyTreeNode::HIERARCHYTREENODEID id = data.toInt();
	HierarchyTreeNode* baseNode = HierarchyTreeController::Instance()->GetTree().GetNode(id);
	HierarchyTreePlatformNode* selectedPlatform = dynamic_cast<HierarchyTreePlatformNode* >(baseNode);
	HierarchyTreeScreenNode* selectedScreen =  dynamic_cast<HierarchyTreeScreenNode* >(baseNode);
	HierarchyTreeControlNode* selectedControl = dynamic_cast<HierarchyTreeControlNode* >(baseNode);
	
	if (!selectedPlatform && !selectedScreen && !selectedControl)
		return;
	
	internalSelectionChanged = true;
	
	//only platform or screen node can be seleted
	if (selectedPlatform || selectedScreen)
	{
		ResetSelection();
		HierarchyTreeController::Instance()->ResetSelectedControl();
		selectedItem->setSelected(true);
	}
	
	if (selectedControl)
	{
		selectedScreen = selectedControl->GetScreenNode();
		selectedPlatform = selectedScreen->GetPlatform();
	}
	else if (selectedScreen)
	{
		selectedPlatform = selectedScreen->GetPlatform();
	}
		
	HierarchyTreeController::Instance()->UpdateSelection(selectedPlatform, selectedScreen);
	HierarchyTreeController::Instance()->UpdateSelection(baseNode);
	
	internalSelectionChanged = false;
	
	if (selectedControl)
	{
		if (ui->treeWidget->selectedItems().size() == 1)
			HierarchyTreeController::Instance()->ResetSelectedControl();
		HierarchyTreeController::Instance()->SelectControl(selectedControl);
	}
}
コード例 #2
0
HierarchyTreeScreenNode* HierarchyTreeController::AddScreen(const QString& name, HierarchyTreeNode::HIERARCHYTREENODEID platform)
{
	HierarchyTreeScreenNode* screenNode = hierarchyTree.AddScreen(name, platform);
	if (screenNode)
	{
		UpdateSelection(screenNode->GetPlatform(), screenNode);
		EmitHierarchyTreeUpdated();
	}
	
	return screenNode;
}
コード例 #3
0
void HierarchyTreeController::DeleteNodesFiles(const HierarchyTreeNode::HIERARCHYTREENODESLIST &nodes)
{
	HierarchyTreeNode::HIERARCHYTREENODESLIST::const_iterator iter;
	for (iter = nodes.begin(); iter != nodes.end(); ++iter)
	{
		HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
		HierarchyTreePlatformNode* platformNode = dynamic_cast<HierarchyTreePlatformNode*>(*iter);

		if (screenNode)
		{
			screenNode->SetMarked(true);
			QString path = screenNode->GetPlatform()->GetScreenPath(screenNode->GetName());
			FileSystem::Instance()->DeleteFile(path.toStdString());
		}

		if (platformNode)
		{
			platformNode->SetMarked(true);
			platformNode->SetChildrenMarked(true);
			FileSystem::Instance()->DeleteDirectory(platformNode->GetPlatformFolder(), true);
		}
	}
}