Resolved issue N_SE-39048
[apps/osp/Calendar.git] / src / ClGoToDatePopup.cpp
index b41c546..4f2c730 100644 (file)
@@ -33,8 +33,6 @@ using namespace Tizen::Social;
 using namespace Tizen::Ui;
 using namespace Tizen::Ui::Controls;
 
-static const int IDA_GO_TO_DATE_POPUP_CANCEL = 10902;
-
 GoToDatePopup::GoToDatePopup(void)
        : __pEditDate(null)
        , __pTarget(null)
@@ -46,10 +44,25 @@ GoToDatePopup::~GoToDatePopup(void)
 }
 
 result
+GoToDatePopup::Initialize(void)
+{
+       return Construct(L"IDL_GO_TO_DATE_POPUP");
+}
+
+void
+GoToDatePopup::RequestPopup(const DateTime& initialDate, Control* pTarget)
+{
+       __date = initialDate;
+       __pTarget = pTarget;
+
+       SetShowState(true);
+       Show();
+}
+
+result
 GoToDatePopup::OnInitializing(void)
 {
        __pEditDate = dynamic_cast<EditDate*>(GetControl(L"IDC_EDITDATE"));
-       AppAssertf(__pEditDate != null, "[E_FAILURE] Unable to get button.");
        __pEditDate->SetYearRange(Calendarbook::GetMinDateTime().GetYear() + 1, Calendarbook::GetMaxDateTime().GetYear() - 1);
        __pEditDate->SetDate(__date);
 
@@ -60,12 +73,10 @@ GoToDatePopup::OnInitializing(void)
        SetTitleText(title);
 
        Button* pButtonDone = dynamic_cast<Button*>(GetControl(L"IDC_BUTTON_DONE"));
-       AppAssertf(pButtonDone != null, "[E_FAILURE] Unable to get button.");
        pButtonDone->SetActionId(IDA_GO_TO_DATE_POPUP_DONE);
        pButtonDone->AddActionEventListener(*this);
 
        Button* pButtonCancel = dynamic_cast<Button*>(GetControl(L"IDC_BUTTON_CANCEL"));
-       AppAssertf(pButtonCancel != null, "[E_FAILURE] Unable to get button.");
        pButtonCancel->SetActionId(IDA_GO_TO_DATE_POPUP_CANCEL);
        pButtonCancel->AddActionEventListener(*this);
 
@@ -85,28 +96,16 @@ GoToDatePopup::OnActionPerformed(const Control& source, int actionId)
        {
        case IDA_GO_TO_DATE_POPUP_DONE:
                __date = __pEditDate->GetDate();
-               SetShowState(false);
-               if (__pTarget != null)
+               if (__pTarget)
                {
                        LinkedList* pArgs = new (std::nothrow) LinkedList();
                        pArgs->Add(new (std::nothrow) DateTime(__date));
                        __pTarget->SendUserEvent(IDA_GO_TO_DATE_POPUP_DONE, pArgs);
                }
-               delete this;
+               SetShowState(false);
                break;
        case IDA_GO_TO_DATE_POPUP_CANCEL:
                SetShowState(false);
-               delete this;
                break;
        }
 }
-
-void
-GoToDatePopup::RequestGoToDate(const DateTime& initialDate, Control* pTarget)
-{
-       GoToDatePopup* pPopup = new (std::nothrow) GoToDatePopup();
-       pPopup->__date = initialDate;
-       pPopup->__pTarget = pTarget;
-       pPopup->Construct(L"IDL_GO_TO_DATE_POPUP");
-       pPopup->Show();
-}