]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMLib.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / modelCDMLib.cpp
index 3dcf9b8786766ce64d0681718d4dc22f16a65f6b..48df51b85c29581095b42db809baa4ab4449cbe0 100644 (file)
@@ -91,6 +91,12 @@ modelCDMLib::modelCDMLib(modelCDMIProjectTreeNode* parent, const std::string& pa
       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")
@@ -98,6 +104,17 @@ modelCDMLib::modelCDMLib(modelCDMIProjectTreeNode* parent, const std::string& pa
               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
             {
@@ -268,6 +285,13 @@ const bool modelCDMLib::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")
@@ -302,8 +326,22 @@ const bool modelCDMLib::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);
+                    }
                 }
             }