From 3f4d409f21bbb1f79f149a5ee66dcddaa505ddb1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 9 Mar 2014 21:08:47 -0500 Subject: decouple the planner's states; need three separate sets: upcoming-now (for alarms in the current time), upcoming-calendar (to show events coming from the selected calendar date), and calendar-month (all the appointments in the month displayed in the menu). --- src/clock-watcher.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/clock-watcher.cpp') diff --git a/src/clock-watcher.cpp b/src/clock-watcher.cpp index a2e700d..5da66c8 100644 --- a/src/clock-watcher.cpp +++ b/src/clock-watcher.cpp @@ -27,17 +27,27 @@ namespace datetime { **** ***/ -ClockWatcherImpl::ClockWatcherImpl(const std::shared_ptr& state): - m_state(state) +ClockWatcherImpl::ClockWatcherImpl(const std::shared_ptr& clock, + const std::shared_ptr& upcoming_planner): + m_clock(clock), + m_upcoming_planner(upcoming_planner) { - m_state->planner->upcoming.changed().connect([this](const std::vector&){ - g_debug("ClockWatcher pulse because upcoming appointments changed"); + m_clock->date_changed.connect([this](){ + const auto now = m_clock->localtime(); + g_debug("ClockWatcher %p refretching appointments due to date change: %s", this, now.format("%F %T").c_str()); + m_upcoming_planner->date().set(now); + }); + + m_clock->minute_changed.connect([this](){ + g_debug("ClockWatcher %p calling pulse() due to clock minute_changed", this); pulse(); }); - m_state->clock->minute_changed.connect([this](){ - g_debug("ClockWatcher pulse because clock minute_changed"); + + m_upcoming_planner->appointments().changed().connect([this](const std::vector&){ + g_debug("ClockWatcher %p calling pulse() due to appointments changed", this); pulse(); }); + pulse(); } @@ -48,9 +58,9 @@ core::Signal& ClockWatcherImpl::alarm_reached() void ClockWatcherImpl::pulse() { - const auto now = m_state->clock->localtime(); + const auto now = m_clock->localtime(); - for(const auto& appointment : m_state->planner->upcoming.get()) + for(const auto& appointment : m_upcoming_planner->appointments().get()) { if (m_triggered.count(appointment.uid)) continue; -- cgit v1.2.3