From 415b0adeec3509506418aebf53f3d9c1f8e3ee9b Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Fri, 29 Sep 2023 21:19:15 +0200 Subject: [PATCH] Extend history items with favorite boolean Refs: #40 --- NEWS.md | 4 ++ icons/icon_favorite.bmp | Bin 0 -> 11162 bytes icons/meson.build | 1 + src/app.h | 6 ++ src/events.h | 1 + src/history.h | 53 +++++++++++++-- src/icons.h | 47 +++++--------- src/l10n.h | 4 ++ src/menu.h | 140 +++++++++++++++++++++++++++++----------- src/model.h | 15 ++++- src/state.h | 41 ++---------- src/ui.cc | 3 + src/ui.h | 2 +- 13 files changed, 206 insertions(+), 111 deletions(-) create mode 100644 icons/icon_favorite.bmp diff --git a/NEWS.md b/NEWS.md index 279da70..308544c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Added +- Extend history items with favorite boolean and make sure favorites + won't disappear from history + [#40](https://github.com/orontee/taranis/issues/40) + - Automatic refresh should not popup connection dialog [#50](https://github.com/orontee/taranis/issues/50) diff --git a/icons/icon_favorite.bmp b/icons/icon_favorite.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6b87ed459d8de4e4684919136a194eed0d863f71 GIT binary patch literal 11162 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 z83dEYgi=pj@*KcbHYJIR%y%fAhistory->get_location(history_index); if (location) { this->update_config_location(*location); + } else { + DialogSynchro(ICON_WARNING, "Title", "Location not found!", + GetLangText("Ok"), nullptr, nullptr); } return 1; } else if (param_one == CustomEvent::show_about_dialog) { this->open_about_dialog(); return 1; + } else if (param_one == CustomEvent::toggle_current_location_favorite) { + this->history->toggle_current_location_favorite(); + return 1; } // Events diff --git a/src/events.h b/src/events.h index 969ab17..3a96e3d 100644 --- a/src/events.h +++ b/src/events.h @@ -9,6 +9,7 @@ enum CustomEvent { refresh_data, select_location_from_history, show_about_dialog, + toggle_current_location_favorite, // Events model_daily_forecast_display_changed, diff --git a/src/history.h b/src/history.h index 8a38083..967fd1d 100644 --- a/src/history.h +++ b/src/history.h @@ -31,23 +31,64 @@ class LocationHistoryProxy { } std::optional result; if (index == 0 and it != std::end(history)) { - result = *it; + result = it->location; } return result; } void update_history_maybe() { - auto &history = this->model->location_history; auto ¤t_location = this->model->location; - auto found = std::find(history.begin(), history.end(), current_location); + auto &history = this->model->location_history; + const auto found = std::find_if(history.begin(), history.end(), + [current_location](const auto &item) { + return item.location == current_location; + }); + const bool found_favorite = (found != history.end() and found->favorite); if (found != history.end()) { history.erase(found); } - history.push_front(this->model->location); + if (history.size() == LocationHistoryProxy::max_size) { + auto last_not_favorite = + std::find_if(history.rbegin(), history.rend(), + [](const auto &item) { return not item.favorite; }); + if (last_not_favorite != history.rend()) { + history.erase(std::prev(last_not_favorite.base())); + } + } + if (history.size() < LocationHistoryProxy::max_size) { + history.push_front(HistoryItem{this->model->location, found_favorite}); + } + } + + bool is_current_location_favorite() const { + auto ¤t_location = this->model->location; + auto &history = this->model->location_history; + const auto found = std::find_if(history.begin(), history.end(), + [current_location](const auto &item) { + return item.location == current_location; + }); + return found != history.end() and found->favorite; + } - if (history.size() > LocationHistoryProxy::max_size) { - history.pop_back(); + void toggle_current_location_favorite() { + auto ¤t_location = this->model->location; + auto &history = this->model->location_history; + auto found = std::find_if(history.begin(), history.end(), + [current_location](const auto &item) { + return item.location == current_location; + }); + if (found == history.end()) { + return; } + found->favorite = (not found->favorite); + } + + bool can_add_favorite() { + auto &history = this->model->location_history; + const auto found = + std::find_if(history.begin(), history.end(), + [](const auto &item) { return not item.favorite; }); + return found != history.end(); } private: diff --git a/src/icons.h b/src/icons.h index 7ab9c80..ef65b8b 100644 --- a/src/icons.h +++ b/src/icons.h @@ -12,6 +12,7 @@ extern const ibitmap icon_10n_2x; extern const ibitmap icon_11n_2x; extern const ibitmap icon_13n_2x; extern const ibitmap icon_50n_2x; +extern const ibitmap icon_favorite; extern const ibitmap icon_menu; extern const ibitmap icon_warning; ; @@ -19,62 +20,44 @@ extern const ibitmap icon_warning; namespace taranis { class Icons { public: - Icons() - : icon_01n{&::icon_01n_2x}, icon_02n{&::icon_02n_2x}, - icon_03n{&::icon_03n_2x}, icon_04n{&::icon_04n_2x}, - icon_09n{&::icon_09n_2x}, icon_10n{&::icon_10n_2x}, - icon_11n{&::icon_11n_2x}, icon_13n{&::icon_13n_2x}, - icon_50n{&::icon_50n_2x}, icon_menu{&::icon_menu}, - icon_warning{&::icon_warning} {} - ibitmap *get(const std::string &name) { if (name == "01d" or name == "01n") { - return const_cast(this->icon_01n); + return const_cast(&icon_01n_2x); } if (name == "02d" or name == "02n") { - return const_cast(this->icon_02n); + return const_cast(&icon_02n_2x); } if (name == "03d" or name == "03n") { - return const_cast(this->icon_03n); + return const_cast(&icon_03n_2x); } if (name == "04d" or name == "04n") { - return const_cast(this->icon_04n); + return const_cast(&icon_04n_2x); } if (name == "09d" or name == "09n") { - return const_cast(this->icon_09n); + return const_cast(&icon_09n_2x); } if (name == "10d" or name == "10n") { - return const_cast(this->icon_10n); + return const_cast(&icon_10n_2x); } if (name == "11d" or name == "11n") { - return const_cast(this->icon_11n); + return const_cast(&icon_11n_2x); } if (name == "13d" or name == "13n") { - return const_cast(this->icon_13n); + return const_cast(&icon_13n_2x); } if (name == "50d" or name == "50n") { - return const_cast(this->icon_50n); + return const_cast(&icon_50n_2x); + } + if (name == "favorite") { + return const_cast(&icon_favorite); } if (name == "menu") { - return const_cast(this->icon_menu); + return const_cast(&icon_menu); } if (name == "warning") { - return const_cast(this->icon_warning); + return const_cast(&icon_warning); } return nullptr; } - -private: - const ibitmap *const icon_01n; - const ibitmap *const icon_02n; - const ibitmap *const icon_03n; - const ibitmap *const icon_04n; - const ibitmap *const icon_09n; - const ibitmap *const icon_10n; - const ibitmap *const icon_11n; - const ibitmap *const icon_13n; - const ibitmap *const icon_50n; - const ibitmap *const icon_menu; - const ibitmap *const icon_warning; }; } // namespace taranis diff --git a/src/l10n.h b/src/l10n.h index faa7d6b..4e5e34e 100644 --- a/src/l10n.h +++ b/src/l10n.h @@ -77,6 +77,8 @@ inline void initialize_translations() { AddTranslation("Units", "Unités"); AddTranslation("About…", "À propos…"); AddTranslation("Quit", "Quitter"); + AddTranslation("Add to favorites", "Ajouter aux favoris"); + AddTranslation("Remove from favorites", "Retirer des favoris"); AddTranslation("Empty", "Vide"); // statusbar.h @@ -167,6 +169,8 @@ inline void initialize_translations() { AddTranslation("Units", "Jednostki"); AddTranslation("About…", "O aplikacji"); AddTranslation("Quit", "Wyjście"); + AddTranslation("Add to favorites", "Dodaj do ulubionych"); + AddTranslation("Remove from favorites", "Usuń z ulubionych"); AddTranslation("Empty", "Pusty"); // statusbar.h diff --git a/src/menu.h b/src/menu.h index fe9246a..d7ed628 100644 --- a/src/menu.h +++ b/src/menu.h @@ -24,6 +24,7 @@ namespace taranis { enum menu_item_index { MENU_ITEM_REFRESH = 100, MENU_ITEM_LOCATION_HISTORY = 200, + MENU_ITEM_TOGGLE_FAVORITE_LOCATION = 201, MENU_ITEM_UNIT_SYSTEM = 202, MENU_ITEM_ABOUT = 203, MENU_ITEM_QUIT = 300, @@ -34,34 +35,44 @@ enum menu_item_index { }; class MenuButton : public Button { - typedef std::array MenuItems; + typedef std::array MenuItems; public: MenuButton(std::shared_ptr model, std::shared_ptr icons, std::shared_ptr fonts) - : Button{MenuButton::icon_size, icons->get("menu")}, + : Button{MenuButton::icon_size, icons->get("menu")}, icons{icons}, unit_system_items{ - imenu{ITEM_ACTIVE, MENU_ITEM_UNIT_SYSTEM_STANDARD, - const_cast(GetLangText("Standard")), nullptr}, - imenu{ITEM_ACTIVE, MENU_ITEM_UNIT_SYSTEM_METRIC, - const_cast(GetLangText("Metric")), nullptr}, - imenu{ITEM_ACTIVE, MENU_ITEM_UNIT_SYSTEM_IMPERIAL, - const_cast(GetLangText("Imperial")), nullptr}, - imenu{0, 0, nullptr, nullptr}}, - items{imenu{ITEM_ACTIVE, taranis::MENU_ITEM_REFRESH, - const_cast(GetLangText("Refresh")), nullptr}, - imenu{ITEM_SUBMENU, taranis::MENU_ITEM_LOCATION_HISTORY, - const_cast(GetLangText("Locations")), - this->location_history_items.data()}, - imenu{ITEM_SUBMENU, taranis::MENU_ITEM_UNIT_SYSTEM, - const_cast(GetLangText("Units")), - const_cast(this->unit_system_items.data())}, - imenu{ITEM_ACTIVE, taranis::MENU_ITEM_ABOUT, - const_cast(GetLangText("About…")), nullptr}, - imenu{ITEM_ACTIVE, taranis::MENU_ITEM_QUIT, - const_cast(GetLangText("Quit")), nullptr}, - imenu{0, 0, nullptr, nullptr}}, - model{model}, font{fonts->get_normal_font()} { + imenuex{ITEM_ACTIVE, MENU_ITEM_UNIT_SYSTEM_STANDARD, + const_cast(GetLangText("Standard")), nullptr, + nullptr, nullptr, nullptr}, + imenuex{ITEM_ACTIVE, MENU_ITEM_UNIT_SYSTEM_METRIC, + const_cast(GetLangText("Metric")), nullptr, nullptr, + nullptr, nullptr}, + imenuex{ITEM_ACTIVE, MENU_ITEM_UNIT_SYSTEM_IMPERIAL, + const_cast(GetLangText("Imperial")), nullptr, + nullptr, nullptr, nullptr}, + imenuex{0, 0, nullptr, nullptr, nullptr, nullptr, nullptr}}, + items{imenuex{ITEM_ACTIVE, taranis::MENU_ITEM_REFRESH, + const_cast(GetLangText("Refresh")), nullptr, + nullptr, nullptr, nullptr}, + imenuex{ITEM_SUBMENU, taranis::MENU_ITEM_LOCATION_HISTORY, + const_cast(GetLangText("Locations")), + this->location_history_items.data(), nullptr, nullptr, + nullptr}, + imenuex{ITEM_SUBMENU, taranis::MENU_ITEM_UNIT_SYSTEM, + const_cast(GetLangText("Units")), + const_cast(this->unit_system_items.data()), + nullptr, nullptr, nullptr}, + imenuex{ITEM_ACTIVE, taranis::MENU_ITEM_ABOUT, + const_cast(GetLangText("About…")), nullptr, + nullptr, nullptr, nullptr}, + imenuex{ITEM_ACTIVE, taranis::MENU_ITEM_QUIT, + const_cast(GetLangText("Quit")), nullptr, nullptr, + nullptr, nullptr}, + imenuex{0, 0, nullptr, nullptr, nullptr, nullptr, nullptr}}, + model{model}, font{fonts->get_normal_font()}, + history{std::make_unique(this->model)} { + this->initialize_favorite_location_icon(); this->update_location_history_items(); } @@ -84,15 +95,20 @@ class MenuButton : public Button { static const int padding{5}; static const int icon_size{70}; - std::array unit_system_items; - std::array location_history_items; + std::shared_ptr icons; + + std::array unit_system_items; + std::array + location_history_items; const MenuItems items; std::vector location_full_names; std::shared_ptr model; - std::shared_ptr font; + std::unique_ptr history; + + const ibitmap *favorite_location_icon; std::optional menu_handler; @@ -112,6 +128,16 @@ class MenuButton : public Button { return {pos_x, pos_y}; } + void initialize_favorite_location_icon() { + const auto menu_properties = LoadContextMenuProperties(); + const auto menu_font_height = + menu_properties and menu_properties->font_normal + ? menu_properties->font_normal->height + : this->font->height * 0.9; + this->favorite_location_icon = BitmapStretchProportionally( + this->icons->get("favorite"), menu_font_height, menu_font_height); + } + void update_location_history_items() { this->location_full_names.clear(); @@ -119,26 +145,68 @@ class MenuButton : public Button { auto &location_history = this->model->location_history; if (location_history.empty()) { this->location_history_items.at(index) = - imenu{ITEM_INACTIVE, taranis::MENU_ITEM_EMPTY_LOCATION_HISTORY, - const_cast(GetLangText("Empty")), nullptr}; + imenuex{ITEM_INACTIVE, + taranis::MENU_ITEM_EMPTY_LOCATION_HISTORY, + const_cast(GetLangText("Empty")), + nullptr, + nullptr, + nullptr, + nullptr}; + ++index; + + this->location_history_items[index] = + imenuex{ITEM_INACTIVE, taranis::MENU_ITEM_TOGGLE_FAVORITE_LOCATION, + nullptr, nullptr, + nullptr, nullptr, + nullptr}; + this->location_full_names.push_back( + const_cast(GetLangText("Add to favorites"))); ++index; } else { - for (const auto &location : location_history) { - this->location_full_names.push_back(format_location(location)); + for (const auto &item : location_history) { + this->location_full_names.push_back(format_location(item.location)); + ibitmap *icon = + item.favorite ? const_cast(this->favorite_location_icon) + : nullptr; const short item_index = taranis::MENU_ITEM_EMPTY_LOCATION_HISTORY + index + 1; - this->location_history_items.at(index) = - imenu{ITEM_ACTIVE, item_index, nullptr, nullptr}; + this->location_history_items.at(index) = imenuex{ + ITEM_ACTIVE, item_index, nullptr, nullptr, icon, nullptr, nullptr}; ++index; - if (index >= this->location_history_items.size() - 1) { + if (index == location_history.size() or + index == this->location_history_items.size() - 2) { + const auto toggle_item_text = + const_cast(history->is_current_location_favorite() + ? GetLangText("Remove from favorites") + : GetLangText("Add to favorites")); + + const bool is_toggle_item_active = + history->is_current_location_favorite() or + history->can_add_favorite(); + + const short toggle_item_state = + is_toggle_item_active ? ITEM_ACTIVE : ITEM_INACTIVE; + + this->location_history_items.at(index) = + imenuex{toggle_item_state, + taranis::MENU_ITEM_TOGGLE_FAVORITE_LOCATION, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr}; + this->location_full_names.push_back(toggle_item_text); + + ++index; break; } } } while (index < this->location_history_items.size()) { - this->location_history_items.at(index) = imenu{0, 0, nullptr, nullptr}; + this->location_history_items.at(index) = + imenuex{0, 0, nullptr, nullptr, nullptr, nullptr, nullptr}; ++index; } index = 0; @@ -174,8 +242,8 @@ class MenuButton : public Button { const auto &[pos_x, pos_y] = this->get_menu_position(); SetMenuFont(this->font.get()); - OpenMenu(const_cast(this->items.data()), 0, pos_x, pos_y, - *this->menu_handler); + OpenMenuEx(const_cast(this->items.data()), 0, pos_x, pos_y, + *this->menu_handler); } }; } // namespace taranis diff --git a/src/model.h b/src/model.h index dc59a5a..93ed1dc 100644 --- a/src/model.h +++ b/src/model.h @@ -163,6 +163,18 @@ struct Alert { std::string description; }; +struct HistoryItem { + const Location location; + bool favorite; + + HistoryItem(const std::string &town, const std::string &country, + bool favorite) + : location{town, country}, favorite{favorite} {} + + HistoryItem(const Location &location, bool favorite) + : location{location}, favorite{favorite} {} +}; + struct Model { std::string source{"OpenWeather"}; UnitSystem unit_system{standard}; @@ -175,8 +187,7 @@ struct Model { std::vector alerts; - std::vector favorite_locations; - std::list location_history; + std::list location_history; bool display_daily_forecast{false}; }; diff --git a/src/state.h b/src/state.h index 6c412da..885b5e0 100644 --- a/src/state.h +++ b/src/state.h @@ -30,7 +30,6 @@ class ApplicationState { input >> root; this->restore_location_history(root); - this->restore_favorite_locations(root); } void dump() { @@ -42,7 +41,6 @@ class ApplicationState { Json::Value root; this->dump_location_history(root); - this->dump_favorite_locations(root); output << root << std::endl; output.close(); @@ -50,7 +48,6 @@ class ApplicationState { private: static constexpr char LOCATION_HISTORY_KEY[]{"location_history"}; - static constexpr char FAVORITE_LOCATIONS_KEY[]{"favorite_locations"}; std::shared_ptr model; @@ -71,8 +68,9 @@ class ApplicationState { if (town.empty()) { return; } - const Location location{town, value.get("country", "").asString()}; - this->model->location_history.push_back(location); + const HistoryItem item{town, value.get("country", "").asString(), + value.get("favorite", false).asBool()}; + this->model->location_history.push_back(item); } } @@ -80,38 +78,13 @@ class ApplicationState { auto &history_value = root[ApplicationState::LOCATION_HISTORY_KEY]; const auto &history = this->model->location_history; int location_index = 0; - for (const auto &location : history) { - history_value[location_index]["town"] = location.town; - history_value[location_index]["country"] = location.country; + for (const auto &item : history) { + history_value[location_index]["town"] = item.location.town; + history_value[location_index]["country"] = item.location.country; + history_value[location_index]["favorite"] = item.favorite; ++location_index; } } - - void restore_favorite_locations(const Json::Value &root) { - this->model->favorite_locations.clear(); - - for (const auto &value : root[ApplicationState::FAVORITE_LOCATIONS_KEY]) { - const auto town{value.get("town", "").asString()}; - if (town.empty()) { - return; - } - const Location location{town, value.get("country", "").asString()}; - this->model->favorite_locations.push_back(location); - } - } - - void dump_favorite_locations(Json::Value &root) { - auto &favorite_locations_value = - root[ApplicationState::FAVORITE_LOCATIONS_KEY]; - const auto &favorites = this->model->favorite_locations; - int favorite_index = 0; - for (const auto &location : favorites) { - favorite_locations_value[favorite_index]["town"] = location.town; - favorite_locations_value[favorite_index]["country"] = location.country; - - ++favorite_index; - } - } }; } // namespace taranis diff --git a/src/ui.cc b/src/ui.cc index 14efaa4..541781e 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -10,6 +10,9 @@ void taranis::handle_menu_item_selected(int item_index) { const auto event_handler = GetEventHandler(); if (item_index == MENU_ITEM_REFRESH) { SendEvent(event_handler, EVT_CUSTOM, CustomEvent::refresh_data, 0); + } else if (item_index == MENU_ITEM_TOGGLE_FAVORITE_LOCATION) { + SendEvent(event_handler, EVT_CUSTOM, + CustomEvent::toggle_current_location_favorite, 0); } else if (item_index == MENU_ITEM_UNIT_SYSTEM_STANDARD) { SendEvent(event_handler, EVT_CUSTOM, CustomEvent::change_unit_system, UnitSystem::standard); diff --git a/src/ui.h b/src/ui.h index 7a683c0..282552f 100644 --- a/src/ui.h +++ b/src/ui.h @@ -77,7 +77,7 @@ class Ui { this->children.push_back(location_box); this->children.push_back(menu_button); this->children.push_back(current_condition_box); - this->children.push_back(alerts_button); + this->children.push_back(this->alerts_button); this->children.push_back(status_bar); this->swipe_detector.set_bounding_box(