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.º 2
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;
}