From 15a383a7b027d281dcdaa85a43eb3563031366bf Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 2 Sep 2014 10:35:27 -0500 Subject: add SnoozePlanner, AggregatePlanner --- include/datetime/planner.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/datetime/planner.h') diff --git a/include/datetime/planner.h b/include/datetime/planner.h index e6ef927..43991ec 100644 --- a/include/datetime/planner.h +++ b/include/datetime/planner.h @@ -38,10 +38,13 @@ class Planner { public: virtual ~Planner() =default; + virtual core::Property>& appointments() =0; protected: Planner() =default; + static void sort(std::vector&); + static void trim(std::vector&, const DateTime& begin, const DateTime& end); }; } // namespace datetime -- cgit v1.2.3 From 63493709a92c76169ad065cc3804b13dbd786537 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 2 Sep 2014 11:15:58 -0500 Subject: add planner.cpp to the build --- include/datetime/planner.h | 5 ++--- src/CMakeLists.txt | 1 + src/planner.cpp | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'include/datetime/planner.h') diff --git a/include/datetime/planner.h b/include/datetime/planner.h index 43991ec..55e72e7 100644 --- a/include/datetime/planner.h +++ b/include/datetime/planner.h @@ -37,12 +37,11 @@ namespace datetime { class Planner { public: - virtual ~Planner() =default; - + virtual ~Planner(); virtual core::Property>& appointments() =0; protected: - Planner() =default; + Planner(); static void sort(std::vector&); static void trim(std::vector&, const DateTime& begin, const DateTime& end); }; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2852a75..512cc5c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,7 @@ set (SERVICE_CXX_SOURCES locations-settings.cpp menu.cpp notifications.cpp + planner.cpp planner-aggregate.cpp planner-snooze.cpp planner-month.cpp diff --git a/src/planner.cpp b/src/planner.cpp index 3f73030..15dab52 100644 --- a/src/planner.cpp +++ b/src/planner.cpp @@ -19,6 +19,8 @@ #include +#include + namespace unity { namespace indicator { namespace datetime { @@ -35,6 +37,7 @@ Planner::~Planner() { } +#if 0 void Planner::set_range_to_calendar_month(const DateTime& dt) { @@ -59,6 +62,7 @@ Planner::set_range_to_upcoming_month(const DateTime& begin) end.format(fmt).c_str()); range().set(std::make_pair(begin,end)); } +#endif void Planner::sort(std::vector& appts) @@ -73,9 +77,9 @@ Planner::trim(std::vector& appts, const DateTime& begin, const DateTime& end) { - decltype(appts) tmp; - auto predicate = [begin,end](const Appointment& a){return begin<=a.begin && a.begin<=end;} - std::copy(std::begin(appts), std::end(appts), std::back_inserter(tmp), predicate); + std::vector tmp; + auto predicate = [begin,end](const Appointment& a){return begin<=a.begin && a.begin<=end;}; + std::copy_if(std::begin(appts), std::end(appts), std::back_inserter(tmp), predicate); appts.swap(tmp); } -- cgit v1.2.3 From db764f321a1450da886c672b3ccd82d1e5dfedd6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 2 Sep 2014 23:37:35 -0500 Subject: remove the new code that we're not using yet --- include/datetime/planner.h | 1 - src/planner.cpp | 38 -------------------------------------- 2 files changed, 39 deletions(-) (limited to 'include/datetime/planner.h') diff --git a/include/datetime/planner.h b/include/datetime/planner.h index 55e72e7..22b6381 100644 --- a/include/datetime/planner.h +++ b/include/datetime/planner.h @@ -43,7 +43,6 @@ public: protected: Planner(); static void sort(std::vector&); - static void trim(std::vector&, const DateTime& begin, const DateTime& end); }; } // namespace datetime diff --git a/src/planner.cpp b/src/planner.cpp index 15dab52..6ca9ca7 100644 --- a/src/planner.cpp +++ b/src/planner.cpp @@ -37,33 +37,6 @@ Planner::~Planner() { } -#if 0 -void -Planner::set_range_to_calendar_month(const DateTime& dt) -{ - // use appointments that occur in dt's calendar month - impl->set_range_to_upcoming_month(dt.add_full(0, // no years - 0, // no months - -(dt.day_of_month()-1), - -dt.hour(), - -dt.minute(), - -dt.seconds()); -} - -void -Planner::set_range_to_upcoming_month(const DateTime& begin) -{ - // use appointments that occur in [dt...dt+1month] - const auto end = begin.add_full(0, 1, 0, 0, 0, -0.1); - const char * fmt = "%F %T"; - g_debug("RangePlanner %p setting range [%s..%s]", - this, - begin.format(fmt).c_str(), - end.format(fmt).c_str()); - range().set(std::make_pair(begin,end)); -} -#endif - void Planner::sort(std::vector& appts) { @@ -72,17 +45,6 @@ Planner::sort(std::vector& appts) [](const Appointment& a, const Appointment& b){return a.begin < b.begin;}); } -void -Planner::trim(std::vector& appts, - const DateTime& begin, - const DateTime& end) -{ - std::vector tmp; - auto predicate = [begin,end](const Appointment& a){return begin<=a.begin && a.begin<=end;}; - std::copy_if(std::begin(appts), std::end(appts), std::back_inserter(tmp), predicate); - appts.swap(tmp); -} - /*** **** ***/ -- cgit v1.2.3