c95bf207d079a01014532c40dbf2a97befea4e53
[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.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
144                         ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), 0);
145         __pLabelSelectCnt->Construct(
146                         Rectangle(0, clientAreaBounds.height-H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL), strTmp);
147         __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
148         __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
149         __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
150         __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
151         AddControl(*__pLabelSelectCnt);
152         __pLabelSelectCnt->Invalidate(true);
153
154         __pButtonSelectRegion = new (std::nothrow) Button();
155         __pButtonSelectRegion->Construct(Rectangle(clientAreaBounds.width - W_COUNT_LABEL_BUTTON - 10,
156                         clientAreaBounds.height - H_COUNT_LABEL_BUTTON - 4, W_COUNT_LABEL_BUTTON, H_COUNT_LABEL_BUTTON),
157                         EMPTY_SPACE);
158         __pButtonSelectRegion->SetActionId(ACTION_ID_BUTTON_MOVE_TO_SELECTION);
159         __pButtonSelectRegion->SetColor(BUTTON_STATUS_NORMAL, COLOR_COUNT_LABEL_BUTTON);
160         Bitmap* pSelectionBitmap = ResourceManager::GetBitmapN(IDB_BUTTON_MOVE_SELECTION);
161         if (pSelectionBitmap != null)
162         {
163                 Rectangle buttonRegionRect = __pButtonSelectRegion->GetBounds();
164                 pSelectionBitmap->Scale(Dimension(buttonRegionRect.width, buttonRegionRect.height));
165                 __pButtonSelectRegion->SetNormalBitmap(Point(buttonRegionRect.width, buttonRegionRect.height),
166                                 *pSelectionBitmap);
167         }
168         AddControl(*__pButtonSelectRegion);
169
170         if (pSelectionBitmap != null)
171         {
172                 delete pSelectionBitmap;
173                 pSelectionBitmap = null;
174         }
175         __pButtonSelectRegion->AddActionEventListener(*this);
176
177         __itemCount=0;
178         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
179
180         return r;
181 }
182
183 result
184 AllListEditorPanel::OnTerminating(void)
185 {
186         AppLogDebug("ENTER");
187         __pPresentationModel->RemovePresentationModelListener(*this);
188         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
189
190         return E_SUCCESS;
191 }
192
193 void
194 AllListEditorPanel::OnUpdateContentList()
195 {
196         AppLogDebug("ENTER");
197         SceneManager* pSceneManager = SceneManager::GetInstance();
198         FileListEditorForm* pFileListEditorForm =
199                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
200         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
201                         GetErrorMessage(GetLastResult()));
202
203         if ( pFileListEditorForm->GetOverlayStatus() == false && __deleteInProgress == false )
204         {
205                 SceneManager* pSceneManager = SceneManager::GetInstance();
206                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
207                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
208         }
209 }
210
211 void
212 AllListEditorPanel::OnActionPerformed(const Control& source, int actionId)
213 {
214         AppLogDebug("ENTER");
215         SceneManager* pSceneManager = SceneManager::GetInstance();
216         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
217
218         switch (actionId)
219         {
220         case ACTION_ID_BUTTON_CHECKED:
221         {
222                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
223                 for (int i=0 ; i < loopCount; ++i)
224                 {
225                         if (__pContentIconListView->IsItemChecked(i) == false)
226                         {
227                                 __pContentIconListView->SetItemChecked(i,true);
228                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
229                         }
230                 }
231                 int checkedCount = GetItemCheckedCount();
232                 String strTmp;
233                 strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
234                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), checkedCount);
235                 __pLabelSelectCnt->SetText(strTmp);
236                 __pLabelSelectCnt->RequestRedraw(true);
237                 SetButtonState();
238                 break;
239         }
240         case ACTION_ID_BUTTON_UNCHECKED:
241         {
242                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
243                 for (int i = 0; i < loopCount; ++i)
244                 {
245                         if (__pContentIconListView->IsItemChecked(i) == true)
246                         {
247                                 __pContentIconListView->SetItemChecked(i,false);
248                         }
249                 }
250                 int checkedCount = GetItemCheckedCount();
251                 String strTmp;
252                 strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
253                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), checkedCount);
254                 __pLabelSelectCnt->SetText(strTmp);
255                 __pLabelSelectCnt->RequestRedraw(true);
256                 __pContentIconListView->UpdateList();
257                 SetButtonState();
258                 break;
259         }
260         case ACTION_ID_BUTTON_MOVE_TO_SELECTION:
261         {
262                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
263                 {
264                         IList* pList = GetItemCheckedIndexListN();
265                         if (pList == null)
266                         {
267                                 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
268                         }
269                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_SELECTION), pList);
270                 }
271                 else
272                 {
273                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_SELECTION));
274                 }
275                 break;
276         }
277         default:
278         {
279                 break;
280         }
281         }
282         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
283 }
284
285 int
286 AllListEditorPanel::GetItemCount(void)
287 {
288         AppLogDebug("ENTER");
289         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
290
291         return __itemCount;
292 }
293
294 IconListViewItem*
295 AllListEditorPanel::CreateItem(int index)
296 {
297         AppLogDebug("ENTER : index(%d)", index);
298         IconListViewItem* pIconListviewItem;
299         Bitmap* pBitmap=null;
300         String* pItemText=null;
301         result r = __pPresentationModel->GetThumbnailInSyncCacheN(index, pItemText, pBitmap);
302         if (pBitmap == null || r == E_FAILURE)
303         {
304                 __pPresentationModel->RequestThumbnail(index);
305                 pBitmap = CommonUtil::GetEmptyThumbnailN();
306         }
307
308         if (pItemText == null)
309         {
310                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
311         }
312         else if ((*pItemText) != ResourceManager::GetString(L"EMPTY_SPACE"))
313         {
314                 delete pItemText;
315                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
316         }
317
318         if (__pContentIconListView->IsItemChecked(index) == true)
319         {
320                 if (pBitmap != null)
321                 {
322                         BufferInfo bufferInfo;
323                         pBitmap->Lock(bufferInfo, INFINITE);
324                         pBitmap->Unlock();
325                         Color dimColor(COLOR_THUMBNAIL_DIM);
326                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
327
328                         Canvas canvas;
329                         canvas.Construct(bufferInfo);
330                         canvas.FillRectangle(dimColor, canvas.GetBounds());
331
332                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
333                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
334                         pIconListviewItem = new (std::nothrow) IconListViewItem();
335                         pIconListviewItem->Construct(*pBitmap, pItemText, pSelectedBitmap);
336                         delete pSelectedBitmap;
337                         pSelectedBitmap = null;
338                 }
339                 else
340                 {
341                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
342                         return null;
343                 }
344         }
345         else
346         {
347                 pIconListviewItem = new (std::nothrow) IconListViewItem();
348                 pIconListviewItem->Construct(*pBitmap, pItemText);
349         }
350
351         if (pBitmap != null)
352         {
353                 delete pBitmap;
354                 pBitmap = null;
355         }
356         if (pItemText != null)
357         {
358                 delete pItemText;
359                 pItemText = null;
360         }
361         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
362
363         return pIconListviewItem;
364 }
365
366 bool
367 AllListEditorPanel::DeleteItem(int index, IconListViewItem* pItem)
368 {
369         AppLogDebug("ENTER");
370         delete pItem;
371         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
372
373         return true;
374 }
375
376 void
377 AllListEditorPanel::OnIconListViewItemStateChanged(IconListView& view, int index, IconListViewItemStatus status)
378 {
379         AppLogDebug("ENTER");
380         if (status == ICON_LIST_VIEW_ITEM_CHECKED || status == ICON_LIST_VIEW_ITEM_UNCHECKED)
381         {
382                 int checkedCount = GetItemCheckedCount();
383                 String strTmp;
384                 strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
385                                 ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), checkedCount);
386                 __pLabelSelectCnt->SetText(strTmp);
387                 __pLabelSelectCnt->RequestRedraw(true);
388                 if (__pCheckButton->IsSelected() == true)
389                 {
390                         __pCheckButton->SetSelected(false);
391                 }
392                 else
393                 {
394                         if (checkedCount != 0 && checkedCount == __pPresentationModel->GetCurrentAlbumContentInfoCount())
395                         {
396                                 __pCheckButton->SetSelected(true);
397                         }
398                 }
399                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
400         }
401         SetButtonState();
402         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
403 }
404
405 void
406 AllListEditorPanel::OnFileInfoChanged(const ContentType contentType)
407 {
408         AppLogDebug("ENTER");
409         if (contentType == CONTENT_TYPE_ALL
410                 || contentType == CONTENT_TYPE_IMAGE
411                 || contentType == CONTENT_TYPE_VIDEO)
412         {
413                 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
414                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
415                 __pContentIconListView->UpdateList();
416         }
417         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
418 }
419
420 void
421 AllListEditorPanel::OnThumbnailDecoded(const int index)
422 {
423         AppLogDebug("ENTER : index(%d)", index);
424         if (index >= 0)
425         {
426                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
427         }
428         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
429 }
430
431 void
432 AllListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
433                                                                 const SceneId& currentSceneId, IList* pArgs)
434 {
435         AppLogDebug("ENTER");
436         __pPresentationModel = FileListPresentationModel::GetInstance();
437
438         SceneManager* pSceneManager = SceneManager::GetInstance();
439         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
440
441         if (previousSceneId == IDSCN_ALL_LIST_SELECTION)
442         {
443                 ResetSelection();
444         }
445         else if (previousSceneId == IDSCN_ALL_LIST)
446         {
447                 ResetSelection();
448         }
449
450         SetButtonState();
451
452         FileListEditorForm* pFileListEditorForm =
453                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
454         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
455                         GetErrorMessage(GetLastResult()));
456
457         pFileListEditorForm->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
458         
459         if (pArgs != null && pArgs->GetCount() > 0)
460         {
461                 String* pDirectory = static_cast<String*>(pArgs->GetAt(0));
462                 if (pDirectory != null && pDirectory->GetLength() > 0)
463                 {
464                         pFileListEditorForm->MoveToAlbum(*pDirectory);
465                 }
466         }
467
468         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
469 }
470
471 void
472 AllListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
473 {
474         AppLogDebug("ENTER");
475         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
476 }
477
478 int
479 AllListEditorPanel::GetItemCheckedCount(void) const
480 {
481         AppLogDebug("ENTER");
482         int count = 0;
483         if (__pContentIconListView != null)
484         {
485                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
486                 for (int i = 0; i < loopCount; ++i)
487                 {
488                         if (__pContentIconListView->IsItemChecked(i))
489                         {
490                                 ++count;
491                         }
492                 }
493         }
494         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
495
496         return count;
497 }
498
499 IList*
500 AllListEditorPanel::GetItemCheckedIndexListN(void) const
501 {
502         AppLogDebug("ENTER");
503         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
504         Integer* pIndex = null;
505
506         if (__pContentIconListView!=null)
507         {
508                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
509                 for (int i = 0; i < loopCount; ++i)
510                 {
511                         if (__pContentIconListView->IsItemChecked(i) == true)
512                         {
513                                 pIndex = new (std::nothrow) Integer(i);
514                                 pList->Add(pIndex);
515                                 AppLogDebug("checked index(%d)", i);
516                         }
517                 }
518         }
519         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
520
521         return pList;
522 }
523
524 result
525 AllListEditorPanel::OnRequestDelete(void)
526 {
527         AppLogDebug("ENTER");
528         IList* pIndexList = GetItemCheckedIndexListN();
529         if (pIndexList->GetCount() <= 0)
530         {
531                 delete pIndexList;
532                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
533
534                 return E_FAILURE;
535         }
536
537         delete __pFileDelete;
538         __pFileDelete = new FileDeleteTimer(pIndexList,
539                         __pPresentationModel,
540                         this );
541         result r = __pFileDelete->StartTimer();
542
543         if (IsFailed(r))
544         {
545                 delete __pFileDelete;
546                 __pFileDelete = null;
547                 return E_FAILURE;
548         }
549         else
550         {
551                 __deleteInProgress = true;
552         }
553         return E_SUCCESS;
554 }
555
556 void AllListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
557 {
558         SceneManager* pSceneManager = SceneManager::GetInstance();
559         FileListEditorForm* pFileListEditorForm =
560                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
561         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
562                         GetErrorMessage(GetLastResult()));
563         pFileListEditorForm->Invalidate(true);
564 }
565
566 void AllListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
567 {
568         __pCheckButton->SetSelected(false);
569         __deleteInProgress = false;
570
571         String strTmp;
572         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
573                         ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), 0);
574         __pLabelSelectCnt->SetText(strTmp);
575         __pLabelSelectCnt->RequestRedraw(true);
576
577         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
578         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
579         __pContentIconListView->UpdateList();
580
581         SceneManager* pSceneManager = SceneManager::GetInstance();
582         if (GetItemCount() > 0)
583         {
584                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
585         }
586         else
587         {
588                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
589         }
590         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
591 }
592
593 result
594 AllListEditorPanel::OnRequestMessage(void)
595 {
596         AppLogDebug("ENTER");
597         IList* pIndexList = GetItemCheckedIndexListN();
598         if (pIndexList == null || pIndexList->GetCount() <= 0)
599         {
600                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
601
602                 return E_FAILURE;
603         }
604
605         String combineText;
606         String path;
607         Integer* pIndex = null;
608         int checkedIndex;
609
610         int loopCount = pIndexList->GetCount();
611         AppLogDebug("pIndexList->GetCount(%d)", loopCount);
612         for (int i = 0; i < loopCount; ++i)
613         {
614                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
615                 if (pIndex != null)
616                 {
617                         checkedIndex = pIndex->ToInt();
618                         path = __pPresentationModel->GetContentFilePath(checkedIndex);
619                 }
620
621                 if (combineText.CompareTo(EMPTY_SPACE) != 0)
622                 {
623                         combineText.Append(L";");
624                 }
625                 combineText.Append(path);
626         }
627
628         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
629         pDataList->Construct();
630         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
631         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
632
633         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE,
634                         pDataList, null);
635         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
636
637         return E_SUCCESS;
638 }
639
640 result
641 AllListEditorPanel::OnRequestEmail(void)
642 {
643         AppLogDebug("ENTER");
644         IList* pIndexList = GetItemCheckedIndexListN();
645         if (pIndexList == null || pIndexList->GetCount() <= 0)
646         {
647                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
648
649                 return E_FAILURE;
650         }
651
652         String combineText;
653         String path;
654         Integer* pIndex = null;
655         int checkedIndex;
656
657         int loopCount = pIndexList->GetCount();
658         AppLogDebug("pIndexList->GetCount(%d)", loopCount);
659         for (int i = 0; i < loopCount; ++i)
660         {
661                 pIndex = static_cast<Integer*>(pIndexList->GetAt(i));
662                 if (pIndex != null)
663                 {
664                         checkedIndex = pIndex->ToInt();
665                         path = __pPresentationModel->GetContentFilePath(checkedIndex);
666                 }
667
668                 if (combineText.CompareTo(EMPTY_SPACE) != 0)
669                 {
670                         combineText.Append(L";");
671                 }
672                 combineText.Append(path);
673         }
674
675         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
676         pDataList->Construct();
677         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS), new (std::nothrow) String(combineText));
678
679         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
680                         pDataList, null);
681         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
682
683         return E_SUCCESS;
684 }
685
686 result
687 AllListEditorPanel::OnRequestSlideShow(void)
688 {
689         AppLogDebug("ENTER");
690         IList* pIndexList = GetItemCheckedIndexListN();
691         if (pIndexList == null)
692         {
693                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
694
695                 return E_FAILURE;
696         }
697
698         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
699         result r = pDataList->Construct();
700         if (r != E_SUCCESS)
701         {
702                 delete pDataList;
703                 pDataList = null;
704                 delete pIndexList;
705                 pIndexList = null;
706                 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
707
708                 return E_FAILURE;
709         }
710
711         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE),
712                         new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
713
714         Integer* pRealIndex = null;
715         int realIndex = -1;
716         String combineText;
717         String path;
718
719         int loopCount = pIndexList->GetCount();
720         if (loopCount > 0)
721         {
722                 for (int i = 0; i < loopCount; ++i)
723                 {
724                         pRealIndex = static_cast<Integer*>(pIndexList->GetAt(i));
725                         if (pRealIndex != null)
726                         {
727                                 realIndex = pRealIndex->ToInt();
728                         }
729
730                         path = __pPresentationModel->GetContentFilePath(realIndex);
731                         if (combineText.CompareTo(EMPTY_SPACE) != 0)
732                         {
733                                 combineText.Append(L";");
734                         }
735                         combineText.Append(path);
736                 }
737                 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), new (std::nothrow) String(combineText));
738         }
739
740         delete pIndexList;
741
742         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE,
743                         APPCONTROL_OPERATION_ID_VIEW, pDataList, null);
744         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
745
746         return E_SUCCESS;
747 }
748
749 void
750 AllListEditorPanel::ResetSelection(void)
751 {
752         AppLogDebug("ENTER");
753         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
754         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
755         __pContentIconListView->UpdateList();
756
757         int checkedCount = GetItemCheckedCount();
758         String strTmp;
759         strTmp.Format(LENGTH_COUNT_LABEL, L"%ls (%d)",
760                         ResourceManager::GetString(L"IDS_COM_BODY_SELECTED").GetPointer(), checkedCount);
761         __pLabelSelectCnt->SetText(strTmp);
762         __pLabelSelectCnt->RequestRedraw(true);
763         __pCheckButton->SetSelected(false);
764         SetButtonState();
765         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
766 }
767
768 void
769 AllListEditorPanel::SetButtonState(void)
770 {
771         AppLogDebug("ENTER");
772         SceneManager* pSceneManager = SceneManager::GetInstance();
773         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
774
775         FileListEditorForm* pFileListEditorForm =
776                         dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
777         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
778                         GetErrorMessage(GetLastResult()));
779
780         if (GetItemCheckedCount() > 0)
781         {
782                 AppLogDebug("BUTTONSTATE : Request Enable");
783                 pFileListEditorForm->SetFooterButtonsState(true);
784                 __pButtonSelectRegion->SetShowState(true);
785         }
786         else
787         {
788                 AppLogDebug("BUTTONSTATE : Request disable");
789                 pFileListEditorForm->SetFooterButtonsState(false);
790                 __pButtonSelectRegion->SetShowState(false);
791         }
792         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
793 }