Fixed N_SE-38563, N_SE-38552
[apps/osp/Settings.git] / src / StTimeZoneForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                StTimeZoneForm.cpp
19  * @brief               This is the implementation file for TimeZoneForm class.
20  */
21
22 #include "StResourceManager.h"
23 #include "StTimeZoneForm.h"
24 #include "StTypes.h"
25
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Base::Utility;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Locales;
32 using namespace Tizen::System;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
36
37 static const int ID_GROUP_COUNT = 1;
38 static const int ID_GROUP_MAX_ITEM_COUNT = 10;
39
40 static const int IDA_FOOTER_ITEM_NAME = 100;
41 static const int IDA_FOOTER_ITEM_TIME = 101;
42
43 static const int MINUTES_TO_HOUR = 60;
44
45 static const int GROUP_INDEX_DEFAULT_LABEL_HEIGHT = 40;
46
47 static const int H_SEARCH_BAR = 86;
48 static const int Y_TABLE_VIEW_AREA = H_SEARCH_BAR;
49
50 static const int W_GMT_FIXED_SIZE = 200;
51
52 TimeZoneForm::TimeZoneForm(void)
53         : __isAppControlRequest(false)
54         , __sortTabSelect(IDA_FOOTER_ITEM_NAME)
55         , __pSearchBar(null)
56         , __timeZoneTotalList(null)
57         , __timeZoneSearchList(null)
58 {
59 }
60
61 TimeZoneForm::~TimeZoneForm(void)
62 {
63 }
64
65 void
66 TimeZoneForm::CreateFooter(void)
67 {
68         Footer* pFooter = GetFooter();
69         AppAssert(pFooter);
70
71         FooterItem  footerItemName;
72         footerItemName.Construct(IDA_FOOTER_ITEM_NAME);
73         footerItemName.SetText(ResourceManager::GetString(L"IDS_ST_BODY_NAME"));
74
75         FooterItem  footerItemTime;
76         footerItemTime.Construct(IDA_FOOTER_ITEM_TIME);
77         footerItemTime.SetText(ResourceManager::GetString(L"IDS_COM_BODY_TIME"));
78
79         pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
80         pFooter->AddItem(footerItemName);
81         pFooter->AddItem(footerItemTime);
82         pFooter->SetBackButton();
83         pFooter->AddActionEventListener(*this);
84
85         SetFormBackEventListener(this);
86 }
87
88 void
89 TimeZoneForm::GetTimeZoneList(void)
90 {
91         IList* pAvailableLocales = null;
92
93         LocaleManager localeManager;
94         localeManager.Construct();
95
96         pAvailableLocales = localeManager.GetAvailableTimeZonesN();
97         if (pAvailableLocales)
98         {
99                 for (int i = 0; i < pAvailableLocales->GetCount(); i++)
100                 {
101                         TimeZone timeZone;
102                         String region;
103                         String country;
104                         String extraData;
105                         String gmtTime;
106                         Integer gmtHour = 0;
107                         String* pKey = static_cast<String*>(pAvailableLocales->GetAt(i));
108
109                         StringTokenizer stringTokenizer(*pKey, L"/");
110                         stringTokenizer.GetNextToken(region);
111                         stringTokenizer.GetNextToken(country);
112
113                         if ((country.IsEmpty() == true) || (country.IsEmpty() == true) || (country.Equals(L"ACT", false))
114                                 || (region.Equals(L"SystemV", false)) || (region.Equals(L"Etc", false)))
115                         {
116                                 continue;
117                         }
118
119                         if (stringTokenizer.HasMoreTokens() == true)
120                         {
121                                 stringTokenizer.GetNextToken(extraData);
122                                 country.Append(L"/" + extraData);
123                         }
124
125                         TimeZone::GetTimeZone(*pKey, timeZone);
126                         gmtHour = timeZone.GetRawOffset();
127
128                         SetTimeZoneLocaleList(new (std::nothrow) TimeZoneData(region, country, gmtHour));
129                         SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(region, country, gmtHour));
130
131                         delete pKey;
132                 }
133         }
134         SortTimeZoneData();
135 }
136
137 void
138 TimeZoneForm::CreateTableView(void)
139 {
140         Rectangle bounds = GetClientAreaBounds();
141         Rectangle tableViewBounds = bounds;
142
143         tableViewBounds.y = Y_TABLE_VIEW_AREA;
144         tableViewBounds.height = (bounds.height - tableViewBounds.y);
145
146         __pTableView = new (std::nothrow) GroupedTableView();
147         __pTableView->Construct(tableViewBounds, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
148         __pTableView->SetItemProvider(this);
149
150         AddControl(__pTableView);
151
152         __pTableView->AddGroupedTableViewItemEventListener(*this);
153
154         RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(this->GetLayoutN());
155         if (pRelativeLayout != null)
156         {
157                 pRelativeLayout->SetHorizontalFitPolicy(*__pSearchBar, FIT_POLICY_PARENT);
158                 pRelativeLayout->SetVerticalFitPolicy(*__pSearchBar, FIT_POLICY_FIXED);
159                 pRelativeLayout->SetHorizontalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
160                 pRelativeLayout->SetRelation(*__pTableView, __pSearchBar, RECT_EDGE_RELATION_TOP_TO_BOTTOM);
161                 pRelativeLayout->SetRelation(*__pTableView, this, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
162                 delete pRelativeLayout;
163         }
164 }
165
166 result
167 TimeZoneForm::OnInitializing(void)
168 {
169         Rectangle bounds = GetClientAreaBounds();
170         Rectangle searchbarBounds = bounds;
171
172         searchbarBounds.y = 0;
173         searchbarBounds.height = H_SEARCH_BAR;
174
175         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_TIME_ZONE"));
176         GetTimeZoneList();
177
178         __pSearchBar = new (std::nothrow) SearchBar();
179         __pSearchBar->Construct(searchbarBounds, true, KEYPAD_ACTION_SEARCH);
180         __pSearchBar->SetGuideText(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"));
181         __pSearchBar->AddSearchBarEventListener(*this);
182         __pSearchBar->AddTextEventListener(*this);
183         __pSearchBar->AddKeypadEventListener(*this);
184         __pSearchBar->SetContentAreaSize(Dimension(0, 0));
185
186         AddControl(__pSearchBar);
187
188         CreateTableView();
189         CreateFooter();
190
191         AppLogDebug("ENTER");
192
193         return E_SUCCESS;
194 }
195
196 result
197 TimeZoneForm::OnTerminating(void)
198 {
199         __pSearchBar = null;
200         RemoveAllTimeZoneLocaleList();
201         __pTableView = null;
202
203         SetFormBackEventListener(null);
204         return E_SUCCESS;
205 }
206
207 void
208 TimeZoneForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
209 {
210         if (pArgs != null)
211         {
212                 String categoryCheck = static_cast<String*>(pArgs->GetAt(0))->GetPointer();
213
214                 if (categoryCheck == L"category:TimeZone")
215                 {
216                         __isAppControlRequest = true;
217                 }
218                 delete pArgs;
219         }
220         __pTableView->UpdateTableView();
221 }
222
223 void
224 TimeZoneForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
225 {
226 }
227
228 void
229 TimeZoneForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
230 {
231         SceneManager* pSceneManager = SceneManager::GetInstance();
232         AppAssert(pSceneManager);
233
234         if (__isAppControlRequest == true)
235         {
236                 UiApp* pApp = UiApp::GetInstance();
237                 AppAssert(pApp);
238                 AppControlTimeZoneResult();
239                 pApp->Terminate();
240         }
241         else
242         {
243                 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
244         }
245 }
246
247 int
248 TimeZoneForm::GetGroupCount(void)
249 {
250         AppLogDebug("ENTER");
251         return ID_GROUP_COUNT;
252 }
253
254 int
255 TimeZoneForm::GetItemCount(int groupIndex)
256 {
257         int itemCount = __timeZoneSearchList->GetCount();
258
259         AppLogDebug("GetItemCount %d", itemCount);
260         return itemCount;
261 }
262
263 TableViewGroupItem*
264 TimeZoneForm::CreateGroupItem(int groupIndex, int itemWidth)
265 {
266         AppLogDebug("ENTER");
267
268         int itemHeight = 0;
269         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
270         String groupText;
271         Label* pLabel = null;
272
273         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
274         pItem->Construct(Dimension(itemWidth, itemHeight));
275
276         pLabel = new (std::nothrow) Label();
277         pLabel->Construct(Rectangle(X_GROUP_INDEX_DEFAULT_LABEL, Y_GROUP_INDEX_DEFAULT_LABEL, itemWidth, GROUP_INDEX_DEFAULT_LABEL_HEIGHT), groupText);
278         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
279         pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
280         pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
281
282         pItem->AddControl(pLabel);
283         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
284         pItem->SetEnabled(false);
285
286         return pItem;
287 }
288
289 TableViewItem*
290 TimeZoneForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
291 {
292         AppLogDebug("CreateItem group[%d] index[%d]", groupIndex, itemIndex);
293
294         int gmtHour = 0;
295         Integer gmtMin = 0;
296         int computeGmtMin = 0;
297         String key;
298         String stringGMT;
299         String tmpStr;
300         String itemMainText;
301         String itemSubText;
302         Rectangle itemMainRectangle;
303         Rectangle itemGMTRectangle;
304         Rectangle itemSubRectangle;
305         int itemHeight = H_GROUP_ITEM_DEFAULT;
306
307         String noSearchResult = ResourceManager::GetString(L"IDS_COM_BODY_NO_SEARCH_RESULTS");
308
309         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
310         Label* pLabel = null;
311         int fontSize = GetFontSize();
312
313         TimeZoneData* pData = static_cast<TimeZoneData*>(__timeZoneSearchList->GetAt(itemIndex));
314
315         TableViewItem* pItem = new (std::nothrow) TableViewItem();
316
317         itemMainText = pData->GetCountryData();
318         itemSubText = pData->GetRegionData();
319         gmtMin = pData->GetGMTData();
320
321         if (itemMainText.Equals(noSearchResult, false))
322         {
323                 ItemTypeOneLine(itemMainRectangle);
324                 itemHeight = (itemMainRectangle.height);
325
326                 RelativeLayout relativeLayout;
327                 relativeLayout.Construct();
328
329                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
330                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
331
332                 pLabel = new (std::nothrow) Label();
333                 pLabel->Construct(itemMainRectangle, itemMainText);
334                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
335                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
336                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
337
338                 pItem->AddControl(pLabel);
339
340                 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
341                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
342                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
343         }
344         else
345         {
346                 gmtHour = (gmtMin.value / MINUTES_TO_HOUR);
347                 gmtMin.value %= MINUTES_TO_HOUR;
348
349                 stringGMT.Append(L"GMT");
350                 if (gmtHour >= 0)
351                 {
352                         stringGMT.Append(L"+");
353                 }
354                 stringGMT.Append(gmtHour);
355
356                 if (gmtMin.value)
357                 {
358                         stringGMT.Append(L":");
359
360                         if (gmtMin.value < 0)
361                         {
362                                 computeGmtMin -= (computeGmtMin + gmtMin.value);
363                                 stringGMT.Append(computeGmtMin);
364                         }
365                         else
366                         {
367                                 stringGMT.Append(gmtMin.value);
368                         }
369                 }
370
371                 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
372                 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
373                 itemGMTRectangle = itemMainRectangle;
374
375                 RelativeLayout relativeLayout;
376                 relativeLayout.Construct();
377
378                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
379                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
380
381                 itemMainRectangle.width = itemWidth;
382                 itemGMTRectangle.width = W_GMT_FIXED_SIZE;
383                 itemGMTRectangle.x = itemMainRectangle.width - itemGMTRectangle.width;
384                 itemMainRectangle.width = itemMainRectangle.width - itemGMTRectangle.width;
385
386                 pLabel = new (std::nothrow) Label();
387                 pLabel->Construct(itemMainRectangle, itemMainText);
388                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
389                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
390                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
391
392                 Label* pSecLabel = new (std::nothrow) Label();
393                 pSecLabel->Construct(itemGMTRectangle, stringGMT);
394                 pSecLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
395                 pSecLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
396                 pSecLabel->SetTextColor(COLOR_MAIN_TEXT);
397
398                 pItem->AddControl(pLabel);
399                 pItem->AddControl(pSecLabel);
400
401                 relativeLayout.SetHorizontalFitPolicy(*pSecLabel, FIT_POLICY_FIXED);
402                 relativeLayout.SetRelation(*pSecLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
403                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
404                 relativeLayout.SetRelation(*pLabel, pSecLabel, RECT_EDGE_RELATION_RIGHT_TO_LEFT);
405
406                 pLabel = new (std::nothrow) Label();
407                 pLabel->Construct(itemSubRectangle, itemSubText);
408                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
409                 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
410                 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
411                 pLabel->SetTextColor(COLOR_SUB_TEXT);
412
413                 pItem->AddControl(pLabel);
414                 relativeLayout.SetMargin(*pLabel, itemSubRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
415                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
416                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
417         }
418
419         return pItem;
420 }
421
422 bool
423 TimeZoneForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
424 {
425         AppLogDebug("ENTER");
426
427         delete pItem;
428         pItem = null;
429
430         return true;
431 }
432
433 bool
434 TimeZoneForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
435 {
436         AppLogDebug("ENTER");
437
438         delete pItem;
439         pItem = null;
440
441         return true;
442 }
443
444 void
445 TimeZoneForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
446 {
447         AppLogDebug("OnTableViewItemStateChanged group[%d] index[%d]", groupIndex, itemIndex);
448
449         SceneManager* pSceneManager = SceneManager::GetInstance();
450         AppAssert(pSceneManager);
451         String noSearchResult = ResourceManager::GetString(L"IDS_COM_BODY_NO_SEARCH_RESULTS");
452         String key;
453         TimeZoneData* pData = static_cast<TimeZoneData*>(__timeZoneSearchList->GetAt(itemIndex));
454
455         if (pData->GetCountryData().Equals(noSearchResult, true))
456         {
457                 AppLogDebug("selected key is \"No Search Result\"");
458                 return;
459         }
460
461         key.Append(pData->GetRegionData() + L"/" + pData->GetCountryData());
462         if (SettingInfo::SetValue(SETTING_INFO_KEY_LOCALE_TIME_ZONE, key) == E_SUCCESS)
463         {
464                 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
465         }
466 }
467
468 void
469 TimeZoneForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
470 {
471         if (mode == SEARCH_BAR_MODE_INPUT)
472         {
473                 // Empty statement
474         }
475         else
476         {
477                 __timeZoneSearchList->RemoveAll();
478
479                 for (int count = 0; count < __timeZoneTotalList->GetCount(); count++)
480                 {
481                         TimeZoneData* pData = null;
482                         pData = static_cast<TimeZoneData*>(__timeZoneTotalList->GetAt(count));
483                         SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(*pData));
484                 }
485                 SortTimeZoneData();
486         }
487         __pTableView->UpdateTableView();
488
489         Invalidate(true);
490 }
491
492 void
493 TimeZoneForm::SortTimeZoneData(void)
494 {
495         TiemZoneComparer* pTimeZoneSort = null;
496
497         if (__sortTabSelect == IDA_FOOTER_ITEM_NAME)
498         {
499                 pTimeZoneSort = new (std::nothrow) TiemZoneComparer(DATA_TYPE_COUNTRY);
500         }
501         else
502         {
503                 pTimeZoneSort = new (std::nothrow) TiemZoneComparer(DATA_TYPE_GMT);
504         }
505         __timeZoneSearchList->Sort(*pTimeZoneSort);
506         delete pTimeZoneSort;
507 }
508
509 void
510 TimeZoneForm::OnTextValueChanged(const Tizen::Ui::Control& source)
511 {
512         String searchData;
513         String searchText = __pSearchBar->GetText();
514
515         if (searchText.CompareTo(L""))
516         {
517                 TimeZoneData* pData = null;
518                 __timeZoneSearchList->RemoveAll(true);
519
520                 for (int count = 0; count < __timeZoneTotalList->GetCount(); count++)
521                 {
522                         String lowerData;
523                         String lowerSearchText;
524                         pData = static_cast<TimeZoneData*>(__timeZoneTotalList->GetAt(count));
525
526                         String country(pData->GetCountryData());
527
528                         pData->GetCountryData().ToLower(lowerData);
529                         searchText.ToLower(lowerSearchText);
530
531                         if (lowerData.Contains(lowerSearchText))
532                         {
533                                 SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(*pData));
534                         }
535                 }
536         }
537         else
538         {
539                 TimeZoneData* pData = null;
540                 __timeZoneSearchList->RemoveAll(true);
541
542                 for (int count = 0; count < __timeZoneTotalList->GetCount(); count++)
543                 {
544                         String lowerData;
545                         String lowerSearchText;
546                         pData = static_cast<TimeZoneData*>(__timeZoneTotalList->GetAt(count));
547
548                         String region(pData->GetRegionData());
549                         String country(pData->GetCountryData());
550                         Integer gmt = pData->GetGMTData();
551
552                         SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(*pData));
553                 }
554         }
555
556         if (__timeZoneSearchList->GetCount() == 0)
557         {
558                 Integer noData;
559                 String noSearchData(ResourceManager::GetString(L"IDS_COM_BODY_NO_SEARCH_RESULTS"));
560                 SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(noSearchData, noSearchData, noData));
561         }
562         else
563         {
564                 SortTimeZoneData();
565         }
566         __pTableView->UpdateTableView();
567 }
568
569 void
570 TimeZoneForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
571 {
572         if (__sortTabSelect == actionId)
573         {
574                 return;
575         }
576         switch (actionId)
577         {
578         case IDA_FOOTER_ITEM_NAME:
579                 // fall through
580         case IDA_FOOTER_ITEM_TIME:
581                 {
582                         __sortTabSelect = actionId;
583                 }
584                 break;
585
586         default:
587                 break;
588         }
589
590         SortTimeZoneData();
591         __pTableView->UpdateTableView();
592 }
593
594 int
595 TimeZoneForm::GetDefaultGroupItemHeight(void)
596 {
597         return 0;
598 }
599
600 int
601 TimeZoneForm::GetDefaultItemHeight(void)
602 {
603         return H_GROUP_ITEM_DEFAULT;
604 }
605
606 void
607 TimeZoneForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
608 {
609 }
610
611 void
612 TimeZoneForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
613 {
614 }
615
616 void
617 TimeZoneForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
618 {
619 }
620
621 void
622 TimeZoneForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
623 {
624 }
625
626 Tizen::Base::Collection::IList*
627 TimeZoneForm::AppControlTimeZoneResult(void)
628 {
629         return null;
630 }
631
632 result
633 TimeZoneForm::InitTimeZoneLocaleList(void)
634 {
635         if (__timeZoneTotalList != null)
636         {
637                 return E_FAILURE;
638         }
639
640         __timeZoneTotalList = new (std::nothrow) ArrayList(SingleObjectDeleter);
641         return __timeZoneTotalList->Construct();
642 }
643
644 void
645 TimeZoneForm::RemoveAllTimeZoneLocaleList(void)
646 {
647         if (__timeZoneTotalList != null)
648         {
649                 delete __timeZoneTotalList;
650                 __timeZoneTotalList = null;
651         }
652
653         if (__timeZoneSearchList != null)
654         {
655                 delete __timeZoneSearchList;
656                 __timeZoneSearchList = null;
657         }
658 }
659
660 result
661 TimeZoneForm::SetTimeZoneLocaleList(TimeZoneData* pTimeZoneData)
662 {
663         InitTimeZoneLocaleList();
664
665         if (__timeZoneTotalList == null)
666         {
667                 return E_FAILURE;
668         }
669
670         return __timeZoneTotalList->Add(pTimeZoneData);
671 }
672
673 result
674 TimeZoneForm::SetTimeZoneLocaleSearchList(TimeZoneData* pTimeZoneData)
675 {
676         if (__timeZoneSearchList == null)
677         {
678                 __timeZoneSearchList = new (std::nothrow) ArrayList(SingleObjectDeleter);
679                 __timeZoneSearchList->Construct();
680         }
681
682         return __timeZoneSearchList->Add(pTimeZoneData);
683 }
684
685 void
686 TimeZoneForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
687 {
688         switch (keypadAction)
689         {
690         case KEYPAD_ACTION_SEARCH:
691                 {
692                         __pSearchBar->HideKeypad();
693                         __pSearchBar->Invalidate(false);
694                 }
695                 break;
696
697         default:
698                 break;
699         }
700 }
701
702 result
703 TiemZoneComparer::Compare(const Tizen::Base::Object& obj1, const Tizen::Base::Object& obj2, int& cmp) const
704 {
705         switch (__type)
706         {
707         case DATA_TYPE_REGION:
708                 {
709                         cmp = static_cast<const TimeZoneData&>(obj1).GetRegionData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetRegionData());
710                 }
711                 break;
712
713         case DATA_TYPE_COUNTRY:
714                 {
715                         cmp = static_cast<const TimeZoneData&>(obj1).GetCountryData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetCountryData());
716                 }
717                 break;
718
719         case DATA_TYPE_GMT:
720                 {
721                         cmp = static_cast<const TimeZoneData&>(obj1).GetGMTData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetGMTData());
722
723                         if (cmp == 0)
724                         {
725                                 cmp = static_cast<const TimeZoneData&>(obj1).GetCountryData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetCountryData());
726                         }
727                 }
728                 break;
729
730         default:
731                 break;
732         }
733
734         return GetLastResult();
735 }
736
737 Tizen::Base::String
738 TimeZoneData::GetCountryData(void) const
739 {
740         return _timeZoneCountry;
741 }
742
743 Tizen::Base::String
744 TimeZoneData::GetRegionData(void) const
745 {
746         return _timeZoneRegion;
747 }
748
749 Tizen::Base::Integer
750 TimeZoneData::GetGMTData(void) const
751 {
752         return _timeZoneGMT;
753 }