summaryrefslogtreecommitdiff
path: root/app/src/windows/tracker.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2024-07-18 15:13:12 +0200
committerFelix Morgner <felix.morgner@gmail.com>2024-07-18 15:13:19 +0200
commit5f4249a37ce816b8deceb299bc841190fbb15983 (patch)
tree96c22776b0274060820ce8e4f8b67aee08f8818c /app/src/windows/tracker.cpp
parent2a0b265c4350cb332f3151fa1c2881609db96d5f (diff)
downloadturns-5f4249a37ce816b8deceb299bc841190fbb15983.tar.xz
turns-5f4249a37ce816b8deceb299bc841190fbb15983.zip
app: move model back to tracker window
Diffstat (limited to 'app/src/windows/tracker.cpp')
-rw-r--r--app/src/windows/tracker.cpp55
1 files changed, 24 insertions, 31 deletions
diff --git a/app/src/windows/tracker.cpp b/app/src/windows/tracker.cpp
index 0fb508d..b7520dd 100644
--- a/app/src/windows/tracker.cpp
+++ b/app/src/windows/tracker.cpp
@@ -42,29 +42,28 @@ namespace turns::app::windows
, m_stack{builder->get_widget<Gtk::Stack>("stack")}
, m_start{builder->get_widget<Gtk::Button>("start")}
, m_title(ADW_WINDOW_TITLE(builder->get_widget<Gtk::Widget>("title")->gobj()))
- , m_turn_order{Gtk::make_managed<widgets::turn_order_view>()}
+ , m_turn_order{domain::turn_order::create()}
+ , m_turn_order_view{Gtk::make_managed<widgets::turn_order_view>(m_turn_order)}
, m_subtitle{Glib::wrap(GTK_WIDGET(m_title)), "subtitle"}
{
setup_actions();
- m_stack->add(*m_turn_order);
+ m_stack->add(*m_turn_order_view);
- Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
+ // clang-format off
+ Glib::Binding::bind_property(m_turn_order->property_empty(),
m_stack->property_visible_child(),
Glib::Binding::Flags::SYNC_CREATE,
- [this](auto empty) { return empty ? m_empty : m_turn_order; });
+ [this](auto empty) { return empty ? m_empty : m_turn_order_view; });
- Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ Glib::Binding::bind_property(m_turn_order->property_running(),
m_controls->property_reveal_child(),
Glib::Binding::Flags::SYNC_CREATE);
- // clang-format off
- Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
+ Glib::Binding::bind_property(m_turn_order->property_empty(),
m_subtitle,
Glib::Binding::Flags::SYNC_CREATE,
- [](auto empty) {
- return empty ? _(lang::no_active_turn_order) : "";
- });
+ [](auto empty) { return empty ? _(lang::no_active_turn_order) : ""; });
// clang-format on
}
@@ -72,20 +71,20 @@ namespace turns::app::windows
{
auto [lifeline, dialog] = editor_for(nullptr);
dialog->present(this);
- dialog->signal_finished().connect([this](auto n, auto p, auto d) { m_turn_order->get_model()->add(n, p, d); });
+ dialog->signal_finished().connect([this](auto n, auto p, auto d) { m_turn_order->add(n, p, d); });
}
auto tracker::handle_delete_participant(Glib::VariantBase param) -> void
{
auto index = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(param);
- m_turn_order->get_model()->remove(index.get());
+ m_turn_order->remove(index.get());
}
auto tracker::handle_edit_participant(Glib::VariantBase param) -> void
{
static_cast<void>(param);
auto index = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(param);
- auto participant = m_turn_order->get_model()->get(index.get());
+ auto participant = m_turn_order->get(index.get());
auto [lifeline, dialog] = editor_for(participant);
dialog->present(this);
}
@@ -103,7 +102,7 @@ namespace turns::app::windows
GTK_WIDGET(this->gobj()),
NULL,
reinterpret_cast<GAsyncReadyCallback>(stop_dialog_callback),
- m_turn_order->get_model().get());
+ m_turn_order.get());
}
auto tracker::setup_actions() -> void
@@ -113,7 +112,7 @@ namespace turns::app::windows
{
auto action = add_action("add_participant", sigc::mem_fun(*this, &tracker::handle_add_participant));
- Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ Glib::Binding::bind_property(m_turn_order->property_running(),
action->property_enabled(),
Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
}
@@ -121,9 +120,9 @@ namespace turns::app::windows
// win.clear
// depends-on: turn_order:empty == false
{
- auto action = add_action("clear", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::clear));
+ auto action = add_action("clear", sigc::mem_fun(*m_turn_order, &domain::turn_order::clear));
- Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
+ Glib::Binding::bind_property(m_turn_order->property_empty(),
action->property_enabled(),
Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
}
@@ -131,33 +130,29 @@ namespace turns::app::windows
// win.next
// depends-on: turn_order:state == running
{
- auto action = add_action("next", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::next));
+ auto action = add_action("next", sigc::mem_fun(*m_turn_order, &domain::turn_order::next));
- Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
- action->property_enabled(),
- Glib::Binding::Flags::SYNC_CREATE);
+ Glib::Binding::bind_property(m_turn_order->property_running(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE);
}
// win.previous
// depends-on: turn_order:has_previous == true
{
- auto action = add_action("previous", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::previous));
+ auto action = add_action("previous", sigc::mem_fun(*m_turn_order, &domain::turn_order::previous));
- Glib::Binding::bind_property(m_turn_order->get_model()->property_has_previous(),
- action->property_enabled(),
- Glib::Binding::Flags::SYNC_CREATE);
+ Glib::Binding::bind_property(m_turn_order->property_has_previous(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE);
}
// win.start
// depends-on: turn_order:empty == false
{
- auto action = add_action("start", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::start));
+ auto action = add_action("start", sigc::mem_fun(*m_turn_order, &domain::turn_order::start));
- Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
+ Glib::Binding::bind_property(m_turn_order->property_empty(),
action->property_enabled(),
Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
- Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ Glib::Binding::bind_property(m_turn_order->property_running(),
m_start->property_visible(),
Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
}
@@ -167,9 +162,7 @@ namespace turns::app::windows
{
auto action = add_action("stop", sigc::mem_fun(*this, &tracker::handle_stop));
- Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
- action->property_enabled(),
- Glib::Binding::Flags::SYNC_CREATE);
+ Glib::Binding::bind_property(m_turn_order->property_running(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE);
}
// win.delete