Resolve N_SE-36252 issue.
authorSungWan Kim <sw0726.kim@samsung.com>
Fri, 26 Apr 2013 01:31:08 +0000 (10:31 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 26 Apr 2013 01:33:27 +0000 (10:33 +0900)
Change-Id: I7a15ce874fe545eac3c98d8cf0827c14adf76cf0
Signed-off-by: SungWan Kim <sw0726.kim@samsung.com>
inc/ClEventDetailsForm.h
inc/ClEventListPresentationModel.h
inc/ClEventPresentationModel.h
inc/ClEventSearchPresentationModel.h
src/ClEventDetailsForm.cpp
src/ClEventListPresentationModel.cpp
src/ClEventPresentationModel.cpp
src/ClEventSearchPresentationModel.cpp

index 472340d..19fc6cb 100644 (file)
@@ -26,6 +26,7 @@
 #include <FBase.h>
 #include <FGraphics.h>
 #include <FUi.h>
+#include "ClICalendarEventChangedEventListener.h"
 
 class CalendarSelectorPopup;
 class EventPresentationModel;
@@ -40,6 +41,7 @@ class EventDetailsForm
        , public virtual Tizen::Ui::Controls::ISectionTableViewItemEventListener
        , public virtual Tizen::Ui::Controls::ISectionTableViewItemProvider
        , public virtual Tizen::Ui::Scenes::ISceneEventListener
+       , public virtual ICalendarEventChangedEventListener
 {
 public:
        result Initialize(void);
@@ -80,6 +82,8 @@ public:
 
        virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
 
+       virtual void OnCalendarEventChanged(void);
+
 private:
        Tizen::Ui::Controls::TableViewItem* CreateMainItemN(int itemWidth, const Tizen::Base::String& title,
                                                                                                          const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end);
index ce9ea87..f3dad5f 100644 (file)
@@ -40,7 +40,7 @@ public:
        virtual ~EventListPresentationModel(void);
 
        result AddCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener);
-       result RemoveCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listner);
+       result RemoveCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener);
        result AddCurrentDateChangedEventListener(ICurrentDateChangedEventListener& listener);
        result RemoveCurrentDateChangedEventListener(ICurrentDateChangedEventListener& listener);
        Tizen::Base::DateTime GetCurrentDate(void) const;
@@ -144,6 +144,7 @@ private:
        Tizen::Base::Runtime::Timer __timer;
        bool __isEmpty;
        bool __isPendingCalendarEventChangedEvent;
+       bool __is24HourEnabled;
 
        static EventListPresentationModel* __pInstance;
 }; // EventListPresentationModel
index 5843b39..aa3e794 100644 (file)
 #include <FGraphics.h>
 #include <FLocales.h>
 #include <FSocial.h>
+#include "ClICalendarAppStatusChangedEventListener.h"
+#include "ClICalendarEventChangedEventListener.h"
 
 class EventPresentationModel
+       : public virtual ICalendarAppStatusChangedEventListener
 {
 public:
        result Construct(const Tizen::Social::RecordId eventId = Tizen::Social::INVALID_RECORD_ID);
 
+       result AddCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener);
+       result RemoveCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener);
+
        Tizen::Base::String GetAccountName(void) const;
        Tizen::Graphics::Bitmap* GetCalendarIconN(void) const;
        Tizen::Base::String GetCalendarName(void) const;
@@ -84,6 +90,12 @@ public:
        EventPresentationModel(void);
        virtual ~EventPresentationModel(void);
 
+       virtual void OnForeground(void);
+       virtual void OnBackground(void);
+
+private:
+       void FireCalendarEventChangedEvent(void);
+
 private:
        Tizen::Social::Calendarbook* __pCalendarbook;
        Tizen::Social::Calendar* __pCalendar;
@@ -93,7 +105,9 @@ private:
        Tizen::Locales::DateTimeFormatter* __pDateFormatter;
        Tizen::Locales::DateTimeFormatter* __pDateTimeFormatter;
        Tizen::Locales::DateTimeFormatter* __pTimeFormatter;
+       Tizen::Base::Collection::LinkedList __listeners;
        bool __allEventEditing;
+       bool __is24HourEnabled;
 }; // EventPresentationModel
 
 #endif // _CL_EVENT_PRESENTATION_MODEL_H_
index f6a1243..7d8250b 100644 (file)
 #include <FGraphics.h>
 #include <FLocales.h>
 #include <FSocial.h>
+#include "ClICalendarAppStatusChangedEventListener.h"
 #include "ClICalendarEventChangedEventListener.h"
 
 class EventSearchPresentationModel
        : public virtual Tizen::Social::ICalendarbookEventListener
+       , public virtual ICalendarAppStatusChangedEventListener
 {
 public:
        result Construct(void);
 
        result AddCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener);
-       result RemoveCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listner);
+       result RemoveCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener);
 
        Tizen::Locales::DateTimeFormatter* GetDateFormatter(void) const;
        Tizen::Locales::DateTimeFormatter* GetTimeFormatter(void) const;
@@ -63,11 +65,15 @@ public:
        virtual void OnCalendarEventsChanged(const Tizen::Base::Collection::IList& eventChangeInfoList);
        virtual void OnCalendarTodosChanged(const Tizen::Base::Collection::IList& todoChangeInfoList);
 
+       virtual void OnForeground(void);
+       virtual void OnBackground(void);
+
        static bool IsSameDay(const Tizen::Base::DateTime& day1, const Tizen::Base::DateTime& day2);
        static bool IsToday(const Tizen::Base::DateTime& date);
 
 private:
        int FindGroupIndex(const Tizen::Base::DateTime& date, int start, int end) const;
+       void FireCalendarEventChangedEvent(void);
        void RemoveAllEvents(void);
 
 private:
@@ -78,6 +84,7 @@ private:
        Tizen::Locales::DateTimeFormatter* __pDateFormatter;
        Tizen::Locales::DateTimeFormatter* __pTimeFormatter;
        Tizen::Base::String __searchText;
+       bool __is24HourEnabled;
 }; // EventSearchPresenationModel
 
 #endif // _CL_EVENT_SEARCH_PRESENTATION_MODEL_H_
index 6f5df43..053a0a1 100644 (file)
@@ -477,7 +477,6 @@ EventDetailsForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneI
                        {
                                __pPm->SetAllEventEditing(false);
                                __pPm->SetEventInstance(*pEvent);
-                               __pTableView->UpdateTableView();
 
                                GetFooter()->SetItemEnabled(0, __pPm->IsEditable());
                                GetFooter()->Invalidate(true);
@@ -503,6 +502,8 @@ EventDetailsForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneI
                        delete pArgs;
                }
 
+               __pTableView->UpdateTableView();
+               __pPm->AddCalendarEventChangedEventListener(*this);
                return;
        }
 
@@ -527,6 +528,7 @@ EventDetailsForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneI
                        GetFooter()->RemoveButtonAt(BUTTON_POSITION_LEFT);
                        GetFooter()->RemoveAllItems();
                }
+               __pPm->AddCalendarEventChangedEventListener(*this);
        }
        else if (pApp->GetMimeType() == MIME_TYPE_VCALENDAR)
        {
@@ -555,6 +557,7 @@ EventDetailsForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneI
                        item.SetText(ResourceManager::GetString(IDS_EMAIL_OPT_ADD_TO_CALENDAR));
                        pFooter->AddItem(item);
                }
+               __pPm->AddCalendarEventChangedEventListener(*this);
        }
 
 CATCH:
@@ -582,6 +585,7 @@ CATCH:
 void
 EventDetailsForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
 {
+       __pPm->RemoveCalendarEventChangedEventListener(*this);
 }
 
 void
@@ -660,6 +664,12 @@ EventDetailsForm::OnActionPerformed(const Control& source, int actionId)
        }
 }
 
+void
+EventDetailsForm::OnCalendarEventChanged(void)
+{
+       __pTableView->UpdateTableView();
+}
+
 TableViewItem*
 EventDetailsForm::CreateMainItemN(int itemWidth, const String& title, const DateTime& start, const DateTime& end)
 {
index be660fd..67179b9 100644 (file)
@@ -127,6 +127,7 @@ EventListPresentationModel::EventListPresentationModel(void)
        , __pCurrentDateChangeEvent(null)
        , __isEmpty(false)
        , __isPendingCalendarEventChangedEvent(false)
+       , __is24HourEnabled(false)
 {
 }
 
@@ -809,6 +810,29 @@ EventListPresentationModel::OnCalendarTodosChanged(const IList& todoChangeInfoLi
 void
 EventListPresentationModel::OnForeground(void)
 {
+       bool is24HourEnabled = false;
+       SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourEnabled);
+       if (is24HourEnabled != __is24HourEnabled)
+       {
+               delete __pDateFormatter;
+               __pDateFormatter = ResourceManager::CreateDateFormatterN(Locales::DATE_TIME_STYLE_FULL);
+
+               String pattern = __pDateFormatter->GetPattern();
+               delete __pMonthFormatter;
+               __pMonthFormatter = ResourceManager::CreateDateFormatterN(Locales::DATE_TIME_STYLE_NONE);
+               __pMonthFormatter->ApplyPattern(GetMonthFormatterPattern(pattern));
+
+               delete __pYearFormatter;
+               __pYearFormatter = ResourceManager::CreateDateFormatterN(Locales::DATE_TIME_STYLE_NONE);
+               __pYearFormatter->ApplyPattern(GetYearFormatterPattern(pattern));
+
+               delete __pTimeFormatter;
+               __pTimeFormatter = ResourceManager::CreateTimeFormatterN();
+               __is24HourEnabled = is24HourEnabled;
+
+               FireCalendarEventChangedEvent();
+       }
+
        DateTime today = GetToday();
        DateTime current = GetCurrentDate();
        current.SetValue(current.GetYear(), current.GetMonth(), current.GetDay(), today.GetHour(), today.GetMinute(), today.GetSecond());
@@ -1015,6 +1039,8 @@ EventListPresentationModel::Construct(void)
 
        __pCurrentDateChangeEvent = new (std::nothrow) CurrentDateChangeEvent();
 
+       SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, __is24HourEnabled);
+
        static_cast<CalendarApp*>(Tizen::App::UiApp::GetInstance())->AddCalendarAppStatusChangedEventListener(*this);
 
        return E_SUCCESS;
index 042c6f2..391b463 100644 (file)
  */
 
 #include <FSystem.h>
+#include "ClCalendarApp.h"
 #include "ClEventPresentationModel.h"
 #include "ClResourceManager.h"
 #include "ClTypes.h"
 
 using namespace Tizen;
+using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
@@ -46,11 +48,14 @@ EventPresentationModel::EventPresentationModel(void)
        , __pDateTimeFormatter(null)
        , __pTimeFormatter(null)
        , __allEventEditing(true)
+       , __is24HourEnabled(false)
 {
 }
 
 EventPresentationModel::~EventPresentationModel(void)
 {
+       static_cast<CalendarApp*>(UiApp::GetInstance())->RemoveCalendarAppStatusChangedEventListener(*this);
+
        delete __pCalendarbook;
        delete __pCalendar;
        delete __pEvent;
@@ -74,6 +79,10 @@ EventPresentationModel::Construct(const RecordId eventId)
        __pDateTimeFormatter = ResourceManager::CreateDateTimeFormatterN(Locales::DATE_TIME_STYLE_LONG);
        __pTimeFormatter = ResourceManager::CreateTimeFormatterN();
 
+       SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, __is24HourEnabled);
+
+       static_cast<CalendarApp*>(UiApp::GetInstance())->AddCalendarAppStatusChangedEventListener(*this);
+
        return E_SUCCESS;
 CATCH:
        delete __pCalendarbook;
@@ -81,6 +90,18 @@ CATCH:
        return r;
 }
 
+result
+EventPresentationModel::AddCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener)
+{
+       return __listeners.Add(&listener);
+}
+
+result
+EventPresentationModel::RemoveCalendarEventChangedEventListener(ICalendarEventChangedEventListener& listener)
+{
+       return __listeners.Remove(listener);
+}
+
 String
 EventPresentationModel::GetAccountName(void) const
 {
@@ -1033,3 +1054,37 @@ EventPresentationModel::RemoveReminderAt(int index)
 {
        return __pEvent->RemoveReminderAt(index);
 }
+
+void
+EventPresentationModel::OnForeground(void)
+{
+       bool is24HourEnabled = false;
+       SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourEnabled);
+       if (is24HourEnabled != __is24HourEnabled)
+       {
+               __pDateFormatter = ResourceManager::CreateDateFormatterN(Locales::DATE_TIME_STYLE_LONG);
+               __pDateTimeFormatter = ResourceManager::CreateDateTimeFormatterN(Locales::DATE_TIME_STYLE_LONG);
+               __pTimeFormatter = ResourceManager::CreateTimeFormatterN();
+               __is24HourEnabled = is24HourEnabled;
+               FireCalendarEventChangedEvent();
+       }
+}
+
+void
+EventPresentationModel::OnBackground(void)
+{
+}
+
+void
+EventPresentationModel::FireCalendarEventChangedEvent(void)
+{
+       if (__listeners.GetCount() > 0)
+       {
+               IEnumerator* pEnum = __listeners.GetEnumeratorN();
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       static_cast<ICalendarEventChangedEventListener*>(pEnum->GetCurrent())->OnCalendarEventChanged();
+               }
+               delete pEnum;
+       }
+}
index fde5c49..15de7ff 100644 (file)
  */
 
 #include <FSystem.h>
+#include "ClCalendarApp.h"
 #include "ClEventSearchPresentationModel.h"
 #include "ClNodes.h"
 #include "ClResourceManager.h"
 #include "ClTypes.h"
 
 using namespace Tizen;
+using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
@@ -37,11 +39,14 @@ EventSearchPresentationModel::EventSearchPresentationModel(void)
        : __pCalendarbook(null)
        , __pDateFormatter(null)
        , __pTimeFormatter(null)
+       , __is24HourEnabled(false)
 {
 }
 
 EventSearchPresentationModel::~EventSearchPresentationModel(void)
 {
+       static_cast<CalendarApp*>(UiApp::GetInstance())->RemoveCalendarAppStatusChangedEventListener(*this);
+
        __calendars.RemoveAll(true);
 
        RemoveAllEvents();
@@ -76,6 +81,10 @@ EventSearchPresentationModel::Construct(void)
        __pDateFormatter = ResourceManager::CreateDateFormatterN(Locales::DATE_TIME_STYLE_FULL);
        __pTimeFormatter = ResourceManager::CreateTimeFormatterN();
 
+       SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, __is24HourEnabled);
+
+       static_cast<CalendarApp*>(UiApp::GetInstance())->AddCalendarAppStatusChangedEventListener(*this);
+
        return E_SUCCESS;
 }
 
@@ -424,15 +433,7 @@ EventSearchPresentationModel::OnCalendarEventsChanged(const IList& eventChangeIn
        if (__searchText.IsEmpty() == false)
        {
                SearchEvent(__searchText);
-               if (__eventChangedListeners.GetCount() > 0)
-               {
-                       IEnumerator* pEnum = __eventChangedListeners.GetEnumeratorN();
-                       while (pEnum->MoveNext() == E_SUCCESS)
-                       {
-                               static_cast<ICalendarEventChangedEventListener*>(pEnum->GetCurrent())->OnCalendarEventChanged();
-                       }
-                       delete pEnum;
-               }
+               FireCalendarEventChangedEvent();
        }
 }
 
@@ -441,6 +442,29 @@ EventSearchPresentationModel::OnCalendarTodosChanged(const IList& todoChangeInfo
 {
 }
 
+void
+EventSearchPresentationModel::OnForeground(void)
+{
+       bool is24HourEnabled = false;
+       SettingInfo::GetValue(KEY_SYSTEM_24_HOUR_NOTATION_ENABLED, is24HourEnabled);
+       if (is24HourEnabled != __is24HourEnabled)
+       {
+               delete __pDateFormatter;
+               __pDateFormatter = ResourceManager::CreateDateFormatterN(Locales::DATE_TIME_STYLE_FULL);
+               delete __pTimeFormatter;
+               __pTimeFormatter = ResourceManager::CreateTimeFormatterN();
+
+               __is24HourEnabled = is24HourEnabled;
+
+               FireCalendarEventChangedEvent();
+       }
+}
+
+void
+EventSearchPresentationModel::OnBackground(void)
+{
+}
+
 bool
 EventSearchPresentationModel::IsSameDay(const DateTime& day1, const DateTime& day2)
 {
@@ -487,6 +511,20 @@ EventSearchPresentationModel::FindGroupIndex(const DateTime& date, int start, in
 }
 
 void
+EventSearchPresentationModel::FireCalendarEventChangedEvent(void)
+{
+       if (__eventChangedListeners.GetCount() > 0)
+       {
+               IEnumerator* pEnum = __eventChangedListeners.GetEnumeratorN();
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       static_cast<ICalendarEventChangedEventListener*>(pEnum->GetCurrent())->OnCalendarEventChanged();
+               }
+               delete pEnum;
+       }
+}
+
+void
 EventSearchPresentationModel::RemoveAllEvents(void)
 {
        __indexedEvents.RemoveAll(true);