merge with master
[apps/osp/Gallery.git] / src / GlAllListSelectionPanel.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                GlAllListSelectionPanel.cpp
19  * @brief               This is the implementation file for AllListSelectionPanel class.
20  */
21
22 #include <FContent.h>
23 #include <FMedia.h>
24 #include "GlAllListSelectionPanel.h"
25 #include "GlCommonUtil.h"
26 #include "GlFileListEditorForm.h"
27 #include "GlFileListPresentationModel.h"
28 #include "GlResourceManager.h"
29 #include "GlTypes.h"
30 #include "GlFileDeleteTimer.h"
31
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::Content;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Media;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
41
42 static const int LENGTH_COUNT_LABEL = 256;
43 static const int H_CONTENT_MARGIN = 24;
44 static const int W_CONTENT_MARGIN = 14;
45 static const int W_CONTENT_SPACE = 20;
46 static const int H_CONTENT_SPACE = 24;
47 static const Color COLOR_THUMBNAIL_DIM (Color::GetColor(COLOR_ID_BLACK));
48 static const int ALPHA_THUMBNAIL_DIM = 70;
49
50 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
51
52 AllListSelectionPanel::AllListSelectionPanel(void)
53         : __pContentIconListView(null)
54         , __pSeletedIndexList(null)
55         , __itemCount(0)
56         , __deleteInProgress(false)
57         , __pPresentationModel(null)
58         , __pFileDelete(null)
59 {
60         AppLogDebug("ENTER");
61         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
62 }
63
64 AllListSelectionPanel::~AllListSelectionPanel(void)
65 {
66         AppLogDebug("ENTER");
67         delete __pFileDelete;
68         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
69 }
70
71 result
72 AllListSelectionPanel::Initialize(void)
73 {
74         AppLogDebug("ENTER");
75         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
76
77         return Construct(RECT_INITIAL); // Should be set proper area at OnInitializing()
78 }
79
80 result
81 AllListSelectionPanel::OnInitializing(void)
82 {
83         AppLogDebug("ENTER");
84         const Form* pForm = dynamic_cast<Form*>(GetParent());
85         TryReturn(pForm != null, E_FAILURE, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
86
87         __pPresentationModel = FileListPresentationModel::GetInstance();
88         __pPresentationModel->ClearThumbnailRequests();
89         __pPresentationModel->AddPresentationModelListener(this);
90
91         Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
92         clientAreaBounds.x = clientAreaBounds.y = 0;
93         result r = SetBounds(clientAreaBounds);
94
95         __pContentIconListView = new (std::nothrow) IconListView();
96         __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height),
97                         DIMENSION_DEFAULT_THUMBNAIL, ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
98         Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
99         if (pBitmapEmpty != null)
100         {
101                 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
102                 delete pBitmapEmpty;
103                 pBitmapEmpty = null;
104         }
105         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
106         __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
107         __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
108         __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
109         __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
110         __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
111         __pContentIconListView->SetItemProvider(*this);
112         __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT);
113         __pContentIconListView->AddIconListViewItemEventListener(*this);
114         __pContentIconListView->SetTouchAnimationEnabled(false);
115         AddControl(*__pContentIconListView);
116         __pContentIconListView->SetShowState(true);
117
118         __itemCount=0;
119         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
120
121         return r;
122 }
123
124 void
125 AllListSelectionPanel::OnUpdateContentList()
126 {
127         AppLogDebug("ENTER");
128         if ( __deleteInProgress == false )
129         {
130                 SceneManager* pSceneManager = SceneManager::GetInstance();
131                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
132         }
133         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
134 }
135
136 result
137 AllListSelectionPanel::OnTerminating(void)
138 {
139         AppLogDebug("ENTER");
140         result r = E_SUCCESS;
141         __pPresentationModel->RemovePresentationModelListener(*this);
142         if (__pSeletedIndexList != null)
143         {
144                 delete __pSeletedIndexList;
145                 __pSeletedIndexList = null;
146         }
147         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
148
149         return r;
150 }
151
152 int
153 AllListSelectionPanel::GetItemCount(void)
154 {
155         AppLogDebug("ENTER");
156         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
157
158         return __itemCount;
159 }
160
161 IconListViewItem*
162 AllListSelectionPanel::CreateItem(int index)
163 {
164         AppLogDebug("ENTER : index(%d)", index);
165         IconListViewItem* pIconListviewItem;
166         Bitmap* pBitmap = null;
167         String* pItemText = null;
168
169         int realIndex = GetRealindexFromVirtualIndex(index);
170         result r = __pPresentationModel->GetThumbnailInSyncCacheN(realIndex, pItemText, pBitmap);
171         if (pBitmap == null || r == E_FAILURE)
172         {
173                 __pPresentationModel->RequestThumbnail(realIndex);
174                 pBitmap = CommonUtil::GetEmptyThumbnailN();
175         }
176
177         if (pItemText == null)
178         {
179                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
180         }
181         else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
182         {
183                 delete pItemText;
184                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
185         }
186
187         if (__pContentIconListView->IsItemChecked(index) == true)
188         {
189                 if (pBitmap != null)
190                 {
191                         BufferInfo bufferInfo;
192                         pBitmap->Lock(bufferInfo, INFINITE);
193                         pBitmap->Unlock();
194
195                         Color dimColor(COLOR_THUMBNAIL_DIM);
196                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
197
198                         Canvas canvas;
199                         canvas.Construct(bufferInfo);
200                         canvas.FillRectangle(dimColor, canvas.GetBounds());
201
202                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
203                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
204                         pIconListviewItem = new (std::nothrow) IconListViewItem();
205                         pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
206                         delete pSelectedBitmap;
207                         pSelectedBitmap = null;
208                 }
209                 else
210                 {
211                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
212                         return null;
213                 }
214
215         }
216         else
217         {
218                 pIconListviewItem = new (std::nothrow) IconListViewItem();
219                 pIconListviewItem->Construct(*pBitmap, pItemText);
220         }
221
222         if (pBitmap != null)
223         {
224                 delete pBitmap;
225                 pBitmap = null;
226         }
227         if (pItemText != null)
228         {
229                 delete pItemText;
230                 pItemText = null;
231         }
232         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
233
234         return pIconListviewItem;
235 }
236
237 bool
238 AllListSelectionPanel::DeleteItem(int index, IconListViewItem* pItem)
239 {
240         AppLogDebug("ENTER");
241         delete pItem;
242         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
243
244         return true;
245 }
246
247 void
248 AllListSelectionPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
249 {
250         AppLogDebug("ENTER");
251         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
252         {
253                 SceneManager* pSceneManager = SceneManager::GetInstance();
254                 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
255
256                 FileListEditorForm* pFileListEditorForm =
257                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
258                 TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get FileListEditorForm.",
259                                 GetErrorMessage(GetLastResult()));
260
261                 String strTmp;
262                 strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
263                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), GetItemCheckedCount());
264                 pFileListEditorForm->SetTitleText(strTmp);
265                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
266         }
267
268         SetButtonState();
269         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
270 }
271
272 void
273 AllListSelectionPanel::OnFileInfoChanged(const ContentType contentType)
274 {
275         AppLogDebug("ENTER");
276         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
277 }
278
279 void
280 AllListSelectionPanel::OnThumbnailDecoded(const int index)
281 {
282         AppLogDebug("ENTER : index(%d)", index);
283         if (index >= 0)
284         {
285                 int virtualIndex = -1;
286                 int loopCount = __pSeletedIndexList->GetCount();
287                 for (int i = 0; i < loopCount; ++i)
288                 {
289                         virtualIndex = GetVirtualIndexFromRealIndex(index);
290                         if (virtualIndex >= 0)
291                         {
292                                 __pContentIconListView->RefreshList(virtualIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
293                                 break;
294                         }
295                 }
296         }
297         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
298 }
299
300 void
301 AllListSelectionPanel::OnSceneActivatedN(const SceneId& previousSceneId,
302                 const SceneId& currentSceneId, IList* pArgs)
303 {
304         AppLogDebug("ENTER");
305         __pPresentationModel = FileListPresentationModel::GetInstance();
306
307         SceneManager* pSceneManager = SceneManager::GetInstance();
308         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
309
310         if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
311         {
312                 if (pArgs != null)
313                 {
314                         __pSeletedIndexList = pArgs;
315                         pArgs = null;
316                 }
317                 ResetSelection();
318                 int loopCount = __pSeletedIndexList->GetCount();
319                 for (int i = 0; i < loopCount; ++i)
320                 {
321                         __pContentIconListView->SetItemChecked(i, true);
322                         __pContentIconListView->RequestRedraw(true);
323                 }
324         }
325         SetButtonState();
326         FileListEditorForm* pFileListEditorForm =
327                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
328         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get FileListEditorForm.",
329                         GetErrorMessage(GetLastResult()));
330
331         if (pArgs != null && pArgs->GetCount() > 0)
332         {
333                 String* pDirectory = static_cast<String*>(pArgs->GetAt(0));
334                 if (pDirectory != null && pDirectory->GetLength() > 0)
335                 {
336                         pFileListEditorForm->MoveToAlbum(*pDirectory);
337                 }
338         }
339         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
340 }
341
342 void
343 AllListSelectionPanel::OnSceneDeactivated(const SceneId& currentSceneId,
344                 const SceneId& nextSceneId)
345 {
346         AppLogDebug("ENTER");
347         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
348 }
349
350 int
351 AllListSelectionPanel::GetItemCheckedCount(void) const
352 {
353         AppLogDebug("ENTER");
354         int count = 0;
355         if (__pContentIconListView != null && __pSeletedIndexList != null)
356         {
357                 int loopCount = __pSeletedIndexList->GetCount();
358                 for (int i = 0; i < loopCount; ++i)
359                 {
360                         if (__pContentIconListView->IsItemChecked(i))
361                         {
362                                 ++count;
363                         }
364                 }
365         }
366         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
367
368         return count;
369 }
370
371 IList*
372 AllListSelectionPanel::GetItemCheckedIndexListN(void)
373 {
374         AppLogDebug("ENTER");
375         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
376         Integer* pIndex=null;
377
378         if (__pContentIconListView!=null)
379         {
380                 int realIndex = -1;
381                 int loopCount = __pSeletedIndexList->GetCount();
382                 for (int i = 0; i < loopCount; ++i)
383                 {
384                         if (__pContentIconListView->IsItemChecked(i))
385                         {
386                                 realIndex = GetRealindexFromVirtualIndex(i);
387                                 pIndex = new (std::nothrow) Integer(realIndex);
388                                 pList->Add(pIndex);
389                         }
390                 }
391         }
392         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
393
394         return pList;
395 }
396
397 int
398 AllListSelectionPanel::GetRealindexFromVirtualIndex(int virtualIndex)
399 {
400         if (__pSeletedIndexList == null || __pSeletedIndexList->GetCount() == 0)
401         {
402                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
403
404                 return -1;
405         }
406
407         Integer* pRealIndex = static_cast<Integer*>(__pSeletedIndexList->GetAt(virtualIndex));
408         int realIndex = -1;
409         if (pRealIndex != null)
410         {
411                 realIndex = pRealIndex->ToInt();
412         }
413         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
414
415         return realIndex;
416 }
417
418 int
419 AllListSelectionPanel::GetVirtualIndexFromRealIndex(int realIndex)
420 {
421         int returnValue = -1;
422         int loopCount = __pSeletedIndexList->GetCount();
423         for (int i = 0; i < loopCount; ++i)
424         {
425                 Integer* pRealIndex = static_cast<Integer*>(__pSeletedIndexList->GetAt(i));
426                 int index = -1;
427                 if (pRealIndex != null)
428                 {
429                         index = pRealIndex->ToInt();
430                 }
431
432                 if (index == realIndex)
433                 {
434                         returnValue = i;
435                         break;
436                 }
437         }
438         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
439
440         return returnValue;
441 }
442
443 result
444 AllListSelectionPanel::OnRequestDelete(void)
445 {
446         AppLogDebug("ENTER");
447         IList* pIndexList = GetItemCheckedIndexListN();
448         if (pIndexList->GetCount() <= 0)
449         {
450                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
451
452                 return E_FAILURE;
453         }
454
455         delete __pFileDelete;
456         __pFileDelete = new FileDeleteTimer(pIndexList,
457                         __pPresentationModel,
458                         this );
459         result r = __pFileDelete->StartTimer();
460
461         if (IsFailed(r))
462         {
463                 delete __pFileDelete;
464                 __pFileDelete = null;
465                 return E_FAILURE;
466         }
467         else
468         {
469                 __deleteInProgress = true;
470         }
471
472         return E_SUCCESS;
473 }
474
475 void AllListSelectionPanel::OnFileOpInvalidate(enum FileActionMode actionId)
476 {
477         SceneManager* pSceneManager = SceneManager::GetInstance();
478         FileListEditorForm* pFileListEditorForm =
479                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
480         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
481                         GetErrorMessage(GetLastResult()));
482         pFileListEditorForm->Invalidate(true);
483 }
484
485 void AllListSelectionPanel::OnFileOpComplete(enum FileActionMode actionId, result res)
486 {
487         __deleteInProgress = false;
488         SceneManager* pSceneManager = SceneManager::GetInstance();
489         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.",
490                         GetErrorMessage(GetLastResult()));
491
492         FileListEditorForm* pFileListEditorForm =
493                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
494         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
495                         GetErrorMessage(GetLastResult()));
496
497         String strTmp;
498         String selectString = ResourceManager::GetString(L"IDS_COM_BODY_SELECTED");
499         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)", selectString.GetPointer(), 0);
500         pFileListEditorForm->SetTitleText(strTmp);
501
502         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
503         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
504         __pContentIconListView->UpdateList();
505
506         if (GetItemCount() > 0)
507         {
508                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
509         }
510         else
511         {
512                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
513         }
514         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
515 }
516
517 result
518 AllListSelectionPanel::OnRequestMessage(void)
519 {
520         AppLogDebug("ENTER");
521         IList* pIndexList = GetItemCheckedIndexListN();
522         if (pIndexList == null || pIndexList->GetCount() <= 0)
523         {
524                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
525
526                 return E_FAILURE;
527         }
528
529         String combineText;
530         String path;
531         Integer* pIndex = null;
532         int checkedIndex;
533
534         int loopCount = pIndexList->GetCount();
535         AppLogDebug("pIndexList->GetCount(%d)", loopCount);
536         for (int i = 0; i < loopCount; ++i)
537         {
538                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
539                 if (pIndex != null)
540                 {
541                         checkedIndex = pIndex->ToInt();
542                         path = __pPresentationModel->GetContentFilePath(checkedIndex);
543                 }
544
545                 if (combineText.CompareTo(EMPTY_SPACE) != 0)
546                 {
547                         combineText.Append(L";");
548                 }
549                 combineText.Append(path);
550         }
551         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
552         pDataList->Construct();
553         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
554
555         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE,
556                         pDataList, null);
557         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
558
559         return E_SUCCESS;
560 }
561
562 result
563 AllListSelectionPanel::OnRequestEmail(void)
564 {
565         AppLogDebug("ENTER");
566         IList* pIndexList = GetItemCheckedIndexListN();
567         if (pIndexList == null || pIndexList->GetCount() <= 0)
568         {
569                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
570
571                 return E_FAILURE;
572         }
573
574         String combineText;
575         String path;
576         Integer* pIndex = null;
577         int checkedIndex;
578
579         int loopCount = pIndexList->GetCount();
580         AppLogDebug("pIndexList->GetCount(%d)", loopCount);
581         for (int i = 0; i < loopCount; ++i)
582         {
583                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
584                 if (pIndex != null)
585                 {
586                         checkedIndex = pIndex->ToInt();
587                         path = __pPresentationModel->GetContentFilePath(checkedIndex);
588                 }
589
590                 if (combineText.CompareTo(EMPTY_SPACE) != 0)
591                 {
592                         combineText.Append(L";");
593                 }
594                 combineText.Append(path);
595         }
596         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
597         pDataList->Construct();
598         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
599
600         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL,
601                         APPCONTROL_OPERATION_ID_COMPOSE, pDataList, null);
602         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
603
604         return E_SUCCESS;
605 }
606
607 result
608 AllListSelectionPanel::OnRequestSlideShow(void)
609 {
610         AppLogDebug("ENTER");
611         IList* pIndexList = GetItemCheckedIndexListN();
612         if (pIndexList == null)
613         {
614                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
615
616                 return E_FAILURE;
617         }
618
619         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
620         result r = pDataList->Construct();
621         if (r != E_SUCCESS)
622         {
623                 delete pDataList;
624                 pDataList = null;
625                 delete pIndexList;
626                 pIndexList = null;
627                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
628
629                 return E_FAILURE;
630         }
631
632         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),
633                         new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
634
635         Integer* pRealIndex = null;
636         int realIndex = -1;
637         String combineText;
638         String path;
639
640         int loopCount = pIndexList->GetCount();
641         if (loopCount > 0)
642         {
643                 for (int i = 0; i < loopCount; ++i)
644                 {
645                         pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
646                         if (pRealIndex != null)
647                         {
648                                 realIndex = pRealIndex->ToInt();
649                         }
650
651                         path = __pPresentationModel->GetContentFilePath(realIndex);
652                         if (combineText.CompareTo(EMPTY_SPACE) != 0)
653                         {
654                                 combineText.Append(L";");
655                         }
656                         combineText.Append(path);
657                 }
658                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH),
659                                 new (std::nothrow) String(combineText));
660         }
661
662         delete pIndexList;
663         pIndexList = null;
664
665         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE,
666                         APPCONTROL_OPERATION_ID_VIEW, pDataList, null);
667         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
668
669         return E_SUCCESS;
670 }
671
672 void
673 AllListSelectionPanel::ResetSelection(void)
674 {
675         AppLogDebug("ENTER");
676         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
677         if (__pSeletedIndexList == null)
678         {
679                 __itemCount = 0;
680         }
681         else
682         {
683                 __itemCount = __pSeletedIndexList->GetCount();
684         }
685
686         SceneManager* pSceneManager = SceneManager::GetInstance();
687         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
688
689         FileListEditorForm* pFileListEditorForm = dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
690         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get FileListEditorForm.", GetErrorMessage(GetLastResult()));
691
692         String strTmp;
693         String bodyText = ResourceManager::GetString(L"IDS_COM_BODY_SELECTED");
694         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)", bodyText.GetPointer(), __itemCount);
695         pFileListEditorForm->SetTitleText(strTmp);
696         if (__pContentIconListView != null)
697         {
698                 __pContentIconListView->UpdateList();
699         }
700         SetButtonState();
701         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
702 }
703
704 void
705 AllListSelectionPanel::SetButtonState(void)
706 {
707         AppLogDebug("ENTER");
708         SceneManager* pSceneManager = SceneManager::GetInstance();
709         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
710
711         FileListEditorForm* pFileListEditorForm = dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
712         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get FileListEditorForm.", GetErrorMessage(GetLastResult()));
713
714         if (GetItemCheckedCount() > 0)
715         {
716                 AppLogDebug("BUTTONSTATE : Request Enable");
717                 pFileListEditorForm->SetFooterButtonsState(true);
718         }
719         else
720         {
721                 AppLogDebug("BUTTONSTATE : Request disable");
722                 pFileListEditorForm->SetFooterButtonsState(false);
723         }
724         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
725 }
726
727