mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
Maps: Add FavoritesModel and remove hacky misusage of JSONArrayModel
This commit is contained in:
parent
29026ce965
commit
bd86beb7e4
7 changed files with 224 additions and 74 deletions
|
@ -6,9 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "MapWidget.h"
|
||||
#include <LibGUI/Dialog.h>
|
||||
#include <LibGUI/ItemListModel.h>
|
||||
#include "FavoritesModel.h"
|
||||
#include <LibGUI/ListView.h>
|
||||
|
||||
namespace Maps {
|
||||
|
@ -17,17 +15,13 @@ class FavoritesPanel final : public GUI::Widget {
|
|||
C_OBJECT(FavoritesPanel)
|
||||
|
||||
public:
|
||||
struct Favorite {
|
||||
String name;
|
||||
MapWidget::LatLng latlng;
|
||||
int zoom;
|
||||
};
|
||||
static ErrorOr<NonnullRefPtr<FavoritesPanel>> try_create();
|
||||
ErrorOr<void> initialize();
|
||||
|
||||
void load_favorites();
|
||||
void reset();
|
||||
ErrorOr<void> add_favorite(Favorite const& favorite);
|
||||
void add_favorite(Favorite favorite);
|
||||
void delete_favorite(Favorite const& favorite);
|
||||
|
||||
Function<void(Vector<Favorite> const&)> on_favorites_change;
|
||||
Function<void(Favorite const&)> on_selected_favorite_change;
|
||||
|
@ -36,11 +30,12 @@ protected:
|
|||
FavoritesPanel() = default;
|
||||
|
||||
private:
|
||||
ErrorOr<void> edit_favorite(int row);
|
||||
ErrorOr<void> edit_favorite(GUI::ModelIndex const& index);
|
||||
void favorites_changed();
|
||||
|
||||
RefPtr<GUI::Frame> m_empty_container;
|
||||
RefPtr<GUI::ListView> m_favorites_list;
|
||||
RefPtr<FavoritesModel> m_model;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue