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