ed4446baa22cd0fd1ac6d9ea8a6925f106dd45b4
[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->AddActionEventListener(*this);
83
84         SetFormBackEventListener(this);
85 }
86
87 void
88 TimeZoneForm::GetTimeZoneList(void)
89 {
90         IList* pAvailableLocales = null;
91
92         LocaleManager localeManager;
93         localeManager.Construct();
94
95         pAvailableLocales = localeManager.GetAvailableTimeZonesN();
96         if (pAvailableLocales)
97         {
98                 for (int i = 0; i < pAvailableLocales->GetCount(); i++)
99                 {
100                         TimeZone timeZone;
101                         String region;
102                         String country;
103                         String extraData;
104                         String gmtTime;
105                         Integer gmtHour = 0;
106                         String* pKey = static_cast<String*>(pAvailableLocales->GetAt(i));
107
108                         StringTokenizer stringTokenizer(*pKey, L"/");
109                         stringTokenizer.GetNextToken(region);
110                         stringTokenizer.GetNextToken(country);
111
112                         if ((country.IsEmpty() == true) || (country.Equals(L"ACT", false))
113                                 || (region.Equals(L"SystemV", false)) || (region.Equals(L"Etc", false)))
114                         {
115                                 continue;
116                         }
117
118                         if (stringTokenizer.HasMoreTokens() == true)
119                         {
120                                 stringTokenizer.GetNextToken(extraData);
121                                 country.Append(L"/" + extraData);
122                         }
123
124                         TimeZone::GetTimeZone(*pKey, timeZone);
125                         gmtHour = timeZone.GetRawOffset();
126
127                         SetTimeZoneLocaleList(new (std::nothrow) TimeZoneData(region, country, gmtHour));
128                         SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(region, country, gmtHour));
129
130                         delete pKey;
131                 }
132         }
133         SortTimeZoneData();
134 }
135
136 void
137 TimeZoneForm::CreateTableView(void)
138 {
139         Rectangle bounds = GetClientAreaBounds();
140         Rectangle tableViewBounds = bounds;
141
142         tableViewBounds.y = Y_TABLE_VIEW_AREA;
143         tableViewBounds.height = (bounds.height - tableViewBounds.y);
144
145         __pTableView = new (std::nothrow) GroupedTableView();
146         __pTableView->Construct(tableViewBounds, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
147         __pTableView->SetItemProvider(this);
148
149         AddControl(__pTableView);
150
151         __pTableView->AddGroupedTableViewItemEventListener(*this);
152
153         RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(this->GetLayoutN());
154         if (pRelativeLayout != null)
155         {
156                 pRelativeLayout->SetHorizontalFitPolicy(*__pSearchBar, FIT_POLICY_PARENT);
157                 pRelativeLayout->SetVerticalFitPolicy(*__pSearchBar, FIT_POLICY_FIXED);
158                 pRelativeLayout->SetHorizontalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
159                 pRelativeLayout->SetRelation(*__pTableView, __pSearchBar, RECT_EDGE_RELATION_TOP_TO_BOTTOM);
160                 pRelativeLayout->SetRelation(*__pTableView, this, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
161                 delete pRelativeLayout;
162         }
163 }
164
165 result
166 TimeZoneForm::OnInitializing(void)
167 {
168         SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
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         itemMainText.Replace(L"_",L" ");
319         itemSubText = pData->GetRegionData();
320         itemSubText.Replace(L"_",L" ");
321         gmtMin = pData->GetGMTData();
322
323         if (itemMainText.Equals(noSearchResult, false))
324         {
325                 ItemTypeOneLine(itemMainRectangle);
326                 itemHeight = (itemMainRectangle.height);
327
328                 RelativeLayout relativeLayout;
329                 relativeLayout.Construct();
330
331                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
332                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
333
334                 pLabel = new (std::nothrow) Label();
335                 pLabel->Construct(itemMainRectangle, itemMainText);
336                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
337                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
338                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
339
340                 pItem->AddControl(pLabel);
341
342                 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
343                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
344                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
345         }
346         else
347         {
348                 gmtHour = (gmtMin.value / MINUTES_TO_HOUR);
349                 gmtMin.value %= MINUTES_TO_HOUR;
350
351                 stringGMT.Append(L"GMT");
352                 if (gmtHour >= 0)
353                 {
354                         stringGMT.Append(L"+");
355                 }
356                 stringGMT.Append(gmtHour);
357
358                 if (gmtMin.value)
359                 {
360                         stringGMT.Append(L":");
361
362                         if (gmtMin.value < 0)
363                         {
364                                 computeGmtMin -= (computeGmtMin + gmtMin.value);
365                                 stringGMT.Append(computeGmtMin);
366                         }
367                         else
368                         {
369                                 stringGMT.Append(gmtMin.value);
370                         }
371                 }
372
373                 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
374                 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
375                 itemGMTRectangle = itemMainRectangle;
376
377                 RelativeLayout relativeLayout;
378                 relativeLayout.Construct();
379
380                 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
381                 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
382
383                 itemMainRectangle.width = itemWidth;
384                 itemGMTRectangle.width = W_GMT_FIXED_SIZE;
385                 itemGMTRectangle.x = itemMainRectangle.width - itemGMTRectangle.width;
386                 itemMainRectangle.width = itemMainRectangle.width - itemGMTRectangle.width;
387
388                 pLabel = new (std::nothrow) Label();
389                 pLabel->Construct(itemMainRectangle, itemMainText);
390                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
391                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
392                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
393
394                 Label* pSecLabel = new (std::nothrow) Label();
395                 pSecLabel->Construct(itemGMTRectangle, stringGMT);
396                 pSecLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
397                 pSecLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
398                 pSecLabel->SetTextColor(COLOR_MAIN_TEXT);
399
400                 pItem->AddControl(pLabel);
401                 pItem->AddControl(pSecLabel);
402
403                 relativeLayout.SetHorizontalFitPolicy(*pSecLabel, FIT_POLICY_FIXED);
404                 relativeLayout.SetRelation(*pSecLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
405                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
406                 relativeLayout.SetRelation(*pLabel, pSecLabel, RECT_EDGE_RELATION_RIGHT_TO_LEFT);
407
408                 pLabel = new (std::nothrow) Label();
409                 pLabel->Construct(itemSubRectangle, itemSubText);
410                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
411                 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
412                 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
413                 pLabel->SetTextColor(COLOR_SUB_TEXT);
414
415                 pItem->AddControl(pLabel);
416                 relativeLayout.SetMargin(*pLabel, itemSubRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
417                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
418                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
419         }
420
421         return pItem;
422 }
423
424 bool
425 TimeZoneForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
426 {
427         AppLogDebug("ENTER");
428
429         delete pItem;
430         pItem = null;
431
432         return true;
433 }
434
435 bool
436 TimeZoneForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
437 {
438         AppLogDebug("ENTER");
439
440         delete pItem;
441         pItem = null;
442
443         return true;
444 }
445
446 void
447 TimeZoneForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
448 {
449         AppLogDebug("OnTableViewItemStateChanged group[%d] index[%d]", groupIndex, itemIndex);
450
451         SceneManager* pSceneManager = SceneManager::GetInstance();
452         AppAssert(pSceneManager);
453         String noSearchResult = ResourceManager::GetString(L"IDS_COM_BODY_NO_SEARCH_RESULTS");
454         String key;
455         TimeZoneData* pData = static_cast<TimeZoneData*>(__timeZoneSearchList->GetAt(itemIndex));
456
457         if (pData->GetCountryData().Equals(noSearchResult, true))
458         {
459                 AppLogDebug("selected key is \"No Search Result\"");
460                 return;
461         }
462         key.Append(pData->GetRegionData() + L"/" + pData->GetCountryData());
463         if (SettingInfo::SetValue(SETTING_INFO_KEY_LOCALE_TIME_ZONE, key) == E_SUCCESS)
464         {
465                 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
466         }
467 }
468
469 void
470 TimeZoneForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
471 {
472         if (mode == SEARCH_BAR_MODE_INPUT)
473         {
474                 // Empty statement
475         }
476         else
477         {
478                 __timeZoneSearchList->RemoveAll();
479
480                 for (int count = 0; count < __timeZoneTotalList->GetCount(); count++)
481                 {
482                         TimeZoneData* pData = null;
483                         pData = static_cast<TimeZoneData*>(__timeZoneTotalList->GetAt(count));
484                         SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(*pData));
485                 }
486                 SortTimeZoneData();
487         }
488         __pTableView->UpdateTableView();
489
490         Invalidate(true);
491 }
492
493 void
494 TimeZoneForm::SortTimeZoneData(void)
495 {
496         TiemZoneComparer* pTimeZoneSort = null;
497
498         if (__sortTabSelect == IDA_FOOTER_ITEM_NAME)
499         {
500                 pTimeZoneSort = new (std::nothrow) TiemZoneComparer(DATA_TYPE_COUNTRY);
501         }
502         else
503         {
504                 pTimeZoneSort = new (std::nothrow) TiemZoneComparer(DATA_TYPE_GMT);
505         }
506         __timeZoneSearchList->Sort(*pTimeZoneSort);
507         delete pTimeZoneSort;
508 }
509
510 void
511 TimeZoneForm::OnTextValueChanged(const Tizen::Ui::Control& source)
512 {
513         String searchData;
514         String searchText = __pSearchBar->GetText();
515
516         if (searchText.CompareTo(L""))
517         {
518                 TimeZoneData* pData = null;
519                 __timeZoneSearchList->RemoveAll(true);
520
521                 for (int count = 0; count < __timeZoneTotalList->GetCount(); count++)
522                 {
523                         String lowerData;
524                         String lowerSearchText;
525                         pData = static_cast<TimeZoneData*>(__timeZoneTotalList->GetAt(count));
526
527                         String country(pData->GetCountryData());
528
529                         pData->GetCountryData().ToLower(lowerData);
530                         searchText.ToLower(lowerSearchText);
531                         lowerData.Replace('_', ' ');
532
533                         if (lowerData.Contains(lowerSearchText))
534                         {
535                                 SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(*pData));
536                         }
537                 }
538         }
539         else
540         {
541                 TimeZoneData* pData = null;
542                 __timeZoneSearchList->RemoveAll(true);
543
544                 for (int count = 0; count < __timeZoneTotalList->GetCount(); count++)
545                 {
546                         String lowerData;
547                         String lowerSearchText;
548                         pData = static_cast<TimeZoneData*>(__timeZoneTotalList->GetAt(count));
549
550                         String region(pData->GetRegionData());
551                         String country(pData->GetCountryData());
552                         Integer gmt = pData->GetGMTData();
553
554                         SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(*pData));
555                 }
556         }
557
558         if (__timeZoneSearchList->GetCount() == 0)
559         {
560                 Integer noData;
561                 String noSearchData(ResourceManager::GetString(L"IDS_COM_BODY_NO_SEARCH_RESULTS"));
562                 SetTimeZoneLocaleSearchList(new (std::nothrow) TimeZoneData(noSearchData, noSearchData, noData));
563         }
564         else
565         {
566                 SortTimeZoneData();
567         }
568         __pTableView->UpdateTableView();
569 }
570
571 void
572 TimeZoneForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
573 {
574         if (__sortTabSelect == actionId)
575         {
576                 return;
577         }
578         switch (actionId)
579         {
580         case IDA_FOOTER_ITEM_NAME:
581                 // fall through
582         case IDA_FOOTER_ITEM_TIME:
583                 {
584                         __sortTabSelect = actionId;
585                 }
586                 break;
587
588         default:
589                 break;
590         }
591
592         SortTimeZoneData();
593         __pTableView->UpdateTableView();
594         __pTableView->ScrollToItem(0, 0, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP);
595 }
596
597 int
598 TimeZoneForm::GetDefaultGroupItemHeight(void)
599 {
600         return 0;
601 }
602
603 int
604 TimeZoneForm::GetDefaultItemHeight(void)
605 {
606         return H_GROUP_ITEM_DEFAULT;
607 }
608
609 void
610 TimeZoneForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
611 {
612 }
613
614 void
615 TimeZoneForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
616 {
617 }
618
619 void
620 TimeZoneForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
621 {
622 }
623
624 void
625 TimeZoneForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
626 {
627 }
628
629 Tizen::Base::Collection::IList*
630 TimeZoneForm::AppControlTimeZoneResult(void)
631 {
632         return null;
633 }
634
635 result
636 TimeZoneForm::InitTimeZoneLocaleList(void)
637 {
638         if (__timeZoneTotalList != null)
639         {
640                 return E_FAILURE;
641         }
642
643         __timeZoneTotalList = new (std::nothrow) ArrayList(SingleObjectDeleter);
644         return __timeZoneTotalList->Construct();
645 }
646
647 void
648 TimeZoneForm::RemoveAllTimeZoneLocaleList(void)
649 {
650         if (__timeZoneTotalList != null)
651         {
652                 delete __timeZoneTotalList;
653                 __timeZoneTotalList = null;
654         }
655
656         if (__timeZoneSearchList != null)
657         {
658                 delete __timeZoneSearchList;
659                 __timeZoneSearchList = null;
660         }
661 }
662
663 result
664 TimeZoneForm::SetTimeZoneLocaleList(TimeZoneData* pTimeZoneData)
665 {
666         InitTimeZoneLocaleList();
667
668         if (__timeZoneTotalList == null)
669         {
670                 return E_FAILURE;
671         }
672
673         return __timeZoneTotalList->Add(pTimeZoneData);
674 }
675
676 result
677 TimeZoneForm::SetTimeZoneLocaleSearchList(TimeZoneData* pTimeZoneData)
678 {
679         if (__timeZoneSearchList == null)
680         {
681                 __timeZoneSearchList = new (std::nothrow) ArrayList(SingleObjectDeleter);
682                 __timeZoneSearchList->Construct();
683         }
684
685         return __timeZoneSearchList->Add(pTimeZoneData);
686 }
687
688 void
689 TimeZoneForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
690 {
691         switch (keypadAction)
692         {
693         case KEYPAD_ACTION_SEARCH:
694                 {
695                         __pSearchBar->HideKeypad();
696                         __pSearchBar->Invalidate(false);
697                 }
698                 break;
699
700         default:
701                 break;
702         }
703 }
704
705 result
706 TiemZoneComparer::Compare(const Tizen::Base::Object& obj1, const Tizen::Base::Object& obj2, int& cmp) const
707 {
708         switch (__type)
709         {
710         case DATA_TYPE_REGION:
711                 {
712                         cmp = static_cast<const TimeZoneData&>(obj1).GetRegionData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetRegionData());
713                 }
714                 break;
715
716         case DATA_TYPE_COUNTRY:
717                 {
718                         cmp = static_cast<const TimeZoneData&>(obj1).GetCountryData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetCountryData());
719                 }
720                 break;
721
722         case DATA_TYPE_GMT:
723                 {
724                         cmp = static_cast<const TimeZoneData&>(obj1).GetGMTData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetGMTData());
725
726                         if (cmp == 0)
727                         {
728                                 cmp = static_cast<const TimeZoneData&>(obj1).GetCountryData().CompareTo(static_cast<const TimeZoneData&>(obj2).GetCountryData());
729                         }
730                 }
731                 break;
732
733         default:
734                 break;
735         }
736
737         return GetLastResult();
738 }
739
740 Tizen::Base::String
741 TimeZoneData::GetCountryData(void) const
742 {
743         return _timeZoneCountry;
744 }
745
746 Tizen::Base::String
747 TimeZoneData::GetRegionData(void) const
748 {
749         return _timeZoneRegion;
750 }
751
752 Tizen::Base::Integer
753 TimeZoneData::GetGMTData(void) const
754 {
755         return _timeZoneGMT;
756 }