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-aggregate.h | 52 +++++++++++++++++++++++++++++++++ include/datetime/planner-snooze.h | 56 ++++++++++++++++++++++++++++++++++++ include/datetime/planner.h | 3 ++ 3 files changed, 111 insertions(+) create mode 100644 include/datetime/planner-aggregate.h create mode 100644 include/datetime/planner-snooze.h (limited to 'include') diff --git a/include/datetime/planner-aggregate.h b/include/datetime/planner-aggregate.h new file mode 100644 index 0000000..eeca9b7 --- /dev/null +++ b/include/datetime/planner-aggregate.h @@ -0,0 +1,52 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +#ifndef INDICATOR_DATETIME_PLANNER_AGGREGATE_H +#define INDICATOR_DATETIME_PLANNER_AGGREGATE_H + +#include + +#include + +namespace unity { +namespace indicator { +namespace datetime { + +/** + * \brief Aggregates one or more Planners + */ +class AggregatePlanner: public Planner +{ +public: + AggregatePlanner(); + virtual ~AggregatePlanner(); + void add(const std::shared_ptr&); + + core::Property>& appointments(); + +protected: + class Impl; + std::unique_ptr impl; +}; + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif // INDICATOR_DATETIME_PLANNER_AGGREGATE_H diff --git a/include/datetime/planner-snooze.h b/include/datetime/planner-snooze.h new file mode 100644 index 0000000..889c4f8 --- /dev/null +++ b/include/datetime/planner-snooze.h @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +#ifndef INDICATOR_DATETIME_PLANNER_SNOOZE_H +#define INDICATOR_DATETIME_PLANNER_SNOOZE_H + +#include +#include +#include + +#include + +namespace unity { +namespace indicator { +namespace datetime { + +/** + * A planner to hold 'Snooze' copies of other appointments + */ +class SnoozePlanner: public Planner +{ +public: + SnoozePlanner(const std::shared_ptr&, + const std::shared_ptr&); + ~SnoozePlanner(); + void add(const Appointment&); + + core::Property>& appointments(); + +protected: + class Impl; + friend class Impl; + std::unique_ptr impl; +}; + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif // INDICATOR_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 d3732ff1a0d149544f89d08fa489e4f0fca8da07 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 2 Sep 2014 10:37:03 -0500 Subject: add snooze properties to our schema; export it on the bus; add tests --- include/datetime/settings-live.h | 1 + include/datetime/settings-shared.h | 1 + include/datetime/settings.h | 1 + 3 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h index 4850e69..bb4cd8d 100644 --- a/include/datetime/settings-live.h +++ b/include/datetime/settings-live.h @@ -59,6 +59,7 @@ private: void update_alarm_volume(); void update_alarm_duration(); void update_alarm_haptic(); + void update_snooze_duration(); GSettings* m_settings; diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h index a211821..c18cfaf 100644 --- a/include/datetime/settings-shared.h +++ b/include/datetime/settings-shared.h @@ -49,5 +49,6 @@ TimeFormatMode; #define SETTINGS_ALARM_VOLUME_S "alarm-default-volume" #define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes" #define SETTINGS_ALARM_HAPTIC_S "alarm-haptic-feedback" +#define SETTINGS_SNOOZE_DURATION_S "snooze-duration-minutes" #endif // INDICATOR_DATETIME_SETTINGS_SHARED diff --git a/include/datetime/settings.h b/include/datetime/settings.h index c6fe13b..0294f60 100644 --- a/include/datetime/settings.h +++ b/include/datetime/settings.h @@ -60,6 +60,7 @@ public: core::Property alarm_haptic; core::Property alarm_volume; core::Property alarm_duration; + core::Property snooze_duration; }; } // 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 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') 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); }; -- cgit v1.2.3 From 000f91caf98706d21868e0b41e42388ef68fc9e5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 2 Sep 2014 11:16:01 -0500 Subject: update Snap Decisions to include snooze --- include/datetime/snap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/datetime/snap.h b/include/datetime/snap.h index ef5c868..572158d 100644 --- a/include/datetime/snap.h +++ b/include/datetime/snap.h @@ -44,8 +44,8 @@ public: typedef std::function appointment_func; void operator()(const Appointment& appointment, - appointment_func show, - appointment_func dismiss); + appointment_func snooze, + appointment_func ok); private: class Impl; -- cgit v1.2.3 From a209741aaf8d0ece778e1e2b9e5a8d1632339ad2 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 2 Sep 2014 23:37:02 -0500 Subject: use the 'override' keyword in the new planner class declarations --- include/datetime/planner-aggregate.h | 2 +- include/datetime/planner-snooze.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/datetime/planner-aggregate.h b/include/datetime/planner-aggregate.h index eeca9b7..892e71a 100644 --- a/include/datetime/planner-aggregate.h +++ b/include/datetime/planner-aggregate.h @@ -38,7 +38,7 @@ public: virtual ~AggregatePlanner(); void add(const std::shared_ptr&); - core::Property>& appointments(); + core::Property>& appointments() override; protected: class Impl; diff --git a/include/datetime/planner-snooze.h b/include/datetime/planner-snooze.h index 889c4f8..e2619fa 100644 --- a/include/datetime/planner-snooze.h +++ b/include/datetime/planner-snooze.h @@ -41,7 +41,7 @@ public: ~SnoozePlanner(); void add(const Appointment&); - core::Property>& appointments(); + core::Property>& appointments() override; protected: class Impl; -- 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 - 1 file changed, 1 deletion(-) (limited to 'include') 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 -- cgit v1.2.3