X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMLibrary.cpp;h=4e831ba6a2fe3a1b4f2eb8950e61d23502a3a9de;hb=f10df58dfa9c4d8489fe35f57f796bcf37e5f9b4;hp=72310c78c3a7553e598b2867a43f9ee7e1bfad3c;hpb=0cc6a7e002ad79de9453517108d7456fd44ddfdb;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMLibrary.cpp b/lib/creaDevManagerLib/modelCDMLibrary.cpp index 72310c7..4e831ba 100644 --- a/lib/creaDevManagerLib/modelCDMLibrary.cpp +++ b/lib/creaDevManagerLib/modelCDMLibrary.cpp @@ -120,6 +120,12 @@ modelCDMLibrary::modelCDMLibrary(modelCDMIProjectTreeNode* parent, const std::st 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") @@ -127,6 +133,17 @@ modelCDMLibrary::modelCDMLibrary(modelCDMIProjectTreeNode* parent, const std::st this->CMakeLists = new modelCDMCMakeListsFile(this, this->path + 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, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(file); + } //if is an unknown file, create file else { @@ -295,6 +312,12 @@ const bool modelCDMLibrary::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") @@ -329,8 +352,22 @@ const bool modelCDMLibrary::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)); + } + else + { + modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(file); + } } }