2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
18 * @file GlVideoListEditorPanel.cpp
19 * @brief This is the implementation file for VideoListEditorPanel class.
24 #include "GlAlbumInfo.h"
25 #include "GlCommonUtil.h"
26 #include "GlFileListPresentationModel.h"
27 #include "GlGalleryApp.h"
28 #include "GlResourceManager.h"
30 #include "GlVideoListEditorPanel.h"
31 #include "GlFileListEditorForm.h"
32 #include "GlFileDeleteTimer.h"
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;
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);
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;
67 VideoListEditorPanel::VideoListEditorPanel()
68 : __pContentIconListView(null)
69 , __pCheckButton(null)
70 , __pLabelSelectCnt(null)
72 , __pPresentationModel(null)
76 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
79 VideoListEditorPanel::~VideoListEditorPanel()
83 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
87 VideoListEditorPanel::Initialize(void)
90 result r = Construct(RECT_INITIAL);
91 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
97 VideoListEditorPanel::OnInitializing(void)
100 const Form* pForm = dynamic_cast<Form*>(GetParent());
101 TryReturn(pForm != null, E_FAILURE, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
103 __pPresentationModel = FileListPresentationModel::GetInstance();
104 __pPresentationModel->ClearThumbnailRequests();
105 __pPresentationModel->AddPresentationModelListener(this);
108 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
109 clientAreaBounds.x = clientAreaBounds.y = 0;
110 SetBounds(clientAreaBounds);
112 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
114 __pContentIconListView = new (std::nothrow) ListView();
116 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
118 __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height), true, false);
119 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
120 if (pBitmapEmpty != null)
122 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
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);
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);
143 __pContentIconListView->Construct(Rectangle(0, 0, clientAreaBounds.width, clientAreaBounds.height), true, false);
144 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
145 if (pBitmapEmpty != null)
147 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
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);
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);
170 __pContentIconListView = new (std::nothrow) ListView();
171 __pContentIconListView->Construct(
172 Rectangle(0, H_SELECTALL_REGION, W_CLIENT_REGION, clientAreaBounds.height-H_SELECTALL_REGION),
174 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
175 if (pBitmapEmpty != null)
177 __pContentIconListView->SetBitmapOfEmptyList(pBitmapEmpty);
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);
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);
197 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
203 VideoListEditorPanel::OnTerminating(void)
205 AppLogDebug("ENTER");
206 __pPresentationModel->RemovePresentationModelListener(*this);
207 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
213 VideoListEditorPanel::UpdatePanelContent()
215 AppLogDebug("ENTER");
216 SceneManager* pSceneManager = SceneManager::GetInstance();
217 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
218 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
222 VideoListEditorPanel::OnActionPerformed(const Control& source, int actionId)
224 AppLogDebug("ENTER");
225 SceneManager* pSceneManager = SceneManager::GetInstance();
226 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
230 case ACTION_ID_SELECTALL_CHECKED:
232 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
233 for (int i = 0; i < loopCount; ++i)
235 if (__pContentIconListView->IsItemChecked(i) == false)
237 __pContentIconListView->SetItemChecked(i,true);
238 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
242 int checkedCount = GetItemCheckedCount();
244 if (checkedCount == 0)
246 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
248 else if (checkedCount == 1)
250 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
254 strTmp.Format(LENGTH_COUNT_LABEL,
255 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
258 __pLabelSelectCnt->SetText(strTmp);
259 __pLabelSelectCnt->RequestRedraw(true);
262 case ACTION_ID_SELECTALL_UNCHECKED:
264 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
265 for (int i = 0; i < loopCount; ++i)
267 if (__pContentIconListView->IsItemChecked(i) == true)
269 __pContentIconListView->SetItemChecked(i,false);
273 int checkedCount = GetItemCheckedCount();
275 if (checkedCount == 0)
277 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
279 else if (checkedCount == 1)
281 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
285 strTmp.Format(LENGTH_COUNT_LABEL,
286 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
289 __pLabelSelectCnt->SetText(strTmp);
290 __pLabelSelectCnt->RequestRedraw(true);
291 __pContentIconListView->UpdateList();
299 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
303 VideoListEditorPanel::GetItemCount(void)
305 AppLogDebug("ENTER");
306 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
312 VideoListEditorPanel::CreateItem(int index, int itemWidth)
314 AppLogDebug("ENTER : index(%d)", index);
315 CustomItem* pItem = new (std::nothrow) CustomItem();
317 Bitmap* pBitmap = null;
318 String* pItemText = null;
319 String* pTitle = null;
320 String* pDuration = null;
322 result r = __pPresentationModel->GetThumbnailVideoInSyncCacheN(index, pItemText, pBitmap, pDuration);
323 if (pBitmap == null || r == E_FAILURE)
325 __pPresentationModel->RequestThumbnail(index);
326 pBitmap = CommonUtil::GetEmptyThumbnailN();
329 if (pItemText == null)
331 pItemText = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
334 pTitle = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
336 if (pDuration == null)
338 pDuration = new (std::nothrow) String(ResourceManager::GetString(L"EMPTY_SPACE"));
341 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
343 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
345 pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_MARK);
347 if (__pContentIconListView->IsItemChecked(index) == true)
351 BufferInfo bufferInfo;
352 pBitmap->Lock(bufferInfo, INFINITE);
355 Color dimColor(COLOR_THUMBNAIL_DIM);
356 dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
359 canvas.Construct(bufferInfo);
360 canvas.FillRectangle(dimColor, canvas.GetBounds());
362 Bitmap* pSelectedBitmap = new (std::nothrow) Bitmap();
363 pSelectedBitmap->Construct(canvas, canvas.GetBounds());
364 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap,
366 delete pSelectedBitmap;
370 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
377 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
382 pTitle = new (std::nothrow) String(SINGLE_SPACE);
384 else if (pTitle->IsEmpty() == true)
387 pTitle = new (std::nothrow) String(SINGLE_SPACE);
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);
394 Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
396 pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
397 Color::GetColor(COLOR_ID_GREY),null,null,false);
401 pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_NORMAL);
402 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
406 pTitle = new (std::nothrow) String(SINGLE_SPACE);
408 else if (pTitle->IsEmpty() == true)
411 pTitle = new (std::nothrow) String(SINGLE_SPACE);
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);
418 Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
420 pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
421 Color::GetColor(COLOR_ID_GREY),null,null,false);
426 pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_MARK);
427 if (__pContentIconListView->IsItemChecked(index) == true)
431 BufferInfo bufferInfo;
432 pBitmap->Lock(bufferInfo, INFINITE);
434 Color dimColor(COLOR_THUMBNAIL_DIM);
435 dimColor.SetAlpha(ALPHA_THUMBNAIL_DIM);
438 canvas.Construct(bufferInfo);
439 canvas.FillRectangle(dimColor, canvas.GetBounds());
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;
448 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
453 pItem->AddElement(RECT_VIDEO_THUMBNAIL, ACTION_ID_FORMAT_THUMBNAIL, *pBitmap);
458 pTitle = new (std::nothrow) String(SINGLE_SPACE);
460 else if (pTitle->IsEmpty() == true)
463 pTitle = new (std::nothrow) String(SINGLE_SPACE);
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);
470 Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth - W_VIDEO_DURATION,
472 pItem->AddElement(durationRect, ACTION_ID_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
473 Color::GetColor(COLOR_ID_GREY),null,null,false);
480 if (pItemText != null)
488 if (pDuration != null)
492 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
498 VideoListEditorPanel::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
500 AppLogDebug("ENTER");
502 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
508 VideoListEditorPanel::OnListViewItemStateChanged(ListView& listView, int index, int elementId,
509 ListItemStatus status)
511 AppLogDebug("ENTER");
513 if (status == LIST_ITEM_STATUS_CHECKED || status == LIST_ITEM_STATUS_UNCHECKED)
515 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
517 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
519 int checkedCount = GetItemCheckedCount();
521 if (checkedCount == 0)
523 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
525 else if (checkedCount == 1)
527 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
531 strTmp.Format(LENGTH_COUNT_LABEL,
532 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
535 __pLabelSelectCnt->SetText(strTmp);
536 __pLabelSelectCnt->RequestRedraw(true);
537 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
542 int checkedCount = GetItemCheckedCount();
544 if (checkedCount == 0)
546 strTmp = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
548 else if (checkedCount == 1)
550 strTmp = ResourceManager::GetString(L"IDS_VR_POP_1_ITEM_SELECTED");
554 strTmp.Format(LENGTH_COUNT_LABEL,
555 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), checkedCount);
558 __pLabelSelectCnt->SetText(strTmp);
559 __pLabelSelectCnt->RequestRedraw(true);
560 if (__pCheckButton->IsSelected())
562 __pCheckButton->SetSelected(false);
564 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
568 if ( __pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
569 && __pPresentationModel->GetAppControlSelectionMode() != APPCONTROL_SELECTION_MODE_MULTIPLE)
571 if (status == LIST_ITEM_STATUS_SELECTED)
573 HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
574 result r = map->Construct();
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);
584 GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
587 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
601 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
605 VideoListEditorPanel::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
607 AppLogDebug("ENTER");
608 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
612 VideoListEditorPanel::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId,
613 ListContextItemStatus status)
615 AppLogDebug("ENTER");
616 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
620 VideoListEditorPanel::OnFileInfoChanged(const ContentType contentType)
622 AppLogDebug("ENTER");
623 if (contentType == CONTENT_TYPE_VIDEO)
625 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
626 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
627 __pContentIconListView->UpdateList();
629 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
633 VideoListEditorPanel::OnThumbnailDecoded(const int index)
635 AppLogDebug("ENTER : index(%d)", index);
638 __pContentIconListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
640 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
644 VideoListEditorPanel::OnSceneActivatedN(const SceneId& previousSceneId,
645 const SceneId& currentSceneId, IList* pArgs)
647 AppLogDebug("ENTER");
648 __pPresentationModel = FileListPresentationModel::GetInstance();
650 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
652 if (currentSceneId == IDSCN_VIDEO_LIST_EDITOR)
654 if (previousSceneId == IDSCN_ALBUM_LIST)
656 AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(pArgs->GetAt(0));
657 if (pAlbumInfo == null)
659 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
664 IList* pDirectoryList = pAlbumInfo->GetDirectoryListN();
665 __pPresentationModel->SetCurrentAlbumInfo(pAlbumInfo->GetAlbumName(), *pDirectoryList);
667 if (pDirectoryList != null)
669 delete pDirectoryList;
673 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
674 __pContentIconListView->UpdateList();
680 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
681 __pContentIconListView->RequestRedraw(true);
684 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
688 VideoListEditorPanel::OnSceneDeactivated(const SceneId& currentSceneId,
689 const SceneId& nextSceneId)
691 AppLogDebug("ENTER");
692 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
696 VideoListEditorPanel::GetItemCheckedCount(void) const
698 AppLogDebug("ENTER");
700 if (__pContentIconListView != null)
702 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
703 for (int i = 0; i < loopCount; ++i)
705 if (__pContentIconListView->IsItemChecked(i))
711 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
717 VideoListEditorPanel::GetItemCheckedIndexList(void) const
719 AppLogDebug("ENTER");
720 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
721 Integer* pIndex = null;
723 if (__pContentIconListView != null)
725 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
726 for (int i = 0; i < loopCount; ++i)
728 if (__pContentIconListView->IsItemChecked(i))
730 pIndex = new (std::nothrow) Integer(i);
735 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
741 VideoListEditorPanel::OnRequestDelete(void)
743 AppLogDebug("ENTER");
744 IList* pIndexList = GetItemCheckedIndexList();
746 if (pIndexList == null || pIndexList->GetCount() <= 0 || __pPresentationModel == null)
749 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
753 delete __pFileDelete;
754 __pFileDelete = new FileDeleteTimer(pIndexList, __pPresentationModel, this);
755 result r = __pFileDelete->StartTimer();
759 delete __pFileDelete;
760 __pFileDelete = null;
764 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
767 void VideoListEditorPanel::OnFileOpInvalidate(enum FileActionMode actionId)
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);
777 void VideoListEditorPanel::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
779 if (actionId == FILE_DELETE_ACTION)
783 else if (actionId == FILE_MOVE_ACTION)
789 VideoListEditorPanel::OnRequestMessage(void)
791 AppLogDebug("ENTER");
792 IList* pIndexList = GetItemCheckedIndexList();
793 if (pIndexList->GetCount() <= 0)
795 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
799 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
800 pArrayList->Construct();
801 int loopCount = pIndexList->GetCount();
803 for (int i = 0; i < loopCount; ++i)
805 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
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);
813 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE, null,
815 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
819 VideoListEditorPanel::OnRequestEmail(void)
821 AppLogDebug("ENTER");
822 IList* pIndexList = GetItemCheckedIndexList();
823 if (pIndexList->GetCount() <= 0)
825 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
829 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
830 pArrayList->Construct();
831 int loopCount = pIndexList->GetCount();
833 for (int i = 0; i < loopCount; ++i)
835 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
838 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
839 pDataList->Construct();
840 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
842 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE, null,
844 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
848 VideoListEditorPanel::OnRequestMoveTo(String& destDirectory)
850 AppLogDebug("ENTER");
851 if (&destDirectory == null || destDirectory.IsEmpty())
853 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
858 IList* pIndexList = GetItemCheckedIndexList();
859 if (pIndexList == null || pIndexList->GetCount() <= 0)
861 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
866 result r = __pPresentationModel->MoveToContentFileList(*pIndexList, destDirectory);
868 TryReturn(r == E_SUCCESS, , "Failed on OnRequestDeleteAction");
870 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_ALL);
871 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
872 __pContentIconListView->UpdateList();
873 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
877 VideoListEditorPanel::OnRequestAppExitWithMultipleSelectionAppControlResult(void)
879 AppLogDebug("ENTER");
880 IList* pIndexList = GetItemCheckedIndexList();
882 if (pIndexList->GetCount() <= 0)
884 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
889 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
890 pArrayList->Construct();
891 int loopCount = pIndexList->GetCount();
893 for (int i = 0; i < loopCount; ++i)
895 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
898 HashMap* map = new (std::nothrow) HashMap(SingleObjectDeleter);
900 map->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
902 GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
905 pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, map);
912 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
916 VideoListEditorPanel::SelectAllPressed(void)
918 bool needToSelectAll = true;
919 int checkedCount = GetItemCheckedCount();
920 int totalFileCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
921 if (checkedCount == totalFileCount)
923 needToSelectAll = false;
926 if (needToSelectAll == true)
928 for (int i = 0 ; i < totalFileCount; ++i)
930 if (__pContentIconListView->IsItemChecked(i) == false)
932 __pContentIconListView->SetItemChecked(i,true);
933 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
939 for (int i = 0 ; i < totalFileCount; ++i)
941 if (__pContentIconListView->IsItemChecked(i) == true)
943 __pContentIconListView->SetItemChecked(i, false);
944 __pContentIconListView->RefreshList(i, LIST_REFRESH_TYPE_ITEM_MODIFY);
950 if (needToSelectAll == true)
952 tempString.Format(LENGTH_COUNT_LABEL,
953 ResourceManager::GetString(L"IDS_VR_POP_PD_ITEMS_SELECTED").GetPointer(), totalFileCount);
957 tempString = ResourceManager::GetString(L"IDS_ST_POP_NO_ITEMS_SELECTED");
960 __pLabelSelectCnt->SetText(tempString);
961 __pLabelSelectCnt->RequestRedraw(true);