Fixed prevent issues
[apps/osp/Gallery.git] / src / GlVideoListEditorPanel.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                GlVideoListEditorPanel.cpp
19  * @brief               This is the implementation file for VideoListEditorPanel class.
20  */
21
22 #include <FContent.h>
23 #include <FMedia.h>
24 #include "GlAlbumInfo.h"
25 #include "GlCommonUtil.h"
26 #include "GlFileListPresentationModel.h"
27 #include "GlGalleryApp.h"
28 #include "GlResourceManager.h"
29 #include "GlTypes.h"
30 #include "GlVideoListEditorPanel.h"
31 #include "GlFileListEditorForm.h"
32 #include "GlFileUpdateTimer.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Content;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Media;
40 using namespace Tizen::Ui::Controls;
41 using namespace Tizen::Ui::Scenes;
42
43 static const unsigned int COLOR_COUNT_LABEL = Color32<68, 68, 68>::Value;
44 static const unsigned int COLOR_SELECT_COUNT_FONT = Color32<255, 255, 255>::Value;
45 static const Color COLOR_THUMBNAIL_DIM (Color::GetColor(COLOR_ID_BLACK));
46 static const Rectangle RECT_VIDEO_THUMBNAIL(16, 16, 172, 128);
47 static const Rectangle RECT_INITIAL(0, 0, 10, 10);
48
49 static const int H_SELECTALL_REGION = 112;
50 static const int ALPHA_THUMBNAIL_DIM = 70;
51 static const int H_COUNT_LABEL = 48;
52 static const int COUNT_LABEL_FONT_SIZE = 33;
53 static const int LENGTH_COUNT_LABEL = 256;
54 static const int W_CLIENT_REGION = 720;
55 static const int H_VIDEO_ITEM = 160;
56 static const int GAP_W_VIDEO_TITLE = 16+172+16;
57 static const int GAP_H_VIDEO_TITLE = 22;
58 static const int W_VIDEO_TITLE = (16+172+16)+(16+64+16);
59 static const int H_VIDEO_TITLE = 64;
60 static const int FONT_SIZE_TITLE = 36;
61 static const int GAP_W_VIDEO_DURATION = 16+172+16;
62 static const int GAP_H_VIDEO_DURATION = 22+64;
63 static const int W_VIDEO_DURATION = (16+172+16)+(16+64+16);
64 static const int H_VIDEO_DURATION = 48;
65 static const int FONT_SIZE_DURATION = 32;
66
67 VideoListEditorPanel::VideoListEditorPanel()
68         : __pContentIconListView(null)
69         , __pCheckButton(null)
70         , __pLabelSelectCnt(null)
71         , __itemCount(0)
72         , __pPresentationModel(null)
73         , __pFileDelete(null)
74 {
75         AppLogDebug("ENTER");
76         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
77 }
78
79 VideoListEditorPanel::~VideoListEditorPanel()
80 {
81         AppLogDebug("ENTER");
82         delete __pFileDelete;
83         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
84 }
85
86 result
87 VideoListEditorPanel::Initialize(void)
88 {
89         AppLogDebug("ENTER");
90         result r = Construct(RECT_INITIAL);
91         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
92
93         return r;
94 }
95
96 result
97 VideoListEditorPanel::OnInitializing(void)
98 {
99         AppLogDebug("ENTER");
100         const Form* pForm = dynamic_cast<Form*>(GetParent());
101         TryReturn(pForm != null, E_FAILURE, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
102
103         __pPresentationModel = FileListPresentationModel::GetInstance();
104         __pPresentationModel->ClearThumbnailRequests();
105         __pPresentationModel->AddPresentationModelListener(this);
106         __itemCount = 0;
107
108         Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
109         clientAreaBounds.x = clientAreaBounds.y = 0;
110         SetBounds(clientAreaBounds);
111
112         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
113         {
114                 __pContentIconListView = new (std::nothrow) ListView();
115
116                 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
117                 {
118                         __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height), true, false);
119                         Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
120                         if (pBitmapEmpty != null)
121                         {
122                                 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
123                                 delete pBitmapEmpty;
124                         }
125                         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
126                         __pContentIconListView->SetItemProvider(*this);
127                         __pContentIconListView->AddListViewItemEventListener(*this);
128                         AddControl(*__pContentIconListView);
129                         __pContentIconListView->SetShowState(true);
130                 }
131                 else
132                 {
133                         __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height), true, false);
134                         Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
135                         if (pBitmapEmpty != null)
136                         {
137                                 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
138                                 delete pBitmapEmpty;
139                         }
140                         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
141                         __pContentIconListView->SetItemProvider(*this);
142                         __pContentIconListView->AddListViewItemEventListener(*this);
143                         AddControl(*__pContentIconListView);
144                         __pContentIconListView->SetShowState(true);
145                 }
146         }
147         else
148         {
149                 __pContentIconListView = new (std::nothrow) ListView();
150                 __pContentIconListView->Construct(
151                                 Rectangle(0, H_SELECTALL_REGION, W_CLIENT_REGION, clientAreaBounds.height-H_SELECTALL_REGION),
152                                 true, false);
153                 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
154                 if (pBitmapEmpty != null)
155                 {
156                         __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
157                         delete pBitmapEmpty;
158                 }
159                 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
160                 __pContentIconListView->SetItemProvider(*this);
161                 __pContentIconListView->AddListViewItemEventListener(*this);
162                 AddControl(*__pContentIconListView);
163                 __pContentIconListView->SetShowState(true);
164
165                 __pLabelSelectCnt = new (std::nothrow) Label();
166                 __pLabelSelectCnt->Construct(
167                                 Rectangle(0, clientAreaBounds.height-H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL),
168                                 ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
169                 __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
170                 __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
171                 __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
172                 __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
173                 __pLabelSelectCnt->SetTextConfig(COUNT_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
174                 AddControl(*__pLabelSelectCnt);
175
176         }
177         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
178
179         return E_SUCCESS;
180 }
181
182 result
183 VideoListEditorPanel::OnTerminating(void)
184 {
185         AppLogDebug("ENTER");
186         __pPresentationModel->RemovePresentationModelListener(*this);
187         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
188
189         return E_SUCCESS;
190 }
191
192 int
193 VideoListEditorPanel::GetItemCount(void)
194 {
195         AppLogDebug("ENTER");
196         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
197
198         return __itemCount;
199 }
200
201 ListItemBase*
202 VideoListEditorPanel::CreateItem(int index, int itemWidth)
203 {
204         AppLogDebug("ENTER : index(%d)", index);
205         CustomItem* pItem = new (std::nothrow) CustomItem();
206
207         Bitmap* pBitmap = null;
208         String* pItemText = null;
209         String* pTitle = null;
210         String* pDuration = null;
211
212         result r = __pPresentationModel->GetThumbnailVideoInSyncCacheN(index, pItemText, pBitmap, pDuration);
213         if (pBitmap == null || r == E_FAILURE)
214         {
215                 __pPresentationModel->RequestThumbnail(index);
216                 pBitmap = CommonUtil::GetEmptyThumbnailN();
217         }
218
219         if (pItemText == null)
220         {
221                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
222         }
223
224         pTitle = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
225
226         if (pDuration == null)
227         {
228                 pDuration = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
229         }
230
231         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
232         {
233                 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
234                 {
235                         pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_MARK);
236
237                         if (__pContentIconListView->IsItemChecked(index) == true)
238                         {
239                                 if (pBitmap != null)
240                                 {
241                                         BufferInfo bufferInfo;
242                                         pBitmap->Lock(bufferInfo, INFINITE);
243                                         pBitmap->Unlock();
244
245                                         Color dimColor(COLOR_THUMBNAIL_DIM);
246                                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
247
248                                         Canvas canvas;
249                                         canvas.Construct(bufferInfo);
250                                         canvas.FillRectangle(dimColor, canvas.GetBounds());
251
252                                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
253                                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
254                                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap,
255                                                         pSelectedBitmap);
256                                         delete pSelectedBitmap;
257                                 }
258                                 else
259                                 {
260                                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
261                                         delete pTitle;
262                                         delete pItemText;
263                                         delete pDuration;
264                                         return null;
265                                 }
266                         }
267                         else
268                         {
269                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
270                         }
271
272                         if (pTitle == null)
273                         {
274                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
275                         }
276                         else if (pTitle->IsEmpty() == true)
277                         {
278                                 delete pTitle;
279                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
280                         }
281
282                         Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
283                         pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
284                                         Color::GetColor(COLOR_ID_BLACK),null,null,false);
285
286                         Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
287                                         H_VIDEO_DURATION);
288                         pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
289                                         Color::GetColor(COLOR_ID_GREY),null,null,false);
290                 }
291                 else
292                 {
293                         pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_NORMAL);
294                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
295
296                         if (pTitle == null)
297                         {
298                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
299                         }
300                         else if (pTitle->IsEmpty() == true)
301                         {
302                                 delete pTitle;
303                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
304                         }
305
306                         Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
307                         pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
308                                         Color::GetColor(COLOR_ID_BLACK),null,null,false);
309
310                         Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
311                                         H_VIDEO_DURATION);
312                         pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
313                                         Color::GetColor(COLOR_ID_GREY),null,null,false);
314                 }
315         }
316         else
317         {
318                 pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_MARK);
319                 if (__pContentIconListView->IsItemChecked(index) == true)
320                 {
321                         if (pBitmap != null)
322                         {
323                                 BufferInfo bufferInfo;
324                                 pBitmap->Lock(bufferInfo, INFINITE);
325                                 pBitmap->Unlock();
326                                 Color dimColor(COLOR_THUMBNAIL_DIM);
327                                 dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
328
329                                 Canvas canvas;
330                                 canvas.Construct(bufferInfo);
331                                 canvas.FillRectangle(dimColor, canvas.GetBounds());
332
333                                 Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
334                                 pSelectedBitmap->Construct(canvas, canvas.GetBounds());
335                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap, pSelectedBitmap);
336                                 delete pSelectedBitmap;
337                         }
338                         else
339                         {
340                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
341                         }
342                 }
343                 else
344                 {
345                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
346                 }
347
348                 if (pTitle == null)
349                 {
350                         pTitle = new (std::nothrow) String(SINGLE_SPACE);
351                 }
352                 else if (pTitle->IsEmpty() == true)
353                 {
354                         delete pTitle;
355                         pTitle = new (std::nothrow) String(SINGLE_SPACE);
356                 }
357
358                 Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
359                 pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
360                                 Color::GetColor(COLOR_ID_BLACK),null,null,false);
361
362                 Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth - W_VIDEO_DURATION,
363                                 H_VIDEO_DURATION);
364                 pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
365                                 Color::GetColor(COLOR_ID_GREY),null,null,false);
366         }
367
368         if (pBitmap != null)
369         {
370                 delete pBitmap;
371         }
372         if (pItemText != null)
373         {
374                 delete pItemText;
375         }
376         if (pTitle != null)
377         {
378                 delete pTitle;
379         }
380         if (pDuration != null)
381         {
382                 delete pDuration;
383         }
384         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
385
386         return pItem;
387 }
388
389 bool
390 VideoListEditorPanel::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
391 {
392         AppLogDebug("ENTER");
393         delete pItem;
394         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
395
396         return true;
397 }
398
399 void
400 VideoListEditorPanel::OnListViewItemStateChanged(ListView& listView, int index, int elementId,
401                 ListItemStatus status)
402 {
403         AppLogDebug("ENTER");
404
405         if (status == LIST_ITEM_STATUS_CHECKED || status == LIST_ITEM_STATUS_UNCHECKED)
406         {
407                 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
408                 {
409                         if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
410                         {
411                                 int checkedCount = GetItemCheckedCount();
412                                 String strTmp;
413                                 if (checkedCount == 0)
414                                 {
415                                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
416                                 }
417                                 else if (checkedCount == 1)
418                                 {
419                                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
420                                 }
421                                 else
422                                 {
423                                         strTmp.Format(LENGTH_COUNT_LABEL,
424                                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
425                                 }
426
427                                 __pLabelSelectCnt->SetText(strTmp);
428                                 __pLabelSelectCnt->RequestRedraw(true);
429                                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
430                         }
431                 }
432                 else
433                 {
434                         int checkedCount = GetItemCheckedCount();
435                         String strTmp;
436                         if (checkedCount == 0)
437                         {
438                                 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
439                         }
440                         else if (checkedCount == 1)
441                         {
442                                 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
443                         }
444                         else
445                         {
446                                 strTmp.Format(LENGTH_COUNT_LABEL,
447                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
448                         }
449
450                         __pLabelSelectCnt->SetText(strTmp);
451                         __pLabelSelectCnt->RequestRedraw(true);
452                         if (__pCheckButton->IsSelected())
453                         {
454                                 __pCheckButton->SetSelected(false);
455                         }
456                         __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
457                 }
458         }
459
460         if (    __pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
461                 && __pPresentationModel->GetAppControlSelectionMode() != APPCONTROL_SELECTION_MODE_MULTIPLE)
462         {
463                 if (status == LIST_ITEM_STATUS_SELECTED)
464                 {
465                         HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
466                         result r = map->Construct();
467                         if (r == E_SUCCESS)
468                         {
469                                 map->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH),
470                                                 new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
471                                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
472                                 pArrayList->Construct();
473
474                                 if (r == E_SUCCESS)
475                                 {
476                                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
477                                         map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
478
479                                         GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
480                                         if (pApp != null)
481                                         {
482                                                 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
483                                                 pApp->Terminate();
484                                         }
485                                         else
486                                         {
487                                                 delete map;
488                                         }
489                                 }
490                         }
491                         else
492                         {
493                                 delete map;
494                         }
495                 }
496         }
497         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
498 }
499
500 void
501 VideoListEditorPanel::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
502 {
503         AppLogDebug("ENTER");
504         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
505 }
506
507 void
508 VideoListEditorPanel::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId,
509                 ListContextItemStatus status)
510 {
511         AppLogDebug("ENTER");
512         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
513 }
514
515 void
516 VideoListEditorPanel::OnFileInfoChanged(const ContentType contentType)
517 {
518         AppLogDebug("ENTER");
519         if (contentType == CONTENT_TYPE_VIDEO)
520         {
521                 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
522                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
523                 __pContentIconListView->UpdateList();
524         }
525         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
526 }
527
528 void
529 VideoListEditorPanel::OnThumbnailDecoded(const int index)
530 {
531         AppLogDebug("ENTER : index(%d)", index);
532         if (index >= 0)
533         {
534                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
535         }
536         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
537 }
538
539 void
540 VideoListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
541                                                                 const SceneId& currentSceneId, IList* pArgs)
542 {
543         AppLogDebug("ENTER");
544         __pPresentationModel = FileListPresentationModel::GetInstance();
545
546         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
547         {
548                 if (currentSceneId == IDSCN_VIDEO_LIST_EDITOR)
549                 {
550                         if (previousSceneId == IDSCN_ALBUM_LIST)
551                         {
552                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
553                                 if (pAlbumInfo == null)
554                                 {
555                                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
556
557                                         return;
558                                 }
559
560                                 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
561                                 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
562
563                                 if (pDirectoryList != null)
564                                 {
565                                         delete pDirectoryList;
566                                 }
567                                 delete pArgs;
568
569                                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
570                                 __pContentIconListView->UpdateList();
571                         }
572                 }
573         }
574         else
575         {
576                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
577                 __pContentIconListView->RequestRedraw(true);
578         }
579
580         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
581 }
582
583 void
584 VideoListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId,
585                                                                 const SceneId& nextSceneId)
586 {
587         AppLogDebug("ENTER");
588         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
589 }
590
591 int
592 VideoListEditorPanel::GetItemCheckedCount(void) const
593 {
594         AppLogDebug("ENTER");
595         int count = 0;
596         if (__pContentIconListView != null)
597         {
598                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
599                 for (int i = 0; i < loopCount; ++i)
600                 {
601                         if (__pContentIconListView->IsItemChecked(i))
602                         {
603                                 ++count;
604                         }
605                 }
606         }
607         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
608
609         return count;
610 }
611
612 IList*
613 VideoListEditorPanel::GetItemCheckedIndexListN(void) const
614 {
615         AppLogDebug("ENTER");
616         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
617         Integer* pIndex = null;
618
619         if (__pContentIconListView != null)
620         {
621                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
622                 for (int i = 0; i < loopCount; ++i)
623                 {
624                         if (__pContentIconListView->IsItemChecked(i))
625                         {
626                                 pIndex = new (std::nothrow) Integer(i);
627                                 pList->Add(pIndex);
628                         }
629                 }
630         }
631         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
632
633         return pList;
634 }
635
636 void
637 VideoListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
638 {
639         SceneManager* pSceneManager = SceneManager::GetInstance();
640         FileListEditorForm* pFileListEditorForm =
641                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
642         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
643                         GetErrorMessage(GetLastResult()));
644         pFileListEditorForm->Invalidate(true);
645 }
646
647 void
648 VideoListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
649 {
650 }
651
652 void
653 VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void)
654 {
655         AppLogDebug("ENTER");
656         IList* pIndexList = GetItemCheckedIndexListN();
657
658         if (pIndexList->GetCount() <= 0)
659         {
660                 delete pIndexList;
661                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
662                 return;
663         }
664
665         HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
666         result r = map->Construct();
667
668         if (r == E_SUCCESS)
669         {
670                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
671                 r = pArrayList->Construct();
672
673                 if (r == E_SUCCESS)
674                 {
675                         Integer* temp = null;
676                         int loopCount = pIndexList->GetCount();
677
678                         for (int i = 0; i < loopCount; ++i)
679                         {
680                                 temp = static_cast<Integer*>(pIndexList->GetAt(i));
681                                 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(temp->ToInt())));
682                         }
683
684                         map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
685
686                         GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
687                         if (pApp != null)
688                         {
689                                 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
690                                 pApp->Terminate();
691                         }
692                         else
693                         {
694                                 delete map;
695                         }
696                 }
697                 else
698                 {
699                         delete map;
700                         delete pArrayList;
701                 }
702         }
703         else
704         {
705                 delete map;
706         }
707
708         delete pIndexList;
709         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
710 }
711
712 void
713 VideoListEditorPanel::SelectAllPressed(void)
714 {
715         bool needToSelectAll = true;
716         int checkedCount = GetItemCheckedCount();
717         int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
718         if (checkedCount == totalFileCount)
719         {
720                 needToSelectAll = false;
721         }
722
723         if (needToSelectAll == true)
724         {
725                 for (int i = 0 ; i < totalFileCount; ++i)
726                 {
727                         if (__pContentIconListView->IsItemChecked(i) == false)
728                         {
729                                 __pContentIconListView->SetItemChecked(i,true);
730                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
731                         }
732                 }
733         }
734         else
735         {
736                 for (int i = 0 ; i < totalFileCount; ++i)
737                 {
738                         if (__pContentIconListView->IsItemChecked(i) == true)
739                         {
740                                 __pContentIconListView->SetItemChecked(i, false);
741                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
742                         }
743                 }
744         }
745
746         String tempString;
747         if (needToSelectAll == true)
748         {
749                 tempString.Format(LENGTH_COUNT_LABEL,
750                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
751         }
752         else
753         {
754                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
755         }
756
757         __pLabelSelectCnt->SetText(tempString);
758         __pLabelSelectCnt->RequestRedraw(true);
759 }