]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMProject.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / modelCDMProject.cpp
index 7edde9ad3738891b6aba77479c0084c5c7068be6..7d0b454eda24c40272a78d8ef410d77dfac711aa 100644 (file)
@@ -189,6 +189,8 @@ modelCDMProject::modelCDMProject(
       while (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
+          std::size_t fileTypePos = stdfileName.find_last_of(".");
+          std::string fileType = stdfileName.substr(fileTypePos);
 
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
@@ -196,11 +198,23 @@ modelCDMProject::modelCDMProject(
               this->CMakeLists = new modelCDMCMakeListsFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
+          //if is a code file, create modelCDMCodeFile
+          else if(
+              fileType == ".c" ||
+              fileType == ".cxx" ||
+              fileType == ".h" ||
+              fileType == ".cpp" ||
+              fileType == ".txx" ||
+              fileType == ".cmake" )
+            {
+              this->children.push_back(new modelCDMCodeFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
+            }
+          //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);
         }
     }
@@ -629,6 +643,8 @@ const bool modelCDMProject::Refresh(std::string*& result)
       while (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
+          std::size_t fileTypePos = stdfileName.find_last_of(".");
+          std::string fileType = stdfileName.substr(fileTypePos);
 
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
@@ -646,6 +662,7 @@ const bool modelCDMProject::Refresh(std::string*& result)
                     return false;
                 }
             }
+          //if is a code file, create modelCDMCodeFile
           //if is an unknown file, create file
           else
             {
@@ -663,8 +680,21 @@ const bool modelCDMProject::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(
+                    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);
+                    }
                 }
             }