Horizon
pool_merge_dialog.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include "common/common.hpp"
4 #include "util/uuid.hpp"
5 #include "nlohmann/json_fwd.hpp"
6 
7 namespace horizon {
8 using json = nlohmann::json;
9 
10 class PoolMergeDialog : public Gtk::Dialog {
11 public:
12  PoolMergeDialog(Gtk::Window *parent, const std::string &local_path, const std::string &remote_path);
13  bool get_merged() const;
14 
15 
16 private:
17  std::string local_path;
18  std::string remote_path;
19  class PoolMergeBox *box = nullptr;
20  void do_merge();
21  void populate_store();
22  void selection_changed();
23  void action_toggled(const Glib::ustring &path);
24 
25  enum class ItemState {
26  CURRENT,
27  LOCAL_ONLY,
28  REMOTE_ONLY,
29  MOVED,
30  CHANGED,
31  MOVED_CHANGED,
32  };
33 
34  class TreeColumns : public Gtk::TreeModelColumnRecord {
35  public:
36  TreeColumns()
37  {
38  Gtk::TreeModelColumnRecord::add(name);
39  Gtk::TreeModelColumnRecord::add(type);
40  Gtk::TreeModelColumnRecord::add(uuid);
41  Gtk::TreeModelColumnRecord::add(delta);
42  Gtk::TreeModelColumnRecord::add(filename_local);
43  Gtk::TreeModelColumnRecord::add(filename_remote);
44  Gtk::TreeModelColumnRecord::add(merge);
45  Gtk::TreeModelColumnRecord::add(state);
46  }
47  Gtk::TreeModelColumn<Glib::ustring> name;
48  Gtk::TreeModelColumn<std::string> filename_local;
49  Gtk::TreeModelColumn<std::string> filename_remote;
50  Gtk::TreeModelColumn<ObjectType> type;
51  Gtk::TreeModelColumn<UUID> uuid;
52  Gtk::TreeModelColumn<json> delta;
53  Gtk::TreeModelColumn<bool> merge;
54  Gtk::TreeModelColumn<ItemState> state;
55  };
56  TreeColumns list_columns;
57 
58  Glib::RefPtr<Gtk::ListStore> item_store;
59  bool merged = false;
60 
61  std::string tables_remote, tables_local;
62  std::string layer_help_remote, layer_help_local;
63 
64  enum class MenuOP { CHECK, UNCHECK, TOGGLE };
65  void append_context_menu_item(const std::string &name, MenuOP op);
66 };
67 } // namespace horizon
horizon::PoolMergeBox
Definition: pool_merge_dialog.cpp:15
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::PoolMergeDialog
Definition: pool_merge_dialog.hpp:10