*/
#include <Model/WeekFlags.h>
+#include <Utils/Log.h>
using namespace model;
{
return raw_flags == 0;
}
+
+WeekDay WeekFlags::GetNextWeekDay(WeekDay day)
+{
+ switch (day)
+ {
+ case model::WeekDay::SUNDAY:
+ return model::WeekDay::MONDAY;
+ case model::WeekDay::MONDAY:
+ return model::WeekDay::TUESDAY;
+ case model::WeekDay::TUESDAY:
+ return model::WeekDay::WEDNESDAY;
+ case model::WeekDay::WEDNESDAY:
+ return model::WeekDay::THURSDAY;
+ case model::WeekDay::THURSDAY:
+ return model::WeekDay::FRIDAY;
+ case model::WeekDay::FRIDAY:
+ return model::WeekDay::SATURDAY;
+ case model::WeekDay::SATURDAY:
+ return model::WeekDay::SUNDAY;
+ default:
+ FAT("Invalid WeekDay");
+ return model::WeekDay::MONDAY;
+ }
+}
static char *WeekFlag2FormattedString(WeekFlags flags)
{
std::stringstream weekflags;
+ WeekDay day, first_day;
- weekflags << GetFormattedWeekDayAcronym(WeekDay::MONDAY, flags.IsOn(WeekDay::MONDAY));
- weekflags << GetFormattedWeekDayAcronym(WeekDay::TUESDAY, flags.IsOn(WeekDay::TUESDAY));
- weekflags << GetFormattedWeekDayAcronym(WeekDay::WEDNESDAY, flags.IsOn(WeekDay::WEDNESDAY));
- weekflags << GetFormattedWeekDayAcronym(WeekDay::THURSDAY, flags.IsOn(WeekDay::THURSDAY));
- weekflags << GetFormattedWeekDayAcronym(WeekDay::FRIDAY, flags.IsOn(WeekDay::FRIDAY));
- weekflags << GetFormattedWeekDayAcronym(WeekDay::SATURDAY, flags.IsOn(WeekDay::SATURDAY));
- weekflags << GetFormattedWeekDayAcronym(WeekDay::SUNDAY, flags.IsOn(WeekDay::SUNDAY));
+ day = first_day = SystemSettings::GetFirstDayOfWeek();
+
+ do
+ {
+ weekflags << GetFormattedWeekDayAcronym(day, flags.IsOn(day));
+ day = WeekFlags::GetNextWeekDay(day);
+ }
+ while (day != first_day);
return strdup(weekflags.str().c_str());
}
AlarmListView::MoreButtonClicked, this);
time_format_change_listener_ = EventBus::AddListener<SystemSettings::TimeFormatChanged>(
- std::bind(&AlarmListView::TimeFormatChanged, this));
+ std::bind(&AlarmListView::UpdateList, this));
+ language_change_listener_ = EventBus::AddListener<SystemSettings::LanguageChanged>(
+ std::bind(&AlarmListView::UpdateList, this));
CreateNoContentLayout(content_);
}
-void AlarmListView::TimeFormatChanged()
+void AlarmListView::UpdateList()
{
elm_genlist_realized_items_update(genlist_);
}
#include <Elementary.h>
#include "Utils/Log.h"
+#include "Utils/SystemSettings.h"
using namespace view;
using namespace utils;
WeekFlagsView::WeekFlagsView(view::MainView &main, WeekFlags &flags)
: PageView(main), flags_(flags)
{
+ language_change_listener_ = EventBus::AddListener<SystemSettings::LanguageChanged>(
+ std::bind(&WeekFlagsView::UpdateList, this));
}
Evas_Object *WeekFlagsView::GetEvasObject()
desc->context->CheckBoxStatusUpdate();
}
-void WeekFlagsView::AppendCheckableListItem(const char *msgid, WeekDay val)
+void WeekFlagsView::AppendCheckableListItem(WeekDay val)
{
CheckBoxDesc *desc = new CheckBoxDesc;
Elm_Object_Item *it;
elm_check_state_set(desc->check, flags_.IsOn(val));
it = elm_list_item_append(list_, NULL, NULL, desc->check,
WeekFlagsView::ItemSelectedCallback, desc);
- elm_object_item_translatable_text_set(it, msgid);
+ elm_object_item_translatable_text_set(it, GetLabelForWeekDay(val));
elm_atspi_accessible_relationship_append(desc->check, ELM_ATSPI_RELATION_CONTROLLED_BY, it);
elm_atspi_accessible_relationship_append(desc->check, ELM_ATSPI_RELATION_DESCRIPTION_FOR, it);
elm_atspi_accessible_relationship_append(it, ELM_ATSPI_RELATION_DESCRIBED_BY, desc->check);
}
+const char *WeekFlagsView::GetLabelForWeekDay(WeekDay day)
+{
+ switch (day)
+ {
+ case WeekDay::ALL_WEEK:
+ return "IDS_ALM_BODY_EVERYDAY";
+ case WeekDay::MONDAY:
+ return "IDS_CLOCK_OPT_EVERY_MONDAY";
+ case WeekDay::TUESDAY:
+ return "IDS_CLOCK_OPT_EVERY_TUESDAY";
+ case WeekDay::WEDNESDAY:
+ return "IDS_CLOCK_OPT_EVERY_WEDNESDAY";
+ case WeekDay::THURSDAY:
+ return "IDS_CLOCK_OPT_EVERY_THURSDAY";
+ case WeekDay::FRIDAY:
+ return "IDS_CLOCK_OPT_EVERY_FRIDAY";
+ case WeekDay::SATURDAY:
+ return "IDS_CLOCK_OPT_EVERY_SATURDAY_ABB";
+ case WeekDay::SUNDAY:
+ return "IDS_CLOCK_OPT_EVERY_SUNDAY";
+ default:
+ ERR("Not handled WeekDay flag");
+ return "";
+ }
+}
+
+void WeekFlagsView::CreateList()
+{
+ WeekDay day, first_day;
+ day = first_day = SystemSettings::GetFirstDayOfWeek();
+
+ AppendCheckableListItem(WeekDay::ALL_WEEK);
+
+ do
+ {
+ AppendCheckableListItem(day);
+ day = WeekFlags::GetNextWeekDay(day);
+ }
+ while (day != first_day);
+}
+
void WeekFlagsView::CreateContent(Evas_Object *parent)
{
list_ = elm_list_add(parent);
evas_object_size_hint_align_set(list_, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(list_);
- AppendCheckableListItem("IDS_ALM_BODY_EVERYDAY", WeekDay::ALL_WEEK);
- AppendCheckableListItem("IDS_CLOCK_OPT_EVERY_MONDAY", WeekDay::MONDAY);
- AppendCheckableListItem("IDS_CLOCK_OPT_EVERY_TUESDAY", WeekDay::TUESDAY);
- AppendCheckableListItem("IDS_CLOCK_OPT_EVERY_WEDNESDAY", WeekDay::WEDNESDAY);
- AppendCheckableListItem("IDS_CLOCK_OPT_EVERY_THURSDAY", WeekDay::THURSDAY);
- AppendCheckableListItem("IDS_CLOCK_OPT_EVERY_FRIDAY", WeekDay::FRIDAY);
- AppendCheckableListItem("IDS_CLOCK_OPT_EVERY_SATURDAY_ABB", WeekDay::SATURDAY);
- AppendCheckableListItem("IDS_CLOCK_OPT_EVERY_SUNDAY", WeekDay::SUNDAY);
+ CreateList();
elm_object_item_translatable_text_set(navi_item_, "IDS_CLOCK_OPT_REPEAT_WEEKLY_ABB2");
elm_object_item_content_set(navi_item_, list_);
}
check_boxes_.clear();
}
+
+void WeekFlagsView::UpdateList()
+{
+ elm_list_clear(list_);
+ CreateList();
+}