[DEBUG #5] correct file selection

This commit is contained in:
Edouard DUPIN 2014-09-12 21:36:20 +02:00
parent b889b4aa5a
commit 3574fd917c
3 changed files with 22 additions and 28 deletions

View File

@ -117,14 +117,14 @@ bool appl::BufferManager::exist(const std::string& _fileName) {
void appl::BufferManager::open(const std::string& _fileName) { void appl::BufferManager::open(const std::string& _fileName) {
if (exist(_fileName) == true) { if (exist(_fileName) == true) {
// TODO : Create a pop-up ... APPL_WARNING(" the element '" << _fileName << "' already exist ... just reselect it ...");
signalSelectFile.emit(_fileName);
return; return;
} }
if (get(_fileName, true) == nullptr) { if (get(_fileName, true) == nullptr) {
APPL_ERROR("Error get '" << _fileName << "' ... ");
return; return;
} }
APPL_INFO("Open buffer:" << _fileName);
signalSelectFile.emit(_fileName); signalSelectFile.emit(_fileName);
APPL_INFO("Open buffer (done)");
} }

View File

@ -124,23 +124,22 @@ void BufferView::onCallbackNewBuffer(const std::string& _value) {
} }
markToRedraw(); markToRedraw();
} }
// TODO : Review this callback with the real shared_ptr on the buffer ...
void BufferView::onCallbackselectNewFile(const std::string& _value) { void BufferView::onCallbackselectNewFile(const std::string& _value) {
m_selectedID = -1; m_selectedID = -1;
std::shared_ptr<appl::Buffer> tmpBuffer; for (size_t iii=0; iii<m_list.size(); iii++) {
if (m_bufferManager != nullptr) { if (m_list[iii] == nullptr) {
tmpBuffer = m_bufferManager->getBufferSelected(); continue;
}
if (tmpBuffer != nullptr) {
for (size_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii] == nullptr) {
continue;
}
if (m_list[iii]->m_buffer != tmpBuffer) {
continue;
}
m_selectedID = iii;
break;
} }
if (m_list[iii]->m_buffer == nullptr) {
continue;
}
if (m_list[iii]->m_buffer->getFileName() != _value) {
continue;
}
m_selectedID = iii;
break;
} }
markToRedraw(); markToRedraw();
} }
@ -164,6 +163,7 @@ void BufferView::onCallbackChangeName() {
} }
markToRedraw(); markToRedraw();
} }
void BufferView::onCallbackIsSave() { void BufferView::onCallbackIsSave() {
markToRedraw(); markToRedraw();
} }
@ -215,8 +215,7 @@ bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextT
return true; return true;
} }
bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) {
{
if (1 == _IdInput && _typeEvent == ewol::key::statusSingle) { if (1 == _IdInput && _typeEvent == ewol::key::statusSingle) {
APPL_INFO("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw ); APPL_INFO("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
if( _raw >= 0 if( _raw >= 0
@ -224,10 +223,9 @@ bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent
&& nullptr != m_list[_raw]) { && nullptr != m_list[_raw]) {
if (m_list[_raw]->m_buffer != nullptr) { if (m_list[_raw]->m_buffer != nullptr) {
if (m_bufferManager != nullptr) { if (m_bufferManager != nullptr) {
APPL_INFO("Select file :" << m_list[_raw]->m_buffer->getFileName() << " in list");
m_bufferManager->open(m_list[_raw]->m_buffer->getFileName()); m_bufferManager->open(m_list[_raw]->m_buffer->getFileName());
} }
m_selectedID = _raw;
markToRedraw();
return true; return true;
} }
} }

View File

@ -433,6 +433,7 @@ void MainWindows::displayProperty() {
} }
void MainWindows::onCallbackselectNewFile(const std::string& _value) { void MainWindows::onCallbackselectNewFile(const std::string& _value) {
APPL_INFO("onCallbackselectNewFile(" << _value << ")");
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
return; return;
@ -447,19 +448,14 @@ void MainWindows::onCallbackselectNewFile(const std::string& _value) {
} }
} }
static const char* const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
static const char* const ednEventIsSave = "edn-buffer-is-saved";
static const char* const ednEventIsModify = "edn-buffer-is-modify";
static const char* const ednEventChangeName = "edn-buffer-change-name";
void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) { void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) {
APPL_INFO("onCallbackPopUpFileSelected(" << _value << ")");
APPL_DEBUG("Request opening the file : " << _value); APPL_DEBUG("Request opening the file : " << _value);
m_bufferManager->open(_value); m_bufferManager->open(_value);
} }
void MainWindows::onCallbackTitleUpdate() { void MainWindows::onCallbackTitleUpdate() {
APPL_INFO("onCallbackTitleUpdate()");
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
return; return;