aboutsummaryrefslogtreecommitdiff
path: root/src/menu.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-03-09 21:08:47 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-03-09 21:08:47 -0500
commit3f4d409f21bbb1f79f149a5ee66dcddaa505ddb1 (patch)
treeab1f4ba4e7635b3ea2cb600cc8de9b3e52a6c9d1 /src/menu.cpp
parent375277fa6b2c8eaac2e2a824bd1e43bbd54b75e3 (diff)
downloadayatana-indicator-datetime-3f4d409f21bbb1f79f149a5ee66dcddaa505ddb1.tar.gz
ayatana-indicator-datetime-3f4d409f21bbb1f79f149a5ee66dcddaa505ddb1.tar.bz2
ayatana-indicator-datetime-3f4d409f21bbb1f79f149a5ee66dcddaa505ddb1.zip
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).
Diffstat (limited to 'src/menu.cpp')
-rw-r--r--src/menu.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/menu.cpp b/src/menu.cpp
index 797757f..d6abd27 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -104,7 +104,7 @@ protected:
m_state->settings->show_events.changed().connect([this](bool){
update_section(Appointments); // showing events got toggled
});
- m_state->planner->upcoming.changed().connect([this](const std::vector<Appointment>&){
+ m_state->calendar_upcoming->appointments().changed().connect([this](const std::vector<Appointment>&){
update_upcoming(); // our m_upcoming is planner->upcoming() filtered by time
});
m_state->clock->date_changed.connect([this](){
@@ -138,12 +138,18 @@ protected:
void update_upcoming()
{
+ // show upcoming appointments that occur after "calendar_next_minute",
+ // where that is the wallclock time on the specified calendar day
+ const auto calendar_day = m_state->calendar_month->month().get();
const auto now = m_state->clock->localtime();
- const auto next_minute = now.add_full(0,0,0,0,1,-now.seconds());
+ int y, m, d;
+ calendar_day.ymd(y, m, d);
+ const auto calendar_now = DateTime::Local(y, m, d, now.hour(), now.minute(), now.seconds());
+ const auto calendar_next_minute = calendar_now.add_full(0, 0, 0, 0, 1, -now.seconds());
std::vector<Appointment> upcoming;
- for(const auto& a : m_state->planner->upcoming.get())
- if (next_minute <= a.begin)
+ for(const auto& a : m_state->calendar_upcoming->appointments().get())
+ if (calendar_next_minute <= a.begin)
upcoming.push_back(a);
if (m_upcoming != upcoming)