void TextureListModel::setScene(DAVA::Scene *scene)
{
	beginResetModel();

	clear();

    activeScene = scene;
    
	DAVA::TexturesMap texturesInNode;
	SceneHelper::EnumerateSceneTextures(scene, texturesInNode, SceneHelper::EXCLUDE_NULL);

	for(DAVA::TexturesMap::iterator t = texturesInNode.begin(); t != texturesInNode.end(); ++t)
	{
		DAVA::TextureDescriptor * descriptor = t->second->texDescriptor;
		if(NULL != descriptor && descriptor->pathname.Exists())
		{
			textureDescriptorsAll.push_back(descriptor);
			texturesAll[descriptor] = SafeRetain(t->second);
		}
	}

	applyFilterAndSort();

	endResetModel();
}
void TextureListModel::setHighlight(const EntityGroup *nodes)
{
	beginResetModel();

	textureDescriptorsHighlight.clear();

	if(NULL != nodes)
	{
        DAVA::TexturesMap texturesInGroup;
		for(int i = 0; i < (int)nodes->Size(); ++i)
		{
			SceneHelper::EnumerateEntityTextures(activeScene, nodes->GetEntity(i), texturesInGroup, SceneHelper::EXCLUDE_NULL);
		}
        
        for(DAVA::TexturesMap::iterator t = texturesInGroup.begin(); t != texturesInGroup.end(); ++t)
        {
            const DAVA::FilePath descPath = t->first;
            for(int i = 0; i < textureDescriptorsAll.size(); ++i)
            {
                if(textureDescriptorsAll[i]->pathname == descPath)
                {
                    textureDescriptorsHighlight.push_back(textureDescriptorsAll[i]);
                }
            }
        }
	}

	if(curFilterBySelectedNode)
	{
		applyFilterAndSort();
	}

	endResetModel();
}
void TextureListModel::setSortMode(TextureListModel::TextureListSortMode sortMode)
{
	beginResetModel();
	curSortMode = sortMode;
	applyFilterAndSort();
	endResetModel();
}
void TextureListModel::setFilterBySelectedNode(bool enabled)
{
	beginResetModel();
	curFilterBySelectedNode = enabled;
	applyFilterAndSort();
	endResetModel();
}
void TextureListModel::setFilter(QString filter)
{
	beginResetModel();
	curFilter = filter;
	applyFilterAndSort();
	endResetModel();
}
void TextureListModel::setHighlight(DAVA::Entity *node)
{
	beginResetModel();

	textureDescriptorsHighlight.clear();

	DAVA::Map<DAVA::String, DAVA::Texture *> texturesInNode;
	SceneDataManager::EnumerateTextures(node, texturesInNode);

	for(DAVA::Map<DAVA::String, DAVA::Texture *>::iterator t = texturesInNode.begin(); t != texturesInNode.end(); ++t)
	{
		const DAVA::String descPath = t->first;
		for(int i = 0; i < textureDescriptorsAll.size(); ++i)
		{
			if(textureDescriptorsAll[i]->pathname == descPath)
			{
				textureDescriptorsHighlight.push_back(textureDescriptorsAll[i]);
			}
		}
	}

	if(curFilterBySelectedNode)
	{
		applyFilterAndSort();
	}

	endResetModel();
}
void TextureListModel::setScene(DAVA::Scene *scene)
{
	beginResetModel();

	clear();

	DAVA::Map<DAVA::String, DAVA::Texture *> texturesInNode;
	SceneDataManager::EnumerateTextures(scene, texturesInNode);

	for(DAVA::Map<DAVA::String, DAVA::Texture *>::iterator t = texturesInNode.begin(); t != texturesInNode.end(); ++t)
	{
		const DAVA::String descPath = t->first;

		// if there is no the same descriptor and this file exists
		if(DAVA::FileSystem::Instance()->IsFile(descPath))
		{
			DAVA::TextureDescriptor * descriptor = DAVA::TextureDescriptor::CreateFromFile(descPath);

			if(NULL != descriptor)
			{
				textureDescriptorsAll.push_back(descriptor);
				texturesAll[descriptor] = t->second;
			}
		}
	}

	applyFilterAndSort();

	endResetModel();
}