From e3d22300ed8acf1ecee5d7f0266e558cf576022d Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 7 Jun 2016 18:07:10 +0200 Subject: [PATCH] [Horus] Model Select bugfixes --- radio/src/gui/horus/menu_model_select.cpp | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/horus/menu_model_select.cpp b/radio/src/gui/horus/menu_model_select.cpp index e6bb162b4..4c4e9d914 100644 --- a/radio/src/gui/horus/menu_model_select.cpp +++ b/radio/src/gui/horus/menu_model_select.cpp @@ -125,6 +125,12 @@ void onModelSelectMenu(const char * result) } else if (result == STR_CHANGE_CATEGORY) { + } + else if (result == STR_CREATE_MODEL) { + storageCheck(true); + currentModel = modelslist.currentModel = modelslist.addModel(currentCategory, createModel()); + selectMode = MODE_SELECT_MODEL; + setCurrentModel(currentCategory->size() - 1); } else if (result == STR_DUPLICATE_MODEL) { char duplicatedFilename[LEN_MODEL_FILENAME+1]; @@ -146,22 +152,32 @@ void initModelsList() modelslist.load(); categoriesVerticalOffset = 0; + bool found = false; int index = 0; for (std::list::iterator it = modelslist.categories.begin(); it != modelslist.categories.end(); ++it, ++index) { if (*it == modelslist.currentCategory) { setCurrentCategory(index); + found = true; break; } } + if (!found) { + setCurrentCategory(0); + } modelsVerticalOffset = 0; + found = false; index = 0; for (ModelsCategory::iterator it = currentCategory->begin(); it != currentCategory->end(); ++it, ++index) { if (*it == modelslist.currentModel) { setCurrentModel(index); + found = true; break; } } + if (!found) { + setCurrentModel(0); + } } bool menuModelSelect(evt_t event) @@ -174,8 +190,8 @@ bool menuModelSelect(evt_t event) event = EVT_REFRESH; if (modelIndex > 0) { modelIndex--; - setCurrentModel(modelIndex); } + setCurrentModel(modelIndex); } switch(event) { @@ -232,13 +248,15 @@ bool menuModelSelect(evt_t event) if (currentModel != modelslist.currentModel) { POPUP_MENU_ADD_ITEM(STR_SELECT_MODEL); } + POPUP_MENU_ADD_ITEM(STR_CREATE_MODEL); POPUP_MENU_ADD_ITEM(STR_DUPLICATE_MODEL); } // POPUP_MENU_ADD_SD_ITEM(STR_BACKUP_MODEL); // POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL); POPUP_MENU_ADD_ITEM(STR_CHANGE_CATEGORY); - POPUP_MENU_ADD_ITEM(STR_DELETE_MODEL); - // POPUP_MENU_ADD_ITEM(STR_CREATE_MODEL); + if (currentModel != modelslist.currentModel) { + POPUP_MENU_ADD_ITEM(STR_DELETE_MODEL); + } // POPUP_MENU_ADD_ITEM(STR_RESTORE_MODEL); POPUP_MENU_START(onModelSelectMenu); }