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