]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMIProjectTreeNode.cpp
index c8770d25d4ce78d5c2357ba97f1e4d6ead65fd33..8b076580636b29a0a9a715c5e7b0e9ae0b2639c5 100644 (file)
@@ -23,7 +23,7 @@
 #  The fact that you are presently reading this means that you have had
 #  knowledge of the CeCILL-B license and that you accept its terms.
 # ------------------------------------------------------------------------
-*/
+ */
 
 /*
  * modelCDMIProjectTreeNode.cpp
 #include "modelCDMIProjectTreeNode.h"
 #include <algorithm>
 
+#include "CDMUtilities.h"
+
+#include "wx/dir.h"
+
 bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y)
 {
   bool returnValue;
@@ -45,42 +49,42 @@ bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x
   unsigned char yType = y->GetType();
 
   while ((i < xName.length()) && (i < yName.length()))
-  {
-    if (tolower (xName[i]) < tolower (yName[i]))
     {
-      noWinner = false;
-      returnValue = true;
-      break;
+      if (tolower (xName[i]) < tolower (yName[i]))
+        {
+          noWinner = false;
+          returnValue = true;
+          break;
+        }
+      else if (tolower (xName[i]) > tolower (yName[i]))
+        {
+          noWinner = false;
+          returnValue = false;
+          break;
+        }
+      i++;
     }
-    else if (tolower (xName[i]) > tolower (yName[i]))
-    {
-      noWinner = false;
-      returnValue = false;
-      break;
-    }
-    i++;
-  }
 
   if(noWinner)
-  {
-    if (xName.length() < yName.length())
-      returnValue = true;
-    else
-      returnValue = false;
-  }
+    {
+      if (xName.length() < yName.length())
+        returnValue = true;
+      else
+        returnValue = false;
+    }
 
   if(xType != yType)
-  {
-    if(xType == DT_DIR)
-      returnValue = true;
-    else
-      returnValue = false;
-  }
+    {
+      if(xType == wxDIR_DIRS)
+        returnValue = true;
+      else
+        returnValue = false;
+    }
 
   return returnValue;
 }
 
-const wxTreeItemId& modelCDMIProjectTreeNode::GetId() const
+const wxCDMTreeItemId& modelCDMIProjectTreeNode::GetId() const
 {
   return this->id;
 }
@@ -105,12 +109,30 @@ const int& modelCDMIProjectTreeNode::GetLevel() const
   return this->level;
 }
 
+modelCDMIProjectTreeNode* modelCDMIProjectTreeNode::GetParent() const
+{
+  return this->parent;
+}
+
+std::vector<modelCDMIProjectTreeNode*> modelCDMIProjectTreeNode::GetParents() const
+{
+  std::vector<modelCDMIProjectTreeNode*> family;
+  modelCDMIProjectTreeNode* someFamily = this->parent;
+  while(someFamily != NULL)
+    {
+      family.push_back(someFamily);
+      someFamily = someFamily->GetParent();
+    }
+  return family;
+
+}
+
 const std::vector<modelCDMIProjectTreeNode*>& modelCDMIProjectTreeNode::GetChildren() const
 {
   return this->children;
 }
 
-void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id)
+void modelCDMIProjectTreeNode::SetId(const wxCDMTreeItemId& id)
 {
   this->id = id;
 }
@@ -140,6 +162,11 @@ const int& modelCDMIProjectTreeNode::GetLength()
 
 const bool modelCDMIProjectTreeNode::OpenInFileExplorer(std::string*& result) const
 {
-  //TODO: implement method
-  return false;
+  if (!CDMUtilities::openFileExplorer(this->GetPath()))
+    return true;
+  else
+    {
+      result = new std::string("Couldn't open file.");
+      return false;
+    }
 }