]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMLib.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMLib.cpp
index 8ebd9ae100555df4211fdc2149729e3b7081062e..16211eed4ade6c269d87e23b93971cda679d397a 100644 (file)
@@ -70,9 +70,17 @@ modelCDMLib::modelCDMLib(const std::string& path, const std::string& name, const
         {
           std::string stdfileName = crea::wx2std(fileName);
 
-          modelCDMLibrary* library = new modelCDMLibrary(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
-          this->libraries.push_back(library);
-          this->children.push_back(library);
+          if(stdfileName != "template_lib")
+            {
+              modelCDMLibrary* library = new modelCDMLibrary(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+              this->libraries.push_back(library);
+              this->children.push_back(library);
+            }
+          else
+            {
+              modelCDMFolder* folder = new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+              this->children.push_back(folder);
+            }
 
           cont = dir.GetNext(&fileName);
         }
@@ -177,26 +185,50 @@ const bool modelCDMLib::Refresh(std::string*& result)
       while (cont)
         {
           std::string stdfileName = crea::wx2std(fileName);
-          std::string libraryName = stdfileName;
-          //check if they already exist
-          bool found = false;
-          for (int i = 0; !found && i < this->libraries.size(); i++)
+
+          if(stdfileName != "template_lib")
             {
-              if (this->libraries[i]->GetName() == libraryName)
+              std::string libraryName = stdfileName;
+              //check if library already exist
+              bool found = false;
+              for (int i = 0; !found && i < this->libraries.size(); i++)
                 {
-                  found = true;
-                  int pos = std::find(this->children.begin(), this->children.end(), this->libraries[i]) - this->children.begin();
-                  checked[pos] = true;
-                  checkedLibraries[i] = true;
-                  if(!this->libraries[i]->Refresh(result))
-                    return false;
+                  if (this->libraries[i]->GetName() == libraryName)
+                    {
+                      found = true;
+                      int pos = std::find(this->children.begin(), this->children.end(), this->libraries[i]) - this->children.begin();
+                      checked[pos] = true;
+                      checkedLibraries[i] = true;
+                      if(!this->libraries[i]->Refresh(result))
+                        return false;
+                    }
+                }
+              if(!found)
+                {
+                  modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+                  this->libraries.push_back(library);
+                  this->children.push_back(library);
                 }
             }
-          if(!found)
+          else
             {
-              modelCDMLibrary* library = new modelCDMLibrary(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
-              this->libraries.push_back(library);
-              this->children.push_back(library);
+              //check if folder already exist
+              bool found = false;
+              for (int i = 0; !found && i < this->children.size(); i++)
+                {
+                  if (this->children[i]->GetName() == stdfileName)
+                    {
+                      found = true;
+                      checked[i] = true;
+                      if(!this->children[i]->Refresh(result))
+                        return false;
+                    }
+                }
+              if(!found)
+                {
+                  modelCDMFolder* folder= new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+                  this->children.push_back(folder);
+                }
             }
           cont = dir.GetNext(&fileName);
         }