Applied latest source code
[apps/native/preloaded/MusicPlayer.git] / src / MpAllListPanel.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                MpAllListPanel.cpp
19  * @brief               This is the implementation file for AllListPanel class.
20  */
21
22 #include <FBase.h>
23 #include <FSclAddressbook.h>
24 #include "MpAllListPanel.h"
25 #include "MpAllListPresentationModel.h"
26 #include "MpMiniPlayer.h"
27 #include "MpMusicPlayerApp.h"
28 #include "MpSettingPresentationModel.h"
29 #include "MpThumbnailInfo.h"
30
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Content;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Social;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
40
41 AllListPanel::AllListPanel(void)
42         : ContentLibaryPanel::ContentLibaryPanel()
43         , ThumbnailBase::ThumbnailBase()
44         , __pContextItem(null)
45         , __pDeletePopup(null)
46         , __pThumbnail(null)
47         , __itemIndex(-1)
48 {
49         AppLogDebug("ENTER");
50         AppLogDebug("EXIT");
51 }
52
53 AllListPanel::~AllListPanel(void)
54 {
55         AppLogDebug("ENTER");
56         AppLogDebug("EXIT");
57 }
58
59 bool
60 AllListPanel::Initialize(void)
61 {
62         AppLogDebug("ENTER");
63         result r = Panel::Construct(IDL_CONTENT_LIBARY_ALL_LIST_PANEL);
64         if (IsFailed(r))
65         {
66                 AppLogDebug("Construct(IDL_CONTENT_LIST_PANEL) failed(%s)", GetErrorMessage(r));
67                 return false;
68         }
69         AppLogDebug("EXIT");
70         return ContentLibaryPanel::Construct();
71 }
72
73 result
74 AllListPanel::OnInitializing(void)
75 {
76         AppLogDebug("ENTER");
77         __pPresentationModel = AllListPresentationModel::GetInstance();
78         __pContentTableView->AddFastScrollListener(*this);
79
80         __pContextItem = CommonUtil::CreateTableViewContextItemN(*this, GetWidth(), FLICK_MENU_STYLE_TYPE_01);
81         if (__pContextItem == null)
82         {
83                 delete __pContextItem;
84                 __pContextItem = null;
85                 AppLogDebug("CommonUtil::CreateContentDeletePopup failed");
86                 return E_FAILURE;
87         }
88
89         __fontSizeValue = CommonUtil::GetFontSizeValue();
90         __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
91         SetFormStyle();
92         SetLayoutFitToForm();
93         UpdateContentList();
94         AppLogDebug("EXIT");
95         return ThumbnailBase::Construct();
96 }
97
98 result
99 AllListPanel::OnTerminating(void)
100 {
101         AppLogDebug("ENTER");
102         ThumbnailBase::Stop();
103
104         if (__pDeletePopup != null)
105         {
106                 delete __pDeletePopup;
107                 __pDeletePopup = null;
108         }
109         if (__pContextItem != null)
110         {
111                 delete __pContextItem;
112                 __pContextItem = null;
113         }
114
115         AppLogDebug("EXIT");
116         return ContentLibaryPanel::OnTerminating();
117 }
118
119 void
120 AllListPanel::OnAppControlCompleteResponseReceived(const AppId& appId,
121                 const String& operationId, AppCtrlResult appControlResult,
122                 const IMap* pExtraData)
123 {
124         AppLogDebug("ENTER");
125         if (pExtraData == null)
126         {
127                 AppLogDebug("EXIT");
128                 return;
129         }
130         AppLogDebug("%ls, %ls", appId.GetPointer(), operationId.GetPointer());
131         result r = E_SUCCESS;
132
133         if (appId.Equals(String(PROVIDER_ID_CONTACT))/* && operationId.Equals(String(OPERATION_ID_PICK))*/)
134         {
135                 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
136                 {
137                         int contactId = -1;
138                         String* pKey = null;
139                         ArrayList* pArrayListValue = null;
140                         String* pResultString = null;
141                         if (pExtraData != null)
142                         {
143                                 IMapEnumerator* pEnum = pExtraData->GetMapEnumeratorN();
144                                 while (pEnum->MoveNext() == E_SUCCESS)
145                                 {
146                                         pKey = static_cast<String*>(pEnum->GetKey());
147                                         if (pKey->Equals(APPCONTROL_KEY_SOCIAL_ITEM_ID, true))
148                                         {
149                                                 pArrayListValue = static_cast<ArrayList*>(pEnum->GetValue());
150                                         }
151                                 }
152                                 delete pEnum;
153
154                                 if (pArrayListValue != null && pArrayListValue->GetCount() > 0)
155                                 {
156                                         for (int iCount = 0; iCount < pArrayListValue->GetCount(); iCount++)
157                                         {
158                                                 pResultString = static_cast<String*>(pArrayListValue->GetAt(iCount));
159                                                 AppLogDebug("extraData : %ls:%ls total contacts %d", pKey->GetPointer(), pResultString->GetPointer(),pArrayListValue->GetCount());
160                                                 Integer::Parse(*pResultString, contactId);
161                                                 pResultString->Clear();
162                                                 if (contactId < 0)
163                                                 {
164                                                         AppLogDebug("pKey is invaild");
165                                                         break;
166                                                 }
167                                                 AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
168                                                 Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
169
170                                                 ContentInformation* pContentInfoStruct = __pPresentationModel->GetContentInfoN(__itemIndex);
171                                                 if (pContentInfoStruct == null)
172                                                 {
173                                                         return;
174                                                 }
175
176                                                 Contact* pContact = pAddressbook->GetContactN(contactId);
177                                                 pContact->Tizen::Social::Contact::SetValue(CONTACT_PROPERTY_ID_RINGTONE, pContentInfoStruct->ContentFilePath);
178                                                 r = pAddressbook->UpdateContact(*pContact);
179
180                                                 delete pContentInfoStruct;
181                                                 delete pContact;
182                                                 delete pAddressbook;
183                                         }
184                                 }
185
186                         }
187
188                         else
189                         {
190                                 AppLogDebug("pExtraData is null");
191                                 return;
192                         }
193
194                         if (r == E_SUCCESS)
195                         {
196                                 GetParent()->SendUserEvent(ID_SHOW_SUCCESS_MESSAGE,null);
197                         }
198                 }
199         }
200         AppLogDebug("EXIT");
201 }
202
203 void
204 AllListPanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
205 {
206         AppLogDebug("ENTER");
207         SceneManager* pSceneManager = SceneManager::GetInstance();
208         AppAssert(pSceneManager);
209
210         switch (actionId)
211         {
212         case IDA_FLICK_MENU_ITEM_SHARE:
213                 {
214                         CreateContextMenuN(source);
215                         SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_EMAIL | CONTEXT_MENU_ITEM_STYLE_MESSAGE);
216                 }
217                 break;
218
219         case IDA_FLICK_MENU_ITEM_SET_AS:
220                 {
221                         CreateContextMenuN(source);
222                         SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_CALL | CONTEXT_MENU_ITEM_STYLE_CALLER);
223                 }
224                 break;
225
226         case IDA_DELETE_POPUP_DELETE:
227                 // fall through         
228         case IDA_DELETE_POPUP_CANCEL:
229                 {
230                         if (__pDeletePopup != null)
231                         {
232                                 __pDeletePopup->SetShowState(false);
233                                 //delete __pDeletePopup;
234                                 //__pDeletePopup = null;
235                         }
236
237                         if (actionId == IDA_DELETE_POPUP_DELETE)
238                         {
239                                 __pPresentationModel->RemoveContent(__itemIndex);
240                                 __pContentTableView->RefreshItem(__itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
241                         }
242                 }
243                 break;
244
245         case IDA_CONTEXT_MENU_ITEM_EMAIL:
246                 // fall through         
247         case IDA_CONTEXT_MENU_ITEM_MESSAGE:
248                 {
249                         result r = E_FAILURE;
250                         String providerID = ((actionId == IDA_CONTEXT_MENU_ITEM_EMAIL) ? PROVIDER_ID_EMAIL : PROVIDER_ID_MESSAGE);
251                         AppControl* pAppControl = AppManager::FindAppControlN(providerID, OPERATION_ID_COMPOSE);
252                         if (pAppControl == null)
253                         {
254                                 AppLogDebug("AppManager::FindAppControlN is null");
255                                 return;
256                         }
257
258                         ContentInformation* pContentInfoStruct = __pPresentationModel->GetContentInfoN(__itemIndex);
259                         if (pContentInfoStruct == null)
260                         {
261                                 AppLogDebug("PresentationModel->GetContentInfoN is null");
262                                 delete pAppControl;
263                                 pAppControl = null;
264                                 return;
265                         }
266
267                         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
268                         pDataList->Construct();
269
270                         Tizen::Base::Collection::ArrayList* pValueList = new (std::nothrow) ArrayList(SingleObjectDeleter);
271                         pValueList->Construct();
272                         pValueList->Add(*(new (std::nothrow) String(pContentInfoStruct->ContentFilePath)));
273                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pValueList);
274
275                         r = pAppControl->Start(null, null, pDataList, this);
276
277                         if (r == E_SUCCESS)
278                         {
279                                 Frame* pFrame = MusicPlayerApp::GetInstance()->GetFrameAt(0);
280                                 AppAssert(pFrame);
281                                 pFrame->SetEnabled(false);
282                         }
283                         else
284                         {
285                                 AppLogDebug("AppControl Start fail");
286                         }
287
288                         pDataList->RemoveAll(true);
289                         delete pDataList;
290                         pDataList = null;
291
292                         delete pContentInfoStruct;
293                         delete pAppControl;
294
295                         if(__pContentTableView->IsContextItemOpened(__itemIndex))
296                         {
297                                 __pContentTableView->CloseContextItem(__itemIndex);
298                         }
299                 }
300                 break;
301
302         case IDA_CONTEXT_MENU_ITEM_CALL:
303                 {
304                         result r = __pPresentationModel->SetCallRingtone(__itemIndex);
305                         if (r == E_SUCCESS)
306                         {
307                                 MessageBox messageBox;
308                                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_SUCCESS"), MSGBOX_STYLE_OK, 3000);
309                                 int modalResult = 0;
310                                 messageBox.ShowAndWait(modalResult);
311                         }
312
313                         if(__pContentTableView->IsContextItemOpened(__itemIndex))
314                         {
315                                 __pContentTableView->CloseContextItem(__itemIndex);
316                         }
317                 }
318                 break;
319
320         case IDA_CONTEXT_MENU_ITEM_CALLER:
321                 {
322                         result r = E_FAILURE;
323                         AppControl* pAppControl = AppManager::FindAppControlN(PROVIDER_ID_CONTACT, OPERATION_ID_SOCIAL_PICK);
324                         if (pAppControl == null)
325                         {
326                                 return;
327                         }
328
329                         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
330                         pDataList->Construct();
331                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE), new (std::nothrow) String(APPCONTROL_OPTION_SINGLE));
332                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE), new (std::nothrow) String(APPCONTROL_OPTION_PERSON));
333                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE), new (std::nothrow) String(APPCONTROL_OPTION_ITEM_ID));
334
335                         r = pAppControl->Start(null, null, pDataList, this);
336                         if (r == E_SUCCESS)
337                         {
338                                 Frame* pFrame = MusicPlayerApp::GetInstance()->GetFrameAt(0);
339                                 AppAssert(pFrame);
340                                 pFrame->SetEnabled(false);
341                         }
342                         else
343                         {
344                                 AppLogDebug("AppControl Start fail");
345                         }
346
347                         pDataList->RemoveAll(true);
348                         delete pDataList;
349                         pDataList = null;
350                         delete pAppControl;
351
352                         if (__pContentTableView->IsContextItemOpened(__itemIndex))
353                         {
354                                 __pContentTableView->CloseContextItem(__itemIndex);
355                         }
356                 }
357                 break;
358
359         case IDA_FLICK_MENU_ITEM_ADDTO:
360                 {
361                         LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER, PICKER_ARGUMENT_TYPE_ACTIVATED_STATE_CONTEXT_ITEM);
362
363                         if (__pContentTableView->IsContextItemOpened(__itemIndex))
364                         {
365                                 __pContentTableView->CloseContextItem(__itemIndex);
366                         }
367                 }
368                 break;
369
370         case IDA_FLICK_MENU_ITEM_DELETE:
371                 {
372                         if (__pDeletePopup == null)
373                         {
374                                 __pDeletePopup = CommonUtil::CreateContentDeletePopup(*this, IDA_DELETE_POPUP_DELETE, IDA_DELETE_POPUP_CANCEL);
375                                 __pDeletePopup->SetPropagatedKeyEventListener(this);
376                         }
377                         __pDeletePopup->SetShowState(true);
378                         __pDeletePopup->Show();
379
380                         if (__pContentTableView->IsContextItemOpened(__itemIndex))
381                         {
382                                 __pContentTableView->CloseContextItem(__itemIndex);
383                         }
384                 }
385                 break;
386
387         case IDA_CONTEXT_MENU_ITEM_EDIT:
388                 // fall through
389         case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
390                 {
391                         if (__pPresentationModel->GetTotalCount() == 0)
392                         {
393                                 MessageBox messageBox;
394                                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 3000);
395
396                                 int modalResult = 0;
397                                 messageBox.ShowAndWait(modalResult);
398                                 break;
399                         }
400                         ArrayList* pData = new (std::nothrow) ArrayList();
401                         pData->Construct();
402                         pData->Add(*(new (std::nothrow) Integer(actionId)));
403                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR),pData);
404                 }
405                 break;
406
407         case IDA_CONTEXT_MENU_ITEM_SEARCH:
408                 {
409                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY));
410                 }
411                 break;
412
413         case IDA_FOOTER_BUTTON_MORE:
414                 {
415                         CreateOptionMenuN(source);
416                         SetOptionMenuItem(CONTEXT_MENU_ITEM_STYLE_SETTINGS | CONTEXT_MENU_ITEM_STYLE_SEARCH | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA |
417                                                                         CONTEXT_MENU_ITEM_STYLE_EDIT | CONTEXT_MENU_ITEM_STYLE_FOLDER_VIEW);
418                 }
419                 break;
420
421         case IDA_FOOTER_BUTTON_BACK:
422                 {
423                         Tizen::App::UiApp::GetInstance()->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
424                 }
425                 break;
426
427         case IDA_CONTEXT_MENU_ITEM_FOLDER_VIEW:
428                 {
429                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FOLDER_LIST));
430                 }
431                 break;
432
433         case IDA_CONTEXT_MENU_ITEM_SETTINGS:
434                 {
435 //                      SettingPresentationModel::GetInstance()->InitializeSettingValue();
436                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_MUSIC_SETTING));
437                 }
438                 break;
439
440         default:
441                 break;
442         }
443
444         TryRemoveContextMenu(actionId);
445         AppLogDebug("EXIT");
446 }
447
448 void
449 AllListPanel::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
450 {
451         AppLogDebug("ENTER");
452         if(IsExistMiniPlayer())
453         {
454                 Tizen::App::UiApp::GetInstance()->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
455         }
456         else
457         {
458                 Tizen::App::Application::GetInstance()->Terminate();
459         }
460         AppLogDebug("EXIT");
461 }
462
463 void
464 AllListPanel::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
465 {
466         AppLogDebug("ENTER");
467         CreateOptionMenuN(source);
468         SetOptionMenuItem(CONTEXT_MENU_ITEM_STYLE_SETTINGS | CONTEXT_MENU_ITEM_STYLE_SEARCH | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA |
469                         CONTEXT_MENU_ITEM_STYLE_EDIT | CONTEXT_MENU_ITEM_STYLE_FOLDER_VIEW);
470
471         AppLogDebug("EXIT");
472 }
473 void
474 AllListPanel::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
475                                                                 const Tizen::Ui::Scenes::SceneId& currentSceneId,
476                                                                 Tizen::Base::Collection::IList* pArgs)
477 {
478         AppLogDebug("ENTER");
479         ContentLibaryPanel::OnSceneActivatedN(previousSceneId, currentSceneId, null);
480
481         GetHeader()->SetItemSelected(0);
482         GetHeader()->Invalidate(true);
483         AppLogDebug("EXIT");
484 }
485
486 void
487 AllListPanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
488                                                                         const Tizen::Ui::Scenes::SceneId& nextSceneId)
489 {
490         AppLogDebug("ENTER");
491         CancelAllThumbnailRequest();
492         ContentLibaryPanel::OnSceneDeactivated(currentSceneId, nextSceneId);
493         __pContentTableView->RefreshItem(__itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
494         AppLogDebug("EXIT");
495 }
496
497 int
498 AllListPanel::GetItemCount(void)
499 {
500         AppLogDebug("ENTER");
501         if (__pPresentationModel == null)
502         {
503                 return INIT_VALUE;
504         }
505         AppLogDebug("EXIT");
506         return  __pPresentationModel->GetTotalCount();
507 }
508
509 TableViewItem*
510 AllListPanel::CreateItem(const int itemIndex, int itemWidth)
511 {
512         AppLogDebug("ENTER");
513         RelativeLayout layout;
514         layout.Construct();
515
516         TableViewItem* pItem = new (std::nothrow) TableViewItem();
517         ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(itemIndex);
518
519         result r = pItem->Construct(layout, Dimension(itemWidth, __itemHeight), TABLE_VIEW_ANNEX_STYLE_NORMAL);
520         TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
521         TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
522
523         r = CreateTableViewItem(*pItem, *pContentInfo);
524         TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
525
526         pItem->SetContextItem(__pContextItem);
527         RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
528         delete pContentInfo;
529
530         AppLogDebug("EXIT");
531         return pItem;
532
533 CATCH:
534         AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
535         delete pContentInfo;
536         return null;
537 }
538
539 void
540 AllListPanel::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
541                                                 int itemIndex,
542                                                 Tizen::Ui::Controls::TableViewItem* pItem,
543                                                 Tizen::Ui::Controls::TableViewItemStatus status)
544 {
545         AppLogDebug("ENTER");
546         SceneManager* pSceneManager = SceneManager::GetInstance();
547         AppAssert(pSceneManager);
548
549         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
550         {
551                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PLAYER), GetContentListN(itemIndex));
552         }
553         AppLogDebug("EXIT");
554 }
555
556 void
557 AllListPanel::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView,
558                                                                         int itemIndex,
559                                                                         Tizen::Ui::Controls::TableViewContextItem* pContextItem,
560                                                                         bool activated)
561 {
562         AppLogDebug("ENTER");
563         if (activated == true)
564         {
565                 __itemIndex = itemIndex;
566         }
567         AppLogDebug("EXIT");
568 }
569
570 void
571 AllListPanel::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
572 {
573         AppLogDebug("ENTER");
574         int totalCount = __pPresentationModel->GetTotalCount();
575         for (int iCount = 0; iCount < totalCount; iCount++)
576         {
577                 String name = __pPresentationModel->GetContentName(iCount);
578                 if (name.GetLength())
579                 {
580                         String firstCharacter;
581
582                         name.SubString(0, 1, firstCharacter);
583                         firstCharacter.ToUpper();
584
585                         mchar language;
586                         firstCharacter.GetCharAt(0, language);
587
588                         if (Character::GetUnicodeCategory(language) == UNICODE_HANGUL)
589                         {
590                                 Tizen::Base::String HangulIndex[] = {"ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ" , "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"};
591
592                                 wchar_t songName;
593                                 name.GetCharAt(0, songName);
594
595                                 wchar_t UnicodeValue = (songName - 0xAC00);
596                                 wchar_t InitialConsonant = ((UnicodeValue - (UnicodeValue % 28)) / 28) / 21;
597                                 int tempIndex = static_cast<int>(InitialConsonant);
598
599                                 if (HangulIndex[tempIndex].CompareTo(index) == 0)
600                                 {
601                                         __pContentTableView->ScrollToItem(iCount);
602                                         break;
603                                 }
604                         }
605                         else if (index.CompareTo("0") == 0 && Character::IsDigit(language) == true)
606                         {
607                                 __pContentTableView->ScrollToItem(iCount);
608                                 break;
609                         }
610                         else if (firstCharacter.CompareTo(index) == 0)
611                         {
612                                 __pContentTableView->ScrollToItem(iCount);
613                                 break;
614                         }
615                 }
616         }
617         AppLogDebug("EXIT");
618 }
619
620 bool
621 AllListPanel::OnKeyPressed(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
622 {
623         AppLogDebug("ENTER");
624         if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
625         {
626                 return true;
627         }
628         AppLogDebug("EXIT");
629         return false;
630
631 }
632
633 bool
634 AllListPanel::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
635 {
636         AppLogDebug("ENTER");
637         if (__pDeletePopup != null && (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC))
638         {
639                 __pDeletePopup->SetShowState(false);
640                 return true;
641         }
642         AppLogDebug("EXIT");
643         return false;
644
645 }
646
647 Tizen::Base::Collection::ArrayList*
648 AllListPanel::GetContentListN(int itemIndex)
649 {
650         AppLogDebug("ENTER");
651         ArrayList* pTempList = new (std::nothrow) ArrayList();
652         pTempList->Construct();
653
654         pTempList->Add(*(new (std::nothrow) String(MUSIC)));
655         pTempList->Add(*(new (std::nothrow) Integer(itemIndex)));
656         pTempList->Add(*(__pPresentationModel->GetContentListN()));
657
658         AppLogDebug("EXIT");
659         return pTempList;
660 }
661
662 void
663 AllListPanel::UpdateContentList(void)
664 {
665         AppLogDebug("ENTER");
666         if (__pPresentationModel != null)
667         {
668                 __pPresentationModel->UpdateContentList();
669         }
670         AppLogDebug("EXIT");
671 }
672
673 Tizen::Base::Collection::IList*
674 AllListPanel::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
675 {
676         AppLogDebug("ENTER");
677         if (pickerType != PICKER_TYPE_PLAY_LIST_PICKER || argumentType != PICKER_ARGUMENT_TYPE_ACTIVATED_STATE_CONTEXT_ITEM)
678         {
679                 AppLogDebug("EXIT");
680                 return null;
681         }
682
683         ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(__itemIndex);
684         if (pContentInfo == null)
685         {
686                 AppLogDebug("EXIT");
687                 return null;
688         }
689
690         ArrayList* pContentPath = new (std::nothrow) ArrayList();
691         result r = pContentPath->Construct();
692         if (IsFailed(r))
693         {
694                 AppLogDebug("EXIT");
695                 delete pContentInfo;
696                 delete pContentPath;
697                 return null;
698         }
699
700         pContentPath->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
701         delete pContentInfo;
702
703         AppLogDebug("EXIT");
704         return pContentPath;
705 }
706
707 bool
708 AllListPanel::IsEmptyContentList(void)
709 {
710         AppLogDebug("ENTER");
711         if (__pPresentationModel == null || __pPresentationModel->GetTotalCount() == INIT_VALUE)
712         {
713                 AppLogDebug("EXIT");
714                 return true;
715         }
716         AppLogDebug("EXIT");
717         return false;
718 }
719
720 result
721 AllListPanel::CreateTableViewItem(Tizen::Ui::Container& parent,
722                                                 const ContentInformation& contentInfoStruct)
723 {
724         AppLogDebug("ENTER");
725         Panel* pTableViewItem =  new (std::nothrow) Panel();
726
727         if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
728         {
729                 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL_FONT_SIZE_GIANT)))
730                 {
731                         AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
732                         return E_FAILURE;
733                 }
734         }
735         else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
736         {
737                 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL_FONT_SIZE_HUGE)))
738                 {
739                         AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
740                         return E_FAILURE;
741                 }
742         }
743         else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
744         {
745                 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL_FONT_SIZE_LARGE)))
746                 {
747                         AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
748                         return E_FAILURE;
749                 }
750         }
751         else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
752         {
753                 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL_FONT_SIZE_SMALL)))
754                 {
755                         AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
756                         return E_FAILURE;
757                 }
758         }
759         else
760         {
761                 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL_DEFAULT)))
762                 {
763                         AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
764                         return E_FAILURE;
765                 }
766         }
767
768         //static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
769         static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfoStruct.TitleName);
770         static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
771
772         parent.AddControl(pTableViewItem);
773         CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
774
775         AppLogDebug("EXIT");
776         return E_SUCCESS;
777 }
778
779 void
780 AllListPanel::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
781 {
782         AppLogDebug("ENTER");
783         __pThumbnail = pThumbnailInfo->GetBitmapN();
784         Object* pParam = pThumbnailInfo->GetUserParamN();
785         if (pParam != null)
786         {
787                 __pContentTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
788                 delete pParam;
789         }
790
791         delete pThumbnailInfo;
792         AppLogDebug("EXIT");
793 }
794
795 void
796 AllListPanel::OnMusicContentUpdateCompleted(void)
797 {
798         AppLogDebug("ENTER");
799         if (__pDeletePopup != null && __pDeletePopup->GetShowState() == true)
800         {
801                 __pDeletePopup->SetShowState(false);
802 //              delete __pDeletePopup;
803 //              __pDeletePopup = null;
804         }
805         ContentLibaryPanel::OnMusicContentUpdateCompleted();
806         AppLogDebug("EXIT");
807 }
808
809 void
810 AllListPanel::OnFontSizeChanged(void)
811 {
812         __fontSizeValue = CommonUtil::GetFontSizeValue();
813         __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
814         __pContentTableView->UpdateTableView();
815
816 }
817
818 void
819 AllListPanel::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
820 {
821         AppLogDebug("ENTER");
822         if (pItem == null)
823         {
824                 AppLogDebug("pItem is null");
825                 delete __pThumbnail;
826                 __pThumbnail = null;
827                 return;
828         }
829
830         Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(IDC_CONTENTS_THUMBNAIL, true));
831         if (__pThumbnail == null || pThumbnailLabel == null)
832         {
833                 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
834                 delete __pThumbnail;
835                 __pThumbnail = null;
836                 return;
837         }
838         pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
839         delete __pThumbnail;
840         __pThumbnail = null;
841         pThumbnailLabel->Invalidate(true);
842         AppLogDebug("EXIT");
843 }