N_SE-40892
[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         __pPresentationModel = FileListPresentationModel::GetInstance();
284
285         SceneManager* pSceneManager = SceneManager::GetInstance();
286         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
287
288         __pFileListEditorForm = dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
289         TryReturnVoid(__pFileListEditorForm != null, "[%s] fail to get FileListEditorForm.", GetErrorMessage(GetLastResult()));
290         __pPresentationModel->AddContentEventListener(__pFileListEditorForm);
291
292         if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
293         {
294                 if (pArgs != null)
295                 {
296                         __pSeletedIndexList = pArgs;
297                 }
298                 ResetSelection();
299                 int loopCount = __pSeletedIndexList->GetCount();
300                 for (int i = 0; i < loopCount; ++i)
301                 {
302                         __pContentIconListView->SetItemChecked(i, true);
303                         __pContentIconListView->RequestRedraw(true);
304                 }
305         }
306         SetButtonState();
307
308         if (pArgs != null && pArgs->GetCount() > 0)
309         {
310                 String* pDirectory = static_cast<String*>(pArgs->GetAt(0));
311                 if (pDirectory != null && pDirectory->GetLength() > 0)
312                 {
313                         __pFileListEditorForm->MoveToAlbum(*pDirectory);
314                 }
315         }
316         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
317 }
318
319 void
320 AllListSelectionPanel::OnSceneDeactivated(const SceneId& currentSceneId,
321                 const SceneId& nextSceneId)
322 {
323         AppLogDebug("ENTER");
324         __pPresentationModel->RemoveContentEventListener(__pFileListEditorForm);
325         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
326 }
327
328 int
329 AllListSelectionPanel::GetItemCheckedCount(void) const
330 {
331         AppLogDebug("ENTER");
332         int count = 0;
333         if (__pContentIconListView != null && __pSeletedIndexList != null)
334         {
335                 int loopCount = __pSeletedIndexList->GetCount();
336                 for (int i = 0; i < loopCount; ++i)
337                 {
338                         if (__pContentIconListView->IsItemChecked(i))
339                         {
340                                 ++count;
341                         }
342                 }
343         }
344         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
345
346         return count;
347 }
348
349 IList*
350 AllListSelectionPanel::GetItemCheckedIndexListN(void) const
351 {
352         AppLogDebug("ENTER");
353         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
354         Integer* pIndex = null;
355
356         if (__pContentIconListView!=null)
357         {
358                 int realIndex = -1;
359                 int loopCount = __pSeletedIndexList->GetCount();
360                 for (int i = 0; i < loopCount; ++i)
361                 {
362                         if (__pContentIconListView->IsItemChecked(i))
363                         {
364                                 realIndex = GetRealindexFromVirtualIndex(i);
365                                 pIndex = new (std::nothrow) Integer(realIndex);
366                                 pList->Add(pIndex);
367                         }
368                 }
369         }
370         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
371
372         return pList;
373 }
374
375 int
376 AllListSelectionPanel::GetRealindexFromVirtualIndex(const int virtualIndex) const
377 {
378         if (__pSeletedIndexList == null || __pSeletedIndexList->GetCount() == 0)
379         {
380                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
381
382                 return -1;
383         }
384
385         Integer* pRealIndex = static_cast<Integer*>(__pSeletedIndexList->GetAt(virtualIndex));
386         int realIndex = -1;
387         if (pRealIndex != null)
388         {
389                 realIndex = pRealIndex->ToInt();
390         }
391         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
392
393         return realIndex;
394 }
395
396 int
397 AllListSelectionPanel::GetVirtualIndexFromRealIndex(const int realIndex) const
398 {
399         int returnValue = -1;
400         int loopCount = __pSeletedIndexList->GetCount();
401         for (int i = 0; i < loopCount; ++i)
402         {
403                 Integer* pRealIndex = static_cast<Integer*>(__pSeletedIndexList->GetAt(i));
404                 int index = -1;
405                 if (pRealIndex != null)
406                 {
407                         index = pRealIndex->ToInt();
408                 }
409
410                 if (index == realIndex)
411                 {
412                         returnValue = i;
413                         break;
414                 }
415         }
416         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
417
418         return returnValue;
419 }
420
421 result
422 AllListSelectionPanel::OnRequestDelete(void)
423 {
424         AppLogDebug("ENTER");
425         IList* pIndexList = GetItemCheckedIndexListN();
426         if (pIndexList->GetCount() <= 0)
427         {
428                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
429
430                 return E_FAILURE;
431         }
432
433         delete __pFileUpdateTimer;
434         __pFileUpdateTimer = new (std::nothrow) FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_ACTION_DELETE);
435         result r = __pFileUpdateTimer->StartTimer();
436
437         if (IsFailed(r))
438         {
439                 delete __pFileUpdateTimer;
440                 __pFileUpdateTimer = null;
441                 return E_FAILURE;
442         }
443         else
444         {
445                 __pPresentationModel->SetUpdateProgressStatus(true);
446         }
447
448         return E_SUCCESS;
449 }
450
451 void AllListSelectionPanel::OnFileOpInvalidate(enum FileActionMode actionId)
452 {
453         __pFileListEditorForm->Invalidate(true);
454 }
455
456 void AllListSelectionPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
457 {
458         __pPresentationModel->SetUpdateProgressStatus(false);
459         SceneManager* pSceneManager = SceneManager::GetInstance();
460         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.",
461                         GetErrorMessage(GetLastResult()));
462
463         String strTmp;
464         String selectString = ResourceManager::GetString(L"IDS_COM_BODY_SELECTED");
465         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)", selectString.GetPointer(), 0);
466         __pFileListEditorForm->SetTitleText(strTmp);
467
468         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
469         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
470         __pContentIconListView->UpdateList();
471
472         if (GetItemCount() > 0)
473         {
474                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
475                                 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
476         }
477         else
478         {
479                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
480         }
481         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
482 }
483
484 result
485 AllListSelectionPanel::OnRequestMessage(void)
486 {
487         AppLogDebug("ENTER");
488         result r = E_SUCCESS;
489         IList* pIndexList = GetItemCheckedIndexListN();
490         if (pIndexList == null || pIndexList->GetCount() <= 0)
491         {
492                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
493
494                 return E_FAILURE;
495         }
496
497         Integer* pIndex = null;
498         int checkedIndex;
499         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
500         pArrayList->Construct();
501         int loopCount = pIndexList->GetCount();
502
503         for (int i = 0; i < loopCount; ++i)
504         {
505                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
506                 if (pIndex != null)
507                 {
508                         checkedIndex = pIndex->ToInt();
509                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(checkedIndex)));
510                 }
511         }
512
513         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
514         pDataList->Construct();
515         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
516         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
517
518         r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE, null,
519                         null, pDataList, null);
520         if (r == E_MAX_EXCEEDED)
521         {
522                 MessageBox messageBox;
523                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
524                                 MSGBOX_STYLE_NONE, 3000);
525                 int modalResult;
526                 messageBox.ShowAndWait(modalResult);
527         }
528
529         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
530
531         return r;
532 }
533
534 result
535 AllListSelectionPanel::OnRequestEmail(void)
536 {
537         AppLogDebug("ENTER");
538         result r = E_SUCCESS;
539
540         IList* pIndexList = GetItemCheckedIndexListN();
541         if (pIndexList == null || pIndexList->GetCount() <= 0)
542         {
543                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
544
545                 return E_FAILURE;
546         }
547
548         Integer* pIndex = null;
549         int checkedIndex;
550         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
551         pArrayList->Construct();
552         int loopCount = pIndexList->GetCount();
553
554         for (int i = 0; i < loopCount; ++i)
555         {
556                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
557                 if (pIndex != null)
558                 {
559                         checkedIndex = pIndex->ToInt();
560                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(checkedIndex)));
561                 }
562         }
563
564         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
565         pDataList->Construct();
566         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
567
568         r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
569                         new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, null);
570
571         if (r == E_MAX_EXCEEDED)
572         {
573                 MessageBox messageBox;
574                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
575                                 MSGBOX_STYLE_NONE, 3000);
576                 int modalResult;
577                 messageBox.ShowAndWait(modalResult);
578         }
579
580         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
581
582         return r;
583 }
584
585 result
586 AllListSelectionPanel::OnRequestSlideShow(void)
587 {
588         AppLogDebug("ENTER");
589         result r = E_SUCCESS;
590         IList* pIndexList = GetItemCheckedIndexListN();
591         if (pIndexList == null)
592         {
593                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
594                 return E_FAILURE;
595         }
596
597         Integer* pRealIndex = null;
598         int realIndex = -1;
599         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
600         pArrayList->Construct();
601         int loopCount = pIndexList->GetCount();
602
603         for (int i = 0; i < loopCount; ++i)
604         {
605                 pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
606                 if (pRealIndex != null)
607                 {
608                         realIndex = pRealIndex->ToInt();
609                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(realIndex)));
610                 }
611         }
612
613         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
614         pDataList->Construct();
615         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
616         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
617
618         r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
619                         new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
620
621         if (r == E_MAX_EXCEEDED)
622         {
623                 MessageBox messageBox;
624                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
625                                 MSGBOX_STYLE_NONE, 3000);
626                 int modalResult;
627                 messageBox.ShowAndWait(modalResult);
628         }
629
630         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
631
632         return r;
633 }
634
635 void
636 AllListSelectionPanel::ResetSelection(void)
637 {
638         AppLogDebug("ENTER");
639         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
640         if (__pSeletedIndexList == null)
641         {
642                 __itemCount = 0;
643         }
644         else
645         {
646                 __itemCount = __pSeletedIndexList->GetCount();
647         }
648
649         SceneManager* pSceneManager = SceneManager::GetInstance();
650         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
651
652         String strTmp;
653         String bodyText = ResourceManager::GetString(L"IDS_COM_BODY_SELECTED");
654         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)", bodyText.GetPointer(), __itemCount);
655         __pFileListEditorForm->SetTitleText(strTmp);
656
657         SetButtonState();
658         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
659 }
660
661 void
662 AllListSelectionPanel::SetButtonState(void)
663 {
664         AppLogDebug("ENTER");
665         SceneManager* pSceneManager = SceneManager::GetInstance();
666         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
667
668         if (GetItemCheckedCount() > 0)
669         {
670                 AppLogDebug("BUTTONSTATE : Request Enable");
671                 __pFileListEditorForm->SetFooterButtonsState(true);
672         }
673         else
674         {
675                 AppLogDebug("BUTTONSTATE : Request disable");
676                 __pFileListEditorForm->SetFooterButtonsState(false);
677         }
678         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
679 }
680
681 void
682 AllListSelectionPanel::OnSelectAllPressed(void)
683 {
684         bool needToSelectAll = true;
685         int checkedCount = GetItemCheckedCount();
686         if (checkedCount == __itemCount)
687         {
688                 needToSelectAll = false;
689         }
690
691         if (needToSelectAll == true)
692         {
693                 for (int i = 0; i < __itemCount; ++i)
694                 {
695                         if (__pContentIconListView->IsItemChecked(i) == false)
696                         {
697                                 __pContentIconListView->SetItemChecked(i, true);
698                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
699                         }
700                 }
701         }
702         else
703         {
704                 for (int i = 0; i < __itemCount; ++i)
705                 {
706                         if (__pContentIconListView->IsItemChecked(i) == true)
707                         {
708                                 __pContentIconListView->SetItemChecked(i, false);
709                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
710                         }
711                 }
712         }
713
714         SceneManager* pSceneManager = SceneManager::GetInstance();
715         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
716
717         String tempString;
718         if (needToSelectAll == true)
719         {
720                 tempString.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
721                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), __itemCount);
722         }
723         else
724         {
725                 tempString.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
726                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), 0);
727         }
728         __pFileListEditorForm->SetTitleText(tempString);
729
730         SetButtonState();
731 }
732
733 result
734 AllListSelectionPanel::OnRotateRequested(RotateMode rotateMode)
735 {
736         AppLogDebug("ENTER");
737         IList* pIndexList = GetItemCheckedIndexListN();
738         if (pIndexList == null)
739         {
740                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
741                 return E_FAILURE;
742         }
743         else if (pIndexList->GetCount() <= 0)
744         {
745                 delete pIndexList;
746                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
747
748                 return E_FAILURE;
749         }
750
751         delete __pFileUpdateTimer;
752         __pFileUpdateTimer = new (std::nothrow) FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_ACTION_ROTATE, rotateMode);
753         result r = __pFileUpdateTimer->StartTimer();
754
755         if (IsFailed(r))
756         {
757                 delete __pFileUpdateTimer;
758                 __pFileUpdateTimer = null;
759                 return E_FAILURE;
760         }
761         else
762         {
763                 __pPresentationModel->SetUpdateProgressStatus(true);
764         }
765         return E_SUCCESS;
766 }
767
768 void AllListSelectionPanel::CancelUpdateProgress(void)
769 {
770         if( __pFileUpdateTimer!= null && __pFileUpdateTimer->IsStarted())
771         {
772                 __pFileUpdateTimer->Cancel();
773                 delete __pFileUpdateTimer;
774                 __pFileUpdateTimer = null;
775         }
776 }