X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=lib%2FcreaDevManagerLib%2FmodelCDMFolder.cpp;h=6195892450508190751bd6c2d9f46d64227594d9;hb=refs%2Fheads%2Fvtk7itk4wx3-mingw64;hp=ca83e0550eb114af6075c73e0e98d51631004350;hpb=11150e550ff03ee658e90cda4b475b4c24da0a7f;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMFolder.cpp b/lib/creaDevManagerLib/modelCDMFolder.cpp index ca83e05..6195892 100644 --- a/lib/creaDevManagerLib/modelCDMFolder.cpp +++ b/lib/creaDevManagerLib/modelCDMFolder.cpp @@ -83,6 +83,14 @@ modelCDMFolder::modelCDMFolder(modelCDMIProjectTreeNode* parent, const std::stri while (cont) { std::string stdfileName = crea::wx2std(fileName); + std::cout << "analyzing " << stdfileName << std::endl; + std::size_t fileTypePos = stdfileName.find_last_of("."); + std::string fileType; + if(fileTypePos != std::string::npos) + fileType = stdfileName.substr(fileTypePos); + else + fileType = ""; + std::cout << "fileType: " << fileType <CMakeLists = new modelCDMCMakeListsFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); this->children.push_back(this->CMakeLists); } + //if is a code file, create code file + else if(fileType == ".c" || + fileType == ".cxx" || + fileType == ".h" || + fileType == ".cpp" || + fileType == ".txx" || + fileType == ".cmake" ) + { + modelCDMCodeFile* file = new modelCDMCodeFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(file); + } + //if is a bbs file, create bbs file + else if(fileType == ".bbs") + { + modelCDMBBSFile* file = new modelCDMBBSFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(file); + } + //if is a bbg file, create bbg file + else if(fileType == ".bbg") + { + modelCDMBBGFile* file = new modelCDMBBGFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(file); + } + //if is an unknown file, create file else { this->children.push_back(new modelCDMFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1)); } - //if is an unknown file, create file + cont = dir.GetNext(&fileName); } } @@ -107,7 +139,7 @@ modelCDMFolder::~modelCDMFolder() { this->folders.clear(); this->CMakeLists = NULL; - for (int i = 0; i < this->children.size(); i++) + for (int i = 0; i < (int)(this->children.size()); i++) { if(this->children[i] != NULL) { @@ -186,7 +218,7 @@ const bool modelCDMFolder::Refresh(std::string*& result) std::string stdfileName = crea::wx2std(fileName); //check if they already exist bool found = false; - for (int i = 0; !found && i < this->folders.size(); i++) + for (int i = 0; !found && i < (int)(this->folders.size()); i++) { if (this->folders[i]->GetName() == stdfileName) { @@ -211,6 +243,12 @@ const bool modelCDMFolder::Refresh(std::string*& result) while (cont) { std::string stdfileName = crea::wx2std(fileName); + std::size_t fileTypePos = stdfileName.find_last_of("."); + std::string fileType; + if(fileTypePos != std::string::npos) + fileType = stdfileName.substr(fileTypePos); + else + fileType = ""; //if CMakeLists, create CMakeLists if(stdfileName == "CMakeLists.txt") @@ -233,7 +271,7 @@ const bool modelCDMFolder::Refresh(std::string*& result) else { bool found = false; - for (int i = 0;!found && i < this->children.size(); i++) + for (int i = 0;!found && i < (int)(this->children.size()); i++) { if (this->children[i]->GetName() == stdfileName) { @@ -246,8 +284,33 @@ const bool modelCDMFolder::Refresh(std::string*& result) if(!found) { - modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); - this->children.push_back(file); + //if is a code file, create modelCDMCodeFile + if( + fileType == ".c" || + fileType == ".cxx" || + fileType == ".h" || + fileType == ".cpp" || + fileType == ".txx" || + fileType == ".cmake" ) + { + this->children.push_back(new modelCDMCodeFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1)); + } + //if is a bbs file, create modelCDMBBSFile + else if(fileType == ".bbs") + { + this->children.push_back(new modelCDMBBSFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1)); + } + //if is a bbg file, create modelCDMBBGFile + else if(fileType == ".bbg") + { + this->children.push_back(new modelCDMBBGFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1)); + } + //if is an unknown file, create modelCDMFile + else + { + modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(file); + } } } @@ -255,7 +318,7 @@ const bool modelCDMFolder::Refresh(std::string*& result) } } - for (int i = 0; i < checkedFolders.size(); i++) + for (int i = 0; i < (int)(checkedFolders.size()); i++) { if(!checkedFolders[i]) { @@ -264,7 +327,7 @@ const bool modelCDMFolder::Refresh(std::string*& result) i--; } } - for (int i = 0; i < checked.size(); i++) + for (int i = 0; i < (int)(checked.size()); i++) { if(!checked[i]) {