From 626c9ba386546c6fbdcc8f1afcf655e71dfff1d7 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 1 Apr 2019 22:17:27 +0200 Subject: [PATCH] [DEV] add print log and correct the tree view --- sources/appl/debug.hpp | 1 + sources/appl/init.cpp | 5 ++-- sources/appl/widget/BufferTree.cpp | 38 ++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/sources/appl/debug.hpp b/sources/appl/debug.hpp index daa2cae..e596b1c 100644 --- a/sources/appl/debug.hpp +++ b/sources/appl/debug.hpp @@ -12,6 +12,7 @@ namespace appl { }; #define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data) +#define APPL_PRINT(data) APPL_BASE(-1, data) #define APPL_CRITICAL(data) APPL_BASE(1, data) #define APPL_ERROR(data) APPL_BASE(2, data) #define APPL_WARNING(data) APPL_BASE(3, data) diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 9d15c51..3aaab61 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -26,6 +26,7 @@ #include #include #include +#include class MainApplication : public ewol::context::Application { private: @@ -38,8 +39,8 @@ class MainApplication : public ewol::context::Application { etk::String tmpppp = _context.getCmd().get(iii); if ( tmpppp == "-h" || tmpppp == "--help") { - APPL_INFO(" --ctags=xxx c-flags-file-name" ); - APPL_INFO(" -h/--help display this help" ); + APPL_PRINT(" --ctags=xxx c-flags-file-name" ); + APPL_PRINT(" -h/--help display this help" ); exit(0); } } diff --git a/sources/appl/widget/BufferTree.cpp b/sources/appl/widget/BufferTree.cpp index 1a49b73..233e2fa 100644 --- a/sources/appl/widget/BufferTree.cpp +++ b/sources/appl/widget/BufferTree.cpp @@ -102,7 +102,42 @@ void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtrhaveChild() == true) { - // already populated... + // already populated... ==> updat list of elements: ... + etk::Vector child = etk::path::list(value.m_path, etk::path::LIST_FOLDER|etk::path::LIST_FILE); + etk::algorithm::quickSort(child, localSort); + APPL_VERBOSE(" nbChilds: " << child.size() << " for path: " << value.m_path); + // Add missing element (at the end ...) + for (auto& it: child) { + bool find = false; + for (auto &nodeIt: _node->getChilds()) { + if (nodeIt->getData().m_path == it) { + find = true; + break; + } + } + if (find == false) { + auto elem = etk::TreeNode::create(TreeElement(it, false)); + _node->addChild(elem); + } + } + // remove destroyed elements: + + size_t iii = 0; + while (iii < _node->getChilds().size()) { + auto node = _node->getChilds()[iii]; + bool find = false; + for (auto& it: child) { + if (node->getData().m_path == it) { + find = true; + break; + } + } + if (find == false) { + _node->rmChild(node); + } else { + ++iii; + } + } return; } etk::Vector child = etk::path::list(value.m_path, etk::path::LIST_FOLDER|etk::path::LIST_FILE); @@ -112,7 +147,6 @@ void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr::create(TreeElement(it, false)); _node->addChild(elem); - // TODO: ETK_FREE(etk::FSNode, it); } }