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