]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMPackageSrc.cpp
Feature #1711 CreaDevManager application implementation
[crea.git] / lib / creaDevManagerLib / modelCDMPackageSrc.cpp
index 529bfe2c32b40f39313b5063982b943e4d0d6f77..97e4ddec9f3b362ba3ec5058c6159f2ec8f14d66 100644 (file)
@@ -88,11 +88,13 @@ modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const s
       while (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
-          modelCDMFile* file;
+          std::size_t fileTypePos = stdfileName.find_last_of(".");
+          std::string fileType = stdfileName.substr(fileTypePos);
+          modelCDMCodeFile* file;
 
           if(stdfileName.substr(0,2) == "bb")
             {
-              file = new modelCDMFile(this, path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+              file = new modelCDMCodeFile(this, path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(file);
               modelCDMBlackBox* blackBox = new modelCDMBlackBox(this, path, stdfileName.substr(2,stdfileName.size()-4), level + 1);
               blackBox->SetHeaderFile(file);
@@ -100,7 +102,7 @@ modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const s
               cont = dir2.GetFirst(&fileName, crea::std2wx(stdfileName.substr(0,stdfileName.size()-2) + ".cxx"), wxDIR_FILES);
               if (cont)
                 {
-                  file = new modelCDMFile(this, path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1);
+                  file = new modelCDMCodeFile(this, path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1);
                   this->children.push_back(file);
                   blackBox->SetSourceFile(file);
                 }
@@ -327,6 +329,8 @@ const bool modelCDMPackageSrc::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")
@@ -361,8 +365,22 @@ const bool modelCDMPackageSrc::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);
+                    }
                 }
             }