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 : __pContextMenuShare(null)
63 , __pDeletePopup(null)
64 , __morePosition(Point(0, 0))
65 , __pContentDirectoryList(null)
66 , __pContentDirectoryNameList(null)
69 , __isCopyOperation(false)
70 , __pPresentationModel(null)
74 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
77 FileListEditorForm::~FileListEditorForm(void)
80 if (__pContentDirectoryList != null)
82 delete __pContentDirectoryList;
85 if (__pContentDirectoryNameList != null)
87 delete __pContentDirectoryNameList;
90 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
94 FileListEditorForm::Initialize(void)
97 result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
98 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
104 FileListEditorForm::OnInitializing(void)
106 AppLogDebug("ENTER");
107 Header* pHeader = GetHeader();
108 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
110 __pPopUp = new (std::nothrow) SlideShowPopUp();
112 if (__pPopUp != null)
114 __pPopUp->Initialize();
115 __pPopUp->SetEventListner(this);
116 AddControl(__pPopUp);
119 __pPresentationModel = FileListPresentationModel::GetInstance();
120 __pPresentationModel->ClearThumbnailRequests();
122 pHeader->SetStyle(HEADER_STYLE_TITLE);
123 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
125 if ((__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
126 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
128 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
129 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
130 ButtonItem selectAll;
131 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FILE_LIST_SELECT_ALL);
132 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
133 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
134 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
135 delete pNormalBitmap;
139 pHeader->AddActionEventListener(*this);
142 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
148 FileListEditorForm::InitializeFooter(void)
150 AppLogDebug("ENTER");
151 Footer* pFooter = GetFooter();
152 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
153 pFooter->RemoveAllItems();
155 result r = E_SUCCESS;
157 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
159 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
161 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
163 FooterItem footerConfirm;
164 footerConfirm.Construct(IDA_FOOTER_CONFIRM);
165 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
166 pFooter->AddItem(footerConfirm);
167 pFooter->SetItemEnabled(0, false);
171 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
174 SetFormBackEventListener(this);
179 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
180 SetFormMenuEventListener(this);
182 FooterItem footerShare;
183 r = footerShare.Construct(IDA_FOOTER_SHARE);
184 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
185 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
186 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
188 if (pBitmapShare != null && pBitmapShareDim != null)
190 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
191 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
194 r = pFooter->AddItem(footerShare);
196 delete pBitmapShareDim;
197 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
199 FooterItem footerDelete;
200 r = footerDelete.Construct(IDA_FOOTER_DELETE);
201 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
202 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
203 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
205 if (pBitmapDelete != null && pBitmapDeleteDim != null)
207 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
208 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
211 r = pFooter->AddItem(footerDelete);
212 delete pBitmapDelete;
213 delete pBitmapDeleteDim;
214 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
216 SetFormBackEventListener(this);
218 SceneManager* pSceneManager = SceneManager::GetInstance();
219 int checkedCount = 0;
221 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
223 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
224 if (pEditorPanel != null)
226 checkedCount = pEditorPanel->GetItemCheckedCount();
229 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
231 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
232 if (pSelectionPanel != null)
234 checkedCount = pSelectionPanel->GetItemCheckedCount();
238 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
240 if (__pOptionMenu != null)
242 delete __pOptionMenu;
243 __pOptionMenu = null;
246 __pOptionMenu = new (std::nothrow) OptionMenu();
247 __pOptionMenu->Construct();
248 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
249 IDA_CONTEXT_MENU_MORE_MOVE);
250 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
251 IDA_CONTEXT_MENU_MORE_COPY);
253 if (checkedCount > 1)
255 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
256 IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
259 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
260 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
262 __pOptionMenu->AddActionEventListener(*this);
266 __pContextMenuShare = new (std::nothrow) ContextMenu();
267 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
268 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
269 IDA_CONTEXT_MENU_SHARE_MESSAGE);
270 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
271 IDA_CONTEXT_MENU_SHARE_EMAIL);
272 __pContextMenuShare->SetShowState(false);
273 __pContextMenuShare->AddActionEventListener(*this);
277 if (__pContentDirectoryNameList != null)
279 delete __pContentDirectoryNameList;
280 __pContentDirectoryNameList = null;
286 pFooter->AddActionEventListener(*this);
287 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
293 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
295 AppLogDebug("ENTER");
296 if (fullPath == null)
298 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
302 String delim(DIRECTORY_SEPARATOR);
303 StringTokenizer st(fullPath,delim);
305 while (st.HasMoreTokens())
307 st.GetNextToken(token);
309 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
315 FileListEditorForm::OnTerminating(void)
317 AppLogDebug("ENTER");
318 __pPresentationModel->RemoveContentEventListener(this);
320 if (__pOptionMenu != null)
322 __pOptionMenu->RemoveActionEventListener(*this);
323 delete __pOptionMenu;
324 __pOptionMenu = null;
327 if (__pContextMenuShare != null)
329 __pContextMenuShare->RemoveActionEventListener(*this);
330 delete __pContextMenuShare;
331 __pContextMenuShare = null;
334 if (__pDeletePopup != null)
336 delete __pDeletePopup;
337 __pDeletePopup = null;
340 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
346 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
348 AppLogDebug("ENTER(actionId=%d)", actionId);
349 SceneManager* pSceneManager = SceneManager::GetInstance();
350 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
354 case IDA_FILE_LIST_SELECT_ALL:
358 case IDA_FOOTER_SHARE:
360 if (__pContextMenuShare->GetShowState() == false)
362 Rectangle rect = source.GetBounds();
363 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
365 __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
369 __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
371 __pContextMenuShare->SetShowState(true);
372 __pContextMenuShare->Show();
376 __pContextMenuShare->SetShowState(false);
381 case IDA_FOOTER_DELETE:
383 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
385 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
386 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
388 __pDeletePopup->SetShowState(true);
389 __pDeletePopup->Show();
393 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
395 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
396 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
398 __pDeletePopup->SetShowState(true);
399 __pDeletePopup->Show();
403 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
405 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
406 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
408 __pDeletePopup->SetShowState(true);
409 __pDeletePopup->Show();
413 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
415 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
416 (pSceneManager->GetCurrentScene()->GetPanel());
417 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
419 __pDeletePopup->SetShowState(true);
420 __pDeletePopup->Show();
427 case IDA_CONTEXT_MENU_MORE_EDIT:
432 case IDA_CONTEXT_MENU_MORE_ADD_TAG:
437 case IDA_CONTEXT_MENU_MORE_COPY:
439 case IDA_CONTEXT_MENU_MORE_MOVE:
441 if (actionId == IDA_CONTEXT_MENU_MORE_MOVE)
443 __isCopyOperation = false;
445 else if (actionId == IDA_CONTEXT_MENU_MORE_COPY)
447 __isCopyOperation = true;
452 __pOptionMenu->SetShowState(true);
453 __pOptionMenu->Show();
459 case IDA_CONTEXT_MENU_MORE_SLIDE_SHOW:
461 if (__pPopUp != null)
463 __pPopUp->SetShowState(true);
469 case IDA_CONTEXT_MENU_SHARE_MESSAGE:
471 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
473 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
474 if (pEditorPanel != null)
476 pEditorPanel->OnRequestMessage();
479 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
481 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
482 if (pSelectionPanel != null)
484 pSelectionPanel->OnRequestMessage();
490 case IDA_CONTEXT_MENU_SHARE_EMAIL:
492 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
494 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
495 if (pEditorPanel != null)
497 pEditorPanel->OnRequestEmail();
500 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
502 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
503 if (pSelectionPanel != null)
505 pSelectionPanel->OnRequestEmail();
511 case IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
513 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
515 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
516 if (pListEditorPanel)
518 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
519 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
520 if (__isCopyOperation)
522 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
526 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
528 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
534 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
536 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
537 (pSceneManager->GetCurrentScene()->GetPanel());
539 if (pSelectionPanel != null)
541 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
542 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
543 if (__isCopyOperation)
545 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
549 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
551 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
558 case IDA_DELETE_POPUP_DEL:
561 __pDeletePopup->SetShowState(false);
562 __pDeletePopup->Invalidate(true);
564 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
566 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
567 if (pEditorPanel != null)
569 result r = pEditorPanel->OnRequestDelete();
572 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
576 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
578 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
579 (pSceneManager->GetCurrentScene()->GetPanel());
581 if (pSelectionPanel != null)
583 result r = pSelectionPanel->OnRequestDelete();
586 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
593 case IDA_DELETE_POPUP_CANCEL:
596 __pDeletePopup->SetShowState(false);
597 __pDeletePopup->Invalidate(true);
601 case IDA_CONTEXT_MENU_ROTATE_LEFT:
603 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
605 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
606 if (pEditorPanel != null)
608 RotateMode rotateMode = ROTATE_MODE_LEFT;
609 pEditorPanel->OnRequestRotate(rotateMode);
612 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
614 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
615 (pSceneManager->GetCurrentScene()->GetPanel());
617 if (pSelectionPanel != null)
619 RotateMode rotateMode = ROTATE_MODE_LEFT;
620 pSelectionPanel->OnRotateRequested(rotateMode);
626 case IDA_CONTEXT_MENU_ROTATE_RIGHT:
628 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
630 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
631 if (pEditorPanel != null)
633 RotateMode rotateMode = ROTATE_MODE_RIGHT;
634 pEditorPanel->OnRequestRotate(rotateMode);
637 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
640 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
641 (pSceneManager->GetCurrentScene()->GetPanel());
643 if (pSelectionPanel != null)
645 RotateMode rotateMode = ROTATE_MODE_RIGHT;
646 pSelectionPanel->OnRotateRequested(rotateMode);
652 case IDA_FOOTER_CONFIRM:
654 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
656 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
657 if (pEditorPanel != null)
659 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
662 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
664 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
665 if (pEditorPanel != null)
667 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
675 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
677 if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
678 (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
680 if (__pContentDirectoryList == null)
684 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
686 String* pDirectory = static_cast<String*>
687 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
689 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
690 (pSceneManager->GetCurrentScene()->GetPanel());
692 if (pEditorPanel != null)
695 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
696 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
697 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
698 if (__isCopyOperation)
700 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
701 __pFileMove->SetCopy();
704 result r = __pFileMove->StartTimer();
709 __isCopyOperation = false;
719 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
721 if ((IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
722 (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
724 if (__pContentDirectoryList == null)
729 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
731 String* pDirectory = static_cast<String*>
732 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
734 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
735 (pSceneManager->GetCurrentScene()->GetPanel());
737 if (pSelectionPanel != null)
740 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
741 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
742 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
743 if (__isCopyOperation)
745 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
746 __pFileMove->SetCopy();
748 result r = __pFileMove->StartTimer();
753 __isCopyOperation = false;
766 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
770 FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
776 FileListEditorForm::GetOverlayStatus(void) const
782 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
785 __pPresentationModel->SetUpdateProgressStatus(false);
786 if (res != COMPLETE_SUCCESS)
788 MessageBox messageBox;
789 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_OPERATION_FAILED"), MSGBOX_STYLE_OK, 3000);
792 messageBox.ShowAndWait(modalResult);
794 SceneManager* pSceneManager = SceneManager::GetInstance();
795 AppAssert(pSceneManager);
796 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
801 FileListEditorForm::OnContentUpdated()
803 AppLogDebug("ENTER");
805 SceneManager* pSceneManager = SceneManager::GetInstance();
807 if(__pDeletePopup != null)
809 if(__pDeletePopup->IsVisible() == true)
811 __pDeletePopup->Destroy();
812 __pDeletePopup = null;
818 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
820 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
821 if (pEditorPanel != null)
823 pEditorPanel->CancelUpdateProgress();
826 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
828 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
829 if (pSelectionPanel != null)
831 pSelectionPanel->CancelUpdateProgress();
835 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
836 && pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
838 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
839 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
842 else if (_overlayMsg == false)
844 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
845 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
848 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
852 FileListEditorForm::SetUpPopup(void)
854 AppLogDebug("ENTER");
855 result r = E_SUCCESS;
857 if (__pDeletePopup != null)
859 delete __pDeletePopup;
860 __pDeletePopup = null;
863 __pDeletePopup = new (std::nothrow) Popup();
864 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
866 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
868 Label* pLabelText = new (std::nothrow) Label();
869 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
870 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
871 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
872 pLabelText->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
873 __pDeletePopup->AddControl(pLabelText);
875 Button* pDeleteButton = new (std::nothrow) Button();
876 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
877 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
878 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
879 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
880 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
881 pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
882 pDeleteButton->AddActionEventListener(*this);
883 __pDeletePopup->AddControl(pDeleteButton);
885 Button* pButtonCancel = new (std::nothrow) Button();
886 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
887 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
888 pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
889 pButtonCancel->AddActionEventListener(*this);
890 __pDeletePopup->AddControl(pButtonCancel);
891 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
897 FileListEditorForm::SetTitleText(const String& titleText)
899 AppLogDebug("ENTER");
900 Header* pHeader = GetHeader();
901 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
902 pHeader->SetTitleText(titleText);
903 pHeader->Invalidate(true);
904 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
908 FileListEditorForm::RefreshFolderList(void)
910 AppLogDebug("ENTER");
911 ContentDirectory contentDirectory;
912 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
913 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
914 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
915 result r = contentDirectory.Construct(*pContentTypeList);
918 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
921 delete pContentTypeList;
923 if (__pContentDirectoryList != null)
925 delete __pContentDirectoryList;
927 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
928 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
929 String* pDirPath = null;
930 String* pDirName = null;
931 String mediaPath = RESERVED_MEDIA_PATH;
932 int length = mediaPath.GetLength();
933 mediaPath.Remove(length-1,1);
935 int loopCount = __pContentDirectoryList->GetCount();
936 for (int i = 0; i < loopCount; ++i)
938 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
939 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
941 if ( *pDirPath == mediaPath)
943 *pDirName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
944 __pContentDirectoryNameList->Add(pDirName);
948 __pContentDirectoryNameList->Add(pDirName);
952 __pOptionMenu->RemoveAllItems();
953 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
954 IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
956 loopCount = __pContentDirectoryNameList->GetCount();
958 for (int i = 0; i < loopCount; ++i)
960 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
962 if ( *pDirName != __pPresentationModel->GetCurrentAlbumName())
964 __pOptionMenu->AddItem(*(new (std::nothrow) String(*pDirName)),
965 IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
970 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
974 FileListEditorForm::OnFormBackRequested(Form& source)
976 AppLogDebug("ENTER");
978 SceneManager* pSceneManager = SceneManager::GetInstance();
979 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
981 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
983 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
985 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
987 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
989 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
994 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
996 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
998 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1000 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1002 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1004 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1006 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1008 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1009 (pSceneManager->GetCurrentScene()->GetPanel());
1010 if (pSelectionPanel != null)
1012 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1015 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1018 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1019 SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
1024 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1027 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1031 FileListEditorForm::SetFooterButtonsState(const bool enableState)
1033 AppLogDebug("ENTER");
1034 Footer* pFooter = GetFooter();
1035 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1037 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1039 if (enableState == true)
1041 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1042 pFooter->SetItemEnabled(0, true);
1046 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1047 pFooter->SetItemEnabled(0, false);
1052 if (enableState == true)
1054 pFooter->SetItemEnabled(0, true);
1055 pFooter->SetItemEnabled(1, true);
1059 pFooter->SetItemEnabled(0, false);
1060 pFooter->SetItemEnabled(1, false);
1063 pFooter->RequestRedraw(true);
1064 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1068 FileListEditorForm::MoveToAlbum(const String& destDirectory)
1070 AppLogDebug("ENTER");
1071 result r = E_FAILURE;
1072 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1073 if (albumName != EMPTY_SPACE)
1075 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1076 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1077 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1078 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1079 delete pDirectoryList;
1081 SceneManager* pSceneManager = SceneManager::GetInstance();
1082 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1085 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1091 FileListEditorForm::SelectAllPressed(void)
1093 SceneManager* pSceneManager = SceneManager::GetInstance();
1094 pSceneManager->GetCurrentScene();
1096 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1098 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1099 if (pEditorPanel != null)
1101 pEditorPanel->OnSelectAllPressed();
1104 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1106 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1107 if (pEditorPanel != null)
1109 pEditorPanel->OnSelectAllPressed();
1112 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1114 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1115 if (pEditorPanel != null)
1117 pEditorPanel->OnSelectAllPressed();
1120 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1122 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1123 if (pEditorPanel != null)
1125 pEditorPanel->OnSelectAllPressed();
1131 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1133 if (__pPopUp != NULL)
1135 __pPopUp->SetShowState(false);
1138 SceneManager* pSceneManager = SceneManager::GetInstance();
1142 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1144 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1145 if (pEditorPanel != null)
1147 pEditorPanel->OnRequestSlideShow();
1150 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1152 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1153 (pSceneManager->GetCurrentScene()->GetPanel());
1155 if (pSelectionPanel != null)
1157 pSelectionPanel->OnRequestSlideShow();
1161 else if (index == 1)
1163 SceneManager* pSceneManager = SceneManager::GetInstance();
1164 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1166 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
1171 FileListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1173 AppLogDebug("ENTER");
1174 __pPresentationModel->RemoveContentEventListener(this);
1175 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1179 FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1181 AppLogDebug("ENTER");
1182 __pPresentationModel->AddContentEventListener(this);
1183 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1187 FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
1190 SceneManager* pSceneManager = SceneManager::GetInstance();
1191 int checkedCount = 0;
1193 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1195 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1196 if (pEditorPanel != null)
1198 checkedCount = pEditorPanel->GetItemCheckedCount();
1201 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1203 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1204 if (pSelectionPanel != null)
1206 checkedCount = pSelectionPanel->GetItemCheckedCount();
1210 if (__pContextMenuShare != null && __pContextMenuShare->GetShowState() == true )
1212 __pContextMenuShare->SetShowState(false);
1215 if ( checkedCount > 0)
1217 if ( __pOptionMenu == null )
1222 __pOptionMenu->RemoveAllItems();
1223 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
1224 IDA_CONTEXT_MENU_MORE_MOVE);
1225 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
1226 IDA_CONTEXT_MENU_MORE_COPY);
1228 if (checkedCount > 1)
1230 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
1231 IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
1234 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
1235 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
1237 __pOptionMenu->SetShowState(true);
1238 __pOptionMenu->Show();