void ObjectOverviewModel::buildTextures(IOManager* io, std::string rootDir, QTreeWidgetItem* root, std::string name) {
    QWidget* rootItem;
    if(name.empty()) {
        rootItem  = new TexturesFolder(model_, owner_);

    } else
        rootItem  = new TexturesSubFolder(rootDir, name, model_, owner_);
	auto tRoot = addChild(root,rootItem);

    if(name.empty()) {
        static_cast<TexturesFolder*>(rootItem)->setTreeItems(tRoot);
    } else {
        static_cast<TexturesSubFolder*>(rootItem)->setTreeItems(tRoot);
    }

	auto textures = io->getAllDataInDirectory(rootDir, ".png");
	for (auto &t : textures) {
        auto textureItem = new TexturesResource(t, rootDir, model_, owner_);
        auto treeItem = addChild(tRoot, textureItem);
        textureItem->setTreeItems(tRoot, treeItem);
	}

    auto sub = io->getAllFoldersInDirectory(rootDir);
    for (int i = 0; i < sub.size(); i++) {
        buildTextures(io, rootDir+sub[i]+"/", tRoot, sub[i]);
    }
}
void ObjectOverviewModel::buildAssets(IOManager* io, std::string rootDir) {
	auto rootItem = new AssetsFolder(model_, owner_);
	auto root = addTopLevelData(rootItem);

	auto tsDir = io->findFolder(rootDir, "tilesets");
	if(tsDir.empty()) {
		std::cout << "tilesets not found? this wasn't supposed to happen" << std::endl;
	} else
		buildTilesets(io, tsDir, root);

	auto tDir = io->findFolder(rootDir, "textures");
    if(tDir.empty()) {
		std::cout << "textures not found? this wasn't supposed to happen" << std::endl;
	} else
		buildTextures(io, tDir, root);

    auto sDir = io->findFolder(rootDir, "sound");
    if(sDir.empty()) {
        std::cout << "sound not found? this wasn't supposed to happen" << std::endl;
    } else
        buildSound(io, sDir, root);

    auto mDir = io->findFolder(rootDir, "music");
    if(mDir.empty()) {
        std::cout << "music not found? this wasn't supposed to happen" << std::endl;
    } else
        buildMusic(io, mDir, root);
}
 void buildShapes(ogl::CObject*& pObject, const pugi::xml_node& _shapes)
 {
   size_t i = 0;
   for(pugi::xml_node _shape = _shapes.first_child(); _shape; _shape = _shape.next_sibling())
   {
     ogl::CShape* pShape = pObject->getShape(i);
     
     pugi::xml_node _textures = _shape.child("textures");
     if(_textures)
       buildTextures(pShape, _textures);
       
     ++i;
   }
 }