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