X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMIProjectTreeNode.cpp;h=8b076580636b29a0a9a715c5e7b0e9ae0b2639c5;hb=f10df58dfa9c4d8489fe35f57f796bcf37e5f9b4;hp=8026b415476857f0e2ca9472ea6580aa7e628c46;hpb=07de43de26544771a25b4edb25cbbf878bf32de3;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp index 8026b41..8b07658 100644 --- a/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp +++ b/lib/creaDevManagerLib/modelCDMIProjectTreeNode.cpp @@ -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 @@ -32,54 +32,59 @@ * Author: Daniel Felipe Gonzalez Obando */ #include "modelCDMIProjectTreeNode.h" +#include + +#include "CDMUtilities.h" -bool modelCDMIProjectTreeNode::CompareNodeItem(const modelCDMIProjectTreeNode& x, const modelCDMIProjectTreeNode& y) +#include "wx/dir.h" + +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())) - { - 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; } @@ -104,16 +109,39 @@ const int& modelCDMIProjectTreeNode::GetLevel() const return this->level; } +modelCDMIProjectTreeNode* modelCDMIProjectTreeNode::GetParent() const +{ + return this->parent; +} + +std::vector modelCDMIProjectTreeNode::GetParents() const +{ + std::vector family; + modelCDMIProjectTreeNode* someFamily = this->parent; + while(someFamily != NULL) + { + family.push_back(someFamily); + someFamily = someFamily->GetParent(); + } + return family; + +} + const std::vector& modelCDMIProjectTreeNode::GetChildren() const { return this->children; } -void modelCDMIProjectTreeNode::SetId(const wxTreeItemId& id) +void modelCDMIProjectTreeNode::SetId(const wxCDMTreeItemId& id) { this->id = id; } +void modelCDMIProjectTreeNode::SortChildren() +{ + std::sort(this->children.begin(), this->children.end(), CompareNodeItem); +} + void modelCDMIProjectTreeNode::SetChildren( const std::vector& children) { @@ -127,8 +155,18 @@ const bool modelCDMIProjectTreeNode::Refresh(std::string*& result) return false; } +const int& modelCDMIProjectTreeNode::GetLength() +{ + return this->length; +} + 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; + } }