aboutsummaryrefslogtreecommitdiff
path: root/include/datetime
diff options
context:
space:
mode:
Diffstat (limited to 'include/datetime')
-rw-r--r--include/datetime/actions-live.h2
-rw-r--r--include/datetime/actions.h4
-rw-r--r--include/datetime/appointment.h12
-rw-r--r--include/datetime/clock-mock.h4
-rw-r--r--include/datetime/clock.h12
-rw-r--r--include/datetime/date-time.h6
-rw-r--r--include/datetime/exporter.h4
-rw-r--r--include/datetime/formatter.h20
-rw-r--r--include/datetime/locations-settings.h8
-rw-r--r--include/datetime/locations.h14
-rw-r--r--include/datetime/menu.h13
-rw-r--r--include/datetime/planner.h6
-rw-r--r--include/datetime/state-live.h49
-rw-r--r--include/datetime/timezone-file.h6
-rw-r--r--include/datetime/timezone.h1
-rw-r--r--include/datetime/timezones-live.h4
16 files changed, 48 insertions, 117 deletions
diff --git a/include/datetime/actions-live.h b/include/datetime/actions-live.h
index 949222d..3607836 100644
--- a/include/datetime/actions-live.h
+++ b/include/datetime/actions-live.h
@@ -36,7 +36,7 @@ namespace datetime {
class LiveActions: public Actions
{
public:
- LiveActions(const std::shared_ptr<State>& state_in): Actions(state_in) {}
+ LiveActions(const std::shared_ptr<State>& state_in);
~LiveActions() =default;
void open_desktop_settings();
diff --git a/include/datetime/actions.h b/include/datetime/actions.h
index 3686b95..99e78f5 100644
--- a/include/datetime/actions.h
+++ b/include/datetime/actions.h
@@ -50,8 +50,8 @@ public:
virtual void open_appointment(const std::string& uid) =0;
virtual void set_location(const std::string& zone, const std::string& name)=0;
void set_calendar_date(const DateTime&);
- GActionGroup* action_group() { return G_ACTION_GROUP(m_actions); }
- std::shared_ptr<State> state() { return m_state; }
+ GActionGroup* action_group();
+ const std::shared_ptr<State> state() const;
protected:
Actions(const std::shared_ptr<State>& state);
diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h
index e034c08..a5283c9 100644
--- a/include/datetime/appointment.h
+++ b/include/datetime/appointment.h
@@ -45,17 +45,7 @@ public:
DateTime begin;
DateTime end;
- bool operator== (const Appointment& that) const
- {
- return (color==that.color) &&
- (summary==that.summary) &&
- (url==that.url) &&
- (uid==that.uid) &&
- (is_event==that.is_event) &&
- (has_alarms==that.has_alarms) &&
- (begin==that.begin) &&
- (end==that.end);
- }
+ bool operator== (const Appointment& that) const;
};
} // namespace datetime
diff --git a/include/datetime/clock-mock.h b/include/datetime/clock-mock.h
index 27926ff..fb9b52f 100644
--- a/include/datetime/clock-mock.h
+++ b/include/datetime/clock-mock.h
@@ -45,9 +45,9 @@ public:
const auto old = m_localtime;
m_localtime = dt;
if (!DateTime::is_same_minute(old, m_localtime))
- minuteChanged();
+ minute_changed();
if (!DateTime::is_same_day(old, m_localtime))
- dateChanged();
+ date_changed();
}
private:
diff --git a/include/datetime/clock.h b/include/datetime/clock.h
index b3e3538..1d488d1 100644
--- a/include/datetime/clock.h
+++ b/include/datetime/clock.h
@@ -43,20 +43,20 @@ public:
virtual DateTime localtime() const =0;
/** \brief A signal which fires when the clock's minute changes */
- core::Signal<> minuteChanged;
+ core::Signal<> minute_changed;
/** \brief A signal which fires when the clock's date changes */
- core::Signal<> dateChanged;
+ core::Signal<> date_changed;
protected:
Clock();
- /** \brief Compares old and new times, emits minuteChanged() or dateChanged() signals if appropriate */
+ /** \brief Compares old and new times, emits minute_changed() or date_changed() signals if appropriate */
void maybe_emit (const DateTime& a, const DateTime& b);
private:
- static void onSystemBusReady(GObject*, GAsyncResult*, gpointer);
- static void onPrepareForSleep(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer);
+ static void on_system_bus_ready(GObject*, GAsyncResult*, gpointer);
+ static void on_prepare_for_sleep(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer);
GCancellable * m_cancellable = nullptr;
GDBusConnection * m_system_bus = nullptr;
@@ -79,7 +79,7 @@ class Timezones;
class LiveClock: public Clock
{
public:
- LiveClock (const std::shared_ptr<Timezones>& zones);
+ LiveClock (const std::shared_ptr<const Timezones>& zones);
virtual ~LiveClock();
virtual DateTime localtime() const;
diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h
index c2429eb..2ad7856 100644
--- a/include/datetime/date-time.h
+++ b/include/datetime/date-time.h
@@ -37,9 +37,9 @@ class DateTime
public:
static DateTime NowLocal();
explicit DateTime(time_t t);
- explicit DateTime(GDateTime* in=nullptr) {reset(in);}
- DateTime& operator=(GDateTime* in) {reset(in); return *this;}
- DateTime& operator=(const DateTime& in) {m_dt=in.m_dt; return *this; }
+ explicit DateTime(GDateTime* in=nullptr);
+ DateTime& operator=(GDateTime* in);
+ DateTime& operator=(const DateTime& in);
DateTime to_timezone(const std::string& zone) const;
void reset(GDateTime* in=nullptr);
diff --git a/include/datetime/exporter.h b/include/datetime/exporter.h
index a32b941..c228cc1 100644
--- a/include/datetime/exporter.h
+++ b/include/datetime/exporter.h
@@ -45,8 +45,8 @@ public:
core::Signal<> name_lost;
- void publish(std::shared_ptr<Actions>& actions,
- std::vector<std::shared_ptr<Menu>>& menus);
+ void publish(const std::shared_ptr<Actions>& actions,
+ const std::vector<std::shared_ptr<Menu>>& menus);
private:
static void on_bus_acquired(GDBusConnection*, const gchar *name, gpointer gthis);
diff --git a/include/datetime/formatter.h b/include/datetime/formatter.h
index 3de109e..0d695e2 100644
--- a/include/datetime/formatter.h
+++ b/include/datetime/formatter.h
@@ -69,27 +69,27 @@ class Formatter
public:
/** \brief The time format string for the menu header */
- core::Property<std::string> headerFormat;
+ core::Property<std::string> header_format;
- /** \brief The time string for the menu header. (eg, the headerFormat + the clock's time */
+ /** \brief The time string for the menu header. (eg, the header_format + the clock's time */
core::Property<std::string> header;
/** \brief Signal to denote when the relativeFormat has changed.
When this is emitted, clients will want to rebuild their
menuitems that contain relative time strings
(ie, the Appointments and Locations menuitems) */
- core::Signal<> relativeFormatChanged;
+ core::Signal<> relative_format_changed;
/** \brief Generate a relative time format for some time (or time range)
from the current clock's value. For example, a full-day interval
starting at the end of the current clock's day yields "Tomorrow" */
- std::string getRelativeFormat(GDateTime* then, GDateTime* then_end=nullptr) const;
+ std::string relative_format(GDateTime* then, GDateTime* then_end=nullptr) const;
protected:
- Formatter(const std::shared_ptr<Clock>&);
+ Formatter(const std::shared_ptr<const Clock>&);
virtual ~Formatter();
- static const char* getDefaultHeaderTimeFormat(bool twelvehour, bool show_seconds);
+ static const char* default_header_time_format(bool twelvehour, bool show_seconds);
private:
@@ -107,10 +107,10 @@ private:
class DesktopFormatter: public Formatter
{
public:
- DesktopFormatter(const std::shared_ptr<Clock>&, const std::shared_ptr<Settings>&);
+ DesktopFormatter(const std::shared_ptr<const Clock>&, const std::shared_ptr<const Settings>&);
private:
- std::shared_ptr<Settings> m_settings;
+ std::shared_ptr<const Settings> m_settings;
void rebuildHeaderFormat();
const gchar* getFullTimeFormatString() const;
@@ -126,8 +126,8 @@ private:
class PhoneFormatter: public Formatter
{
public:
- PhoneFormatter(const std::shared_ptr<Clock>& clock): Formatter(clock) {
- headerFormat.set(getDefaultHeaderTimeFormat(is_locale_12h(), false));
+ PhoneFormatter(const std::shared_ptr<const Clock>& clock): Formatter(clock) {
+ header_format.set(default_header_time_format(is_locale_12h(), false));
}
};
diff --git a/include/datetime/locations-settings.h b/include/datetime/locations-settings.h
index d01cbb5..8757f43 100644
--- a/include/datetime/locations-settings.h
+++ b/include/datetime/locations-settings.h
@@ -39,12 +39,12 @@ public:
* @param[in] settings the #Settings whose locations property is to be used
* @param[in] timezones the #Timezones to always show first in the list
*/
- SettingsLocations (const std::shared_ptr<Settings>& settings,
- const std::shared_ptr<Timezones>& timezones);
+ SettingsLocations (const std::shared_ptr<const Settings>& settings,
+ const std::shared_ptr<const Timezones>& timezones);
private:
- std::shared_ptr<Settings> m_settings;
- std::shared_ptr<Timezones> m_timezones;
+ std::shared_ptr<const Settings> m_settings;
+ std::shared_ptr<const Timezones> m_timezones;
void reload();
};
diff --git a/include/datetime/locations.h b/include/datetime/locations.h
index ee67615..b840436 100644
--- a/include/datetime/locations.h
+++ b/include/datetime/locations.h
@@ -39,18 +39,10 @@ namespace datetime {
class Location
{
public:
- const std::string& zone() const { return m_zone; }
-
- const std::string& name() const { return m_name; }
-
- bool operator== (const Location& that) const
- {
- return (name() == that.name()) &&
- (zone() == that.zone()) &&
- (m_offset == that.m_offset);
- }
-
Location (const std::string& zone, const std::string& name);
+ const std::string& zone() const;
+ const std::string& name() const;
+ bool operator== (const Location& that) const;
private:
diff --git a/include/datetime/menu.h b/include/datetime/menu.h
index fcd709f..7b351c3 100644
--- a/include/datetime/menu.h
+++ b/include/datetime/menu.h
@@ -43,12 +43,12 @@ class Menu
public:
enum Profile { Desktop, DesktopGreeter, Phone, PhoneGreeter, NUM_PROFILES };
enum Section { Calendar, Appointments, Locations, Settings, NUM_SECTIONS };
- const std::string& name() const { return m_name; }
- Profile profile() const { return m_profile; }
- GMenuModel* menu_model() { return G_MENU_MODEL(m_menu); }
+ const std::string& name() const;
+ Profile profile() const;
+ GMenuModel* menu_model();
protected:
- Menu (Profile profile_in, const std::string& name_in): m_profile(profile_in), m_name(name_in) {}
+ Menu (Profile profile_in, const std::string& name_in);
virtual ~Menu() =default;
GMenu* m_menu = nullptr;
@@ -70,13 +70,12 @@ private:
class MenuFactory
{
public:
- MenuFactory (std::shared_ptr<Actions>& actions, std::shared_ptr<State>& state);
+ MenuFactory (const std::shared_ptr<Actions>& actions, const std::shared_ptr<const State>& state);
std::shared_ptr<Menu> buildMenu(Menu::Profile profile);
- std::shared_ptr<State> state() { return m_state; }
private:
std::shared_ptr<Actions> m_actions;
- std::shared_ptr<State> m_state;
+ std::shared_ptr<const State> m_state;
};
} // namespace datetime
diff --git a/include/datetime/planner.h b/include/datetime/planner.h
index a8f9941..376a31f 100644
--- a/include/datetime/planner.h
+++ b/include/datetime/planner.h
@@ -43,9 +43,9 @@ public:
virtual ~Planner() =default;
/**
- * \brief Timestamp used to determine the appointments in the `upcoming' and `thisMonth' properties.
+ * \brief Timestamp used to determine the appointments in the `upcoming' and `this_month' properties.
* Setting this value will cause the planner to re-query its backend and
- * update the `upcoming' and `thisMonth' properties.
+ * update the `upcoming' and `this_month' properties.
*/
core::Property<DateTime> time;
@@ -57,7 +57,7 @@ public:
/**
* \brief The appointments that occur in the same month as the time property
*/
- core::Property<std::vector<Appointment>> thisMonth;
+ core::Property<std::vector<Appointment>> this_month;
protected:
Planner() =default;
diff --git a/include/datetime/state-live.h b/include/datetime/state-live.h
deleted file mode 100644
index 2b93722..0000000
--- a/include/datetime/state-live.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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 <http://www.gnu.org/licenses/>.
- *
- * Authors:
- * Charles Kerr <charles.kerr@canonical.com>
- */
-
-#ifndef INDICATOR_DATETIME_STATE_LIVE_H
-#define INDICATOR_DATETIME_STATE_LIVE_H
-
-#include <datetime/state.h>
-
-namespace unity {
-namespace indicator {
-namespace datetime {
-
-/***
-****
-***/
-
-class LiveState: public State
-{
-public:
- LiveState();
- virtual ~LiveState() =default;
-};
-
-/***
-****
-***/
-
-
-} // namespace datetime
-} // namespace indicator
-} // namespace unity
-
-#endif // INDICATOR_DATETIME_SETTINGS_LIVE_H
diff --git a/include/datetime/timezone-file.h b/include/datetime/timezone-file.h
index 7f47df6..d77aaae 100644
--- a/include/datetime/timezone-file.h
+++ b/include/datetime/timezone-file.h
@@ -37,9 +37,9 @@ namespace datetime {
class FileTimezone: public Timezone
{
public:
- FileTimezone() {}
- FileTimezone(const std::string& filename) { setFilename(filename); }
- ~FileTimezone() {clear();}
+ FileTimezone();
+ FileTimezone(const std::string& filename);
+ ~FileTimezone();
private:
void setFilename(const std::string& filename);
diff --git a/include/datetime/timezone.h b/include/datetime/timezone.h
index ffa5a84..7d2ace8 100644
--- a/include/datetime/timezone.h
+++ b/include/datetime/timezone.h
@@ -35,7 +35,6 @@ protected:
Timezone() =default;
public:
- //virtual ~Timezone() {}
core::Property<std::string> timezone;
};
diff --git a/include/datetime/timezones-live.h b/include/datetime/timezones-live.h
index 286c967..ca4ef31 100644
--- a/include/datetime/timezones-live.h
+++ b/include/datetime/timezones-live.h
@@ -38,14 +38,14 @@ namespace datetime {
class LiveTimezones: public Timezones
{
public:
- LiveTimezones(std::shared_ptr<Settings>& settings, const std::string& filename);
+ LiveTimezones(const std::shared_ptr<const Settings>& settings, const std::string& filename);
private:
void update_geolocation();
void update_timezones();
FileTimezone m_file;
- std::shared_ptr<Settings> m_settings;
+ std::shared_ptr<const Settings> m_settings;
std::shared_ptr<GeoclueTimezone> m_geo;
};