Fixed jira issue and fixed prevent issue
[apps/osp/MusicPlayer.git] / src / MpPlaylistContentListForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                MpPlaylistContentListForm.cpp
19  * @brief               This is the implementation file for PlaylistContentListForm class.
20  */
21
22 #include <FSocial.h>
23 #include "MpNowPlayContentPanel.h"
24 #include "MpPlaylistContentListForm.h"
25 #include "MpPlaylistListPresentationModel.h"
26 #include "MpPlaylistPickerPopup.h"
27 #include "MpSharePopup.h"
28 #include "MpThumbnailInfo.h"
29
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Content;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Io;
36 using namespace Tizen::Social;
37 using namespace Tizen::System;
38 using namespace Tizen::Ui;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
41
42 static const int COUNT_MESSAGE_BOX_TIMEOUT = 3000;
43
44 PlaylistContentListForm::PlaylistContentListForm(void)
45         : ContentListForm::ContentListForm()
46         , ThumbnailBase::ThumbnailBase()
47         , __pContentListTableView(null)
48         , __pThumbnail(null)
49         , __pPresentationModel(null)
50         , __checkedItemCount(0)
51         , __currentContentType(-1)
52         , __activatedStateContextItem(-1)
53 {
54         AppLogDebug("ENTER");
55         AppLogDebug("EXIT");
56 }
57
58 PlaylistContentListForm::~PlaylistContentListForm(void)
59 {
60         AppLogDebug("ENTER");
61         AppLogDebug("EXIT");
62 }
63
64 result
65 PlaylistContentListForm::Initialize(void)
66 {
67         AppLogDebug("ENTER");
68         if (IsFailed(Form::Construct(IDL_CONTENT_LIST_FORM)))
69         {
70                 AppLogDebug("Construct(IDL_CONTENT_LIST_FORM) failed(%s)", GetErrorMessage(GetLastResult()));
71                 return false;
72         }
73
74         AppLogDebug("EXIT");
75         return Construct();
76 }
77
78 result
79 PlaylistContentListForm::Construct(void)
80 {
81         AppLogDebug("ENTER");
82         __pContentListTableView = static_cast<TableView*>(GetControl(IDC_TABLEVIEW_CONTENT_LIST));
83         __pContentListTableView->AddTableViewItemEventListener(*this);
84         __pContentListTableView->SetItemProvider(this);
85
86         SetContentList(__pContentListTableView);
87         AppLogDebug("EXIT");
88         return ContentListForm::Construct();
89 }
90
91 result
92 PlaylistContentListForm::OnInitializing(void)
93 {
94         AppLogDebug("ENTER");
95         SetFooter();
96         AppLogDebug("EXIT");
97         return ThumbnailBase::Construct();
98 }
99
100 result
101 PlaylistContentListForm::OnTerminating(void)
102 {
103         AppLogDebug("ENTER");
104         ThumbnailBase::Stop();
105         AppLogDebug("EXIT");
106         return ContentListForm::OnTerminating();
107 }
108
109 void
110 PlaylistContentListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
111 {
112         AppLogDebug("ENTER");
113         SceneManager* pSceneManager = SceneManager::GetInstance();
114
115         AppAssert(pSceneManager);
116
117         switch (actionId)
118         {
119         case IDA_HEADER_BUTTON_SELECTE_ALL:
120                 {
121                         bool isChecked = true;
122                         if (__checkedItemCount == __pContentListTableView->GetItemCount())
123                         {
124                                 isChecked = false;
125                         }
126                         SetItemCheckedAll(isChecked);
127                 }
128                 break;
129
130         case IDA_CONTEXT_MENU_ITEM_SEARCH:
131                 {
132                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY));
133                 }
134                 break;
135
136         case IDA_CONTEXT_MENU_ITEM_EDIT:
137                 {
138                         if (__pPresentationModel->GetContentCount() == 0)
139                         {
140                                 MessageBox messageBox;
141                                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 500);
142
143                                 int modalResult = 0;
144                                 messageBox.ShowAndWait(modalResult);
145                         }
146                         else
147                         {
148                                 ToggleScreenState(SCREEN_STATE_EDITOR);
149                         }
150                 }
151                 break;
152
153         case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
154                 {
155                         if (__pPresentationModel->GetContentCount() == 0)
156                         {
157                                 MessageBox messageBox;
158                                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 500);
159
160                                 int modalResult = 0;
161                                 messageBox.ShowAndWait(modalResult);
162                         }
163                         else
164                         {
165                                 LanucherPicker(PICKER_TYPE_SHARE_PICKER);
166                         }
167                 }
168                 break;
169
170         case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
171                 {
172                         LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
173                 }
174                 break;
175
176         case IDA_FOOTER_BUTTON_MORE:
177                 {
178                         Point anchorPoint(X_POINT_FOOTER_MORE, Y_POINT_PORTRAIT_FOOTER_MORE);
179                         if ((GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE) || (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE))
180                         {
181                                 anchorPoint.y = Y_POINT_LANDSCAPE_FOOTER_MORE;
182                         }
183                         CreateContextMenuN(source);
184                         SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SHARE_VIA | CONTEXT_MENU_ITEM_STYLE_EDIT, anchorPoint);
185                 }
186                 break;
187
188         case IDA_FOOTER_BUTTON_DELETE:
189                 {
190                         if (__currentContentType == RECENTLY_ADDED_CONTENT)
191                         {
192                                 RemoveCheckedTableviewItem(true);
193                         }
194                         else
195                         {
196                                 int totalCount = __pPresentationModel->GetContentCount();
197                                 for (int iCount = 0; iCount < totalCount; iCount++)
198                                 {
199                                         if (__pContentListTableView->IsItemChecked(iCount) == true)
200                                         {
201                                                 ContentInformation* pContentInfoStruct = __pPresentationModel->GetContentInfoN(iCount);
202                                                 if (pContentInfoStruct == null)
203                                                 {
204                                                         return;
205                                                 }
206 //                                              __pContentListTableView->SetItemChecked(iCount, false);
207                                                 __pPresentationModel->DeleteContent(__currentContentType, *pContentInfoStruct);
208
209                                                 delete pContentInfoStruct;
210                                         }
211                                 }
212                                 RemoveCheckedTableviewItem(false);
213                                 __pPresentationModel->UpdatePlaylistContentList(__currentContentType, __headerTitle);
214                                 UpdateScreenState();
215                                 UpdateTableView();
216                         }
217                 }
218                 break;
219
220         default:
221                 break;
222         }
223
224         TryRemoveContextMenu(actionId);
225         AppLogDebug("EXIT");
226 }
227
228 void
229 PlaylistContentListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
230                                         const Tizen::Ui::Scenes::SceneId& currentSceneId,
231                                         Tizen::Base::Collection::IList* pArgs)
232 {
233         AppLogDebug("ENTER");
234         if (pArgs != null && previousSceneId.Equals(IDSCN_PLAYLIST_LIST, true) == true)
235         {
236                 __prevSceneId.Append(*static_cast<String*>(pArgs->GetAt(DATA_ITEM_SCENE_NAME)));
237                 __headerTitle.Append(*static_cast<String*>(pArgs->GetAt(DATA_ITEM_CONTENT_NAME)));
238                 __currentContentType = static_cast<Integer*>(pArgs->GetAt(DATA_ITEM_CONTENT_TYPE))->ToInt();
239
240                 __pPresentationModel = PlaylistListPresentationModel::GetInstance();
241                 __pPresentationModel->UpdatePlaylistContentList(__currentContentType, __headerTitle);
242
243                 SetHeader();
244                 UpdateScreenState();
245                 UpdateTableView();
246
247                 pArgs->RemoveAll(true);
248                 delete pArgs;
249         }
250         AppLogDebug("EXIT");
251 }
252
253 void
254 PlaylistContentListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
255                                                                         const Tizen::Ui::Scenes::SceneId& nextSceneId)
256 {
257         AppLogDebug("ENTER");
258         CancelAllThumbnailRequest();
259         AppLogDebug("EXIT");
260 }
261
262 int
263 PlaylistContentListForm::GetItemCount(void)
264 {
265         AppLogDebug("ENTER");
266         if (__pPresentationModel == null)
267         {
268                 AppLogDebug("EXIT");
269                 return INIT_VALUE;
270         }
271         AppLogDebug("EXIT");
272         return __pPresentationModel->GetContentCount();
273 }
274
275 Tizen::Ui::Controls::TableViewItem*
276 PlaylistContentListForm::CreateItem(const int itemIndex, int itemWidth)
277 {
278         AppLogDebug("ENTER");
279         RelativeLayout layout;
280         layout.Construct();
281
282         TableViewAnnexStyle tableViewAnnexStyle = TABLE_VIEW_ANNEX_STYLE_NORMAL;
283         if (GetScreenState() != SCREEN_STATE_NORMAL)
284         {
285                 tableViewAnnexStyle = TABLE_VIEW_ANNEX_STYLE_MARK;
286         }
287
288         TableViewItem* pItem = new (std::nothrow) TableViewItem();
289         ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(itemIndex);
290
291         result r = pItem->Construct(layout, Dimension(itemWidth, ITEM_HEIGHT), tableViewAnnexStyle);
292         TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
293         TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
294
295         r = CreateTableViewItem(*pItem, *pContentInfo);
296         TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
297
298         RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
299         delete pContentInfo;
300
301         AppLogDebug("EXIT");
302         return pItem;
303
304 CATCH:
305         AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
306         delete pContentInfo;
307         return null;
308 }
309
310 void
311 PlaylistContentListForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
312                                                         int itemIndex,
313                                                         Tizen::Ui::Controls::TableViewItem* pItem,
314                                                         Tizen::Ui::Controls::TableViewItemStatus status)
315 {
316         AppLogDebug("ENTER");
317         if (GetScreenState() != SCREEN_STATE_NORMAL)
318         {
319                 SetItemCheckedStateChanged(status);
320                 AppLogDebug("EXIT");
321                 return;
322         }
323
324         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
325         {
326                 SceneManager* pSceneManager = SceneManager::GetInstance();
327                 AppAssert(pSceneManager);
328
329                 ArrayList* pSceneArg = MakePlayerSceneParam(itemIndex);
330                 if (pSceneArg != null)
331                 {
332                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PLAYER), pSceneArg);
333                 }
334         }
335         AppLogDebug("EXIT");
336 }
337
338 void
339 PlaylistContentListForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex,
340                                                                                 Tizen::Ui::Controls::TableViewContextItem* pContextItem,
341                                                                                 bool activated)
342 {
343         AppLogDebug("ENTER");
344         if (itemIndex >= 0)
345         {
346                 __activatedStateContextItem = itemIndex;
347         }
348         AppLogDebug("EXIT");
349 }
350
351 int
352 PlaylistContentListForm::GetDefaultItemHeight(void)
353 {
354         AppLogDebug("ENTER");
355         AppLogDebug("EXIT");
356         return ITEM_HEIGHT;
357 }
358
359 bool
360 PlaylistContentListForm::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
361 {
362         AppLogDebug("ENTER");
363         AppLogDebug("EXIT");
364         return true;
365 }
366
367 void
368 PlaylistContentListForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView,
369                                                         int itemIndexFrom,
370                                                         int itemIndexTo)
371 {
372         AppLogDebug("ENTER");
373         AppLogDebug("EXIT");
374 }
375
376 Tizen::Base::Collection::ArrayList*
377 PlaylistContentListForm::GetSearchResultContentList(int itemIndex)
378 {
379         AppLogDebug("ENTER");
380         ArrayList* pTempList = new (std::nothrow) ArrayList();
381         if (pTempList == null)
382         {
383                 AppLogDebug("EXIT");
384                 return null;
385         }
386         pTempList->Construct();
387
388         pTempList->Add(*(new (std::nothrow) String(MUSIC)));
389         pTempList->Add(*(new (std::nothrow) Integer(itemIndex)));
390         pTempList->Add(*(__pPresentationModel->GetContentPathListN(__currentContentType)));
391         AppLogDebug("EXIT");
392         return pTempList;
393 }
394
395 Tizen::Base::Collection::ArrayList*
396 PlaylistContentListForm::GetAudioContentInfoContentList(int itemIndex)
397 {
398         AppLogDebug("ENTER");
399         ArrayList* pTempList = new (std::nothrow) ArrayList();
400         if (pTempList == null)
401         {
402                 AppLogDebug("EXIT");
403                 return null;
404         }
405         pTempList->Construct();
406
407         pTempList->Add(*(new (std::nothrow) String(MUSIC)));
408         pTempList->Add(*(new (std::nothrow) Integer(itemIndex)));
409         pTempList->Add(*(__pPresentationModel->GetContentPathListN(__currentContentType)));
410         AppLogDebug("EXIT");
411         return pTempList;
412 }
413
414 bool
415 PlaylistContentListForm::IsEmptyContentList(void)
416 {
417         AppLogDebug("ENTER");
418         if (__pPresentationModel->GetContentCount() != INIT_VALUE)
419         {
420                 return false;
421         }
422         AppLogDebug("EXIT");
423         return true;
424 }
425
426 int
427 PlaylistContentListForm::GetCheckedItemCount(void)
428 {
429         AppLogDebug("ENTER");
430         AppLogDebug("EXIT");
431         return __checkedItemCount;
432 }
433
434 Tizen::Base::Collection::ArrayList*
435 PlaylistContentListForm::MakePlayerSceneParam(int startIndex)
436 {
437         AppLogDebug("ENTER");
438         if (__currentContentType != RECENTLY_ADDED_CONTENT)
439         {
440                 AppLogDebug("EXIT");
441                 return GetAudioContentInfoContentList(startIndex);
442         }
443         else if (__currentContentType == RECENTLY_ADDED_CONTENT)
444         {
445                 AppLogDebug("EXIT");
446                 return GetSearchResultContentList(startIndex);
447         }
448         AppLogDebug("EXIT");
449         return null;
450 }
451
452 result
453 PlaylistContentListForm::SetHeader(void)
454 {
455         AppLogDebug("ENTER");
456         CommonUtil::SetSimpleTitleStyle(*GetHeader(), __headerTitle);
457         AppLogDebug("EXIT");
458         return E_SUCCESS;
459 }
460
461 result
462 PlaylistContentListForm::SetFooter(void)
463 {
464         AppLogDebug("ENTER");
465         CommonUtil::SetBackButtonStyleFooter(*GetFooter(), STYLE_MORE_ADD);
466         AppLogDebug("EXIT");
467         return E_SUCCESS;
468 }
469
470 result
471 PlaylistContentListForm::CreateTableViewItem(Tizen::Ui::Controls::TableViewItem& parent, const ContentInformation& contentInfo)
472 {
473         AppLogDebug("ENTER");
474         Panel* pTableViewItem =  new (std::nothrow) Panel();
475         if (GetScreenState() != SCREEN_STATE_NORMAL)
476         {
477                 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL)))
478                 {
479                         AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
480                         return E_FAILURE;
481                 }
482         }
483         else
484         {
485                 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL)))
486                 {
487                         AppLogDebug("Construct(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
488                         return E_FAILURE;
489                 }
490         }
491
492         static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfo.TitleName);
493         static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfo.ArtistName);
494         static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
495
496         parent.AddControl(*pTableViewItem);
497         CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
498
499         AppLogDebug("EXIT");
500         return E_SUCCESS;
501 }
502
503 void
504 PlaylistContentListForm::OnAppControlCompleteResponseReceived(const AppId& appId,
505                 const String& operationId, AppCtrlResult appControlResult,
506                 const IMap* pExtraData)
507 {
508         AppLogDebug("ENTER");
509         if (pExtraData == null)
510         {
511                 AppLogDebug("EXIT");
512                 return;
513         }
514         AppLogDebug("%ls, %ls", appId.GetPointer(), operationId.GetPointer());
515         if (appId.Equals(String(PROVIDER_ID_CONTACT)))
516         {
517                 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
518                 {
519                         const String* pResultString = static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
520
521                         AppLogDebug("%ls", pResultString->GetPointer());
522                         int contactId;
523                         Integer::Parse(*pResultString, contactId);
524
525                         AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
526                         Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
527
528                         ContentInformation* pCcontentInfo = __pPresentationModel->GetContentInfoN(__activatedStateContextItem);
529                         if (pCcontentInfo == null)
530                         {
531                                 delete pAddressbook;
532                                 pAddressbook = null;
533                                 return;
534                         }
535
536                         Contact* pContact = pAddressbook->GetContactN(contactId);
537                         pContact->SetValue(CONTACT_PROPERTY_ID_RINGTONE, pCcontentInfo->ContentFilePath);
538                         result r = pAddressbook->UpdateContact(*pContact);
539
540                         if (r == E_SUCCESS)
541                         {
542                                 MessageBox messageBox;
543                                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_SUCCESS"),
544                                                 MSGBOX_STYLE_OK,
545                                                 COUNT_MESSAGE_BOX_TIMEOUT);
546                                 int modalResult = 0;
547                                 messageBox.ShowAndWait(modalResult);
548                         }
549
550                         delete pCcontentInfo;
551                         pCcontentInfo = null;
552
553                         delete pContact;
554                         pContact = null;
555
556                         delete pAddressbook;
557                         pAddressbook = null;
558                 }
559         }
560         AppLogDebug("EXIT");
561 }
562
563 void
564 PlaylistContentListForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
565 {
566         AppLogDebug("ENTER");
567         Object* pParam = null;
568         __pThumbnail = pThumbnailInfo->GetBitmapN();
569         pParam = pThumbnailInfo->GetUserParamN();
570         if (pParam != null)
571         {
572                 __pContentListTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
573                 delete pParam;
574         }
575
576         delete pThumbnailInfo;
577         AppLogDebug("EXIT");
578 }
579
580 void
581 PlaylistContentListForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
582 {
583         AppLogDebug("ENTER");
584         Panel* pItemPanel = null;
585         if (GetScreenState() != SCREEN_STATE_NORMAL)
586         {
587                 pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENTS_LIBARY_EDITOR_ITEM_PANEL));
588         }
589         else
590         {
591                 pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENTS_LIBARY_ITEM_PANEL));
592         }
593
594         if (pItemPanel == null)
595         {
596                 AppLogDebug("pItemPanel is null");
597                 delete __pThumbnail;
598                 __pThumbnail = null;
599                 return;
600         }
601
602         Label* pThumbnailLabel = static_cast<Label*>(pItemPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
603         if (__pThumbnail == null || pThumbnailLabel == null)
604         {
605                 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
606                 delete __pThumbnail;
607                 __pThumbnail = null;
608                 return;
609         }
610
611         pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
612         delete __pThumbnail;
613         __pThumbnail = null;
614         pThumbnailLabel->Invalidate(true);
615         AppLogDebug("EXIT");
616 }
617
618 void
619 PlaylistContentListForm::UpdateTableView(void)
620 {
621         AppLogDebug("ENTER");
622         __pContentListTableView->UpdateTableView();
623         AppLogDebug("EXIT");
624 }
625
626 void
627 PlaylistContentListForm::UpdateContentList(void)
628 {
629         AppLogDebug("ENTER");
630         __pPresentationModel->UpdatePlaylistContentList(__currentContentType, __headerTitle);
631         UpdateTableView();
632         AppLogDebug("EXIT");
633 }
634
635 void
636 PlaylistContentListForm::SetItemCheckedAll(bool isChecked)
637 {
638         AppLogDebug("ENTER");
639         if (isChecked == true)
640         {
641                 __checkedItemCount = __pContentListTableView->GetItemCount();
642         }
643         else
644         {
645                 __checkedItemCount = INIT_VALUE;
646         }
647         CommonUtil::SetItemCheckedAll(isChecked, *__pContentListTableView);
648         CommonUtil::SetFooterItemEnabled(*GetFooter(), isChecked);
649         SetCheckedCountBallonTooltip(GetCheckedItemCount());
650         AppLogDebug("EXIT");
651 }
652
653 void
654 PlaylistContentListForm::RemoveCheckedTableviewItem(bool itemRemove)
655 {
656         AppLogDebug("ENTER");
657         if (itemRemove)
658         {
659                 int totalCount = __pContentListTableView->GetItemCount();
660                 for (int iCount = 0; iCount < totalCount; iCount++)
661                 {
662                         if (__pContentListTableView->IsItemChecked(iCount) == true)
663                         {
664                                 __pContentListTableView->SetItemChecked(iCount, false);
665                                 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(iCount);
666                                 if (pContentInfo != null)
667                                 {
668                                         RemoveContentAt(pContentInfo->contentId);
669                                         delete pContentInfo;
670                                 }
671                         }
672                 }
673         }
674         else
675         {
676                 SetItemCheckedAll(false);
677         }
678         AppLogDebug("EXIT");
679 }
680
681 void
682 PlaylistContentListForm::SetItemCheckedStateChanged(Tizen::Ui::Controls::TableViewItemStatus status)
683 {
684         AppLogDebug("ENTER");
685         if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED)
686         {
687                 __checkedItemCount--;
688                 if (__checkedItemCount == INIT_VALUE)
689                 {
690                         CommonUtil::SetFooterItemEnabled(*GetFooter(), false);
691                 }
692         }
693         else if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
694         {
695                 if (__checkedItemCount == INIT_VALUE)
696                 {
697                         CommonUtil::SetFooterItemEnabled(*GetFooter(), true);
698                 }
699
700                 __checkedItemCount++;
701         }
702
703         SetCheckedCountBallonTooltip(GetCheckedItemCount());
704         AppLogDebug("EXIT");
705 }
706
707 Tizen::Base::Collection::IList*
708 PlaylistContentListForm::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
709 {
710         AppLogDebug("ENTER");
711         Tizen::Base::Collection::ArrayList* pContentFilePathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
712         if (IsFailed(pContentFilePathList->Construct()))
713         {
714                 AppLogDebug("pContentList->Construct failed(%s)", GetErrorMessage(GetLastResult()));
715                 delete pContentFilePathList;
716                 return null;
717         }
718
719         if (argumentType == PICKER_ARGUMENT_TYPE_ACTIVATED_STATE_CONTEXT_ITEM)
720         {
721                 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(__activatedStateContextItem);
722                 if (pContentInfo == null)
723                 {
724                         delete pContentFilePathList;
725                         AppLogDebug("GetContentInfoN(%d) is null", __activatedStateContextItem);
726                         return null;
727                 }
728
729                 pContentFilePathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
730                 delete pContentInfo;
731         }
732         else if (argumentType == PICKER_ARGUMENT_TYPE_CHECKED_ITEM_ALL)
733         {
734                 int totalCount = __pContentListTableView->GetItemCount();
735                 for (int iCount = 0; iCount < totalCount; iCount++)
736                 {
737                         if (__pContentListTableView->IsItemChecked(iCount) == true)
738                         {
739                                 ContentInformation* pContentInfo = __pPresentationModel->GetContentInfoN(iCount);
740                                 if (pContentInfo == null)
741                                 {
742                                         AppLogDebug("GetContentInfoN(%d) is null", iCount);
743                                         delete pContentFilePathList;
744                                         return null;
745                                 }
746
747                                 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER)
748                                 {
749                                         pContentFilePathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
750                                 }
751                                 else if (pickerType == PICKER_TYPE_SHARE_PICKER)
752                                 {
753                                         pContentFilePathList->Add(*(new (std::nothrow) String(L"attachment:" + pContentInfo->ContentFilePath)));
754                                 }
755                                 delete pContentInfo;
756                         }
757                 }
758         }
759         AppLogDebug("EXIT");
760         return pContentFilePathList;
761 }