Horizon
pool_cache_window.hpp
1 #pragma once
2 #include "common/common.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include "pool/pool.hpp"
5 #include "util/uuid.hpp"
6 #include <array>
7 #include <gtkmm.h>
8 #include <set>
9 #include "pool_cache_status.hpp"
10 #include "util/item_set.hpp"
11 
12 namespace horizon {
13 using json = nlohmann::json;
14 
15 class PoolCacheWindow : public Gtk::Window {
16 public:
17  PoolCacheWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, const std::string &cache_path,
18  const std::string &pool_path, class PoolProjectManagerAppWindow *aw);
19  static PoolCacheWindow *create(Gtk::Window *p, const std::string &cache_path, const std::string &pool_path,
20  class PoolProjectManagerAppWindow *aw);
21 
22  void refresh_list(const class PoolCacheStatus &status);
23  void select_items(const ItemSet &items);
24 
25 private:
26  void selection_changed();
27  void update_from_pool();
28  void cleanup();
29 
30  std::string cache_path;
31  std::string base_path;
32 
33  Pool pool;
34  class PoolProjectManagerAppWindow *appwin;
35 
36  Gtk::TreeView *pool_item_view = nullptr;
37  Gtk::Stack *stack = nullptr;
38  Gtk::TextView *delta_text_view = nullptr;
39  Gtk::Button *update_from_pool_button = nullptr;
40  Gtk::Label *status_label = nullptr;
41 
42  class TreeColumns : public Gtk::TreeModelColumnRecord {
43  public:
44  TreeColumns()
45  {
46  Gtk::TreeModelColumnRecord::add(name);
47  Gtk::TreeModelColumnRecord::add(type);
48  Gtk::TreeModelColumnRecord::add(uuid);
49  Gtk::TreeModelColumnRecord::add(state);
50  Gtk::TreeModelColumnRecord::add(delta);
51  Gtk::TreeModelColumnRecord::add(filename_cached);
52  }
53  Gtk::TreeModelColumn<Glib::ustring> name;
54  Gtk::TreeModelColumn<std::string> filename_cached;
55  Gtk::TreeModelColumn<ObjectType> type;
56  Gtk::TreeModelColumn<UUID> uuid;
57  Gtk::TreeModelColumn<PoolCacheStatus::Item::State> state;
58  Gtk::TreeModelColumn<json> delta;
59  };
60  TreeColumns tree_columns;
61 
62  Glib::RefPtr<Gtk::ListStore> item_store;
63 };
64 } // namespace horizon
horizon::PoolCacheStatus
Definition: pool_cache_status.hpp:11
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:23
horizon::PoolCacheWindow
Definition: pool_cache_window.hpp:15
horizon::PoolProjectManagerAppWindow
Definition: pool-prj-mgr-app_win.hpp:21