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 GlFileListEditorForm.cpp
19 * @brief This is the implementation file for FileListEditorForm class.
22 #include "GlAllListEditorPanel.h"
23 #include "GlAllListSelectionPanel.h"
24 #include "GlFileListEditorForm.h"
25 #include "GlFileListPresentationModel.h"
26 #include "GlGalleryApp.h"
27 #include "GlImageListEditorPanel.h"
28 #include "GlResourceManager.h"
29 #include "GlSlideSettingListener.h"
31 #include "GlVideoListEditorPanel.h"
32 #include "GlFileMoveTimer.h"
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Content;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43 using namespace Tizen::Base::Utility;
45 static const int GAP_W_POPUP_ITEM = 5;
46 static const int W_DELETE_POPUP = 600;
47 static const int H_DELETE_POPUP = 300;
48 static const int H_DELETE_LABEL = 180;
49 static const int Y_DELETE_BUTTON = 180;
50 static const int H_DELETE_BUTTON = 80;
51 static const int H_TOAST_LABEL = 48;
53 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
54 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
55 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
57 FileListEditorForm::FileListEditorForm(void)
58 : __pContextMenuMore(null)
59 , __pContextMenuShare(null)
60 , __pContextEditorMenuMove(null)
61 , __pContextSelectionMenuMove(null)
62 , __pDeletePopup(null)
63 , __morePosition(Point(0, 0))
64 , __pContentDirectoryList(null)
65 , __pContentDirectoryNameList(null)
68 , __isCopyOperation(false)
69 , __pPresentationModel(null)
73 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
76 FileListEditorForm::~FileListEditorForm(void)
79 if (__pContentDirectoryList != null)
81 delete __pContentDirectoryList;
83 if (__pContentDirectoryNameList != null)
85 delete __pContentDirectoryNameList;
88 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
92 FileListEditorForm::Initialize(void)
95 result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
96 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
102 FileListEditorForm::OnInitializing(void)
104 AppLogDebug("ENTER");
105 Header* pHeader = GetHeader();
106 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
108 __pPopUp = new (std::nothrow) SlideShowPopUp();
110 if (__pPopUp != null)
112 __pPopUp->Initialize();
113 __pPopUp->SetEventListner(this);
114 AddControl(*__pPopUp);
117 __pPresentationModel = FileListPresentationModel::GetInstance();
118 __pPresentationModel->ClearThumbnailRequests();
120 pHeader->SetStyle(HEADER_STYLE_TITLE);
121 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
123 if ((__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
124 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
126 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
127 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
128 ButtonItem selectAll;
129 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FILE_LIST_SELECT_ALL);
130 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
131 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
132 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
133 delete pNormalBitmap;
137 pHeader->AddActionEventListener(*this);
140 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
146 FileListEditorForm::InitializeFooter(void)
148 AppLogDebug("ENTER");
149 Footer* pFooter = GetFooter();
150 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
151 pFooter->RemoveAllItems();
153 result r = E_SUCCESS;
155 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
157 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
159 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
161 FooterItem footerConfirm;
162 footerConfirm.Construct(ACTION_ID_FOOTER_CONFIRM);
163 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
164 pFooter->AddItem(footerConfirm);
165 pFooter->SetItemEnabled(0, false);
169 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
171 pFooter->SetBackButton();
172 SetFormBackEventListener(this);
176 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
178 ButtonItem footerMore;
179 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
180 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
181 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
183 if (pBitmapMore != null && pBitmapMoreDim != NULL)
185 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
186 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
188 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
191 delete pBitmapMoreDim;
193 FooterItem footerShare;
194 r = footerShare.Construct(ACTION_ID_FOOTER_SHARE);
195 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
196 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
197 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
199 if (pBitmapShare != null && pBitmapShareDim != null)
201 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
202 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
205 r = pFooter->AddItem(footerShare);
207 delete pBitmapShareDim;
208 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
210 FooterItem footerDelete;
211 r = footerDelete.Construct(ACTION_ID_FOOTER_DELETE);
212 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
213 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
214 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
216 if (pBitmapDelete != null && pBitmapDeleteDim != null)
218 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
219 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
222 r = pFooter->AddItem(footerDelete);
223 delete pBitmapDelete;
224 delete pBitmapDeleteDim;
225 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
227 pFooter->SetBackButton();
228 SetFormBackEventListener(this);
230 SceneManager* pSceneManager = SceneManager::GetInstance();
231 int checkedCount = 0;
233 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
235 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
236 if (pEditorPanel != null)
238 checkedCount = pEditorPanel->GetItemCheckedCount();
241 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
243 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
244 if (pSelectionPanel != null)
246 checkedCount = pSelectionPanel->GetItemCheckedCount();
250 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
252 if (__pContextMenuMore != null)
254 delete __pContextMenuMore;
255 __pContextMenuMore = null;
258 __pContextMenuMore = new (std::nothrow) ContextMenu();
259 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
261 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
262 ACTION_ID_CONTEXT_MENU_MORE_MOVE);
263 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
264 ACTION_ID_CONTEXT_MENU_MORE_COPY);
266 if (checkedCount > 1)
268 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"),
269 ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW);
272 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),ACTION_ID_CONTEXT_MENU_ROTATE_LEFT);
273 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),ACTION_ID_CONTEXT_MENU_ROTATE_RIGHT);
275 __pContextMenuMore->SetShowState(false);
276 __pContextMenuMore->AddActionEventListener(*this);
278 __pContextMenuShare = new (std::nothrow) ContextMenu();
279 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
280 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
281 ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE);
282 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
283 ACTION_ID_CONTEXT_MENU_SHARE_EMAIL);
284 __pContextMenuShare->SetShowState(false);
285 __pContextMenuShare->AddActionEventListener(*this);
287 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
288 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
289 __pContextEditorMenuMove->AddActionEventListener(*this);
291 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
292 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
293 __pContextSelectionMenuMove->AddActionEventListener(*this);
295 if (__pContentDirectoryNameList != null)
297 delete __pContentDirectoryNameList;
298 __pContentDirectoryNameList = null;
304 pFooter->AddActionEventListener(*this);
305 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
311 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
313 AppLogDebug("ENTER");
314 if (fullPath == null)
316 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
320 String delim(DIRECTORY_SEPARATOR);
321 StringTokenizer st(fullPath,delim);
323 while (st.HasMoreTokens())
325 st.GetNextToken(token);
327 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
333 FileListEditorForm::OnTerminating(void)
335 AppLogDebug("ENTER");
337 if (__pContextMenuMore != null)
339 __pContextMenuMore->RemoveActionEventListener(*this);
340 delete __pContextMenuMore;
341 __pContextMenuMore = null;
344 if (__pContextMenuShare != null)
346 __pContextMenuShare->RemoveActionEventListener(*this);
347 delete __pContextMenuShare;
348 __pContextMenuShare = null;
351 if (__pContextEditorMenuMove != null)
353 __pContextEditorMenuMove->RemoveActionEventListener(*this);
354 delete __pContextEditorMenuMove;
355 __pContextEditorMenuMove = null;
358 if (__pContextSelectionMenuMove != null)
360 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
361 delete __pContextSelectionMenuMove;
362 __pContextSelectionMenuMove = null;
365 if (__pDeletePopup != null)
367 delete __pDeletePopup;
368 __pDeletePopup = null;
370 __overlayMsg = false;
371 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
377 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
379 AppLogDebug("ENTER(actionId=%d)", actionId);
380 SceneManager* pSceneManager = SceneManager::GetInstance();
381 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
385 case ACTION_ID_FILE_LIST_SELECT_ALL:
388 case ACTION_ID_FOOTER_MORE:
392 if (__pContextMenuMore->GetShowState() == false)
394 Rectangle rect = source.GetBounds();
395 __morePosition = Point(rect.width/8,rect.y);
396 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
398 __pContextMenuMore->SetAnchorPosition(Point(rect.width/10,rect.y));
402 __pContextMenuMore->SetAnchorPosition(Point(rect.width/10,rect.y - H_TOAST_LABEL));
404 __pContextMenuMore->SetShowState(true);
405 __pContextMenuMore->Show();
409 __pContextMenuMore->SetShowState(false);
413 case ACTION_ID_FOOTER_SHARE:
415 if (__pContextMenuShare->GetShowState() == false)
417 Rectangle rect = source.GetBounds();
418 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
420 __pContextMenuShare->SetAnchorPosition(Point(rect.width/8*3 ,rect.y));
424 __pContextMenuShare->SetAnchorPosition(Point(rect.width/8*3 ,rect.y - H_TOAST_LABEL));
426 __pContextMenuShare->SetShowState(true);
427 __pContextMenuShare->Show();
431 __pContextMenuShare->SetShowState(false);
435 case ACTION_ID_FOOTER_DELETE:
437 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
439 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
440 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
442 __pDeletePopup->SetShowState(true);
443 __pDeletePopup->Show();
447 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
449 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
450 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
452 __pDeletePopup->SetShowState(true);
453 __pDeletePopup->Show();
457 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
459 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
460 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
462 __pDeletePopup->SetShowState(true);
463 __pDeletePopup->Show();
467 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
469 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
470 (pSceneManager->GetCurrentScene()->GetPanel());
471 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
473 __pDeletePopup->SetShowState(true);
474 __pDeletePopup->Show();
480 case ACTION_ID_CONTEXT_MENU_MORE_EDIT:
484 case ACTION_ID_CONTEXT_MENU_MORE_ADD_TAG:
488 case ACTION_ID_CONTEXT_MENU_MORE_COPY:
489 case ACTION_ID_CONTEXT_MENU_MORE_MOVE:
491 if (actionId == ACTION_ID_CONTEXT_MENU_MORE_MOVE)
493 __isCopyOperation = false;
495 else if (actionId == ACTION_ID_CONTEXT_MENU_MORE_COPY)
497 __isCopyOperation = true;
500 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
502 if (__pContextEditorMenuMove->GetShowState() == false)
504 __pContextEditorMenuMove->SetAnchorPosition(__morePosition);
505 __pContextEditorMenuMove->SetShowState(true);
506 __pContextEditorMenuMove->Show();
510 __pContextEditorMenuMove->SetShowState(false);
513 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
515 if (__pContextSelectionMenuMove->GetShowState() == false)
517 __pContextSelectionMenuMove->SetAnchorPosition(__morePosition);
518 __pContextSelectionMenuMove->SetShowState(true);
519 __pContextSelectionMenuMove->Show();
523 __pContextSelectionMenuMove->SetShowState(false);
529 case ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW:
531 if (__pPopUp != null)
533 __pPopUp->SetShowState(true);
539 case ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE:
541 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
543 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
544 if (pEditorPanel != null)
546 pEditorPanel->OnRequestMessage();
549 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
551 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
552 if (pSelectionPanel != null)
554 pSelectionPanel->OnRequestMessage();
559 case ACTION_ID_CONTEXT_MENU_SHARE_EMAIL:
561 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
563 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
564 if (pEditorPanel != null)
566 pEditorPanel->OnRequestEmail();
569 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
571 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
572 if (pSelectionPanel != null)
574 pSelectionPanel->OnRequestEmail();
579 case ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
581 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
583 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
584 if (pListEditorPanel)
586 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
587 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
588 if (__isCopyOperation)
590 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
594 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
596 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
602 case ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
604 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
606 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
607 (pSceneManager->GetCurrentScene()->GetPanel());
608 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
609 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
610 if (__isCopyOperation)
612 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
616 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
618 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
622 case ACTION_ID_DELETE_POPUP_DEL:
624 __overlayMsg = false;
625 __pDeletePopup->SetShowState(false);
626 __pDeletePopup->Invalidate(true);
628 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
630 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
631 if (pEditorPanel != null)
633 result r = pEditorPanel->OnRequestDelete();
636 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
640 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
642 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
643 (pSceneManager->GetCurrentScene()->GetPanel());
645 if (pSelectionPanel != null)
647 result r = pSelectionPanel->OnRequestDelete();
650 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
656 case ACTION_ID_DELETE_POPUP_CANCEL:
658 __overlayMsg = false;
659 __pDeletePopup->SetShowState(false);
660 __pDeletePopup->Invalidate(true);
664 case ACTION_ID_CONTEXT_MENU_ROTATE_LEFT:
666 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
668 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
669 if (pEditorPanel != null)
671 RotateMode rotateMode = ROTATE_MODE_LEFT;
672 pEditorPanel->OnRequestRotate(rotateMode);
675 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
677 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
678 (pSceneManager->GetCurrentScene()->GetPanel());
680 if (pSelectionPanel != null)
682 RotateMode rotateMode = ROTATE_MODE_LEFT;
683 pSelectionPanel->OnRotateRequested(rotateMode);
690 case ACTION_ID_CONTEXT_MENU_ROTATE_RIGHT:
692 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
694 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
695 if (pEditorPanel != null)
697 RotateMode rotateMode = ROTATE_MODE_RIGHT;
698 pEditorPanel->OnRequestRotate(rotateMode);
701 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
704 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
705 (pSceneManager->GetCurrentScene()->GetPanel());
707 if (pSelectionPanel != null)
709 RotateMode rotateMode = ROTATE_MODE_RIGHT;
710 pSelectionPanel->OnRotateRequested(rotateMode);
717 case ACTION_ID_FOOTER_CONFIRM:
719 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
721 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
722 if (pEditorPanel != null)
724 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
727 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
729 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
730 if (pEditorPanel != null)
732 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
739 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
741 if ((ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
742 (actionId <= ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
744 if (__pContentDirectoryList == null)
748 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
750 String* pDirectory = static_cast<String*>
751 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
753 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
754 (pSceneManager->GetCurrentScene()->GetPanel());
756 if (pEditorPanel != null)
759 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
760 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
761 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
762 if (__isCopyOperation)
764 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
765 __pFileMove->SetCopy();
768 result r = __pFileMove->StartTimer();
773 __isCopyOperation = false;
783 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
785 if ((ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
786 (actionId <= ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
788 if (__pContentDirectoryList == null)
793 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
795 String* pDirectory = static_cast<String*>
796 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
798 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
799 (pSceneManager->GetCurrentScene()->GetPanel());
801 if (pSelectionPanel != null)
804 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
805 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
806 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
807 if (__isCopyOperation)
809 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
810 __pFileMove->SetCopy();
812 result r = __pFileMove->StartTimer();
817 __isCopyOperation = false;
830 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
834 FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
840 FileListEditorForm::GetOverlayStatus()
846 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
848 __overlayMsg = false;
849 __pPresentationModel->SetUpdateProgressStatus(false);
850 if (res != COMPLETE_SUCCESS)
852 MessageBox messageBox;
853 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_OPERATION_FAILED"), MSGBOX_STYLE_OK, 3000);
856 messageBox.ShowAndWait(modalResult);
857 __overlayMsg = false;
858 SceneManager* pSceneManager = SceneManager::GetInstance();
859 AppAssert(pSceneManager);
860 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
865 FileListEditorForm::OnContentUpdated()
867 AppLogDebug("ENTER");
869 if (__overlayMsg == false)
871 SceneManager* pSceneManager = SceneManager::GetInstance();
872 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
874 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
878 FileListEditorForm::SetUpPopup(void)
880 AppLogDebug("ENTER");
881 result r = E_SUCCESS;
883 if (__pDeletePopup != null)
885 delete __pDeletePopup;
886 __pDeletePopup = null;
889 __pDeletePopup = new (std::nothrow) Popup();
890 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
892 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
894 Label* pLabelText = new (std::nothrow) Label();
895 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
896 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
897 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
898 __pDeletePopup->AddControl(*pLabelText);
900 Button* pDeleteButton = new (std::nothrow) Button();
901 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
902 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
903 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
904 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
905 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
906 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
907 pDeleteButton->AddActionEventListener(*this);
908 __pDeletePopup->AddControl(*pDeleteButton);
910 Button* pButtonCancel = new (std::nothrow) Button();
911 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
912 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
913 pButtonCancel->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
914 pButtonCancel->AddActionEventListener(*this);
915 __pDeletePopup->AddControl(*pButtonCancel);
916 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
922 FileListEditorForm::SetTitleText(const String& titleText)
924 AppLogDebug("ENTER");
925 Header* pHeader = GetHeader();
926 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
927 pHeader->SetTitleText(titleText);
928 pHeader->Invalidate(true);
929 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
933 FileListEditorForm::RefreshFolderList(void)
935 AppLogDebug("ENTER");
936 ContentDirectory contentDirectory;
937 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
938 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
939 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
940 result r = contentDirectory.Construct(*pContentTypeList);
943 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
946 delete pContentTypeList;
948 if (__pContentDirectoryList != null)
950 delete __pContentDirectoryList;
952 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
953 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
954 String* pDirPath = null;
955 String* pDirName = null;
957 int loopCount = __pContentDirectoryList->GetCount();
958 for (int i = 0; i < loopCount; ++i)
960 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
961 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
962 __pContentDirectoryNameList->Add(pDirName);
964 __pContextEditorMenuMove->RemoveAllItems();
965 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
966 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
967 __pContextSelectionMenuMove->RemoveAllItems();
968 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
969 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
971 loopCount = __pContentDirectoryNameList->GetCount();
972 for (int i = 0; i < loopCount; ++i)
974 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
975 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
976 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
977 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
978 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
980 __pContextEditorMenuMove->SetShowState(false);
981 __pContextSelectionMenuMove->SetShowState(false);
982 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
986 FileListEditorForm::OnFormBackRequested(Form& source)
988 AppLogDebug("ENTER");
990 SceneManager* pSceneManager = SceneManager::GetInstance();
991 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
993 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
995 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
997 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
999 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1001 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1006 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1008 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1010 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1012 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1014 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1016 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1018 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1020 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1021 (pSceneManager->GetCurrentScene()->GetPanel());
1022 if (pSelectionPanel != null)
1024 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1027 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1030 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
1035 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1038 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1042 FileListEditorForm::SetFooterButtonsState(bool enableState)
1044 AppLogDebug("ENTER");
1045 Footer* pFooter = GetFooter();
1046 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1048 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
1050 if (enableState == true)
1052 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1053 pFooter->SetItemEnabled(0, true);
1057 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1058 pFooter->SetItemEnabled(0, false);
1064 if (enableState == true)
1066 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1067 pFooter->SetItemEnabled(0, true);
1068 pFooter->SetItemEnabled(1, true);
1072 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1073 pFooter->SetItemEnabled(0, false);
1074 pFooter->SetItemEnabled(1, false);
1077 pFooter->RequestRedraw(true);
1078 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1082 FileListEditorForm::MoveToAlbum(String& destDirectory)
1084 AppLogDebug("ENTER");
1085 result r = E_FAILURE;
1086 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1087 if (albumName != EMPTY_SPACE)
1089 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1090 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1091 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1092 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1093 delete pDirectoryList;
1095 SceneManager* pSceneManager = SceneManager::GetInstance();
1096 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1099 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1105 FileListEditorForm::SelectAllPressed(void)
1107 SceneManager* pSceneManager = SceneManager::GetInstance();
1108 pSceneManager->GetCurrentScene();
1110 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1112 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1113 if (pEditorPanel != null)
1115 pEditorPanel->SelectAllPressed();
1118 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1120 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1121 if (pEditorPanel != null)
1123 pEditorPanel->SelectAllPressed();
1126 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1128 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1129 if (pEditorPanel != null)
1131 pEditorPanel->SelectAllPressed();
1134 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1136 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1137 if (pEditorPanel != null)
1139 pEditorPanel->SelectAllPressed();
1145 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1147 if (__pPopUp != NULL)
1149 __pPopUp->SetShowState(false);
1152 SceneManager* pSceneManager = SceneManager::GetInstance();
1156 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1158 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1159 if (pEditorPanel != null)
1161 pEditorPanel->OnRequestSlideShow();
1164 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1166 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1167 (pSceneManager->GetCurrentScene()->GetPanel());
1169 if (pSelectionPanel != null)
1171 pSelectionPanel->OnRequestSlideShow();
1175 else if (index == 1)
1177 SceneManager* pSceneManager = SceneManager::GetInstance();
1178 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1180 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));