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