[DEV] update new etk Uri API

This commit is contained in:
Edouard DUPIN 2018-10-23 22:19:31 +02:00
parent c8863cde93
commit 437e6b3c18
3 changed files with 19 additions and 22 deletions

View File

@ -10,7 +10,6 @@
#include <ewol/widget/Image.hpp> #include <ewol/widget/Image.hpp>
#include <ewol/context/Context.hpp> #include <ewol/context/Context.hpp>
#include <etk/os/FSNode.hpp>
#include <eproperty/Value.hpp> #include <eproperty/Value.hpp>
appl::MainWindows::MainWindows() : appl::MainWindows::MainWindows() :
@ -42,7 +41,7 @@ void appl::MainWindows::onCallbackShortCut(const etk::String& _value) {
} }
} }
void appl::MainWindows::setListOfFiles(etk::Vector<etk::String> _listImages) { void appl::MainWindows::setListOfFiles(etk::Vector<etk::Path> _listImages) {
m_listImages = _listImages; m_listImages = _listImages;
if (m_listImages.size() == 0) { if (m_listImages.size() == 0) {
m_idDisplayed = -1; m_idDisplayed = -1;
@ -51,7 +50,7 @@ void appl::MainWindows::setListOfFiles(etk::Vector<etk::String> _listImages) {
} else { } else {
m_idDisplayed = 0; m_idDisplayed = 0;
m_image->propertySource.set(m_listImages[0]); m_image->propertySource.set(m_listImages[0]);
propertyTitle.set("EVI:" + m_listImages[0]); propertyTitle.set("EVI:" + m_listImages[0].getString());
} }
} }
@ -74,7 +73,7 @@ bool appl::MainWindows::onEventEntry(const ewol::event::Entry& _event) {
return true; return true;
} }
m_image->propertySource.set(m_listImages[m_idDisplayed]); m_image->propertySource.set(m_listImages[m_idDisplayed]);
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size())); propertyTitle.set("EVI:" + m_listImages[m_idDisplayed].getString() + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size()));
return true; return true;
} }
if (_event.getType() == gale::key::keyboard::left) { if (_event.getType() == gale::key::keyboard::left) {
@ -84,7 +83,7 @@ bool appl::MainWindows::onEventEntry(const ewol::event::Entry& _event) {
return true; return true;
} }
m_image->propertySource.set(m_listImages[m_idDisplayed]); m_image->propertySource.set(m_listImages[m_idDisplayed]);
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size())); propertyTitle.set("EVI:" + m_listImages[m_idDisplayed].getString() + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size()));
return true; return true;
} }
if (_event.getType() == gale::key::keyboard::down) { if (_event.getType() == gale::key::keyboard::down) {
@ -93,7 +92,7 @@ bool appl::MainWindows::onEventEntry(const ewol::event::Entry& _event) {
m_idDisplayed = m_listImages.size()-1; m_idDisplayed = m_listImages.size()-1;
} }
m_image->propertySource.set(m_listImages[m_idDisplayed]); m_image->propertySource.set(m_listImages[m_idDisplayed]);
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size())); propertyTitle.set("EVI:" + m_listImages[m_idDisplayed].getString() + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size()));
return true; return true;
} }
if (_event.getType() == gale::key::keyboard::up) { if (_event.getType() == gale::key::keyboard::up) {
@ -102,19 +101,19 @@ bool appl::MainWindows::onEventEntry(const ewol::event::Entry& _event) {
m_idDisplayed = 0; m_idDisplayed = 0;
} }
m_image->propertySource.set(m_listImages[m_idDisplayed]); m_image->propertySource.set(m_listImages[m_idDisplayed]);
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size())); propertyTitle.set("EVI:" + m_listImages[m_idDisplayed].getString() + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size()));
return true; return true;
} }
if (_event.getType() == gale::key::keyboard::pageDown) { if (_event.getType() == gale::key::keyboard::pageDown) {
m_idDisplayed = m_listImages.size()-1; m_idDisplayed = m_listImages.size()-1;
m_image->propertySource.set(m_listImages[m_idDisplayed]); m_image->propertySource.set(m_listImages[m_idDisplayed]);
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size())); propertyTitle.set("EVI:" + m_listImages[m_idDisplayed].getString() + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size()));
return true; return true;
} }
if (_event.getType() == gale::key::keyboard::pageUp) { if (_event.getType() == gale::key::keyboard::pageUp) {
m_idDisplayed = 0; m_idDisplayed = 0;
m_image->propertySource.set(m_listImages[m_idDisplayed]); m_image->propertySource.set(m_listImages[m_idDisplayed]);
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size())); propertyTitle.set("EVI:" + m_listImages[m_idDisplayed].getString() + " " + etk::toString(m_idDisplayed+1) + "/" + etk::toString(m_listImages.size()));
return true; return true;
} }
} }

View File

@ -13,7 +13,7 @@ namespace appl {
class MainWindows : public ewol::widget::Windows { class MainWindows : public ewol::widget::Windows {
private: private:
ewol::widget::ImageShared m_image; ewol::widget::ImageShared m_image;
etk::Vector<etk::String> m_listImages; etk::Vector<etk::Path> m_listImages;
int64_t m_idDisplayed; int64_t m_idDisplayed;
public: public:
// Constructeur // Constructeur
@ -22,7 +22,7 @@ namespace appl {
public: public:
DECLARE_FACTORY(MainWindows); DECLARE_FACTORY(MainWindows);
~MainWindows() {}; ~MainWindows() {};
void setListOfFiles(etk::Vector<etk::String> _listImages); void setListOfFiles(etk::Vector<etk::Path> _listImages);
protected: protected:
void onCallbackShortCut(const etk::String& _value); void onCallbackShortCut(const etk::String& _value);
bool onEventInput(const ewol::event::Input& _event) override; bool onEventInput(const ewol::event::Input& _event) override;

View File

@ -6,7 +6,8 @@
#include <etk/types.hpp> #include <etk/types.hpp>
#include <etk/types.hpp> #include <etk/types.hpp>
#include <etk/os/FSNode.hpp> #include <etk/theme/theme.hpp>
#include <etk/path/fileSystem.hpp>
#include <ewol/ewol.hpp> #include <ewol/ewol.hpp>
#include <ewol/object/Object.hpp> #include <ewol/object/Object.hpp>
#include <ewol/context/Context.hpp> #include <ewol/context/Context.hpp>
@ -17,7 +18,7 @@
namespace appl { namespace appl {
class MainApplication : public ewol::context::Application { class MainApplication : public ewol::context::Application {
private: private:
etk::Vector<etk::String> m_listFiles; etk::Vector<etk::Path> m_listFiles;
public: public:
virtual void onCreate(ewol::Context& _context) { virtual void onCreate(ewol::Context& _context) {
APPL_INFO(" == > CREATE ... (START) [" << gale::getBoardType() << "] (" << gale::getCompilationMode() << ") (BEGIN)"); APPL_INFO(" == > CREATE ... (START) [" << gale::getBoardType() << "] (" << gale::getCompilationMode() << ") (BEGIN)");
@ -35,19 +36,16 @@ namespace appl {
continue; continue;
} }
// TODO : Check if it is a path ... // TODO : Check if it is a path ...
if (etk::FSNodeExist(tmpppp) == false) { if (etk::path::exist(tmpppp) == false) {
APPL_ERROR("element does not exist: '" << tmpppp << "' ==> rejected"); APPL_ERROR("element does not exist: '" << tmpppp << "' ==> rejected");
} else { } else {
etk::FSNode elem(tmpppp); if (etk::path::isFile(tmpppp) == true) {
if (elem.getNodeType() == etk::typeNode_folder) { m_listFiles.pushBack(tmpppp);
etk::Vector<etk::String> tmp = elem.folderGetSub(false, true, ".*"); } else {
tmp.sort(0, tmp.size(), [](const etk::String& _left, const etk::String& _right) { return _left < _right;}); etk::Vector<etk::Path> list = etk::path::list(tmpppp, etk::path::LIST_FILE);
for (auto &it : tmp) { for (auto &it : list) {
m_listFiles.pushBack(it); m_listFiles.pushBack(it);
} }
} else {
// simple file:
m_listFiles.pushBack(tmpppp);
} }
} }
} }