2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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"
30 #include "GlSlideShowPopUp.h"
32 #include "GlVideoListEditorPanel.h"
33 #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::System;
41 using namespace Tizen::Ui;
42 using namespace Tizen::Ui::Controls;
43 using namespace Tizen::Ui::Scenes;
44 using namespace Tizen::Base::Utility;
46 static const int GAP_W_POPUP_ITEM = 5;
47 static const int W_DELETE_POPUP = 600;
48 static const int H_DELETE_POPUP = 300;
49 static const int H_DELETE_LABEL = 180;
50 static const int Y_DELETE_BUTTON = 180;
51 static const int H_DELETE_BUTTON = 80;
52 static const int H_TOAST_LABEL = 48;
54 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
55 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
56 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
58 static const String RESERVED_MEDIA_PATH = Environment::GetMediaPath();
60 FileListEditorForm::FileListEditorForm(void)
61 : __pContextMenuMore(null)
62 , __pContextMenuShare(null)
63 , __pContextEditorMenuMove(null)
64 , __pContextSelectionMenuMove(null)
65 , __pDeletePopup(null)
66 , __morePosition(Point(0, 0))
67 , __pContentDirectoryList(null)
68 , __pContentDirectoryNameList(null)
71 , __isCopyOperation(false)
72 , __pPresentationModel(null)
76 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
79 FileListEditorForm::~FileListEditorForm(void)
82 if (__pContentDirectoryList != null)
84 delete __pContentDirectoryList;
87 if (__pContentDirectoryNameList != null)
89 delete __pContentDirectoryNameList;
92 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
96 FileListEditorForm::Initialize(void)
99 result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
100 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
106 FileListEditorForm::OnInitializing(void)
108 AppLogDebug("ENTER");
109 Header* pHeader = GetHeader();
110 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
112 __pPopUp = new (std::nothrow) SlideShowPopUp();
114 if (__pPopUp != null)
116 __pPopUp->Initialize();
117 __pPopUp->SetEventListner(this);
118 AddControl(__pPopUp);
121 __pPresentationModel = FileListPresentationModel::GetInstance();
122 __pPresentationModel->ClearThumbnailRequests();
124 pHeader->SetStyle(HEADER_STYLE_TITLE);
125 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
127 if ((__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
128 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
130 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
131 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
132 ButtonItem selectAll;
133 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FILE_LIST_SELECT_ALL);
134 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
135 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
136 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
137 delete pNormalBitmap;
141 pHeader->AddActionEventListener(*this);
144 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
150 FileListEditorForm::InitializeFooter(void)
152 AppLogDebug("ENTER");
153 Footer* pFooter = GetFooter();
154 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
155 pFooter->RemoveAllItems();
157 result r = E_SUCCESS;
159 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
161 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
163 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
165 FooterItem footerConfirm;
166 footerConfirm.Construct(IDA_FOOTER_CONFIRM);
167 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
168 pFooter->AddItem(footerConfirm);
169 pFooter->SetItemEnabled(0, false);
173 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
175 pFooter->SetBackButton();
176 SetFormBackEventListener(this);
180 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
182 ButtonItem footerMore;
183 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
184 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
185 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
186 Bitmap* pBitmapMorePressed = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_PRESSED);
188 if (pBitmapMore != null && pBitmapMoreDim != NULL && pBitmapMorePressed != null)
190 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
191 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
192 footerMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapMorePressed);
194 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
197 delete pBitmapMoreDim;
198 delete pBitmapMorePressed;
200 FooterItem footerShare;
201 r = footerShare.Construct(IDA_FOOTER_SHARE);
202 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
203 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
204 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
206 if (pBitmapShare != null && pBitmapShareDim != null)
208 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
209 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
212 r = pFooter->AddItem(footerShare);
214 delete pBitmapShareDim;
215 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
217 FooterItem footerDelete;
218 r = footerDelete.Construct(IDA_FOOTER_DELETE);
219 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
220 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
221 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
223 if (pBitmapDelete != null && pBitmapDeleteDim != null)
225 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
226 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
229 r = pFooter->AddItem(footerDelete);
230 delete pBitmapDelete;
231 delete pBitmapDeleteDim;
232 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
234 pFooter->SetBackButton();
235 SetFormBackEventListener(this);
237 SceneManager* pSceneManager = SceneManager::GetInstance();
238 int checkedCount = 0;
240 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
242 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
243 if (pEditorPanel != null)
245 checkedCount = pEditorPanel->GetItemCheckedCount();
248 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
250 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
251 if (pSelectionPanel != null)
253 checkedCount = pSelectionPanel->GetItemCheckedCount();
257 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
259 if (__pContextMenuMore != null)
261 delete __pContextMenuMore;
262 __pContextMenuMore = null;
265 __pContextMenuMore = new (std::nothrow) ContextMenu();
266 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
268 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
269 IDA_CONTEXT_MENU_MORE_MOVE);
270 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
271 IDA_CONTEXT_MENU_MORE_COPY);
273 if (checkedCount > 1)
275 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
276 IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
279 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
280 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
282 __pContextMenuMore->SetShowState(false);
283 __pContextMenuMore->AddActionEventListener(*this);
285 __pContextMenuShare = new (std::nothrow) ContextMenu();
286 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
287 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
288 IDA_CONTEXT_MENU_SHARE_MESSAGE);
289 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
290 IDA_CONTEXT_MENU_SHARE_EMAIL);
291 __pContextMenuShare->SetShowState(false);
292 __pContextMenuShare->AddActionEventListener(*this);
294 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
295 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
296 __pContextEditorMenuMove->AddActionEventListener(*this);
298 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
299 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
300 __pContextSelectionMenuMove->AddActionEventListener(*this);
302 if (__pContentDirectoryNameList != null)
304 delete __pContentDirectoryNameList;
305 __pContentDirectoryNameList = null;
311 pFooter->AddActionEventListener(*this);
312 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
318 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
320 AppLogDebug("ENTER");
321 if (fullPath == null)
323 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
327 String delim(DIRECTORY_SEPARATOR);
328 StringTokenizer st(fullPath,delim);
330 while (st.HasMoreTokens())
332 st.GetNextToken(token);
334 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
340 FileListEditorForm::OnTerminating(void)
342 AppLogDebug("ENTER");
343 __pPresentationModel->RemoveContentEventListener(this);
344 if (__pContextMenuMore != null)
346 __pContextMenuMore->RemoveActionEventListener(*this);
347 delete __pContextMenuMore;
348 __pContextMenuMore = null;
351 if (__pContextMenuShare != null)
353 __pContextMenuShare->RemoveActionEventListener(*this);
354 delete __pContextMenuShare;
355 __pContextMenuShare = null;
358 if (__pContextEditorMenuMove != null)
360 __pContextEditorMenuMove->RemoveActionEventListener(*this);
361 delete __pContextEditorMenuMove;
362 __pContextEditorMenuMove = null;
365 if (__pContextSelectionMenuMove != null)
367 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
368 delete __pContextSelectionMenuMove;
369 __pContextSelectionMenuMove = null;
372 if (__pDeletePopup != null)
374 delete __pDeletePopup;
375 __pDeletePopup = null;
378 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
384 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
386 AppLogDebug("ENTER(actionId=%d)", actionId);
387 SceneManager* pSceneManager = SceneManager::GetInstance();
388 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
392 case IDA_FILE_LIST_SELECT_ALL:
396 case IDA_FOOTER_MORE:
400 if (__pContextMenuMore->GetShowState() == false)
402 Rectangle rect = source.GetBounds();
403 __morePosition = Point(rect.width / 8, rect.y);
404 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
406 __pContextMenuMore->SetAnchorPosition(Point(rect.width / 10, rect.y));
410 __pContextMenuMore->SetAnchorPosition(Point(rect.width / 10, rect.y - H_TOAST_LABEL));
412 __pContextMenuMore->SetShowState(true);
413 __pContextMenuMore->Show();
417 __pContextMenuMore->SetShowState(false);
422 case IDA_FOOTER_SHARE:
424 if (__pContextMenuShare->GetShowState() == false)
426 Rectangle rect = source.GetBounds();
427 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
429 __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
433 __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
435 __pContextMenuShare->SetShowState(true);
436 __pContextMenuShare->Show();
440 __pContextMenuShare->SetShowState(false);
445 case IDA_FOOTER_DELETE:
447 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
449 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
450 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
452 __pDeletePopup->SetShowState(true);
453 __pDeletePopup->Show();
457 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
459 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
460 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
462 __pDeletePopup->SetShowState(true);
463 __pDeletePopup->Show();
467 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
469 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
470 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
472 __pDeletePopup->SetShowState(true);
473 __pDeletePopup->Show();
477 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
479 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
480 (pSceneManager->GetCurrentScene()->GetPanel());
481 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
483 __pDeletePopup->SetShowState(true);
484 __pDeletePopup->Show();
491 case IDA_CONTEXT_MENU_MORE_EDIT:
496 case IDA_CONTEXT_MENU_MORE_ADD_TAG:
501 case IDA_CONTEXT_MENU_MORE_COPY:
503 case IDA_CONTEXT_MENU_MORE_MOVE:
505 if (actionId == IDA_CONTEXT_MENU_MORE_MOVE)
507 __isCopyOperation = false;
509 else if (actionId == IDA_CONTEXT_MENU_MORE_COPY)
511 __isCopyOperation = true;
514 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
516 if (__pContextEditorMenuMove->GetShowState() == false)
518 __pContextEditorMenuMove->SetAnchorPosition(Point(__morePosition.x, __morePosition.y - 48));
519 __pContextEditorMenuMove->SetShowState(true);
520 __pContextEditorMenuMove->Show();
524 __pContextEditorMenuMove->SetShowState(false);
527 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
529 if (__pContextSelectionMenuMove->GetShowState() == false)
531 __pContextSelectionMenuMove->SetAnchorPosition(__morePosition);
532 __pContextSelectionMenuMove->SetShowState(true);
533 __pContextSelectionMenuMove->Show();
537 __pContextSelectionMenuMove->SetShowState(false);
543 case IDA_CONTEXT_MENU_MORE_SLIDE_SHOW:
545 if (__pPopUp != null)
547 __pPopUp->SetShowState(true);
553 case IDA_CONTEXT_MENU_SHARE_MESSAGE:
555 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
557 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
558 if (pEditorPanel != null)
560 pEditorPanel->OnRequestMessage();
563 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
565 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
566 if (pSelectionPanel != null)
568 pSelectionPanel->OnRequestMessage();
574 case IDA_CONTEXT_MENU_SHARE_EMAIL:
576 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
578 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
579 if (pEditorPanel != null)
581 pEditorPanel->OnRequestEmail();
584 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
586 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
587 if (pSelectionPanel != null)
589 pSelectionPanel->OnRequestEmail();
595 case IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
597 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
599 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
600 if (pListEditorPanel)
602 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
603 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
604 if (__isCopyOperation)
606 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
610 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
612 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
619 case IDA_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
621 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
623 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
624 (pSceneManager->GetCurrentScene()->GetPanel());
626 if (pSelectionPanel != null)
628 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
629 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
630 if (__isCopyOperation)
632 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
636 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
638 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
644 case IDA_DELETE_POPUP_DEL:
647 __pDeletePopup->SetShowState(false);
648 __pDeletePopup->Invalidate(true);
650 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
652 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
653 if (pEditorPanel != null)
655 result r = pEditorPanel->OnRequestDelete();
658 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
662 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
664 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
665 (pSceneManager->GetCurrentScene()->GetPanel());
667 if (pSelectionPanel != null)
669 result r = pSelectionPanel->OnRequestDelete();
672 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
679 case IDA_DELETE_POPUP_CANCEL:
682 __pDeletePopup->SetShowState(false);
683 __pDeletePopup->Invalidate(true);
687 case IDA_CONTEXT_MENU_ROTATE_LEFT:
689 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
691 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
692 if (pEditorPanel != null)
694 RotateMode rotateMode = ROTATE_MODE_LEFT;
695 pEditorPanel->OnRequestRotate(rotateMode);
698 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
700 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
701 (pSceneManager->GetCurrentScene()->GetPanel());
703 if (pSelectionPanel != null)
705 RotateMode rotateMode = ROTATE_MODE_LEFT;
706 pSelectionPanel->OnRotateRequested(rotateMode);
712 case IDA_CONTEXT_MENU_ROTATE_RIGHT:
714 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
716 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
717 if (pEditorPanel != null)
719 RotateMode rotateMode = ROTATE_MODE_RIGHT;
720 pEditorPanel->OnRequestRotate(rotateMode);
723 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
726 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
727 (pSceneManager->GetCurrentScene()->GetPanel());
729 if (pSelectionPanel != null)
731 RotateMode rotateMode = ROTATE_MODE_RIGHT;
732 pSelectionPanel->OnRotateRequested(rotateMode);
738 case IDA_FOOTER_CONFIRM:
740 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
742 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
743 if (pEditorPanel != null)
745 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
748 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
750 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
751 if (pEditorPanel != null)
753 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
761 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
763 if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
764 (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
766 if (__pContentDirectoryList == null)
770 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
772 String* pDirectory = static_cast<String*>
773 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
775 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
776 (pSceneManager->GetCurrentScene()->GetPanel());
778 if (pEditorPanel != null)
781 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
782 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
783 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
784 if (__isCopyOperation)
786 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
787 __pFileMove->SetCopy();
790 result r = __pFileMove->StartTimer();
795 __isCopyOperation = false;
805 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
807 if ((IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
808 (actionId <= IDA_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
810 if (__pContentDirectoryList == null)
815 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
817 String* pDirectory = static_cast<String*>
818 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
820 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
821 (pSceneManager->GetCurrentScene()->GetPanel());
823 if (pSelectionPanel != null)
826 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
827 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
828 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
829 if (__isCopyOperation)
831 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
832 __pFileMove->SetCopy();
834 result r = __pFileMove->StartTimer();
839 __isCopyOperation = false;
852 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
856 FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
862 FileListEditorForm::GetOverlayStatus(void) const
868 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
871 __pPresentationModel->SetUpdateProgressStatus(false);
872 if (res != COMPLETE_SUCCESS)
874 MessageBox messageBox;
875 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_OPERATION_FAILED"), MSGBOX_STYLE_OK, 3000);
878 messageBox.ShowAndWait(modalResult);
880 SceneManager* pSceneManager = SceneManager::GetInstance();
881 AppAssert(pSceneManager);
882 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
887 FileListEditorForm::OnContentUpdated()
889 AppLogDebug("ENTER");
891 SceneManager* pSceneManager = SceneManager::GetInstance();
893 if(__pDeletePopup != null)
895 if(__pDeletePopup->IsVisible() == true)
897 __pDeletePopup->Destroy();
898 __pDeletePopup = null;
904 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
906 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
907 if (pEditorPanel != null)
909 pEditorPanel->CancelUpdateProgress();
912 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
914 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
915 if (pSelectionPanel != null)
917 pSelectionPanel->CancelUpdateProgress();
921 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
922 && pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
924 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
925 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
928 else if (_overlayMsg == false)
930 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
931 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
934 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
938 FileListEditorForm::SetUpPopup(void)
940 AppLogDebug("ENTER");
941 result r = E_SUCCESS;
943 if (__pDeletePopup != null)
945 delete __pDeletePopup;
946 __pDeletePopup = null;
949 __pDeletePopup = new (std::nothrow) Popup();
950 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
952 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
954 Label* pLabelText = new (std::nothrow) Label();
955 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
956 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
957 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
958 pLabelText->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
959 __pDeletePopup->AddControl(pLabelText);
961 Button* pDeleteButton = new (std::nothrow) Button();
962 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
963 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
964 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
965 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
966 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
967 pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
968 pDeleteButton->AddActionEventListener(*this);
969 __pDeletePopup->AddControl(pDeleteButton);
971 Button* pButtonCancel = new (std::nothrow) Button();
972 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
973 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
974 pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
975 pButtonCancel->AddActionEventListener(*this);
976 __pDeletePopup->AddControl(pButtonCancel);
977 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
983 FileListEditorForm::SetTitleText(const String& titleText)
985 AppLogDebug("ENTER");
986 Header* pHeader = GetHeader();
987 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
988 pHeader->SetTitleText(titleText);
989 pHeader->Invalidate(true);
990 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
994 FileListEditorForm::RefreshFolderList(void)
996 AppLogDebug("ENTER");
997 ContentDirectory contentDirectory;
998 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
999 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1000 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1001 result r = contentDirectory.Construct(*pContentTypeList);
1004 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1007 delete pContentTypeList;
1009 if (__pContentDirectoryList != null)
1011 delete __pContentDirectoryList;
1013 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
1014 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1015 String* pDirPath = null;
1016 String* pDirName = null;
1017 String mediaPath = RESERVED_MEDIA_PATH;
1018 int length = mediaPath.GetLength();
1019 mediaPath.Remove(length-1,1);
1021 int loopCount = __pContentDirectoryList->GetCount();
1022 for (int i = 0; i < loopCount; ++i)
1024 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
1025 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
1027 if ( *pDirPath == mediaPath)
1029 *pDirName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
1030 __pContentDirectoryNameList->Add(pDirName);
1034 __pContentDirectoryNameList->Add(pDirName);
1037 __pContextEditorMenuMove->RemoveAllItems();
1038 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
1039 IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
1040 __pContextSelectionMenuMove->RemoveAllItems();
1041 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
1042 IDA_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
1044 loopCount = __pContentDirectoryNameList->GetCount();
1045 for (int i = 0; i < loopCount; ++i)
1047 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
1049 if ( *pDirName != __pPresentationModel->GetCurrentAlbumName())
1051 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
1052 IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
1053 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
1054 IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
1057 __pContextEditorMenuMove->SetShowState(false);
1058 __pContextSelectionMenuMove->SetShowState(false);
1059 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1063 FileListEditorForm::OnFormBackRequested(Form& source)
1065 AppLogDebug("ENTER");
1067 SceneManager* pSceneManager = SceneManager::GetInstance();
1068 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
1070 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1072 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1074 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1076 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1078 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1083 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1085 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1087 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1089 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1091 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1093 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1095 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1097 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1098 (pSceneManager->GetCurrentScene()->GetPanel());
1099 if (pSelectionPanel != null)
1101 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1104 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1107 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1108 SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
1113 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1116 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1120 FileListEditorForm::SetFooterButtonsState(const bool enableState)
1122 AppLogDebug("ENTER");
1123 Footer* pFooter = GetFooter();
1124 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1126 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1128 if (enableState == true)
1130 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1131 pFooter->SetItemEnabled(0, true);
1135 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1136 pFooter->SetItemEnabled(0, false);
1141 if (enableState == true)
1143 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1144 pFooter->SetItemEnabled(0, true);
1145 pFooter->SetItemEnabled(1, true);
1149 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1150 pFooter->SetItemEnabled(0, false);
1151 pFooter->SetItemEnabled(1, false);
1154 pFooter->RequestRedraw(true);
1155 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1159 FileListEditorForm::MoveToAlbum(const String& destDirectory)
1161 AppLogDebug("ENTER");
1162 result r = E_FAILURE;
1163 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1164 if (albumName != EMPTY_SPACE)
1166 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1167 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1168 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1169 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1170 delete pDirectoryList;
1172 SceneManager* pSceneManager = SceneManager::GetInstance();
1173 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1176 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1182 FileListEditorForm::SelectAllPressed(void)
1184 SceneManager* pSceneManager = SceneManager::GetInstance();
1185 pSceneManager->GetCurrentScene();
1187 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1189 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1190 if (pEditorPanel != null)
1192 pEditorPanel->OnSelectAllPressed();
1195 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1197 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1198 if (pEditorPanel != null)
1200 pEditorPanel->OnSelectAllPressed();
1203 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1205 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1206 if (pEditorPanel != null)
1208 pEditorPanel->OnSelectAllPressed();
1211 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1213 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1214 if (pEditorPanel != null)
1216 pEditorPanel->OnSelectAllPressed();
1222 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1224 if (__pPopUp != NULL)
1226 __pPopUp->SetShowState(false);
1229 SceneManager* pSceneManager = SceneManager::GetInstance();
1233 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1235 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1236 if (pEditorPanel != null)
1238 pEditorPanel->OnRequestSlideShow();
1241 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1243 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1244 (pSceneManager->GetCurrentScene()->GetPanel());
1246 if (pSelectionPanel != null)
1248 pSelectionPanel->OnRequestSlideShow();
1252 else if (index == 1)
1254 SceneManager* pSceneManager = SceneManager::GetInstance();
1255 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1257 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
1262 FileListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1264 AppLogDebug("ENTER");
1265 __pPresentationModel->RemoveContentEventListener(this);
1266 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1270 FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1272 AppLogDebug("ENTER");
1273 __pPresentationModel->AddContentEventListener(this);
1274 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));