aboutsummaryrefslogtreecommitdiff
path: root/src/menu.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-03-14 17:37:00 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-03-14 17:37:00 +0000
commit9f3136ba1c79020c10e58fa53e87a84bcce7dc29 (patch)
treefa0c19e8e5c7f362b7a04f0ad3e6f57d96c1462c /src/menu.cpp
parent39d8fc602053397a3596d6d35afb5738b09b05a6 (diff)
parent35b0a3601f1d7d9f757467ffc7b909c461c2f49d (diff)
downloadayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.tar.gz
ayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.tar.bz2
ayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.zip
When the user clicks on a date in the calendar, update the "Upcoming Events" section to show events starting at that date. Fixes: 1290169, 1290171, 1291468
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)