]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMIProjectTreeNode.cpp
index 8026b415476857f0e2ca9472ea6580aa7e628c46..b444af28d2f8bf922a0e9aa510f158c7a1a9abdd 100644 (file)
  *      Author: Daniel Felipe Gonzalez Obando
  */
 #include "modelCDMIProjectTreeNode.h"
+#include <algorithm>
 
-bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode& x, const modelCDMIProjectTreeNode& y)
+bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode* x, const modelCDMIProjectTreeNode* y)
 {
   bool returnValue;
   bool noWinner = true;
   unsigned int i = 0;
-  std::string xName = x.GetName();
-  std::string yName = y.GetName();
-  unsigned char xType = x.GetType();
-  unsigned char yType = y.GetType();
+  std::string xName = x->GetName();
+  std::string yName = y->GetName();
+  unsigned char xType = x->GetType();
+  unsigned char yType = y->GetType();
 
   while ((i < xName.length()) && (i < yName.length()))
   {
@@ -114,6 +115,11 @@ void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id)
   this->id = id;
 }
 
+void modelCDMIProjectTreeNode::SortChildren()
+{
+  std::sort(this->children.begin(), this->children.end(), CompareNodeItem);
+}
+
 void modelCDMIProjectTreeNode::SetChildren(
     const std::vector<modelCDMIProjectTreeNode*>& children)
 {