示例#1
0
void ChangeNodeHeirarchy::IncrementUnsavedChanges()
{
	HierarchyTreeNode* sourceNode = 0;
	HierarchyTreeNode* targetNode = HierarchyTreeController::Instance()->GetTree().GetNode(targetNodeID);

	switch (this->type)
	{
		case TYPE_PLATFORM:
			// The Platform nodes could only be moved within root node
			targetNode->IncrementUnsavedChanges();
			break;

		case TYPE_SCREEN:
		case TYPE_AGGREGATOR:
			// If Screen nodes are moved within one platform, it's enough to increment unsaved changes only in this platform...
			targetNode->IncrementUnsavedChanges();

			// ...Otherwise we need more complicated handling
			sourceNode = HierarchyTreeController::Instance()->GetTree().GetNode(items.front());
			if (sourceNode != targetNode)
			{
				sourceNode->IncrementUnsavedChanges();

				// Need to mark all screens which being moved to other platform.
				// Otherwise they won't be saved to files at the new location
				// Before mark, need to store current mark state for correct rollback.
				storedMarks.clear();
				for (HierarchyTreeNode::HIERARCHYTREENODESIDLIST::iterator it = items.begin(); it != items.end(); ++it)
				{
					HierarchyTreeNode* node = HierarchyTreeController::Instance()->GetTree().GetNode(*it);
					storedMarks[*it] = node->IsMarked();

					node->SetMarked(true);
				}
			}

			break;

		case TYPE_CONTROLS:
			targetNode->IncrementUnsavedChanges();

			sourceNode = HierarchyTreeController::Instance()->GetScreenNodeForNode(HierarchyTreeController::Instance()->GetTree().GetNode(items.front()));
			if (sourceNode != targetNode)
			{
				sourceNode->IncrementUnsavedChanges();
			}
			break;

		default:
			break;
	}
}
示例#2
0
void ChangeNodeHeirarchy::DecrementUnsavedChanges()
{
	HierarchyTreeNode* sourceNode = 0;
	HierarchyTreeNode* targetNode = HierarchyTreeController::Instance()->GetTree().GetNode(targetNodeID);

	switch (this->type)
	{
		case TYPE_PLATFORM:
			targetNode->DecrementUnsavedChanges();
			break;

		case TYPE_SCREEN:
		case TYPE_AGGREGATOR:
			targetNode->DecrementUnsavedChanges();

			sourceNode = HierarchyTreeController::Instance()->GetTree().GetNode(items.front());
			if (sourceNode != targetNode)
			{
				sourceNode->DecrementUnsavedChanges();
			}

			// Restore mark state. See comments in IncrementUnsavedChanges()
			for (HierarchyTreeNode::HIERARCHYTREENODESIDLIST::iterator it = items.begin(); it != items.end(); ++it)
			{
				HierarchyTreeNode* node = HierarchyTreeController::Instance()->GetTree().GetNode(*it);

				if (storedMarks.find(*it) != storedMarks.end())
				{
					node->SetMarked(storedMarks[*it]);
				}
			}
			break;

		case TYPE_CONTROLS:
			targetNode->DecrementUnsavedChanges();

			sourceNode = HierarchyTreeController::Instance()->GetScreenNodeForNode(HierarchyTreeController::Instance()->GetTree().GetNode(items.front()));
			if (sourceNode != targetNode)
			{
				sourceNode->DecrementUnsavedChanges();
			}
			break;

		default:
			break;
	}
}