mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-24 05:31:36 -05:00
* Fix crash issues with empty FreqMan files * Added ability to delete empty files * Fix missing Comma character when editing text #1125
This commit is contained in:
parent
7576432e44
commit
344a8dc0a0
@ -226,8 +226,13 @@ void FrequencyManagerView::on_new_category(NavigationView& nav) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FrequencyManagerView::on_delete() {
|
void FrequencyManagerView::on_delete() {
|
||||||
database.erase(database.begin() + menu_view.get_index());
|
if (database.empty()) {
|
||||||
save_freqman_file(file_list[categories[current_category_id].second], database);
|
delete_freqman_file(file_list[categories[current_category_id].second]);
|
||||||
|
refresh_list();
|
||||||
|
} else {
|
||||||
|
database.erase(database.begin() + menu_view.get_index());
|
||||||
|
save_freqman_file(file_list[categories[current_category_id].second], database);
|
||||||
|
}
|
||||||
change_category(current_category_id);
|
change_category(current_category_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,6 +277,9 @@ FrequencyManagerView::FrequencyManagerView(
|
|||||||
};
|
};
|
||||||
|
|
||||||
button_edit_freq.on_select = [this, &nav](Button&) {
|
button_edit_freq.on_select = [this, &nav](Button&) {
|
||||||
|
if (database.empty()) {
|
||||||
|
database.push_back({0, 0, "", SINGLE});
|
||||||
|
}
|
||||||
auto new_view = nav.push<FrequencyKeypadView>(database[menu_view.get_index()].frequency_a);
|
auto new_view = nav.push<FrequencyKeypadView>(database[menu_view.get_index()].frequency_a);
|
||||||
new_view->on_changed = [this](rf::Frequency f) {
|
new_view->on_changed = [this](rf::Frequency f) {
|
||||||
on_edit_freq(f);
|
on_edit_freq(f);
|
||||||
@ -279,6 +287,9 @@ FrequencyManagerView::FrequencyManagerView(
|
|||||||
};
|
};
|
||||||
|
|
||||||
button_edit_desc.on_select = [this, &nav](Button&) {
|
button_edit_desc.on_select = [this, &nav](Button&) {
|
||||||
|
if (database.empty()) {
|
||||||
|
database.push_back({0, 0, "", SINGLE});
|
||||||
|
}
|
||||||
desc_buffer = database[menu_view.get_index()].description;
|
desc_buffer = database[menu_view.get_index()].description;
|
||||||
on_edit_desc(nav);
|
on_edit_desc(nav);
|
||||||
};
|
};
|
||||||
|
@ -281,6 +281,13 @@ bool get_freq_string(freqman_entry& entry, std::string& item_string) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool delete_freqman_file(std::string& file_stem) {
|
||||||
|
File freqman_file;
|
||||||
|
std::string freq_file_path = "/FREQMAN/" + file_stem + ".TXT";
|
||||||
|
delete_file(freq_file_path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool save_freqman_file(std::string& file_stem, freqman_db& db) {
|
bool save_freqman_file(std::string& file_stem, freqman_db& db) {
|
||||||
File freqman_file;
|
File freqman_file;
|
||||||
std::string freq_file_path = "/FREQMAN/" + file_stem + ".TXT";
|
std::string freq_file_path = "/FREQMAN/" + file_stem + ".TXT";
|
||||||
|
@ -98,6 +98,7 @@ using freqman_db = std::vector<freqman_entry>;
|
|||||||
bool load_freqman_file(std::string& file_stem, freqman_db& db);
|
bool load_freqman_file(std::string& file_stem, freqman_db& db);
|
||||||
bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freqs, bool load_ranges, bool load_hamradios, uint8_t limit);
|
bool load_freqman_file_ex(std::string& file_stem, freqman_db& db, bool load_freqs, bool load_ranges, bool load_hamradios, uint8_t limit);
|
||||||
bool get_freq_string(freqman_entry& entry, std::string& item_string);
|
bool get_freq_string(freqman_entry& entry, std::string& item_string);
|
||||||
|
bool delete_freqman_file(std::string& file_stem);
|
||||||
bool save_freqman_file(std::string& file_stem, freqman_db& db);
|
bool save_freqman_file(std::string& file_stem, freqman_db& db);
|
||||||
bool create_freqman_file(std::string& file_stem, File& freqman_file);
|
bool create_freqman_file(std::string& file_stem, File& freqman_file);
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ class AlphanumView : public TextEntryView {
|
|||||||
bool on_encoder(const EncoderEvent delta) override;
|
bool on_encoder(const EncoderEvent delta) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ' .<";
|
const char* const keys_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ, .<";
|
||||||
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz' .<";
|
const char* const keys_lower = "abcdefghijklmnopqrstuvwxyz, .<";
|
||||||
const char* const keys_digit = "0123456789!\"#'()*+-/:;=>?@[\\]<";
|
const char* const keys_digit = "0123456789!\"#'()*+-/:;=>?@[\\]<";
|
||||||
|
|
||||||
const std::pair<std::string, const char*> key_sets[3] = {
|
const std::pair<std::string, const char*> key_sets[3] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user