Fixed prevent issues
[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 "GlFileUpdateTimer.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 = 9;
44 static const int W_CONTENT_MARGIN = 6;
45 static const int W_CONTENT_SPACE = 6;
46 static const int H_CONTENT_SPACE = 6;
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         , __pFileListEditorForm(null)
57         , __pFileUpdateTimer(null)
58         , __pPresentationModel(null)
59 {
60         AppLogDebug("ENTER");
61         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
62 }
63
64 AllListSelectionPanel::~AllListSelectionPanel(void)
65 {
66         AppLogDebug("ENTER");
67         delete __pFileUpdateTimer;
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         }
104         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
105         __pContentIconListView->SetMargin(MARGIN_TYPE_LEFT, W_CONTENT_MARGIN);
106         __pContentIconListView->SetMargin(MARGIN_TYPE_RIGHT, W_CONTENT_MARGIN);
107         __pContentIconListView->SetMargin(MARGIN_TYPE_TOP, H_CONTENT_MARGIN);
108         __pContentIconListView->SetItemSpacing(W_CONTENT_SPACE, H_CONTENT_SPACE);
109         __pContentIconListView->SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE);
110         __pContentIconListView->SetItemProvider(*this);
111         __pContentIconListView->SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT);
112         __pContentIconListView->AddIconListViewItemEventListener(*this);
113         __pContentIconListView->SetTouchAnimationEnabled(false);
114         AddControl(*__pContentIconListView);
115         __pContentIconListView->SetShowState(true);
116
117         __itemCount = 0;
118         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
119
120         return r;
121 }
122
123 result
124 AllListSelectionPanel::OnTerminating(void)
125 {
126         AppLogDebug("ENTER");
127         result r = E_SUCCESS;
128         __pPresentationModel->RemovePresentationModelListener(*this);
129         if (__pSeletedIndexList != null)
130         {
131                 delete __pSeletedIndexList;
132                 __pSeletedIndexList = null;
133         }
134         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
135
136         return r;
137 }
138
139 int
140 AllListSelectionPanel::GetItemCount(void)
141 {
142         AppLogDebug("ENTER");
143         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
144
145         return __itemCount;
146 }
147
148 IconListViewItem*
149 AllListSelectionPanel::CreateItem(int index)
150 {
151         AppLogDebug("ENTER : index(%d)", index);
152         IconListViewItem* pIconListviewItem;
153         Bitmap* pBitmap = null;
154         String* pItemText = null;
155
156         int realIndex = GetRealindexFromVirtualIndex(index);
157         result r = __pPresentationModel->GetThumbnailInSyncCacheN(realIndex, pItemText, pBitmap);
158         if (pBitmap == null || r == E_FAILURE)
159         {
160                 __pPresentationModel->RequestThumbnail(realIndex);
161                 pBitmap = CommonUtil::GetEmptyThumbnailN();
162         }
163
164         if (pItemText == null)
165         {
166                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
167         }
168         else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
169         {
170                 delete pItemText;
171                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
172         }
173
174         if (__pContentIconListView->IsItemChecked(index) == true)
175         {
176                 if (pBitmap != null)
177                 {
178                         BufferInfo bufferInfo;
179                         pBitmap->Lock(bufferInfo, INFINITE);
180                         pBitmap->Unlock();
181
182                         Color dimColor(COLOR_THUMBNAIL_DIM);
183                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
184
185                         Canvas canvas;
186                         canvas.Construct(bufferInfo);
187                         canvas.FillRectangle(dimColor, canvas.GetBounds());
188
189                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
190                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
191                         pIconListviewItem = new (std::nothrow) IconListViewItem();
192                         pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
193                         delete pSelectedBitmap;
194                 }
195                 else
196                 {
197                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
198                         delete pItemText;
199                         return null;
200                 }
201
202         }
203         else
204         {
205                 pIconListviewItem = new (std::nothrow) IconListViewItem();
206                 pIconListviewItem->Construct(*pBitmap, pItemText);
207         }
208
209         if (pBitmap != null)
210         {
211                 delete pBitmap;
212         }
213         if (pItemText != null)
214         {
215                 delete pItemText;
216         }
217         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
218
219         return pIconListviewItem;
220 }
221
222 bool
223 AllListSelectionPanel::DeleteItem(int index, IconListViewItem* pItem)
224 {
225         AppLogDebug("ENTER");
226         delete pItem;
227         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
228
229         return true;
230 }
231
232 void
233 AllListSelectionPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
234 {
235         AppLogDebug("ENTER");
236         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
237         {
238                 SceneManager* pSceneManager = SceneManager::GetInstance();
239                 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
240
241                 String strTmp;
242                 strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
243                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), GetItemCheckedCount());
244                 __pFileListEditorForm->SetTitleText(strTmp);
245                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
246         }
247
248         SetButtonState();
249         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
250 }
251
252 void
253 AllListSelectionPanel::OnFileInfoChanged(const ContentType contentType)
254 {
255         AppLogDebug("ENTER");
256         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
257 }
258
259 void
260 AllListSelectionPanel::OnThumbnailDecoded(const int index)
261 {
262         AppLogDebug("ENTER : index(%d)", index);
263         if (index >= 0)
264         {
265                 int virtualIndex = -1;
266                 int loopCount = __pSeletedIndexList->GetCount();
267                 for (int i = 0; i < loopCount; ++i)
268                 {
269                         virtualIndex = GetVirtualIndexFromRealIndex(index);
270                         if (virtualIndex >= 0)
271                         {
272                                 __pContentIconListView->RefreshList(virtualIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
273                                 break;
274                         }
275                 }
276         }
277         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
278 }
279
280 void
281 AllListSelectionPanel::OnSceneActivatedN(const SceneId& previousSceneId,
282                 const SceneId& currentSceneId, IList* pArgs)
283 {
284         AppLogDebug("ENTER");
285         __pPresentationModel = FileListPresentationModel::GetInstance();
286
287         SceneManager* pSceneManager = SceneManager::GetInstance();
288         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
289
290         __pFileListEditorForm = dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
291         TryReturnVoid(__pFileListEditorForm != null, "[%s] fail to get FileListEditorForm.", GetErrorMessage(GetLastResult()));
292         __pPresentationModel->AddContentEventListener(__pFileListEditorForm);
293
294         if (previousSceneId == IDSCN_ALL_LIST_EDITOR)
295         {
296                 if (pArgs != null)
297                 {
298                         __pSeletedIndexList = pArgs;
299                 }
300                 ResetSelection();
301                 int loopCount = __pSeletedIndexList->GetCount();
302                 for (int i = 0; i < loopCount; ++i)
303                 {
304                         __pContentIconListView->SetItemChecked(i, true);
305                         __pContentIconListView->RequestRedraw(true);
306                 }
307         }
308         SetButtonState();
309
310         if (pArgs != null && pArgs->GetCount() > 0)
311         {
312                 String* pDirectory = static_cast<String*>(pArgs->GetAt(0));
313                 if (pDirectory != null && pDirectory->GetLength() > 0)
314                 {
315                         __pFileListEditorForm->MoveToAlbum(*pDirectory);
316                 }
317         }
318         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
319 }
320
321 void
322 AllListSelectionPanel::OnSceneDeactivated(const SceneId& currentSceneId,
323                 const SceneId& nextSceneId)
324 {
325         AppLogDebug("ENTER");
326         __pPresentationModel->RemoveContentEventListener(__pFileListEditorForm);
327         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
328 }
329
330 int
331 AllListSelectionPanel::GetItemCheckedCount(void) const
332 {
333         AppLogDebug("ENTER");
334         int count = 0;
335         if (__pContentIconListView != null && __pSeletedIndexList != null)
336         {
337                 int loopCount = __pSeletedIndexList->GetCount();
338                 for (int i = 0; i < loopCount; ++i)
339                 {
340                         if (__pContentIconListView->IsItemChecked(i))
341                         {
342                                 ++count;
343                         }
344                 }
345         }
346         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
347
348         return count;
349 }
350
351 IList*
352 AllListSelectionPanel::GetItemCheckedIndexListN(void)
353 {
354         AppLogDebug("ENTER");
355         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
356         Integer* pIndex = null;
357
358         if (__pContentIconListView!=null)
359         {
360                 int realIndex = -1;
361                 int loopCount = __pSeletedIndexList->GetCount();
362                 for (int i = 0; i < loopCount; ++i)
363                 {
364                         if (__pContentIconListView->IsItemChecked(i))
365                         {
366                                 realIndex = GetRealindexFromVirtualIndex(i);
367                                 pIndex = new (std::nothrow) Integer(realIndex);
368                                 pList->Add(pIndex);
369                         }
370                 }
371         }
372         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
373
374         return pList;
375 }
376
377 int
378 AllListSelectionPanel::GetRealindexFromVirtualIndex(int virtualIndex)
379 {
380         if (__pSeletedIndexList == null || __pSeletedIndexList->GetCount() == 0)
381         {
382                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
383
384                 return -1;
385         }
386
387         Integer* pRealIndex = static_cast<Integer*>(__pSeletedIndexList->GetAt(virtualIndex));
388         int realIndex = -1;
389         if (pRealIndex != null)
390         {
391                 realIndex = pRealIndex->ToInt();
392         }
393         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
394
395         return realIndex;
396 }
397
398 int
399 AllListSelectionPanel::GetVirtualIndexFromRealIndex(int realIndex)
400 {
401         int returnValue = -1;
402         int loopCount = __pSeletedIndexList->GetCount();
403         for (int i = 0; i < loopCount; ++i)
404         {
405                 Integer* pRealIndex = static_cast<Integer*>(__pSeletedIndexList->GetAt(i));
406                 int index = -1;
407                 if (pRealIndex != null)
408                 {
409                         index = pRealIndex->ToInt();
410                 }
411
412                 if (index == realIndex)
413                 {
414                         returnValue = i;
415                         break;
416                 }
417         }
418         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
419
420         return returnValue;
421 }
422
423 result
424 AllListSelectionPanel::OnRequestDelete(void)
425 {
426         AppLogDebug("ENTER");
427         IList* pIndexList = GetItemCheckedIndexListN();
428         if (pIndexList->GetCount() <= 0)
429         {
430                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
431
432                 return E_FAILURE;
433         }
434
435         delete __pFileUpdateTimer;
436         __pFileUpdateTimer = new FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_DELETE_ACTION);
437         result r = __pFileUpdateTimer->StartTimer();
438
439         if (IsFailed(r))
440         {
441                 delete __pFileUpdateTimer;
442                 __pFileUpdateTimer = null;
443                 return E_FAILURE;
444         }
445         else
446         {
447                 __pPresentationModel->SetUpdateProgressStatus(true);
448         }
449
450         return E_SUCCESS;
451 }
452
453 void AllListSelectionPanel::OnFileOpInvalidate(enum FileActionMode actionId)
454 {
455         __pFileListEditorForm->Invalidate(true);
456 }
457
458 void AllListSelectionPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
459 {
460         __pPresentationModel->SetUpdateProgressStatus(false);
461         SceneManager* pSceneManager = SceneManager::GetInstance();
462         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.",
463                         GetErrorMessage(GetLastResult()));
464
465         String strTmp;
466         String selectString = ResourceManager::GetString(L"IDS_COM_BODY_SELECTED");
467         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)", selectString.GetPointer(), 0);
468         __pFileListEditorForm->SetTitleText(strTmp);
469
470         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
471         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
472         __pContentIconListView->UpdateList();
473
474         if (GetItemCount() > 0)
475         {
476                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
477         }
478         else
479         {
480                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
481         }
482         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
483 }
484
485 result
486 AllListSelectionPanel::OnRequestMessage(void)
487 {
488         AppLogDebug("ENTER");
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         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE, null,
519                         null, pDataList, null);
520         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
521
522         return E_SUCCESS;
523 }
524
525 result
526 AllListSelectionPanel::OnRequestEmail(void)
527 {
528         AppLogDebug("ENTER");
529         IList* pIndexList = GetItemCheckedIndexListN();
530         if (pIndexList == null || pIndexList->GetCount() <= 0)
531         {
532                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
533
534                 return E_FAILURE;
535         }
536
537         Integer* pIndex = null;
538         int checkedIndex;
539         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
540         pArrayList->Construct();
541         int loopCount = pIndexList->GetCount();
542
543         for (int i = 0; i < loopCount; ++i)
544         {
545                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
546                 if (pIndex != null)
547                 {
548                         checkedIndex = pIndex->ToInt();
549                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(checkedIndex)));
550                 }
551         }
552
553         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
554         pDataList->Construct();
555         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
556
557         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
558                         new (std::nothrow) String(APPCONTROL_URI_MAIL_TO), null, pDataList, null);
559         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
560
561         return E_SUCCESS;
562 }
563
564 result
565 AllListSelectionPanel::OnRequestSlideShow(void)
566 {
567         AppLogDebug("ENTER");
568         IList* pIndexList = GetItemCheckedIndexListN();
569         if (pIndexList == null)
570         {
571                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
572                 return E_FAILURE;
573         }
574
575         Integer* pRealIndex = null;
576         int realIndex = -1;
577         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
578         pArrayList->Construct();
579         int loopCount = pIndexList->GetCount();
580
581         for (int i = 0; i < loopCount; ++i)
582         {
583                 pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
584                 if (pRealIndex != null)
585                 {
586                         realIndex = pRealIndex->ToInt();
587                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(realIndex)));
588                 }
589         }
590
591         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
592         pDataList->Construct();
593         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
594         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
595
596         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
597                         new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
598         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
599
600         return E_SUCCESS;
601 }
602
603 void
604 AllListSelectionPanel::ResetSelection(void)
605 {
606         AppLogDebug("ENTER");
607         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
608         if (__pSeletedIndexList == null)
609         {
610                 __itemCount = 0;
611         }
612         else
613         {
614                 __itemCount = __pSeletedIndexList->GetCount();
615         }
616
617         SceneManager* pSceneManager = SceneManager::GetInstance();
618         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
619
620         String strTmp;
621         String bodyText = ResourceManager::GetString(L"IDS_COM_BODY_SELECTED");
622         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)", bodyText.GetPointer(), __itemCount);
623         __pFileListEditorForm->SetTitleText(strTmp);
624         if (__pContentIconListView != null)
625         {
626                 __pContentIconListView->UpdateList();
627         }
628         SetButtonState();
629         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
630 }
631
632 void
633 AllListSelectionPanel::SetButtonState(void)
634 {
635         AppLogDebug("ENTER");
636         SceneManager* pSceneManager = SceneManager::GetInstance();
637         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
638
639         if (GetItemCheckedCount() > 0)
640         {
641                 AppLogDebug("BUTTONSTATE : Request Enable");
642                 __pFileListEditorForm->SetFooterButtonsState(true);
643         }
644         else
645         {
646                 AppLogDebug("BUTTONSTATE : Request disable");
647                 __pFileListEditorForm->SetFooterButtonsState(false);
648         }
649         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
650 }
651
652 void
653 AllListSelectionPanel::SelectAllPressed(void)
654 {
655         bool needToSelectAll = true;
656         int checkedCount = GetItemCheckedCount();
657         if (checkedCount == __itemCount)
658         {
659                 needToSelectAll = false;
660         }
661
662         if (needToSelectAll == true)
663         {
664                 for (int i = 0 ; i < __itemCount; ++i)
665                 {
666                         if (__pContentIconListView->IsItemChecked(i) == false)
667                         {
668                                 __pContentIconListView->SetItemChecked(i,true);
669                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
670                         }
671                 }
672         }
673         else
674         {
675                 for (int i = 0 ; i < __itemCount; ++i)
676                 {
677                         if (__pContentIconListView->IsItemChecked(i) == true)
678                         {
679                                 __pContentIconListView->SetItemChecked(i, false);
680                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
681                         }
682                 }
683         }
684
685         SceneManager* pSceneManager = SceneManager::GetInstance();
686         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
687
688         String tempString;
689         if (needToSelectAll == true)
690         {
691                 tempString.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
692                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), __itemCount);
693         }
694         else
695         {
696                 tempString.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
697                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), 0);
698         }
699         __pFileListEditorForm->SetTitleText(tempString);
700
701         SetButtonState();
702 }
703
704 result
705 AllListSelectionPanel::OnRotateRequested(RotateMode rotateMode)
706 {
707         AppLogDebug("ENTER");
708         IList* pIndexList = GetItemCheckedIndexListN();
709         if (pIndexList == null)
710         {
711                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
712                 return E_FAILURE;
713         }
714         else if (pIndexList->GetCount() <= 0)
715         {
716                 delete pIndexList;
717                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
718
719                 return E_FAILURE;
720         }
721
722         delete __pFileUpdateTimer;
723         __pFileUpdateTimer = new FileUpdateTimer(pIndexList, __pPresentationModel, this, FILE_ROTATE_ACTION, rotateMode);
724         result r = __pFileUpdateTimer->StartTimer();
725
726         if (IsFailed(r))
727         {
728                 delete __pFileUpdateTimer;
729                 __pFileUpdateTimer = null;
730                 return E_FAILURE;
731         }
732         else
733         {
734                 __pPresentationModel->SetUpdateProgressStatus(true);
735         }
736         return E_SUCCESS;
737 }
738