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