f3fd6daf9974fbb98a7797d961f4d140f7195dfa
[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 "GlFileDeleteTimer.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_SELECTALL_REGION = Color32<0x2A, 0x36, 0x4A>::Value;
44 static const unsigned int COLOR_COUNT_LABEL = Color32<68, 68, 68>::Value;
45 static const unsigned int COLOR_SELECT_COUNT_FONT = Color32<255, 255, 255>::Value;
46 static const Color COLOR_THUMBNAIL_DIM (Color::GetColor(COLOR_ID_BLACK));
47 static const Rectangle RECT_VIDEO_THUMBNAIL(16, 16, 172, 128);
48 static const Rectangle RECT_INITIAL(0, 0, 10, 10);
49
50 static const int H_SELECTALL_REGION = 112;
51 static const int ALPHA_THUMBNAIL_DIM = 70;
52 static const int H_COUNT_LABEL = 48;
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                         __pLabelSelectCnt = new (std::nothrow) Label();
132                         __pLabelSelectCnt->Construct(
133                                         Rectangle(0, clientAreaBounds.height - H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL),
134                                         ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
135                         __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
136                         __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
137                         __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
138                         __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
139                         AddControl(*__pLabelSelectCnt);
140                 }
141                 else
142                 {
143                         __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height), true, false);
144                         Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
145                         if (pBitmapEmpty != null)
146                         {
147                                 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
148                                 delete pBitmapEmpty;
149                         }
150                         __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
151                         __pContentIconListView->SetItemProvider(*this);
152                         __pContentIconListView->AddListViewItemEventListener(*this);
153                         AddControl(*__pContentIconListView);
154                         __pContentIconListView->SetShowState(true);
155                 }
156         }
157         else
158         {
159                 Panel* pCheckPanel = new (std::nothrow) Panel();
160                 pCheckPanel->Construct(Rectangle(0, 0, clientAreaBounds.width, H_SELECTALL_REGION));
161                 pCheckPanel->SetBackgroundColor(COLOR_SELECTALL_REGION);
162                 __pCheckButton = new (std::nothrow) CheckButton();
163                 __pCheckButton->Construct(pCheckPanel->GetBounds(), CHECK_BUTTON_STYLE_MARK, BACKGROUND_STYLE_DEFAULT,
164                                 false, ResourceManager::GetString(L"IDS_COM_BODY_SELECT_ALL"));
165                 __pCheckButton->SetActionId(ACTION_ID_SELECTALL_CHECKED, ACTION_ID_SELECTALL_UNCHECKED);
166                 __pCheckButton->AddActionEventListener(*this);
167                 pCheckPanel->AddControl(*__pCheckButton);
168                 AddControl(*pCheckPanel);
169
170                 __pContentIconListView = new (std::nothrow) ListView();
171                 __pContentIconListView->Construct(
172                                 Rectangle(0, H_SELECTALL_REGION, W_CLIENT_REGION, clientAreaBounds.height-H_SELECTALL_REGION),
173                                 true, false);
174                 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
175                 if (pBitmapEmpty != null)
176                 {
177                         __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
178                         delete pBitmapEmpty;
179                 }
180                 __pContentIconListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
181                 __pContentIconListView->SetItemProvider(*this);
182                 __pContentIconListView->AddListViewItemEventListener(*this);
183                 AddControl(*__pContentIconListView);
184                 __pContentIconListView->SetShowState(true);
185
186                 __pLabelSelectCnt = new (std::nothrow) Label();
187                 __pLabelSelectCnt->Construct(
188                                 Rectangle(0, clientAreaBounds.height-H_COUNT_LABEL, clientAreaBounds.width, H_COUNT_LABEL),
189                                 ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED"));
190                 __pLabelSelectCnt->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
191                 __pLabelSelectCnt->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
192                 __pLabelSelectCnt->SetBackgroundColor(COLOR_COUNT_LABEL);
193                 __pLabelSelectCnt->SetTextColor(Color(COLOR_SELECT_COUNT_FONT));
194                 AddControl(*__pLabelSelectCnt);
195
196         }
197         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
198
199         return E_SUCCESS;
200 }
201
202 result
203 VideoListEditorPanel::OnTerminating(void)
204 {
205         AppLogDebug("ENTER");
206         __pPresentationModel->RemovePresentationModelListener(*this);
207         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
208
209         return E_SUCCESS;
210 }
211
212 void
213 VideoListEditorPanel::UpdatePanelContent()
214 {
215         AppLogDebug("ENTER");
216         SceneManager* pSceneManager = SceneManager::GetInstance();
217         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
218         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
219 }
220
221 void
222 VideoListEditorPanel::OnActionPerformed(const Control& source, int actionId)
223 {
224         AppLogDebug("ENTER");
225         SceneManager* pSceneManager = SceneManager::GetInstance();
226         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
227
228         switch (actionId)
229         {
230         case ACTION_ID_SELECTALL_CHECKED:
231         {
232                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
233                 for (int i = 0; i < loopCount; ++i)
234                 {
235                         if (__pContentIconListView->IsItemChecked(i) == false)
236                         {
237                                 __pContentIconListView->SetItemChecked(i,true);
238                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
239                         }
240                 }
241
242                 int checkedCount = GetItemCheckedCount();
243                 String strTmp;
244                 if (checkedCount == 0)
245                 {
246                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
247                 }
248                 else if (checkedCount == 1)
249                 {
250                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
251                 }
252                 else
253                 {
254                         strTmp.Format(LENGTH_COUNT_LABEL,
255                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
256                 }
257
258                 __pLabelSelectCnt->SetText(strTmp);
259                 __pLabelSelectCnt->RequestRedraw(true);
260                 break;
261         }
262         case ACTION_ID_SELECTALL_UNCHECKED:
263         {
264                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
265                 for (int i = 0; i < loopCount; ++i)
266                 {
267                         if (__pContentIconListView->IsItemChecked(i) == true)
268                         {
269                                 __pContentIconListView->SetItemChecked(i,false);
270                         }
271                 }
272
273                 int checkedCount = GetItemCheckedCount();
274                 String strTmp;
275                 if (checkedCount == 0)
276                 {
277                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
278                 }
279                 else if (checkedCount == 1)
280                 {
281                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
282                 }
283                 else
284                 {
285                         strTmp.Format(LENGTH_COUNT_LABEL,
286                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
287                 }
288
289                 __pLabelSelectCnt->SetText(strTmp);
290                 __pLabelSelectCnt->RequestRedraw(true);
291                 __pContentIconListView->UpdateList();
292                 break;
293         }
294         default:
295         {
296                 break;
297         }
298         }
299         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
300 }
301
302 int
303 VideoListEditorPanel::GetItemCount(void)
304 {
305         AppLogDebug("ENTER");
306         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
307
308         return __itemCount;
309 }
310
311 ListItemBase*
312 VideoListEditorPanel::CreateItem(int index, int itemWidth)
313 {
314         AppLogDebug("ENTER : index(%d)", index);
315         CustomItem* pItem = new (std::nothrow) CustomItem();
316
317         Bitmap* pBitmap = null;
318         String* pItemText = null;
319         String* pTitle = null;
320         String* pDuration = null;
321
322         result r = __pPresentationModel->GetThumbnailVideoInSyncCacheN(index, pItemText, pBitmap, pDuration);
323         if (pBitmap == null || r == E_FAILURE)
324         {
325                 __pPresentationModel->RequestThumbnail(index);
326                 pBitmap = CommonUtil::GetEmptyThumbnailN();
327         }
328
329         if (pItemText == null)
330         {
331                 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
332         }
333
334         pTitle = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
335
336         if (pDuration == null)
337         {
338                 pDuration = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
339         }
340
341         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
342         {
343                 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
344                 {
345                         pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_MARK);
346
347                         if (__pContentIconListView->IsItemChecked(index) == true)
348                         {
349                                 if (pBitmap != null)
350                                 {
351                                         BufferInfo bufferInfo;
352                                         pBitmap->Lock(bufferInfo, INFINITE);
353                                         pBitmap->Unlock();
354
355                                         Color dimColor(COLOR_THUMBNAIL_DIM);
356                                         dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
357
358                                         Canvas canvas;
359                                         canvas.Construct(bufferInfo);
360                                         canvas.FillRectangle(dimColor, canvas.GetBounds());
361
362                                         Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
363                                         pSelectedBitmap->Construct(canvas, canvas.GetBounds());
364                                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap,
365                                                         pSelectedBitmap);
366                                         delete pSelectedBitmap;
367                                 }
368                                 else
369                                 {
370                                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
371
372                                         return null;
373                                 }
374                         }
375                         else
376                         {
377                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
378                         }
379
380                         if (pTitle == null)
381                         {
382                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
383                         }
384                         else if (pTitle->IsEmpty() == true)
385                         {
386                                 delete pTitle;
387                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
388                         }
389
390                         Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
391                         pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
392                                         Color::GetColor(COLOR_ID_BLACK),null,null,false);
393
394                         Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
395                                         H_VIDEO_DURATION);
396                         pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
397                                         Color::GetColor(COLOR_ID_GREY),null,null,false);
398                 }
399                 else
400                 {
401                         pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_NORMAL);
402                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
403
404                         if (pTitle == null)
405                         {
406                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
407                         }
408                         else if (pTitle->IsEmpty() == true)
409                         {
410                                 delete pTitle;
411                                 pTitle = new (std::nothrow) String(SINGLE_SPACE);
412                         }
413
414                         Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
415                         pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
416                                         Color::GetColor(COLOR_ID_BLACK),null,null,false);
417
418                         Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
419                                         H_VIDEO_DURATION);
420                         pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
421                                         Color::GetColor(COLOR_ID_GREY),null,null,false);
422                 }
423         }
424         else
425         {
426                 pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_MARK);
427                 if (__pContentIconListView->IsItemChecked(index) == true)
428                 {
429                         if (pBitmap != null)
430                         {
431                                 BufferInfo bufferInfo;
432                                 pBitmap->Lock(bufferInfo, INFINITE);
433                                 pBitmap->Unlock();
434                                 Color dimColor(COLOR_THUMBNAIL_DIM);
435                                 dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
436
437                                 Canvas canvas;
438                                 canvas.Construct(bufferInfo);
439                                 canvas.FillRectangle(dimColor, canvas.GetBounds());
440
441                                 Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
442                                 pSelectedBitmap->Construct(canvas, canvas.GetBounds());
443                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap, pSelectedBitmap);
444                                 delete pSelectedBitmap;
445                         }
446                         else
447                         {
448                                 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
449                         }
450                 }
451                 else
452                 {
453                         pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
454                 }
455
456                 if (pTitle == null)
457                 {
458                         pTitle = new (std::nothrow) String(SINGLE_SPACE);
459                 }
460                 else if (pTitle->IsEmpty() == true)
461                 {
462                         delete pTitle;
463                         pTitle = new (std::nothrow) String(SINGLE_SPACE);
464                 }
465
466                 Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
467                 pItem->AddElement(titleRect, ACTION_ID_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
468                                 Color::GetColor(COLOR_ID_BLACK),null,null,false);
469
470                 Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth - W_VIDEO_DURATION,
471                                 H_VIDEO_DURATION);
472                 pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
473                                 Color::GetColor(COLOR_ID_GREY),null,null,false);
474         }
475
476         if (pBitmap != null)
477         {
478                 delete pBitmap;
479         }
480         if (pItemText != null)
481         {
482                 delete pItemText;
483         }
484         if (pTitle != null)
485         {
486                 delete pTitle;
487         }
488         if (pDuration != null)
489         {
490                 delete pDuration;
491         }
492         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
493
494         return pItem;
495 }
496
497 bool
498 VideoListEditorPanel::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
499 {
500         AppLogDebug("ENTER");
501         delete pItem;
502         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
503
504         return true;
505 }
506
507 void
508 VideoListEditorPanel::OnListViewItemStateChanged(ListView& listView, int index, int elementId,
509                 ListItemStatus status)
510 {
511         AppLogDebug("ENTER");
512
513         if (status == LIST_ITEM_STATUS_CHECKED || status == LIST_ITEM_STATUS_UNCHECKED)
514         {
515                 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
516                 {
517                         if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
518                         {
519                                 int checkedCount = GetItemCheckedCount();
520                                 String strTmp;
521                                 if (checkedCount == 0)
522                                 {
523                                         strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
524                                 }
525                                 else if (checkedCount == 1)
526                                 {
527                                         strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
528                                 }
529                                 else
530                                 {
531                                         strTmp.Format(LENGTH_COUNT_LABEL,
532                                                         ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
533                                 }
534
535                                 __pLabelSelectCnt->SetText(strTmp);
536                                 __pLabelSelectCnt->RequestRedraw(true);
537                                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
538                         }
539                 }
540                 else
541                 {
542                         int checkedCount = GetItemCheckedCount();
543                         String strTmp;
544                         if (checkedCount == 0)
545                         {
546                                 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
547                         }
548                         else if (checkedCount == 1)
549                         {
550                                 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
551                         }
552                         else
553                         {
554                                 strTmp.Format(LENGTH_COUNT_LABEL,
555                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
556                         }
557
558                         __pLabelSelectCnt->SetText(strTmp);
559                         __pLabelSelectCnt->RequestRedraw(true);
560                         if (__pCheckButton->IsSelected())
561                         {
562                                 __pCheckButton->SetSelected(false);
563                         }
564                         __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
565                 }
566         }
567
568         if (    __pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
569                 && __pPresentationModel->GetAppControlSelectionMode() != APPCONTROL_SELECTION_MODE_MULTIPLE)
570         {
571                 if (status == LIST_ITEM_STATUS_SELECTED)
572                 {
573                         HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
574                         result r = map->Construct();
575                         if (r == E_SUCCESS)
576                         {
577                                 map->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH),
578                                                 new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
579                                 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
580                                 pArrayList->Construct();
581                                 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
582                                 map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
583
584                                 GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
585                                 if (pApp != null)
586                                 {
587                                         pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
588                                         pApp->Terminate();
589                                 }
590                                 else
591                                 {
592                                         delete map;
593                                 }
594                         }
595                         else
596                         {
597                                 delete map;
598                         }
599                 }
600         }
601         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
602 }
603
604 void
605 VideoListEditorPanel::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
606 {
607         AppLogDebug("ENTER");
608         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
609 }
610
611 void
612 VideoListEditorPanel::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId,
613                 ListContextItemStatus status)
614 {
615         AppLogDebug("ENTER");
616         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
617 }
618
619 void
620 VideoListEditorPanel::OnFileInfoChanged(const ContentType contentType)
621 {
622         AppLogDebug("ENTER");
623         if (contentType == CONTENT_TYPE_VIDEO)
624         {
625                 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
626                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
627                 __pContentIconListView->UpdateList();
628         }
629         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
630 }
631
632 void
633 VideoListEditorPanel::OnThumbnailDecoded(const int index)
634 {
635         AppLogDebug("ENTER : index(%d)", index);
636         if (index >= 0)
637         {
638                 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
639         }
640         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
641 }
642
643 void
644 VideoListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
645                                                                 const SceneId& currentSceneId, IList* pArgs)
646 {
647         AppLogDebug("ENTER");
648         __pPresentationModel = FileListPresentationModel::GetInstance();
649
650         if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
651         {
652                 if (currentSceneId == IDSCN_VIDEO_LIST_EDITOR)
653                 {
654                         if (previousSceneId == IDSCN_ALBUM_LIST)
655                         {
656                                 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
657                                 if (pAlbumInfo == null)
658                                 {
659                                         AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
660
661                                         return;
662                                 }
663
664                                 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
665                                 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
666
667                                 if (pDirectoryList != null)
668                                 {
669                                         delete pDirectoryList;
670                                 }
671                                 delete pArgs;
672
673                                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
674                                 __pContentIconListView->UpdateList();
675                         }
676                 }
677         }
678         else
679         {
680                 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
681                 __pContentIconListView->RequestRedraw(true);
682         }
683
684         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
685 }
686
687 void
688 VideoListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId,
689                                                                 const SceneId& nextSceneId)
690 {
691         AppLogDebug("ENTER");
692         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
693 }
694
695 int
696 VideoListEditorPanel::GetItemCheckedCount(void) const
697 {
698         AppLogDebug("ENTER");
699         int count = 0;
700         if (__pContentIconListView != null)
701         {
702                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
703                 for (int i = 0; i < loopCount; ++i)
704                 {
705                         if (__pContentIconListView->IsItemChecked(i))
706                         {
707                                 ++count;
708                         }
709                 }
710         }
711         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
712
713         return count;
714 }
715
716 IList*
717 VideoListEditorPanel::GetItemCheckedIndexList(void) const
718 {
719         AppLogDebug("ENTER");
720         IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
721         Integer* pIndex = null;
722
723         if (__pContentIconListView != null)
724         {
725                 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
726                 for (int i = 0; i < loopCount; ++i)
727                 {
728                         if (__pContentIconListView->IsItemChecked(i))
729                         {
730                                 pIndex = new (std::nothrow) Integer(i);
731                                 pList->Add(pIndex);
732                         }
733                 }
734         }
735         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
736
737         return pList;
738 }
739
740 void
741 VideoListEditorPanel::OnRequestDelete(void)
742 {
743         AppLogDebug("ENTER");
744         IList* pIndexList = GetItemCheckedIndexList();
745
746         if (pIndexList == null || pIndexList->GetCount() <= 0 || __pPresentationModel == null)
747         {
748                 delete pIndexList;
749                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
750
751                 return;
752         }
753         delete __pFileDelete;
754         __pFileDelete = new FileDeleteTimer(pIndexList, __pPresentationModel, this);
755         result r = __pFileDelete->StartTimer();
756
757         if (IsFailed(r))
758         {
759                 delete __pFileDelete;
760                 __pFileDelete = null;
761                 return ;
762         }
763
764         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
765 }
766
767 void VideoListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
768 {
769         SceneManager* pSceneManager = SceneManager::GetInstance();
770         FileListEditorForm* pFileListEditorForm =
771                                 dynamic_cast<FileListEditorForm*>(pSceneManager->GetCurrentScene()->GetForm());
772         TryReturnVoid(pFileListEditorForm != null, "[%s] fail to get SceneManager.",
773                         GetErrorMessage(GetLastResult()));
774         pFileListEditorForm->Invalidate(true);
775 }
776
777 void VideoListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
778 {
779         if (actionId == FILE_DELETE_ACTION)
780         {
781                 //Do nothing
782         }
783         else if (actionId == FILE_MOVE_ACTION)
784         {
785         }
786 }
787
788 void
789 VideoListEditorPanel::OnRequestMessage(void)
790 {
791         AppLogDebug("ENTER");
792         IList* pIndexList = GetItemCheckedIndexList();
793         if (pIndexList->GetCount() <= 0)
794         {
795                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
796                 return;
797         }
798
799         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
800         pArrayList->Construct();
801         int loopCount = pIndexList->GetCount();
802
803         for (int i = 0; i < loopCount; ++i)
804         {
805                 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
806         }
807
808         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
809         pDataList->Construct();
810         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
811         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
812
813         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE, null,
814                         pDataList, null);
815         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
816 }
817
818 void
819 VideoListEditorPanel::OnRequestEmail(void)
820 {
821         AppLogDebug("ENTER");
822         IList* pIndexList = GetItemCheckedIndexList();
823         if (pIndexList->GetCount() <= 0)
824         {
825                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
826                 return;
827         }
828
829         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
830         pArrayList->Construct();
831         int loopCount = pIndexList->GetCount();
832
833         for (int i = 0; i < loopCount; ++i)
834         {
835                 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
836         }
837
838         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
839         pDataList->Construct();
840         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
841
842         __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL,     APPCONTROL_OPERATION_ID_COMPOSE, null,
843                         pDataList, null);
844         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
845 }
846
847 void
848 VideoListEditorPanel::OnRequestMoveTo(String& destDirectory)
849 {
850         AppLogDebug("ENTER");
851         if (&destDirectory == null || destDirectory.IsEmpty())
852         {
853                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
854
855                 return;
856         }
857
858         IList* pIndexList = GetItemCheckedIndexList();
859         if (pIndexList == null || pIndexList->GetCount() <= 0)
860         {
861                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
862
863                 return;
864         }
865
866         result r = __pPresentationModel->MoveToContentFileList(*pIndexList, destDirectory);
867         delete pIndexList;
868         TryReturn(r == E_SUCCESS, , "Failed on OnRequestDeleteAction");
869
870         __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
871         __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
872         __pContentIconListView->UpdateList();
873         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
874 }
875
876 void
877 VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void)
878 {
879         AppLogDebug("ENTER");
880         IList* pIndexList = GetItemCheckedIndexList();
881
882         if (pIndexList->GetCount() <= 0)
883         {
884                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
885
886                 return;
887         }
888
889         ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
890         pArrayList->Construct();
891         int loopCount = pIndexList->GetCount();
892
893         for (int i = 0; i < loopCount; ++i)
894         {
895                 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
896         }
897
898         HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
899         map->Construct();
900         map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
901
902         GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
903         if (pApp != null)
904         {
905                 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
906                 pApp->Terminate();
907         }
908         else
909         {
910                 delete map;
911         }
912         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
913 }
914
915 void
916 VideoListEditorPanel::SelectAllPressed(void)
917 {
918         bool needToSelectAll = true;
919         int checkedCount = GetItemCheckedCount();
920         int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
921         if (checkedCount == totalFileCount)
922         {
923                 needToSelectAll = false;
924         }
925
926         if (needToSelectAll == true)
927         {
928                 for (int i = 0 ; i < totalFileCount; ++i)
929                 {
930                         if (__pContentIconListView->IsItemChecked(i) == false)
931                         {
932                                 __pContentIconListView->SetItemChecked(i,true);
933                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
934                         }
935                 }
936         }
937         else
938         {
939                 for (int i = 0 ; i < totalFileCount; ++i)
940                 {
941                         if (__pContentIconListView->IsItemChecked(i) == true)
942                         {
943                                 __pContentIconListView->SetItemChecked(i, false);
944                                 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
945                         }
946                 }
947         }
948
949         String tempString;
950         if (needToSelectAll == true)
951         {
952                 tempString.Format(LENGTH_COUNT_LABEL,
953                                                 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
954         }
955         else
956         {
957                 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
958         }
959
960         __pLabelSelectCnt->SetText(tempString);
961         __pLabelSelectCnt->RequestRedraw(true);
962 }