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