Frequency save and naming bugfix

This commit is contained in:
furrtek 2017-02-03 16:22:12 +00:00
parent 84be3a363c
commit 3fca8be317
4 changed files with 22 additions and 16 deletions

View File

@ -31,24 +31,23 @@ using namespace portapack;
namespace ui {
void FrequencySaveView::on_save_name(NavigationView& nav) {
// TODO: Here be a bug.
textentry(nav, desc_buffer, 28);
database.entries.push_back({ value_, "", desc_buffer, (int32_t)options_category.selected_index_value() });
nav.pop();
void FrequencySaveView::on_save_name(char * name) {
database.entries.push_back({ value_, "", name, (int32_t)options_category.selected_index_value() });
nav_.pop();
}
void FrequencySaveView::on_save_timestamp(NavigationView& nav) {
void FrequencySaveView::on_save_timestamp() {
database.entries.push_back({ value_, "", str_timestamp, (int32_t)options_category.selected_index_value() });
nav.pop();
nav_.pop();
}
void FrequencySaveView::focus() {
if (error == ERROR_ACCESS) {
nav_.display_modal("Error", "File acces error", ABORT, nullptr);
} else {
if (error == ERROR_DUPLICATE)
} else if (error == ERROR_DUPLICATE) {
nav_.display_modal("Error", "Frequency already saved", INFO, nullptr);
error = NO_ERROR;
} else {
button_save_timestamp.focus();
}
}
@ -120,10 +119,12 @@ FrequencySaveView::FrequencySaveView(
big_display.set(value);
button_save_name.on_select = [this, &nav](Button&) {
on_save_name(nav);
textentry(nav, desc_buffer, 28, [this](char * buffer) {
on_save_name(buffer);
});
};
button_save_timestamp.on_select = [this, &nav](Button&) {
on_save_timestamp(nav);
on_save_timestamp();
};
button_cancel.on_select = [this, &nav](Button&) {
@ -216,6 +217,7 @@ void FreqManView::on_edit_desc(NavigationView& nav) {
}
void FreqManView::on_delete() {
size_t n;
database.entries.erase(database.entries.begin() + menu_view.highlighted());
setup_list();
}
@ -240,7 +242,7 @@ void FreqManView::setup_list() {
});
}
menu_view.set_highlighted(menu_view.highlighted()); // Refresh
menu_view.set_highlighted(0); // Refresh
}
void FreqManView::focus() {

View File

@ -50,8 +50,8 @@ private:
std::string str_timestamp { };
//int32_t category_id_ { -1 };
void on_save_name(NavigationView& nav);
void on_save_timestamp(NavigationView& nav);
void on_save_name(char * name);
void on_save_timestamp();
void on_tick_second();
freqman_db database { };

View File

@ -111,7 +111,11 @@ MenuView::MenuView(
}
MenuView::~MenuView() {
clear();
for (auto child : children_) {
if (!child->id) {
delete child;
}
}
rtc_time::signal_tick_second -= signal_token_tick_second;
}
@ -129,7 +133,7 @@ void MenuView::on_tick_second() {
void MenuView::clear() {
for (auto child : children_) {
if (!child->id) {
delete child;
remove_child(child);
}
}
}

Binary file not shown.