NABI_Issue Fix 53297 53607 53635 53606 53534
[apps/osp/Contacts.git] / src / CtContactListEditorPanel.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        CtContactListEditorPanel.cpp
19  * @brief       This is the implementation file for the ContactListEditorPanel class.
20  */
21
22 #include <FSocial.h>
23 #include "CtContactListEditorPanel.h"
24 #include "CtContactListItem.h"
25 #include "CtContactListPresentationModel.h"
26 #include "CtContactsApp.h"
27 #include "CtCommonUtil.h"
28 #include "CtMainForm.h"
29 #include "CtResourceManager.h"
30 #include "CtSceneRegister.h"
31 #include "CtSearchListItem.h"
32 #include "CtSearchListEventListener.h"
33 #include "CtTypes.h"
34
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Ui;
40 using namespace Tizen::Ui::Controls;
41 using namespace Tizen::Ui::Scenes;
42 using namespace Tizen::Social;
43
44 static const int IDA_HEADER_CONTACTS = 10;
45 static const int IDA_HEADER_GROUPS = 11;
46 static const int IDA_HEADER_FAVORITES = 12;
47 static const int IDA_CHECK_SELECT_ALL_CHECKED = 20;
48 static const int IDA_CHECK_SELECT_ALL_UNCHECKED = 21;
49 static const int IDA_FOOTER_DELETE = 30;
50 static const int IDA_FOOTER_CANCEL = 31;
51 static const int IDA_FOOTER_DONE = 32;
52 static const int IDA_POPUP_CONTACT_VALUE_CLOSE = 40;
53 static const int IDA_POPUP_DELETE_OK = 41;
54 static const int IDA_POPUP_DELETE_CANCEL = 42;
55 static const int IDA_POPUP_DELETE_PROGRESS_CANCEL = 43;
56
57 static const int X_EMPTY_IMAGE = 220;
58 static const int Y_EMPTY_IMAGE = 300;
59 static const int W_EMPTY_IMAGE = 280;
60 static const int H_EMPTY_IMAGE = 280;
61 static const int Y_EMPTY_COMMENT = 618;
62 static const int H_EMPTY_COMMENT = 38;
63 static const int W_INITIAL_PANEL = 10;
64 static const int H_INITIAL_PANEL = 10;
65 static const int H_SELECT_ALL = 112;
66 static const int H_SEARCHBAR = 86;
67 static const int H_BOTTOM_LABEL = 48;
68 static const int H_GROUP_ITEM = 76;
69 static const int W_CONTACT_VALUE_POPUP = 688;
70 static const int H_CONTACT_VALUE_POPUP = 532;
71 static const int H_CONTACT_VALUE_POPUP_LIST_VIEW = 338;
72 static const int H_CLOSE_BUTTON = 74;
73 static const int Y_CLOSE_BUTTON = 358;
74 static const int W_CLOSE_BUTTON = 394;
75 static const int H_DELETE_PROGRESS_POPUP = 308;
76 static const int Y_DELETE_POPUP_TITLE = 20;
77 static const int H_DELETE_POPUP_ELEMENT = 60;
78 static const int H_DELETE_POPUP_PROGRESS = 34;
79 static const int Y_DELETE_POPUP_CANCEL_BUTTON = 214;
80 static const int H_DELETE_POPUP_CANCEL_BUTTON = 74;
81 static const int W_DELETE_POPUP_CANCEL_BUTTON = 394;
82 static const int X_LIST_ITEM_TEXT_MARGIN = 32;
83 static const int H_CHECK_LABEL = 72;
84 static const int Y_CHECK_LABEL = 20;
85
86 static const int FONT_SIZE_EMPTY_COMMENT = 32;
87 static const int FONT_SIZE_BOTTOM_LABEL = 32;
88 static const int FONT_SIZE_DELETE_POPUP_TEXT = 36;
89
90 static const unsigned int COLOR_EMPTY_COMMENT = Color32<102, 102, 102>::Value;
91 static const unsigned int COLOR_BOTTOM_LABEL_BG = Color32<68, 68, 68>::Value;
92 static const unsigned int COLOR_BOTTOM_LABEL_FONT = Color32<255, 255, 255>::Value;
93 static const unsigned int COLOR_DELETE_POPUP_TEXT = Color32<128, 128, 128>::Value;
94 static const unsigned int COLOR_CHECK_LABEL_BG = Color32<220, 218, 211>::Value;
95 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<213, 82, 82>::Value;
96 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
97 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
98
99 static const int LIST_VIEW_GROUP_INDEX_SHIFT = 16;
100 static const int LIST_VIEW_MASK = 0xFFFF;
101
102 static const wchar_t* IDB_NO_CONTENTS = L"00_Nocontents_text.png";
103
104 ContactListEditorPanel::ContactListEditorPanel(void)
105 : __pTempContactValueHashMap(null)
106 , __pSelectAll(null)
107 , __pListView(null)
108 , __pSearchListView(null)
109 , __pSearchBar(null)
110 , __pCheckLabel(null)
111 , __pEmptyImageLabel(null)
112 , __pEmptyCommentLabel(null)
113 , __pBottomLabel(null)
114 , __pMultipleContactValuePopup(null)
115 , __pDeleteProgressPopup(null)
116 , __pDeleteConfirmationPopup(null)
117 , __pContactValueListEvent(null)
118 , __pPresentationModel(null)
119 , __pSearchListEvent(null)
120 , __isContactRemoved(false)
121 , __selectedIndex(-1)
122 , __selectedSearchIndex(-1)
123 , __deleteGroupIndex(0)
124 , __deleteItemIndex(0)
125 {
126         __deleteContactTimer.Construct(*this);
127 }
128
129 ContactListEditorPanel::~ContactListEditorPanel(void)
130 {
131 }
132
133 void
134 ContactListEditorPanel::Initialize(void)
135 {
136         Construct(Rectangle(0, 0, W_INITIAL_PANEL, H_INITIAL_PANEL));
137 }
138
139 result
140 ContactListEditorPanel::OnInitializing(void)
141 {
142         const Form* pForm = dynamic_cast<Form*>(GetParent());
143         AppAssert(pForm);
144
145         FloatRectangle clientBounds = pForm->GetClientAreaBoundsF();
146         SetBounds(FloatRectangle(0, 0, clientBounds.width, clientBounds.height));
147
148         __pPresentationModel = ContactListPresentationModel::GetInstance();
149
150         __pCheckLabel = new (std::nothrow) Label();
151         __pCheckLabel->Construct(Rectangle(0, H_SEARCHBAR + Y_CHECK_LABEL, clientBounds.width, H_CHECK_LABEL), L"");
152         __pCheckLabel->SetBackgroundColor(COLOR_CHECK_LABEL_BG);
153
154         AddControl(__pCheckLabel);
155
156         __pSelectAll = new (std::nothrow) CheckButton();
157         __pSelectAll->Construct(Rectangle(0, H_SEARCHBAR, clientBounds.width, H_SELECT_ALL), CHECK_BUTTON_STYLE_MARK, BACKGROUND_STYLE_NONE);
158         __pSelectAll->SetText(ResourceManager::GetString(L"IDS_COM_BODY_SELECT_ALL"));
159         __pSelectAll->SetActionId(IDA_CHECK_SELECT_ALL_CHECKED, IDA_CHECK_SELECT_ALL_UNCHECKED);
160         __pSelectAll->AddActionEventListener(*this);
161
162         AddControl(__pSelectAll);
163
164         __pListView = new (std::nothrow) GroupedListView();
165         __pListView->Construct(Rectangle(0, H_SEARCHBAR + H_SELECT_ALL, clientBounds.width, clientBounds.height - H_SEARCHBAR - H_SELECT_ALL - H_BOTTOM_LABEL), GROUPED_LIST_VIEW_STYLE_INDEXED, true, true);
166         __pListView->SetItemProvider(*this);
167         __pListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_PB_BODY_NO_CONTACTS"));
168         __pListView->AddFastScrollListener(*this);
169         __pListView->AddGroupedListViewItemEventListener(*this);
170         __pListView->AddTouchEventListener(*this);
171
172         AddControl(__pListView);
173
174         __pSearchBar = new (std::nothrow) SearchBar();
175         __pSearchBar->Construct(Rectangle(0, 0, clientBounds.width, H_SEARCHBAR));
176         __pSearchBar->SetGuideText(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"));
177         __pSearchBar->AddSearchBarEventListener(*this);
178         __pSearchBar->AddTextEventListener(*this);
179         __pSearchBar->AddKeypadEventListener(*this);
180         __pSearchBar->SetContentAreaSize(Dimension(0, 0));
181
182         __pSearchListEvent = new (std::nothrow) SearchListEventListener(LIST_ANNEX_STYLE_MARK, __pPresentationModel);
183
184         AddControl(__pSearchBar);
185
186         __pSearchListView = new (std::nothrow) GroupedListView();
187         __pSearchListView->Construct(Rectangle(0, H_SEARCHBAR, clientBounds.width, clientBounds.height - H_SEARCHBAR - H_BOTTOM_LABEL), GROUPED_LIST_VIEW_STYLE_INDEXED, true, false);
188         __pSearchListView->SetItemProvider(*__pSearchListEvent);
189         __pSearchListView->AddGroupedListViewItemEventListener(*this);
190         __pSearchListView->AddTouchEventListener(*this);
191         __pSearchListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_PB_BODY_NO_CONTACTS"));
192         __pSearchListView->SetShowState(false);
193
194         AddControl(__pSearchListView);
195
196         __pEmptyImageLabel = new (std::nothrow) Label();
197         __pEmptyImageLabel->Construct(Rectangle(X_EMPTY_IMAGE, Y_EMPTY_IMAGE, W_EMPTY_IMAGE, H_EMPTY_IMAGE), L"");
198         Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
199         if (pBitmap != null)
200         {
201                 __pEmptyImageLabel->SetBackgroundBitmap(*pBitmap);
202                 delete pBitmap;
203         }
204         __pEmptyImageLabel->SetShowState(false);
205
206         AddControl(__pEmptyImageLabel);
207
208         __pEmptyCommentLabel = new (std::nothrow) Label();
209         __pEmptyCommentLabel->Construct(Rectangle(0, Y_EMPTY_COMMENT, clientBounds.width, H_EMPTY_COMMENT),
210                                                                                                                                 ResourceManager::GetString(L"IDS_PB_BODY_NO_CONTACTS"));
211         __pEmptyCommentLabel->SetTextConfig(FONT_SIZE_EMPTY_COMMENT, LABEL_TEXT_STYLE_NORMAL);
212         __pEmptyCommentLabel->SetTextColor(Color(COLOR_EMPTY_COMMENT));
213         __pEmptyCommentLabel->SetShowState(false);
214
215         AddControl(__pEmptyCommentLabel);
216
217         __pBottomLabel = new (std::nothrow) Label();
218         __pBottomLabel->Construct(FloatRectangle(0, clientBounds.height - H_BOTTOM_LABEL, clientBounds.width, H_BOTTOM_LABEL),
219                                                                                                         ResourceManager::GetString(L"IDS_COM_POP_SELECTED") + INITIAL_SELECTED_COUNT);
220         __pBottomLabel->SetBackgroundColor(Color(COLOR_BOTTOM_LABEL_BG));
221         __pBottomLabel->SetTextColor(Color(COLOR_BOTTOM_LABEL_FONT));
222         __pBottomLabel->SetTextConfig(FONT_SIZE_BOTTOM_LABEL, LABEL_TEXT_STYLE_BOLD);
223         __pBottomLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
224         __pBottomLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
225         AddControl(__pBottomLabel);
226
227         __pTempContactValueHashMap = new (std::nothrow) HashMap();
228         __pTempContactValueHashMap->Construct();
229
230         return E_SUCCESS;
231 }
232
233 result
234 ContactListEditorPanel::OnTerminating(void)
235 {
236         result r = E_SUCCESS;
237
238         if (__pPresentationModel != null)
239         {
240                 __pPresentationModel->RemoveContactChangeListener(*this);
241         }
242
243         delete __pSearchListEvent;
244
245         __pTempContactValueHashMap->RemoveAll(true);
246         delete __pTempContactValueHashMap;
247
248         delete __pDeleteProgressPopup;
249         delete __pDeleteConfirmationPopup;
250         delete __pMultipleContactValuePopup;
251
252         return r;
253 }
254
255 void
256 ContactListEditorPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
257 {
258         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
259         SceneManager* pSceneManager = SceneManager::GetInstance();
260         Form* pForm = dynamic_cast<Form*>(GetParent());
261         AppAssert(pForm);
262
263         switch (actionId)
264         {
265         case IDA_HEADER_CONTACTS:
266                 {
267                         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
268                         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK && pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
269                         {
270                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST_EDITOR));
271                         }
272                         else
273                         {
274                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTACT_LIST));
275                         }
276                 }
277                 break;
278         case IDA_HEADER_GROUPS:
279                 {
280                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_GROUP_LIST));
281                 }
282                 break;
283         case IDA_HEADER_FAVORITES:
284                 {
285                         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
286                         {
287                                 if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_SINGLE)
288                                 {
289                                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
290                                 }
291                                 else if (pContactsApp->GetSelectionMode() == APP_CONTROL_SELECTION_MODE_MULTI)
292                                 {
293                                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST_EDITOR));
294                                 }
295                         }
296                         else
297                         {
298                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FAVORITE_LIST));
299                         }
300                 }
301                 break;
302         case IDA_CHECK_SELECT_ALL_CHECKED:
303                 {
304                         for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
305                         {
306                                 int itemCount = __pListView->GetItemCountAt(groupIndex);
307                                 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
308                                 {
309                                         __pListView->SetItemChecked(groupIndex, itemIndex, true);
310
311                                         int index = 0;
312                                         index |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
313                                         index |= itemIndex;
314                                         Integer hashMapIndex(index);
315
316                                         if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
317                                         {
318                                                 if (__pTempContactValueHashMap->GetValue(hashMapIndex) == null)
319                                                 {
320                                                         String phoneNumber = __pPresentationModel->GetDefaultPhoneNumber(groupIndex, itemIndex);
321                                                         __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(index)), *(new (std::nothrow) String(phoneNumber)));
322                                                 }
323                                         }
324                                         else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
325                                         {
326                                                 if (__pTempContactValueHashMap->GetValue(hashMapIndex) == null)
327                                                 {
328                                                         String email = __pPresentationModel->GetDefaultEmail(groupIndex, itemIndex);
329                                                         __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(index)), *(new (std::nothrow) String(email)));
330                                                 }
331                                         }
332                                 }
333                         }
334                         __pListView->Invalidate(true);
335                         UpdateBottomLabel();
336                 }
337                 break;
338         case IDA_CHECK_SELECT_ALL_UNCHECKED:
339                 {
340                         for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
341                         {
342                                 int itemCount = __pListView->GetItemCountAt(groupIndex);
343                                 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
344                                 {
345                                         __pListView->SetItemChecked(groupIndex, itemIndex, false);
346                                 }
347                         }
348                         __pTempContactValueHashMap->RemoveAll(true);
349                         __pListView->Invalidate(true);
350                         UpdateBottomLabel();
351                 }
352                 break;
353         case IDA_FOOTER_DELETE:
354                 {
355                         ShowDeleteConfirmationPopup();
356                 }
357                 break;
358         case IDA_FOOTER_CANCEL:
359                 {
360                         pSceneManager->GoBackward(BackwardSceneTransition());
361                 }
362                 break;
363         case IDA_FOOTER_DONE:
364                 {
365                         ReturnMultipleValues();
366                 }
367                 break;
368         case IDA_POPUP_CONTACT_VALUE_CLOSE:
369                 {
370                         HideContactValuePopup();
371                 }
372                 break;
373         case IDA_POPUP_DELETE_OK:
374                 {
375                         ShowDeleteProgressPopup();
376                 }
377                 break;
378         case IDA_POPUP_DELETE_CANCEL:
379                 {
380                         HideDeleteConfirmationPopup();
381                 }
382                 break;
383         case IDA_POPUP_DELETE_PROGRESS_CANCEL:
384                 {
385                         __deleteContactTimer.Cancel();
386                         HideDeleteProgressPopup();
387                         pSceneManager->GoBackward(BackwardSceneTransition());
388                 }
389                 break;
390         default:
391                 break;
392         }
393 }
394
395 void
396 ContactListEditorPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
397                                                                                 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
398 {
399         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
400
401         Form* pForm = dynamic_cast<Form*>(GetParent());
402         AppAssert(pForm);
403
404         Header* pHeader = pForm->GetHeader();
405         pHeader->AddActionEventListener(*this);
406
407         Footer* pFooter = pForm->GetFooter();
408         pFooter->RemoveAllItems();
409         pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
410         pForm->SetFormMenuEventListener(null);
411
412         __pPresentationModel->InitializeContactList();
413         __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
414         __pListView->UpdateList();
415
416         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
417         {
418                 pFooter->SetShowState(true);
419
420                 FooterItem footerItemDone;
421                 footerItemDone.Construct(IDA_FOOTER_DONE);
422                 footerItemDone.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
423                 pFooter->AddItem(footerItemDone);
424
425                 if (__pPresentationModel->GetContactCount() == 0)
426                 {
427                         pFooter->SetItemEnabled(0, false);
428
429                         __pSearchBar->SetShowState(false);
430                         __pCheckLabel->SetShowState(false);
431                         __pSelectAll->SetShowState(false);
432                         __pListView->SetShowState(false);
433                         __pEmptyImageLabel->SetShowState(true);
434                         __pEmptyCommentLabel->SetShowState(true);
435                         __pBottomLabel->SetShowState(false);
436
437                 }
438                 else
439                 {
440                         for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
441                         {
442                                 int itemCount = __pListView->GetItemCountAt(groupIndex);
443                                 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
444                                 {
445                                         __pListView->SetItemChecked(groupIndex, itemIndex, false);
446                                 }
447                         }
448
449                          pFooter->SetItemEnabled(0, false);
450
451                         __pSearchBar->SetShowState(true);
452                         __pCheckLabel->SetShowState(true);
453                         __pSelectAll->SetShowState(true);
454                         __pListView->SetShowState(true);
455                         __pEmptyImageLabel->SetShowState(false);
456                         __pEmptyCommentLabel->SetShowState(false);
457
458                         __pSelectAll->SetSelected(false);
459                 }
460         }
461         else
462         {
463                 __pSelectAll->SetSelected(false);
464                 for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
465                 {
466                         int itemCount = __pListView->GetItemCountAt(groupIndex);
467                         for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
468                         {
469                                 __pListView->SetItemChecked(groupIndex, itemIndex, false);
470                         }
471                 }
472
473                 FooterItem footerDelete;
474                 footerDelete.Construct(IDA_FOOTER_DELETE);
475                 footerDelete.SetText(ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
476
477                 FooterItem footerCancel;
478                 footerCancel.Construct(IDA_FOOTER_CANCEL);
479                 footerCancel.SetText(ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
480                 pFooter->AddItem(footerCancel);
481                 pFooter->AddItem(footerDelete);
482                 pFooter->SetItemEnabled(1, false);
483         }
484
485         __pPresentationModel->AddContactChangeListener(*this);
486         pFooter->AddActionEventListener(*this);
487         UpdateBottomLabel();
488
489         if (pArgs != null)
490         {
491                 pArgs->RemoveAll(true);
492                 delete pArgs;
493         }
494 }
495
496 void
497 ContactListEditorPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
498                                                                                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
499 {
500         Form* pForm = dynamic_cast<Form*>(GetParent());
501         AppAssert(pForm);
502
503         if (pForm->IsFooterVisible() == false)
504         {
505                 pForm->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
506         }
507
508         Header* pHeader = pForm->GetHeader();
509         pHeader->RemoveActionEventListener(*this);
510
511         Footer* pFooter = pForm->GetFooter();
512         pFooter->RemoveActionEventListener(*this);
513
514         if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
515         {
516                 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
517         }
518
519         __pPresentationModel->RemoveContactChangeListener(*this);
520 }
521
522 result
523 ContactListEditorPanel::RemoveContactList(void)
524 {
525         result r = E_FAILURE;
526
527         for (int groupIndex = __deleteGroupIndex; groupIndex < __pListView->GetGroupCount(); groupIndex++)
528         {
529                 int itemCount = __pListView->GetItemCountAt(groupIndex);
530                 for (int itemIndex = __deleteItemIndex; itemIndex < itemCount; itemIndex++)
531                 {
532                         if (__pListView->IsItemChecked(groupIndex, itemIndex) == true)
533                         {
534                                 r = __pPresentationModel->RemoveContact(groupIndex, itemIndex, false);
535
536                                 __deleteGroupIndex = groupIndex;
537                                 __deleteItemIndex = ++itemIndex;
538
539                                 return r;
540                         }
541                 }
542                 __deleteItemIndex = 0;
543         }
544
545         __deleteGroupIndex = 0;
546         __deleteItemIndex = 0;
547
548         return r;
549 }
550
551 int
552 ContactListEditorPanel::GetCheckedContactCounts(void)
553 {
554         int contactCount = 0;
555
556         for (int groupIndex = __deleteGroupIndex; groupIndex < __pListView->GetGroupCount(); groupIndex++)
557         {
558                 int itemCount = __pListView->GetItemCountAt(groupIndex);
559                 for (int itemIndex = __deleteItemIndex; itemIndex < itemCount; itemIndex++)
560                 {
561                         if (__pListView->IsItemChecked(groupIndex, itemIndex) == true)
562                         {
563                                 contactCount++;
564                         }
565                 }
566         }
567
568         return contactCount;
569 }
570
571 Tizen::Ui::Controls::ListItemBase*
572 ContactListEditorPanel::CreateItem(int groupIndex, int itemIndex, int itemWidth)
573 {
574         String name;
575         Bitmap* pThumbnail = null;
576
577         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
578
579         CustomItem* pItem = new (std::nothrow) CustomItem();
580         pItem->Construct(Dimension(itemWidth, pContactsApp->GetListItemSingleLineHeight()), LIST_ANNEX_STYLE_MARK);
581
582         __pPresentationModel->GetContactItemInfoN(groupIndex, itemIndex, name, pThumbnail);
583
584         ContactListItem* pCustomElement = new (std::nothrow) ContactListItem(name, pThumbnail);
585         pItem->AddElement(Rectangle(0, 0, itemWidth - (ListItemBase::GetAnnexWidth(LIST_ANNEX_STYLE_MARK) + X_LIST_ITEM_TEXT_MARGIN), pContactsApp->GetListItemSingleLineHeight()), 0, *(static_cast<ICustomElement *>(pCustomElement)));
586
587         return pItem;
588 }
589
590 bool
591 ContactListEditorPanel::DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
592 {
593         delete pItem;
594         pItem = null;
595
596         return true;
597 }
598
599 int
600 ContactListEditorPanel::GetItemCount(int groupIndex)
601 {
602         return __pPresentationModel->GetContactCount(groupIndex);
603 }
604
605 int
606 ContactListEditorPanel::GetGroupCount(void)
607 {
608         return __pPresentationModel->GetKeyCount();
609 }
610
611 Tizen::Ui::Controls::GroupItem*
612 ContactListEditorPanel::CreateGroupItem(int groupIndex, int itemWidth)
613 {
614         GroupItem* pItem = new (std::nothrow) GroupItem();
615         pItem->Construct(Dimension(itemWidth, H_GROUP_ITEM));
616         pItem->SetElement(__pPresentationModel->GetKey(groupIndex), null);
617
618         return pItem;
619 }
620
621 bool
622 ContactListEditorPanel::DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::GroupItem* pItem, int itemWidth)
623 {
624         delete pItem;
625         pItem = null;
626
627         return true;
628 }
629
630 void
631 ContactListEditorPanel::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
632 {
633         if (mode == SEARCH_BAR_MODE_NORMAL)
634         {
635                 int count = __pPresentationModel->GetSearchedContactCount();
636                 bool isChecked = true;
637
638                 for (int index = 0; index < count; index++)
639                 {
640                         int groupIndex = 0;
641                         int itemIndex = 0;
642
643                         __pPresentationModel->GetItemMainIndex(index, groupIndex, itemIndex);
644
645                         __pListView->SetItemChecked(groupIndex, itemIndex, __pSearchListView->IsItemChecked(0, index));
646                 }
647
648                 for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount() && isChecked == true; groupIndex++)
649                 {
650                         int itemCount = __pListView->GetItemCountAt(groupIndex);
651                         for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
652                         {
653                                 if (__pListView->IsItemChecked(groupIndex, itemIndex) == false)
654                                 {
655                                         isChecked = false;
656                                         break;
657                                 }
658                         }
659                 }
660
661                 __pListView->SetShowState(true);
662                 __pListView->Invalidate(true);
663                 __pCheckLabel->SetShowState(true);
664                 __pSelectAll->SetShowState(true);
665                 __pSelectAll->SetSelected(isChecked);
666                 __pSearchListView->SetShowState(false);
667                 __pPresentationModel->ResetSearchedContactList();
668                 __pSearchListView->UpdateList();
669         }
670 }
671
672 void
673 ContactListEditorPanel::OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
674 {
675 }
676
677 void
678 ContactListEditorPanel::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus status)
679 {
680         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
681
682         int mainGroupIndex = groupIndex;
683         int mainItemIndex = itemIndex;
684
685         if (listView.Equals(*__pSearchListView) == true)
686         {
687                 __selectedSearchIndex = 0;
688                 __selectedSearchIndex |= groupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
689                 __selectedSearchIndex |= itemIndex;
690
691                 __pPresentationModel->GetItemMainIndex(itemIndex, mainGroupIndex, mainItemIndex);
692         }
693
694         __selectedIndex = 0;
695         __selectedIndex |= mainGroupIndex << LIST_VIEW_GROUP_INDEX_SHIFT;
696         __selectedIndex |= mainItemIndex;
697
698         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
699         {
700                 if (listView.IsItemChecked(groupIndex, itemIndex) == true)
701                 {
702                         IList* pList = null;
703                         if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
704                         {
705                                 pList = __pPresentationModel->GetAllPhoneNumbersN(mainGroupIndex, mainItemIndex);
706
707                                 if (pList == null)
708                                 {
709                                         ReturnResultFailed();
710                                 }
711                                 else
712                                 {
713                                         if (pList->GetCount() > 1)
714                                         {
715                                                 listView.SetItemChecked(groupIndex, itemIndex, false);
716                                                 __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
717                                                 ShowContactValuePopup(mainGroupIndex, mainItemIndex);
718                                         }
719                                         else if (pList->GetCount() == 1)
720                                         {
721                                                 String* pContactValueInfo = static_cast<String *>(pList->GetAt(0));
722                                                 int blankIndex = 0;
723                                                 pContactValueInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
724                                                 pContactValueInfo->Remove(0, blankIndex + 1);
725                                                 __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(__selectedIndex)), *(new (std::nothrow) String(*pContactValueInfo)));
726                                                 delete pList;
727                                         }
728                                 }
729                         }
730                         else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
731                         {
732                                 pList = __pPresentationModel->GetAllEmailsN(mainGroupIndex, mainItemIndex);
733
734                                 if (pList == null)
735                                 {
736                                         ReturnResultFailed();
737                                 }
738                                 else
739                                 {
740                                         if (pList->GetCount() > 1)
741                                         {
742                                                 listView.SetItemChecked(groupIndex, itemIndex, false);
743                                                 __pContactValueListEvent = new (std::nothrow) ContactValueListItemProvider(pList);
744                                                 ShowContactValuePopup(mainGroupIndex, mainItemIndex);
745                                         }
746                                         else if (pList->GetCount() == 1)
747                                         {
748                                                 String* pContactValueInfo = static_cast<String *>(pList->GetAt(0));
749                                                 int blankIndex = 0;
750                                                 pContactValueInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
751                                                 pContactValueInfo->Remove(0, blankIndex + 1);
752                                                 __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(__selectedIndex)), *(new (std::nothrow) String(*pContactValueInfo)));
753                                                 delete pList;
754                                         }
755                                 }
756                         }
757                 }
758                 else
759                 {
760                         Integer keyIndex(__selectedIndex);
761                         __pTempContactValueHashMap->Remove(keyIndex, true);
762                 }
763         }
764
765         if (listView.Equals(*__pListView) == true)
766         {
767                 if (listView.IsItemChecked(groupIndex, itemIndex) == true)
768                 {
769                         bool isChecked = true;
770                         for (int groupIndex = 0; groupIndex < listView.GetGroupCount() && isChecked == true; groupIndex++)
771                         {
772                                 int itemCount = listView.GetItemCountAt(groupIndex);
773                                 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
774                                 {
775                                         if (listView.IsItemChecked(groupIndex, itemIndex) == false)
776                                         {
777                                                 isChecked = false;
778                                                 break;
779                                         }
780                                 }
781                         }
782                         __pSelectAll->SetSelected(isChecked);
783                 }
784                 else if (listView.IsItemChecked(groupIndex, itemIndex) == false)
785                 {
786                         __pSelectAll->SetSelected(false);
787                 }
788         }
789         else if (listView.Equals(*__pSearchListView) == true)
790         {
791                 int count = __pPresentationModel->GetSearchedContactCount();
792
793                 for (int index = 0; index < count; index++)
794                 {
795                         int groupIndex = 0;
796                         int itemIndex = 0;
797
798                         __pPresentationModel->GetItemMainIndex(index, groupIndex, itemIndex);
799
800                         __pListView->SetItemChecked(groupIndex, itemIndex, __pSearchListView->IsItemChecked(0, index));
801                 }
802         }
803
804         UpdateBottomLabel();
805 }
806
807 void
808 ContactListEditorPanel::OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction)
809 {
810 }
811
812 void
813 ContactListEditorPanel::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
814 {
815 }
816
817 void
818 ContactListEditorPanel::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
819 {
820         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
821
822         int groupIndex = (__selectedIndex >> LIST_VIEW_GROUP_INDEX_SHIFT) & LIST_VIEW_MASK;
823         int itemIndex = __selectedIndex & LIST_VIEW_MASK;
824
825         IList* pList = null;
826         if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
827         {
828                 pList = __pPresentationModel->GetAllPhoneNumbersN(groupIndex, itemIndex);
829         }
830         else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
831         {
832                 pList = __pPresentationModel->GetAllEmailsN(groupIndex, itemIndex);
833         }
834
835         if (pList == null)
836         {
837                 ReturnResultFailed();
838         }
839         else
840         {
841                 String* pContactValueInfo = static_cast<String *>(pList->GetAt(index));
842                 int blankIndex = 0;
843                 pContactValueInfo->IndexOf(CHARACTER_SPACE, 0, blankIndex);
844                 pContactValueInfo->Remove(0, blankIndex + 1);
845                 __pTempContactValueHashMap->Add(*(new (std::nothrow) Integer(__selectedIndex)), *(new (std::nothrow) String(*pContactValueInfo)));
846         }
847         delete pList;
848
849         HideContactValuePopup();
850
851         if (__pListView->GetShowState() == true)
852         {
853                 __pListView->SetItemChecked(groupIndex, itemIndex, true);
854
855                 bool isChecked = true;
856                 for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount() && isChecked == true; groupIndex++)
857                 {
858                         int itemCount = __pListView->GetItemCountAt(groupIndex);
859                         for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
860                         {
861                                 if (__pListView->IsItemChecked(groupIndex, itemIndex) == false)
862                                 {
863                                         isChecked = false;
864                                         break;
865                                 }
866                         }
867                 }
868
869                 __pSelectAll->SetSelected(isChecked);
870         }
871         else
872         {
873                 groupIndex = (__selectedSearchIndex >> LIST_VIEW_GROUP_INDEX_SHIFT) & LIST_VIEW_MASK;
874                 itemIndex = __selectedSearchIndex & LIST_VIEW_MASK;
875                 __pSearchListView->SetItemChecked(groupIndex, itemIndex, true);
876
877                 int count = __pPresentationModel->GetSearchedContactCount();
878
879                 for (int index = 0; index < count; index++)
880                 {
881                         __pPresentationModel->GetItemMainIndex(index, groupIndex, itemIndex);
882
883                         __pListView->SetItemChecked(groupIndex, itemIndex, __pSearchListView->IsItemChecked(0, index));
884                 }
885         }
886
887         UpdateBottomLabel();
888 }
889
890 void
891 ContactListEditorPanel::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
892 {
893 }
894
895 void
896 ContactListEditorPanel::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
897 {
898         __pListView->ScrollToItem(__pPresentationModel->GetKeyIndex(index), -1);
899         __pListView->Invalidate(false);
900 }
901
902 void
903 ContactListEditorPanel::OnTextValueChanged(const Tizen::Ui::Control& source)
904 {
905         String searchText = __pSearchBar->GetText();
906         searchText.Trim();
907
908         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
909         if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
910         {
911                 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_PHONE_ONLY);
912         }
913         else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
914         {
915                 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_HAS_EMAIL_ONLY);
916         }
917         else
918         {
919                 __pPresentationModel->SetSearchText(searchText, SEARCH_TYPE_NORMAL);
920         }
921
922         if (searchText.GetLength() != 0)
923         {
924                 __pCheckLabel->SetShowState(false);
925                 __pSelectAll->SetShowState(false);
926                 __pListView->SetShowState(false);
927                 __pSearchListView->SetShowState(true);
928
929                 __pSearchListView->UpdateList();
930
931                 int count = __pPresentationModel->GetSearchedContactCount();
932
933                 for (int index = 0; index < count; index++)
934                 {
935                         int groupIndex = 0;
936                         int itemIndex = 0;
937
938                         __pPresentationModel->GetItemMainIndex(index, groupIndex, itemIndex);
939                         __pSearchListView->SetItemChecked(0, index, __pListView->IsItemChecked(groupIndex, itemIndex));
940                 }
941
942                 __pSearchListView->Invalidate(true);
943         }
944         else
945         {
946                 __pCheckLabel->SetShowState(true);
947                 __pSelectAll->SetShowState(true);
948                 __pListView->SetShowState(true);
949                 __pSearchListView->SetShowState(false);
950
951                 int count = __pPresentationModel->GetSearchedContactCount();
952                 bool isChecked = true;
953
954                 for (int index = 0; index < count; index++)
955                 {
956                         int groupIndex = 0;
957                         int itemIndex = 0;
958
959                         __pPresentationModel->GetItemMainIndex(index, groupIndex, itemIndex);
960                         __pListView->SetItemChecked(groupIndex, itemIndex, __pSearchListView->IsItemChecked(0, index));
961                 }
962
963                 for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount() && isChecked == true; groupIndex++)
964                 {
965                         int itemCount = __pListView->GetItemCountAt(groupIndex);
966                         for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
967                         {
968                                 if (__pListView->IsItemChecked(groupIndex, itemIndex) == false)
969                                 {
970                                         isChecked = false;
971                                         break;
972                                 }
973                         }
974                 }
975
976                 __pSelectAll->SetSelected(isChecked);
977                 __pListView->Invalidate(true);
978         }
979 }
980
981 void
982 ContactListEditorPanel::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
983 {
984 }
985
986 void
987 ContactListEditorPanel::OnContactsChanged(void)
988 {
989         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
990         Form* pForm = dynamic_cast<Form*>(GetParent());
991         AppAssert(pForm);
992
993         HideContactValuePopup();
994
995         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
996         {
997                 Footer* pFooter = pForm->GetFooter();
998                 pFooter->RemoveAllItems();
999
1000                 FooterItem footerItemDone;
1001                 footerItemDone.Construct(IDA_FOOTER_DONE);
1002                 footerItemDone.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
1003                 pFooter->AddItem(footerItemDone);
1004
1005                 __pPresentationModel->InitializeContactList();
1006
1007                 if (__pPresentationModel->GetContactCount() == 0)
1008                 {
1009                         pFooter->SetItemEnabled(0, false);
1010
1011                         __pSearchBar->SetShowState(false);
1012                         __pCheckLabel->SetShowState(false);
1013                         __pSelectAll->SetShowState(false);
1014                         __pListView->SetShowState(false);
1015                         __pEmptyImageLabel->SetShowState(true);
1016                         __pEmptyCommentLabel->SetShowState(true);
1017                         __pBottomLabel->SetShowState(false);
1018                 }
1019                 else
1020                 {
1021                         if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
1022                         {
1023                                 Form* pForm = dynamic_cast<Form*>(GetParent());
1024                                 AppAssert(pForm);
1025
1026                                 __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
1027                                 pForm->SetFocus();
1028                         }
1029
1030                         __pListView->SetShowState(true);
1031                         __pSelectAll->SetShowState(true);
1032                         __pCheckLabel->SetShowState(true);
1033
1034                         for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
1035                         {
1036                                 int itemCount = __pListView->GetItemCountAt(groupIndex);
1037                                 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
1038                                 {
1039                                         if (__pListView->IsItemChecked(groupIndex, itemIndex) == true)
1040                                         {
1041                                                 __pListView->SetItemChecked(groupIndex, itemIndex, false);
1042                                         }
1043                                 }
1044                         }
1045
1046                         pFooter->SetItemEnabled(0, false);
1047
1048                         __pSearchBar->SetShowState(true);
1049                         __pSelectAll->SetSelected(false);
1050                         __pEmptyImageLabel->SetShowState(false);
1051                         __pEmptyCommentLabel->SetShowState(false);
1052                         UpdateBottomLabel();
1053
1054                         __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
1055                         __pListView->UpdateList();
1056                 }
1057         }
1058         else if (__isContactRemoved == false)
1059         {
1060                 __pPresentationModel->InitializeContactList();
1061                 if( __pPresentationModel->GetContactCount() == 0)
1062                 {
1063                         SceneManager* pSceneManager = SceneManager::GetInstance();
1064                         pSceneManager->GoBackward(BackwardSceneTransition());
1065                         return;
1066                 }
1067                 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
1068                 {
1069                         Form* pForm = dynamic_cast<Form*>(GetParent());
1070                         AppAssert(pForm);
1071
1072                         __pSearchBar->SetMode(SEARCH_BAR_MODE_NORMAL);
1073                         pForm->SetFocus();
1074                 }
1075                 __pSelectAll->SetSelected(false);
1076
1077                 for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
1078                 {
1079                         int itemCount = __pListView->GetItemCountAt(groupIndex);
1080                         for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
1081                         {
1082                                 if (__pListView->IsItemChecked(groupIndex, itemIndex) == true)
1083                                 {
1084                                         __pListView->SetItemChecked(groupIndex, itemIndex, false);
1085                                 }
1086                         }
1087                 }
1088                 UpdateBottomLabel();
1089                 __pListView->SetFastScrollIndex(__pPresentationModel->GetAllKeys(), false);
1090                 __pListView->UpdateList();
1091         }
1092 }
1093
1094 void
1095 ContactListEditorPanel::OnCategoriesChanged(void)
1096 {
1097 }
1098
1099 result
1100 ContactListEditorPanel::UpdateBottomLabel(void)
1101 {
1102         Form* pForm = dynamic_cast<Form*>(GetParent());
1103         AppAssert(pForm);
1104         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1105         int selectedCount = 0;
1106         int fotterItemIndex = 1;
1107
1108         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
1109         {
1110                 fotterItemIndex = 0;
1111         }
1112
1113
1114         for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
1115         {
1116                 int itemCount = __pListView->GetItemCountAt(groupIndex);
1117                 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
1118                 {
1119                         if (__pListView->IsItemChecked(groupIndex, itemIndex) == true)
1120                         {
1121                                 selectedCount++;
1122                         }
1123                 }
1124         }
1125
1126         String selected = ResourceManager::GetString(L"IDS_COM_POP_SELECTED");
1127         selected.Append(L" (");
1128         selected.Append(selectedCount);
1129         selected.Append(L")");
1130         __pBottomLabel->SetText(selected);
1131         __pBottomLabel->SetPosition(FloatPoint(0, pForm->GetClientAreaBoundsF().height - H_BOTTOM_LABEL));
1132         __pBottomLabel->Invalidate(false);
1133
1134         Footer* pFooter = pForm->GetFooter();
1135
1136         if (selectedCount > 0 && __pBottomLabel->GetShowState() == false)
1137         {
1138                 __pBottomLabel->SetShowState(true);
1139                 __pListView->SetSize(__pListView->GetSize().width, __pListView->GetSize().height - H_BOTTOM_LABEL);
1140                 __pSearchListView->SetSize(__pSearchListView->GetSize().width, __pSearchListView->GetSize().height - H_BOTTOM_LABEL);
1141                 pFooter->SetItemEnabled(fotterItemIndex, true);
1142         }
1143         else if (selectedCount == 0 && __pBottomLabel->GetShowState() == true)
1144         {
1145                 __pBottomLabel->SetShowState(false);
1146                 __pListView->SetSize(__pListView->GetSize().width, __pListView->GetSize().height + H_BOTTOM_LABEL);
1147                 __pSearchListView->SetSize(__pSearchListView->GetSize().width, __pSearchListView->GetSize().height + H_BOTTOM_LABEL);
1148                 pFooter->SetItemEnabled(fotterItemIndex, false);
1149         }
1150
1151         pFooter->Invalidate(true);
1152
1153         return E_SUCCESS;
1154 }
1155
1156 void
1157 ContactListEditorPanel::ShowContactValuePopup(int groupIndex, int itemIndex)
1158 {
1159         delete __pMultipleContactValuePopup;
1160         __pMultipleContactValuePopup = new (std::nothrow) Popup();
1161         __pMultipleContactValuePopup->Construct(true, Dimension(W_CONTACT_VALUE_POPUP, H_CONTACT_VALUE_POPUP));
1162         __pMultipleContactValuePopup->SetTitleText(__pPresentationModel->GetName(groupIndex, itemIndex));
1163         __pMultipleContactValuePopup->SetPropagatedKeyEventListener(this);
1164
1165         Rectangle popupClientBounds = __pMultipleContactValuePopup->GetClientAreaBounds();
1166
1167         ListView* pListView = new (std::nothrow) ListView();
1168         pListView->Construct(Rectangle(0, 0, popupClientBounds.width, H_CONTACT_VALUE_POPUP_LIST_VIEW));
1169         pListView->SetItemProvider(*__pContactValueListEvent);
1170         pListView->AddListViewItemEventListener(*this);
1171
1172         __pMultipleContactValuePopup->AddControl(pListView);
1173
1174         Button* pCancelButton = new (std::nothrow) Button();
1175         pCancelButton->Construct(Rectangle((popupClientBounds.width - W_CLOSE_BUTTON) / 2, Y_CLOSE_BUTTON, W_CLOSE_BUTTON, H_CLOSE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CLOSE"));
1176         pCancelButton->SetActionId(IDA_POPUP_CONTACT_VALUE_CLOSE);
1177         pCancelButton->AddActionEventListener(*this);
1178
1179         __pMultipleContactValuePopup->AddControl(pCancelButton);
1180         __pMultipleContactValuePopup->SetShowState(true);
1181         __pMultipleContactValuePopup->Show();
1182 }
1183
1184 void
1185 ContactListEditorPanel::HideContactValuePopup(void)
1186 {
1187         if (__pMultipleContactValuePopup != null)
1188         {
1189                 __pMultipleContactValuePopup->SetShowState(false);
1190                 Invalidate(true);
1191         }
1192 }
1193
1194 void
1195 ContactListEditorPanel::ShowDeleteConfirmationPopup(void)
1196 {
1197         if (__pDeleteConfirmationPopup == null)
1198         {
1199                 __pDeleteConfirmationPopup = new (std::nothrow) Popup();
1200                 __pDeleteConfirmationPopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
1201                 __pDeleteConfirmationPopup->SetPropagatedKeyEventListener(this);
1202
1203                 Rectangle popupClientBounds = __pDeleteConfirmationPopup->GetClientAreaBounds();
1204
1205                 Label* pLabel = new (std::nothrow) Label();
1206                 pLabel->Construct(Rectangle(X_DELETE_LABEL, Y_DELETE_LABEL, W_DELETE_LABEL, H_DELETE_LABEL), ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
1207                 pLabel->SetTextConfig(FONT_SIZE_DELETE_CONFIRM, LABEL_TEXT_STYLE_NORMAL);
1208                 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1209                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1210
1211                 Button* pDeleteButton = new (std::nothrow) Button();
1212                 pDeleteButton->Construct(Rectangle(X_DELETE_LABEL + W_DELETE_BUTTON + W_POPUP_ITEM_GAP, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_SK_DELETE"));
1213                 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
1214                 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
1215                 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
1216                 pDeleteButton->SetTextSize(FONT_SIZE_DELETE_BUTTON);
1217                 pDeleteButton->SetActionId(IDA_POPUP_DELETE_OK);
1218                 pDeleteButton->AddActionEventListener(*this);
1219
1220                 Button* pCancelButton = new (std::nothrow) Button();
1221                 pCancelButton->Construct(Rectangle(X_DELETE_LABEL, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_PB_SK_CANCEL"));
1222                 pCancelButton->SetTextSize(FONT_SIZE_DELETE_BUTTON);
1223                 pCancelButton->SetActionId(IDA_POPUP_DELETE_CANCEL);
1224                 pCancelButton->AddActionEventListener(*this);
1225
1226                 __pDeleteConfirmationPopup->AddControl(pLabel);
1227                 __pDeleteConfirmationPopup->AddControl(pDeleteButton);
1228                 __pDeleteConfirmationPopup->AddControl(pCancelButton);
1229         }
1230
1231         __pDeleteConfirmationPopup->SetShowState(true);
1232         __pDeleteConfirmationPopup->Show();
1233 }
1234
1235 void
1236 ContactListEditorPanel::HideDeleteConfirmationPopup(void)
1237 {
1238         if (__pDeleteConfirmationPopup != null)
1239         {
1240                 __pDeleteConfirmationPopup->SetShowState(false);
1241                 Invalidate(true);
1242         }
1243 }
1244
1245 void
1246 ContactListEditorPanel::ShowDeleteProgressPopup(void)
1247 {
1248         if (__pDeleteProgressPopup != null)
1249         {
1250                 delete __pDeleteProgressPopup;
1251         }
1252
1253         __pDeleteProgressPopup = new (std::nothrow) Popup();
1254         __pDeleteProgressPopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_PROGRESS_POPUP));
1255         __pDeleteProgressPopup->AddWindowEventListener(*this);
1256
1257         Rectangle clientBounds = __pDeleteProgressPopup->GetClientAreaBounds();
1258
1259         Label* pLabelTitle = new (std::nothrow) Label();
1260         pLabelTitle->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE, clientBounds.width, H_DELETE_POPUP_ELEMENT), ResourceManager::GetString(L"IDS_PB_POP_DELETING_CONTACTS_ING"));
1261         pLabelTitle->SetTextColor(COLOR_DELETE_POPUP_TEXT);
1262         pLabelTitle->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_BOLD);
1263         pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1264
1265         __pDeleteProgressPopup->AddControl(pLabelTitle);
1266
1267         Progress* pProgress = new (std::nothrow) Progress();
1268         pProgress->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE + H_DELETE_POPUP_ELEMENT, clientBounds.width, H_DELETE_POPUP_PROGRESS), 0, GetCheckedContactCounts());
1269
1270         __pDeleteProgressPopup->AddControl(pProgress);
1271
1272         Label* pLabelPercentage = new (std::nothrow) Label();
1273         pLabelPercentage->Construct(Rectangle(0, pProgress->GetY() + pProgress->GetHeight(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), Integer::ToString(pProgress->GetPercentComplete()) + L"%");
1274         pLabelPercentage->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1275         pLabelPercentage->SetTextColor(COLOR_DELETE_POPUP_TEXT);
1276         pLabelPercentage->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
1277
1278         __pDeleteProgressPopup->AddControl(pLabelPercentage);
1279
1280         String currentOfTotal(Integer::ToString(pProgress->GetValue()) + L" / " + Integer::ToString(GetCheckedContactCounts()));
1281         Label* pLabelTotal = new (std::nothrow) Label();
1282         pLabelTotal->Construct(Rectangle(clientBounds.width / 2, pLabelPercentage->GetY(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), currentOfTotal);
1283         pLabelTotal->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1284         pLabelTotal->SetTextColor(COLOR_DELETE_POPUP_TEXT);
1285         pLabelTotal->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
1286
1287         __pDeleteProgressPopup->AddControl(pLabelTotal);
1288
1289         Button* pCancelButton = new (std::nothrow) Button();
1290         pCancelButton->Construct(Rectangle((clientBounds.width - W_DELETE_POPUP_CANCEL_BUTTON) / 2, Y_DELETE_POPUP_CANCEL_BUTTON, W_DELETE_POPUP_CANCEL_BUTTON, H_DELETE_POPUP_CANCEL_BUTTON));
1291         pCancelButton->SetText(ResourceManager::GetString("IDS_PB_SK_CANCEL"));
1292         pCancelButton->SetActionId(IDA_POPUP_DELETE_PROGRESS_CANCEL);
1293         pCancelButton->AddActionEventListener(*this);
1294
1295         __pDeleteProgressPopup->AddControl(pCancelButton);
1296         __pDeleteProgressPopup->Show();
1297
1298         __isContactRemoved = true;
1299 }
1300
1301 void
1302 ContactListEditorPanel::HideDeleteProgressPopup(void)
1303 {
1304         if (__pDeleteProgressPopup != null)
1305         {
1306                 delete __pDeleteProgressPopup;
1307                 __pDeleteProgressPopup = null;
1308         }
1309         __isContactRemoved = false;
1310
1311         __pListView->UpdateList();
1312         Invalidate(true);
1313 }
1314
1315 void
1316 ContactListEditorPanel::ReturnValues(RequestId requestId, Tizen::App::AppCtrlResult appCtrlResult, const Tizen::Base::Collection::IMap* pReturnValue)
1317 {
1318         AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
1319         result r = pAppManager->SendAppControlResult(requestId, appCtrlResult, pReturnValue);
1320         AppLogDebug("[%s] The return result from SendAppControlResult(), AppCtrlResult value : %d.", GetErrorMessage(r), appCtrlResult);
1321
1322         UiApp::GetInstance()->Terminate();
1323 }
1324
1325 void
1326 ContactListEditorPanel::ReturnMultipleValues(void)
1327 {
1328         if (CommonUtil::isMemoryAvailable() == false)
1329         {
1330                 CommonUtil::showMemoryFullMessageBox();
1331                 return;
1332         }
1333
1334         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1335
1336         if (pContactsApp->GetOperationId() == OPERATION_ID_PICK)
1337         {
1338                 ArrayList* pValueList = new (std::nothrow) ArrayList();
1339                 pValueList->Construct();
1340
1341                 HashMap* pReturnValue = new (std::nothrow) HashMap();
1342                 pReturnValue->Construct();
1343
1344                 if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_PHONE)
1345                 {
1346                         IMapEnumerator* pMapEnum = __pTempContactValueHashMap->GetMapEnumeratorN();
1347                         while (pMapEnum->MoveNext() == E_SUCCESS)
1348                         {
1349                                 String* pValue = static_cast<String*> (pMapEnum->GetValue());
1350                                 pValueList->Add(new (std::nothrow) String(*pValue));
1351                         }
1352                         pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_PHONE), pValueList);
1353
1354                         delete pMapEnum;
1355                 }
1356                 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_EMAIL)
1357                 {
1358                         IMapEnumerator* pMapEnum = __pTempContactValueHashMap->GetMapEnumeratorN();
1359                         while (pMapEnum->MoveNext() == E_SUCCESS)
1360                         {
1361                                 String* pValue = static_cast<String*> (pMapEnum->GetValue());
1362                                 pValueList->Add(new (std::nothrow) String(*pValue));
1363                         }
1364                         pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_EMAIL), pValueList);
1365
1366                         delete pMapEnum;
1367                 }
1368                 else if (pContactsApp->GetReturnType() == APP_CONTROL_RETURN_TYPE_ITEM_ID)
1369                 {
1370                         for (int groupIndex = 0; groupIndex < __pListView->GetGroupCount(); groupIndex++)
1371                         {
1372                                 int itemCount = __pListView->GetItemCountAt(groupIndex);
1373                                 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
1374                                 {
1375                                         if (__pListView->IsItemChecked(groupIndex, itemIndex) == true)
1376                                         {
1377                                                 String contactId;
1378                                                 contactId.Append(__pPresentationModel->GetContactId(groupIndex, itemIndex));
1379                                                 pValueList->Add(new (std::nothrow) String(contactId));
1380                                         }
1381                                 }
1382                         }
1383                         pReturnValue->Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), pValueList);
1384                 }
1385                 else
1386                 {
1387                         delete pValueList;
1388
1389                         ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, pReturnValue);
1390
1391                         return;
1392                 }
1393
1394                 ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_SUCCEEDED, pReturnValue);
1395         }
1396 }
1397
1398 void
1399 ContactListEditorPanel::ReturnResultFailed(void)
1400 {
1401         ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
1402
1403         ReturnValues(pContactsApp->GetRequestId(), APP_CTRL_RESULT_FAILED, null);
1404 }
1405
1406 void
1407 ContactListEditorPanel::OnKeypadWillOpen(Tizen::Ui::Control& source)
1408 {
1409 }
1410
1411 void
1412 ContactListEditorPanel::OnKeypadOpened(Tizen::Ui::Control& source)
1413 {
1414         Form* pForm = dynamic_cast<Form*>(GetParent());
1415         AppAssert(pForm);
1416
1417         if (__pBottomLabel->GetShowState() == true)
1418         {
1419                 __pSearchListView->SetBounds(Rectangle(0, H_SEARCHBAR, pForm->GetClientAreaBounds().width, pForm->GetClientAreaBounds().height - H_SEARCHBAR - H_BOTTOM_LABEL));
1420                 __pBottomLabel->SetPosition(FloatPoint(0, pForm->GetClientAreaBoundsF().height - H_BOTTOM_LABEL));
1421                 __pBottomLabel->Invalidate(true);
1422         }
1423         else
1424         {
1425                 __pSearchListView->SetBounds(Rectangle(0, H_SEARCHBAR, pForm->GetClientAreaBounds().width, pForm->GetClientAreaBounds().height - H_SEARCHBAR));
1426         }
1427 }
1428
1429 void
1430 ContactListEditorPanel::OnKeypadClosed(Tizen::Ui::Control& source)
1431 {
1432         Form* pForm = dynamic_cast<Form*>(GetParent());
1433         AppAssert(pForm);
1434
1435         if (__pBottomLabel->GetShowState() == true)
1436         {
1437                 __pSearchListView->SetBounds(Rectangle(0, H_SEARCHBAR, pForm->GetClientAreaBounds().width, pForm->GetClientAreaBounds().height - H_SEARCHBAR - H_BOTTOM_LABEL));
1438                 __pBottomLabel->SetPosition(FloatPoint(0, pForm->GetClientAreaBoundsF().height - H_BOTTOM_LABEL));
1439                 __pBottomLabel->Invalidate(true);
1440                 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_CONTACT_LIST_EDITOR)
1441                 {
1442                         UpdateBottomLabel();
1443                 }
1444         }
1445         else
1446         {
1447                 __pSearchListView->SetBounds(Rectangle(0, H_SEARCHBAR, pForm->GetClientAreaBounds().width, pForm->GetClientAreaBounds().height - H_SEARCHBAR));
1448         }
1449 }
1450
1451 void
1452 ContactListEditorPanel::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1453 {
1454         Form* pForm = dynamic_cast<Form*>(GetParent());
1455         AppAssert(pForm);
1456         if (__pBottomLabel->GetShowState() == true)
1457         {
1458                 __pSearchListView->SetBounds(Rectangle(0, H_SEARCHBAR, pForm->GetClientAreaBounds().width, pForm->GetClientAreaBounds().height - H_SEARCHBAR - H_BOTTOM_LABEL));
1459                 __pBottomLabel->SetPosition(FloatPoint(0, pForm->GetClientAreaBoundsF().height - H_BOTTOM_LABEL));
1460                 __pBottomLabel->Invalidate(true);
1461         }
1462         else
1463         {
1464                 __pSearchListView->SetBounds(Rectangle(0, H_SEARCHBAR, pForm->GetClientAreaBounds().width, pForm->GetClientAreaBounds().height - H_SEARCHBAR));
1465         }
1466 }
1467
1468 void
1469 ContactListEditorPanel::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
1470 {
1471         if (keypadAction == KEYPAD_ACTION_SEARCH)
1472         {
1473                 __pSearchBar->HideKeypad();
1474         }
1475 }
1476
1477 void
1478 ContactListEditorPanel::OnWindowActivated (const Tizen::Ui::Window &source)
1479 {
1480         __deleteContactTimer.Start(1);
1481 }
1482
1483 void
1484 ContactListEditorPanel::OnWindowDeactivated (const Tizen::Ui::Window &source)
1485 {
1486 }
1487
1488 void
1489 ContactListEditorPanel::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
1490 {
1491         Progress* pProgress = static_cast<Progress *>(__pDeleteProgressPopup->GetControl(1));
1492
1493         pProgress->SetValue(pProgress->GetValue() + 1);
1494         pProgress->Invalidate(false);
1495
1496         Label* pLabelPercentage = static_cast<Label *>(__pDeleteProgressPopup->GetControl(2));
1497
1498         pLabelPercentage->SetText(Integer::ToString(pProgress->GetPercentComplete()) + L"%");
1499         pLabelPercentage->Invalidate(false);
1500
1501         Label* pLabelTotal = static_cast<Label *>(__pDeleteProgressPopup->GetControl(3));
1502
1503         String currentOfTotal = pLabelTotal->GetText();
1504         currentOfTotal.Remove(0, Integer::ToString(pProgress->GetValue() - 1).GetLength());
1505         currentOfTotal.Insert(Integer::ToString(pProgress->GetValue()), 0);
1506         pLabelTotal->SetText(currentOfTotal);
1507         pLabelTotal->Invalidate(false);
1508
1509         if (RemoveContactList() == E_SUCCESS)
1510         {
1511                 __deleteContactTimer.Start(1);
1512         }
1513         else
1514         {
1515                 SceneManager* pSceneManager = SceneManager::GetInstance();
1516                 pSceneManager->GoBackward(BackwardSceneTransition());
1517         }
1518 }
1519
1520 void
1521 ContactListEditorPanel::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
1522 {
1523         GroupedListView* pList = static_cast<GroupedListView*>(&const_cast<Control&>(source));
1524         if (pList != null)
1525         {
1526                 pList->SetFocus();
1527         }
1528 }
1529
1530 void
1531 ContactListEditorPanel::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1532 {
1533 }
1534
1535 void
1536 ContactListEditorPanel::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1537 {
1538 }
1539
1540 void
1541 ContactListEditorPanel::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1542 {
1543 }
1544
1545 void
1546 ContactListEditorPanel::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1547 {
1548 }
1549
1550 bool
1551 ContactListEditorPanel::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1552 {
1553         return false;
1554 }
1555
1556 bool
1557 ContactListEditorPanel::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
1558 {
1559         if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
1560         {
1561                 if (__pDeleteConfirmationPopup && __pDeleteConfirmationPopup->GetShowState() == true)
1562                 {
1563                         HideDeleteConfirmationPopup();
1564                         return true;
1565                 }
1566                 if (__pMultipleContactValuePopup && __pMultipleContactValuePopup->GetShowState() == true)
1567                 {
1568                         HideContactValuePopup();
1569                         return true;
1570                 }
1571         }
1572         return false;
1573 }
1574
1575 bool
1576 ContactListEditorPanel::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1577 {
1578         return false;
1579 }
1580
1581 bool
1582 ContactListEditorPanel::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
1583 {
1584         return false;
1585 }