287e426f6c5d2d524d9b5d0520a92f9d6d8f221f
[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
262                                         return null;
263                                 }
264                         }
265                         else
266                         {
267                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
268                         }
269
270                         if (pTitle == null)
271                         {
272                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
273                         }
274                         else if (pTitle->IsEmpty() == true)
275                         {
276                                 delete pTitle;
277                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
278                         }
279
280                         Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
281                         pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
282                                         Color::GetColor(COLOR_ID_BLACK),null,null,false);
283
284                         Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
285                                         H_VIDEO_DURATION);
286                         pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
287                                         Color::GetColor(COLOR_ID_GREY),null,null,false);
288                 }
289                 else
290                 {
291                         pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_NORMAL);
292                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
293
294                         if (pTitle == null)
295                         {
296                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
297                         }
298                         else if (pTitle->IsEmpty() == true)
299                         {
300                                 delete pTitle;
301                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
302                         }
303
304                         Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
305                         pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
306                                         Color::GetColor(COLOR_ID_BLACK),null,null,false);
307
308                         Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
309                                         H_VIDEO_DURATION);
310                         pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
311                                         Color::GetColor(COLOR_ID_GREY),null,null,false);
312                 }
313         }
314         else
315         {
316                 pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_MARK);
317                 if (__pContentIconListView->IsItemChecked(index) == true)
318                 {
319                         if (pBitmap != null)
320                         {
321                                 BufferInfo bufferInfo;
322                                 pBitmap->Lock(bufferInfo, INFINITE);
323                                 pBitmap->Unlock();
324                                 Color dimColor(COLOR_THUMBNAIL_DIM);
325                                 dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
326
327                                 Canvas canvas;
328                                 canvas.Construct(bufferInfo);
329                                 canvas.FillRectangle(dimColor, canvas.GetBounds());
330
331                                 Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
332                                 pSelectedBitmap->Construct(canvas, canvas.GetBounds());
333                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap, pSelectedBitmap);
334                                 delete pSelectedBitmap;
335                         }
336                         else
337                         {
338                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
339                         }
340                 }
341                 else
342                 {
343                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
344                 }
345
346                 if (pTitle == null)
347                 {
348                         pTitle = new (std::nothrow) String(SINGLE_SPACE);
349                 }
350                 else if (pTitle->IsEmpty() == true)
351                 {
352                         delete pTitle;
353                         pTitle = new (std::nothrow) String(SINGLE_SPACE);
354                 }
355
356                 Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
357                 pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
358                                 Color::GetColor(COLOR_ID_BLACK),null,null,false);
359
360                 Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth - W_VIDEO_DURATION,
361                                 H_VIDEO_DURATION);
362                 pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
363                                 Color::GetColor(COLOR_ID_GREY),null,null,false);
364         }
365
366         if (pBitmap != null)
367         {
368                 delete pBitmap;
369         }
370         if (pItemText != null)
371         {
372                 delete pItemText;
373         }
374         if (pTitle != null)
375         {
376                 delete pTitle;
377         }
378         if (pDuration != null)
379         {
380                 delete pDuration;
381         }
382         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
383
384         return pItem;
385 }
386
387 bool
388 VideoListEditorPanel::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
389 {
390         AppLogDebug("ENTER");
391         delete pItem;
392         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
393
394         return true;
395 }
396
397 void
398 VideoListEditorPanel::OnListViewItemStateChanged(ListView& listView, int index, int elementId,
399                 ListItemStatus status)
400 {
401         AppLogDebug("ENTER");
402
403         if (status == LIST_ITEM_STATUS_CHECKED || status == LIST_ITEM_STATUS_UNCHECKED)
404         {
405                 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
406                 {
407                         if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
408                         {
409                                 int checkedCount = GetItemCheckedCount();
410                                 String strTmp;
411                                 if (checkedCount == 0)
412                                 {
413                                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
414                                 }
415                                 else if (checkedCount == 1)
416                                 {
417                                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
418                                 }
419                                 else
420                                 {
421                                         strTmp.Format(LENGTH_COUNT_LABEL,
422                                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
423                                 }
424
425                                 __pLabelSelectCnt->SetText(strTmp);
426                                 __pLabelSelectCnt->RequestRedraw(true);
427                                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
428                         }
429                 }
430                 else
431                 {
432                         int checkedCount = GetItemCheckedCount();
433                         String strTmp;
434                         if (checkedCount == 0)
435                         {
436                                 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
437                         }
438                         else if (checkedCount == 1)
439                         {
440                                 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
441                         }
442                         else
443                         {
444                                 strTmp.Format(LENGTH_COUNT_LABEL,
445                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
446                         }
447
448                         __pLabelSelectCnt->SetText(strTmp);
449                         __pLabelSelectCnt->RequestRedraw(true);
450                         if (__pCheckButton->IsSelected())
451                         {
452                                 __pCheckButton->SetSelected(false);
453                         }
454                         __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
455                 }
456         }
457
458         if (    __pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
459                 && __pPresentationModel->GetAppControlSelectionMode() != APPCONTROL_SELECTION_MODE_MULTIPLE)
460         {
461                 if (status == LIST_ITEM_STATUS_SELECTED)
462                 {
463                         HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
464                         result r = map->Construct();
465                         if (r == E_SUCCESS)
466                         {
467                                 map->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH),
468                                                 new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
469                                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
470                                 pArrayList->Construct();
471
472                                 if (r == E_SUCCESS)
473                                 {
474                                         pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
475                                         map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
476
477                                         GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
478                                         if (pApp != null)
479                                         {
480                                                 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
481                                                 pApp->Terminate();
482                                         }
483                                         else
484                                         {
485                                                 delete map;
486                                         }
487                                 }
488                         }
489                         else
490                         {
491                                 delete map;
492                         }
493                 }
494         }
495         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
496 }
497
498 void
499 VideoListEditorPanel::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
500 {
501         AppLogDebug("ENTER");
502         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
503 }
504
505 void
506 VideoListEditorPanel::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId,
507                 ListContextItemStatus status)
508 {
509         AppLogDebug("ENTER");
510         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
511 }
512
513 void
514 VideoListEditorPanel::OnFileInfoChanged(const ContentType contentType)
515 {
516         AppLogDebug("ENTER");
517         if (contentType == CONTENT_TYPE_VIDEO)
518         {
519                 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
520                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
521                 __pContentIconListView->UpdateList();
522         }
523         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
524 }
525
526 void
527 VideoListEditorPanel::OnThumbnailDecoded(const int index)
528 {
529         AppLogDebug("ENTER : index(%d)", index);
530         if (index >= 0)
531         {
532                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
533         }
534         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
535 }
536
537 void
538 VideoListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
539                                                                 const SceneId& currentSceneId, IList* pArgs)
540 {
541         AppLogDebug("ENTER");
542         __pPresentationModel = FileListPresentationModel::GetInstance();
543
544         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
545         {
546                 if (currentSceneId == IDSCN_VIDEO_LIST_EDITOR)
547                 {
548                         if (previousSceneId == IDSCN_ALBUM_LIST)
549                         {
550                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
551                                 if (pAlbumInfo == null)
552                                 {
553                                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
554
555                                         return;
556                                 }
557
558                                 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
559                                 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
560
561                                 if (pDirectoryList != null)
562                                 {
563                                         delete pDirectoryList;
564                                 }
565                                 delete pArgs;
566
567                                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
568                                 __pContentIconListView->UpdateList();
569                         }
570                 }
571         }
572         else
573         {
574                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
575                 __pContentIconListView->RequestRedraw(true);
576         }
577
578         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
579 }
580
581 void
582 VideoListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId,
583                                                                 const SceneId& nextSceneId)
584 {
585         AppLogDebug("ENTER");
586         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
587 }
588
589 int
590 VideoListEditorPanel::GetItemCheckedCount(void) const
591 {
592         AppLogDebug("ENTER");
593         int count = 0;
594         if (__pContentIconListView != null)
595         {
596                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
597                 for (int i = 0; i < loopCount; ++i)
598                 {
599                         if (__pContentIconListView->IsItemChecked(i))
600                         {
601                                 ++count;
602                         }
603                 }
604         }
605         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
606
607         return count;
608 }
609
610 IList*
611 VideoListEditorPanel::GetItemCheckedIndexListN(void) const
612 {
613         AppLogDebug("ENTER");
614         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
615         Integer* pIndex = null;
616
617         if (__pContentIconListView != null)
618         {
619                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
620                 for (int i = 0; i < loopCount; ++i)
621                 {
622                         if (__pContentIconListView->IsItemChecked(i))
623                         {
624                                 pIndex = new (std::nothrow) Integer(i);
625                                 pList->Add(pIndex);
626                         }
627                 }
628         }
629         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
630
631         return pList;
632 }
633
634 void
635 VideoListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
636 {
637         SceneManager* pSceneManager = SceneManager::GetInstance();
638         FileListEditorForm* pFileListEditorForm =
639                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
640         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
641                         GetErrorMessage(GetLastResult()));
642         pFileListEditorForm->Invalidate(true);
643 }
644
645 void
646 VideoListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
647 {
648 }
649
650 void
651 VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void)
652 {
653         AppLogDebug("ENTER");
654         IList* pIndexList = GetItemCheckedIndexListN();
655
656         if (pIndexList->GetCount() <= 0)
657         {
658                 delete pIndexList;
659                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
660                 return;
661         }
662
663         HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
664         result r = map->Construct();
665
666         if (r == E_SUCCESS)
667         {
668                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
669                 r = pArrayList->Construct();
670
671                 if (r == E_SUCCESS)
672                 {
673                         Integer* temp = null;
674                         int loopCount = pIndexList->GetCount();
675
676                         for (int i = 0; i < loopCount; ++i)
677                         {
678                                 temp = static_cast<Integer*>(pIndexList->GetAt(i));
679                                 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(temp->ToInt())));
680                         }
681
682                         map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
683
684                         GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
685                         if (pApp != null)
686                         {
687                                 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
688                                 pApp->Terminate();
689                         }
690                         else
691                         {
692                                 delete map;
693                         }
694                 }
695                 else
696                 {
697                         delete map;
698                         delete pArrayList;
699                 }
700         }
701         else
702         {
703                 delete map;
704         }
705
706         delete pIndexList;
707         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
708 }
709
710 void
711 VideoListEditorPanel::SelectAllPressed(void)
712 {
713         bool needToSelectAll = true;
714         int checkedCount = GetItemCheckedCount();
715         int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
716         if (checkedCount == totalFileCount)
717         {
718                 needToSelectAll = false;
719         }
720
721         if (needToSelectAll == true)
722         {
723                 for (int i = 0 ; i < totalFileCount; ++i)
724                 {
725                         if (__pContentIconListView->IsItemChecked(i) == false)
726                         {
727                                 __pContentIconListView->SetItemChecked(i,true);
728                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
729                         }
730                 }
731         }
732         else
733         {
734                 for (int i = 0 ; i < totalFileCount; ++i)
735                 {
736                         if (__pContentIconListView->IsItemChecked(i) == true)
737                         {
738                                 __pContentIconListView->SetItemChecked(i, false);
739                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
740                         }
741                 }
742         }
743
744         String tempString;
745         if (needToSelectAll == true)
746         {
747                 tempString.Format(LENGTH_COUNT_LABEL,
748                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
749         }
750         else
751         {
752                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
753         }
754
755         __pLabelSelectCnt->SetText(tempString);
756         __pLabelSelectCnt->RequestRedraw(true);
757 }