Exemplo n.º 1
0
	void EditorListDelegate::SaveToYaml(UIList *forList, YamlNode *)
	{
		HierarchyTreeNode *node = HierarchyTreeController::Instance()->GetTree().GetNode(aggregatorID);
		HierarchyTreeAggregatorNode *aggregatorNode = dynamic_cast<HierarchyTreeAggregatorNode*>(node);
		if (aggregatorNode)
		{
			forList->SetAggregatorPath(aggregatorNode->GetPath());
		}
		else
		{
			forList->SetAggregatorPath(String());
		}
	}
Exemplo n.º 2
0
	UIControl* EditorListDelegate::GetCurrentAggregatorControl()
	{
		HierarchyTreeNode *node = HierarchyTreeController::Instance()->GetTree().GetNode(aggregatorID);
		HierarchyTreeAggregatorNode *aggregatorNode = dynamic_cast<HierarchyTreeAggregatorNode*>(node);
		
		// Update cell size to fit new aggregator control size
		if (aggregatorNode)
		{
			return aggregatorNode->GetScreen();
		}
		
		return NULL;
	}
Exemplo n.º 3
0
bool HierarchyTreePlatformNode::Load(YamlNode* platform)
{
	YamlNode* width = platform->Get(WIDTH_NODE);
	YamlNode* height = platform->Get(HEIGHT_NODE);
	if (!width || !height)
		return false;
	
	bool result = true;
	SetSize(width->AsInt(), height->AsInt());
	ActivatePlatform();
	
	YamlNode* screens = platform->Get(SCREENS_NODE);
	if (screens)
	{
		for (int i = 0; i < screens->GetCount(); i++)
		{
			YamlNode* screen = screens->Get(i);
			if (!screen)
				continue;
			String screenName = screen->AsString();
			
			QString screenPath = QString(SCREEN_PATH).arg(GetPlatformFolder()).arg(QString::fromStdString(screenName));
			HierarchyTreeScreenNode* screenNode = new HierarchyTreeScreenNode(this, QString::fromStdString(screenName));
			result &= screenNode->Load(screenPath);
			AddTreeNode(screenNode);
		}
	}
	
	YamlNode* aggregators = platform->Get(AGGREGATORS_NODE);
	if (aggregators)
	{
		for (int i = 0; i < aggregators->GetCount(); i++)
		{
			YamlNode* aggregator = aggregators->Get(i);
			if (!aggregator)
				continue;
			String aggregatorName = aggregator->AsString();
			
			QString aggregatorPath = QString(SCREEN_PATH).arg(GetPlatformFolder()).arg(QString::fromStdString(aggregatorName));
			HierarchyTreeAggregatorNode* aggregatorNode = new HierarchyTreeAggregatorNode(this, QString::fromStdString(aggregatorName), Rect());
			result &= aggregatorNode->Load(aggregator, aggregatorPath);
			AddTreeNode(aggregatorNode);			
		}
	}
	
	return result;
}
void LibraryController::UpdateLibrary()
{
	HierarchyTreePlatformNode* activePlatform = HierarchyTreeController::Instance()->GetActivePlatform();
	HierarchyTreeScreenNode* activeScreen = HierarchyTreeController::Instance()->GetActiveScreen();
	for (CONTROLS::iterator iter = controls.begin(); iter != controls.end(); ++iter)
	{
		HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(iter->first);
		if (!node)
			continue;
		
		bool visible = node->GetPlatform() == activePlatform;
		if (dynamic_cast<HierarchyTreeAggregatorNode*>(activeScreen))
		{
			visible = false;
		}
		widget->SetItemVisible(iter->second, visible);
	}
}
Exemplo n.º 5
0
void HierarchyTreeWidget::OnDeleteControlAction()
{
	QList<QTreeWidgetItem*> items = ui->treeWidget->selectedItems();
	if (!items.size())
		return;

	bool needConfirm = false;
	HierarchyTreeNode::HIERARCHYTREENODESLIST nodes;
	for (QList<QTreeWidgetItem*>::iterator iter = items.begin(); iter != items.end(); ++iter)
	{
		QTreeWidgetItem* item = (*iter);
		QVariant data = item->data(ITEM_ID);
		HierarchyTreeNode::HIERARCHYTREENODEID id = data.toInt();
		HierarchyTreeNode* node = HierarchyTreeController::Instance()->GetTree().GetNode(id);
		
		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));
			}
		}
		
		nodes.push_back(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);
	CommandsController::Instance()->ExecuteCommand(cmd);
	SafeRelease(cmd);
}
void ListPropertyGridWidget::FillComboboxes()
{
    WidgetSignalsBlocker aggregatorsBlocker(ui->aggregatorsComboBox);
	WidgetSignalsBlocker orientationBlocked(ui->orientationComboBox);
	// Reset lists
	ui->aggregatorsComboBox->clear();
	nodeIDList.clear();

	// Add empty aggregator and set its id as "0"
	ui->aggregatorsComboBox->addItem(QString("none"));
	nodeIDList.push_back(0);
	
	// Put into combobox available aggregators names
	const HierarchyTreePlatformNode* platform = HierarchyTreeController::Instance()->GetActivePlatform();
	if (platform)
	{
		const HierarchyTreeNode::HIERARCHYTREENODESLIST& items = platform->GetChildNodes();
		for (HierarchyTreeNode::HIERARCHYTREENODESCONSTITER iter = items.begin();
			 iter != items.end();
			 ++iter)
		{
			HierarchyTreeNode* node = (*iter);
			// Get aggregator node id and put it into internal list
			HierarchyTreeAggregatorNode* aggregatorNode = dynamic_cast<HierarchyTreeAggregatorNode*>(node);
			if (aggregatorNode)
			{
				ui->aggregatorsComboBox->addItem(aggregatorNode->GetName());
				nodeIDList.push_back(aggregatorNode->GetId());
			}
		}
	}
	
	ui->orientationComboBox->clear();
    int itemsCount = ListPropertyGridWidgetHelper::GetOrientationCount();
    for (int i = 0; i < itemsCount; i ++)
    {
        ui->orientationComboBox->addItem(ListPropertyGridWidgetHelper::GetOrientationDesc(i));
    }
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 8
0
bool HierarchyTreePlatformNode::Save(YamlNode* node, bool saveAll)
{
	YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP);
	platform->Set(WIDTH_NODE, GetWidth());
	platform->Set(HEIGHT_NODE, GetHeight());

	MultiMap<String, YamlNode*> &platformsMap = node->AsMap();
	platformsMap.erase(GetName().toStdString());
	platformsMap.insert(std::pair<String, YamlNode*>(GetName().toStdString(), platform));
	ActivatePlatform();
	
	MultiMap<String, YamlNode*> &platformMap = platform->AsMap();
	YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY);
	platformMap.erase(SCREENS_NODE);
	platformMap.insert(std::pair<String, YamlNode*>(SCREENS_NODE, screens));
	
	YamlNode* aggregators = new YamlNode(YamlNode::TYPE_MAP);
	platformMap.erase(AGGREGATORS_NODE);
	platformMap.insert(std::pair<String, YamlNode*>(AGGREGATORS_NODE, aggregators));

    // Add the Localization info - specific for each Platform.
    SaveLocalization(platform);

	QString platformFolder = GetPlatformFolder();

	QDir dir;
	dir.mkpath(platformFolder);
	
	bool result = true;
	
	//save aggregators node before save screens
	for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
		 iter != GetChildNodes().end();
		 ++iter)
	{
		HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter);
		if (!node)
			continue;

		QString path = QString(SCREEN_PATH).arg(platformFolder).arg(node->GetName());
		MultiMap<String, YamlNode*> &aggregatorsMap = aggregators->AsMap();
		
		YamlNode* aggregator = new YamlNode(YamlNode::TYPE_MAP);
		result &= node->Save(aggregator, path, saveAll);
		
		aggregatorsMap.erase(node->GetName().toStdString());
		aggregatorsMap.insert(std::pair<String, YamlNode*>(node->GetName().toStdString(), aggregator));
	}
		
	
	for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
		 iter != GetChildNodes().end();
		 ++iter)
	{
		HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter);
		if (node)
			continue;	//skip aggregators
		
		HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
		if (!screenNode)
			continue;
		
		QString screenPath = QString(SCREEN_PATH).arg(platformFolder).arg(screenNode->GetName());
		result &= screenNode->Save(screenPath, saveAll);
		
		screens->AddValueToArray(screenNode->GetName().toStdString());
	}
	return result;
}
HierarchyTreeControlNode* LibraryController::CreateNewControl(HierarchyTreeNode* parentNode, const QString& strType, const QString& name, const Vector2& position)
{
	String type = strType.toStdString();

	HierarchyTreeControlNode* controlNode = NULL;
	UIControl* control = NULL;
	CONTROLS::iterator iter;
	
	for (iter = controls.begin(); iter != controls.end(); ++iter)
	{
		HierarchyTreeNode* node = iter->first;
		if (strType == node->GetName())
			break;
	}
	
	if (iter == controls.end() ||
		dynamic_cast<HierarchyTreeControlNode*>(iter->first))
	{
		//create standart control
		BaseObject* object = ObjectFactory::Instance()->New(type);
		control = dynamic_cast<UIControl*>(object);
		if (!control)
		{
			SafeRelease(object);
			return NULL;
		}
		 
		controlNode = new HierarchyTreeControlNode(parentNode, control, name);
	}
	else
	{
		//create aggregator
		HierarchyTreeAggregatorNode* aggregator = dynamic_cast<HierarchyTreeAggregatorNode*>(iter->first);
		if (aggregator)
		{
			controlNode = aggregator->CreateChild(parentNode, name);
			control = controlNode->GetUIObject();
		}
	}
	
	parentNode->AddTreeNode(controlNode);
	
	// In case the control has subcontrols - they should be added to the control node too.
	if (control && !control->GetSubcontrols().empty())
	{
		List<UIControl*> subControls = control->GetSubcontrols();
		for (List<UIControl*>::iterator iter = subControls.begin(); iter != subControls.end(); iter ++)
		{
			UIControl* subControl = (*iter);
			if (!subControl)
			{
				continue;
			}

			HierarchyTreeControlNode* subControlNode =
				new HierarchyTreeControlNode(controlNode, subControl,
											 QString::fromStdString(subControl->GetName()));
			controlNode->AddTreeNode(subControlNode);
		}
	}

	// Initialize a control through its metadata.
	BaseMetadata* newControlMetadata = MetadataFactory::Instance()->GetMetadataForUIControl(control);

	METADATAPARAMSVECT params;
	params.push_back(BaseMetadataParams(controlNode->GetId(), control));
	newControlMetadata->SetupParams(params);

	// Ready to do initialization!
	newControlMetadata->InitializeControl(name.toStdString(), position);

	SAFE_DELETE(newControlMetadata);

	SafeRelease(control);
	return controlNode;
}