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