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 = 620;
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 : __pShareContextMenu(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 SetOrientation(ORIENTATION_AUTOMATIC);
111 AddOrientationEventListener(*this);
113 __pPopUp = new (std::nothrow) SlideShowPopUp();
115 if (__pPopUp != null)
117 __pPopUp->Initialize();
118 __pPopUp->SetEventListner(this);
119 AddControl(__pPopUp);
122 __pPresentationModel = FileListPresentationModel::GetInstance();
123 __pPresentationModel->ClearThumbnailRequests();
125 pHeader->SetStyle(HEADER_STYLE_TITLE);
126 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
128 if ((__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
129 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
131 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
132 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
133 ButtonItem selectAll;
134 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FILE_LIST_SELECT_ALL);
135 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
136 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
137 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
138 delete pNormalBitmap;
142 pHeader->AddActionEventListener(*this);
145 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
151 FileListEditorForm::InitializeFooter(void)
153 AppLogDebug("ENTER");
154 Footer* pFooter = GetFooter();
155 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
156 pFooter->RemoveAllItems();
158 result r = E_SUCCESS;
160 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
162 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
164 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
166 FooterItem footerConfirm;
167 footerConfirm.Construct(IDA_FOOTER_CONFIRM);
168 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
169 pFooter->AddItem(footerConfirm);
170 pFooter->SetItemEnabled(0, false);
171 pFooter->SetShowState(true);
172 pFooter->Invalidate(true);
176 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
177 pFooter->SetShowState(false);
178 pFooter->Invalidate(true);
181 SetFormBackEventListener(this);
186 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
187 SetFormMenuEventListener(this);
189 FooterItem footerShare;
190 r = footerShare.Construct(IDA_FOOTER_SHARE);
191 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
192 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
193 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
195 if (pBitmapShare != null && pBitmapShareDim != null)
197 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
198 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
201 r = pFooter->AddItem(footerShare);
203 delete pBitmapShareDim;
204 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
206 FooterItem footerDelete;
207 r = footerDelete.Construct(IDA_FOOTER_DELETE);
208 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
209 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
210 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
212 if (pBitmapDelete != null && pBitmapDeleteDim != null)
214 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
215 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
218 r = pFooter->AddItem(footerDelete);
219 delete pBitmapDelete;
220 delete pBitmapDeleteDim;
221 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
223 SetFormBackEventListener(this);
225 SceneManager* pSceneManager = SceneManager::GetInstance();
226 int checkedCount = 0;
228 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
230 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
231 if (pEditorPanel != null)
233 checkedCount = pEditorPanel->GetItemCheckedCount();
236 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
238 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
239 if (pSelectionPanel != null)
241 checkedCount = pSelectionPanel->GetItemCheckedCount();
245 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
247 if (__pOptionMenu != null)
249 delete __pOptionMenu;
250 __pOptionMenu = null;
253 __pOptionMenu = new (std::nothrow) OptionMenu();
254 __pOptionMenu->Construct();
255 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
256 IDA_CONTEXT_MENU_MORE_MOVE);
257 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
258 IDA_CONTEXT_MENU_MORE_COPY);
260 if (checkedCount > 1)
262 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
263 IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
266 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
267 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
269 __pOptionMenu->AddActionEventListener(*this);
271 if (__pContentDirectoryNameList != null)
273 delete __pContentDirectoryNameList;
274 __pContentDirectoryNameList = null;
280 pFooter->AddActionEventListener(*this);
281 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
287 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
289 AppLogDebug("ENTER");
290 if (fullPath == null)
292 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
296 String delim(DIRECTORY_SEPARATOR);
297 StringTokenizer st(fullPath,delim);
299 while (st.HasMoreTokens())
301 st.GetNextToken(token);
303 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
309 FileListEditorForm::OnTerminating(void)
311 AppLogDebug("ENTER");
312 __pPresentationModel->RemoveContentEventListener(this);
314 if (__pOptionMenu != null)
316 __pOptionMenu->RemoveActionEventListener(*this);
317 delete __pOptionMenu;
318 __pOptionMenu = null;
321 if (__pShareContextMenu != null)
323 __pShareContextMenu->RemoveActionEventListener(*this);
324 delete __pShareContextMenu;
325 __pShareContextMenu = null;
328 if (__pDeletePopup != null)
330 delete __pDeletePopup;
331 __pDeletePopup = null;
334 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
340 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
342 AppLogDebug("ENTER(actionId=%d)", actionId);
343 SceneManager* pSceneManager = SceneManager::GetInstance();
344 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
348 case IDA_FILE_LIST_SELECT_ALL:
352 case IDA_FOOTER_SHARE:
354 if ( __pShareContextMenu != NULL)
356 delete __pShareContextMenu;
357 __pShareContextMenu = null;
360 __pShareContextMenu = new (std::nothrow) ContextMenu();
361 __pShareContextMenu->Construct(Point(GetClientAreaBounds().width/3 + 15, GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST , CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
362 __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
363 IDA_CONTEXT_MENU_SHARE_MESSAGE);
364 __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
365 IDA_CONTEXT_MENU_SHARE_EMAIL);
366 __pShareContextMenu->SetFocusable(true);
367 __pShareContextMenu->AddActionEventListener(*this);
369 Rectangle rect = source.GetBounds();
370 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
372 __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
376 __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
379 __pShareContextMenu->SetShowState(true);
380 __pShareContextMenu->Show();
385 case IDA_FOOTER_DELETE:
387 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
389 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
390 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
392 __pDeletePopup->SetShowState(true);
393 __pDeletePopup->Show();
397 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
399 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
400 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
402 __pDeletePopup->SetShowState(true);
403 __pDeletePopup->Show();
407 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
409 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
410 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
412 __pDeletePopup->SetShowState(true);
413 __pDeletePopup->Show();
417 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
419 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
420 (pSceneManager->GetCurrentScene()->GetPanel());
421 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
423 __pDeletePopup->SetShowState(true);
424 __pDeletePopup->Show();
431 case IDA_CONTEXT_MENU_MORE_EDIT:
436 case IDA_CONTEXT_MENU_MORE_ADD_TAG:
441 case IDA_CONTEXT_MENU_MORE_COPY:
443 case IDA_CONTEXT_MENU_MORE_MOVE:
445 if (actionId == IDA_CONTEXT_MENU_MORE_MOVE)
447 __isCopyOperation = false;
449 else if (actionId == IDA_CONTEXT_MENU_MORE_COPY)
451 __isCopyOperation = true;
456 __pOptionMenu->SetShowState(true);
457 __pOptionMenu->Show();
463 case IDA_CONTEXT_MENU_MORE_SLIDE_SHOW:
465 if (__pPopUp != null)
467 __pPopUp->SetShowState(true);
473 case IDA_CONTEXT_MENU_SHARE_MESSAGE:
475 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
477 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
478 if (pEditorPanel != null)
480 pEditorPanel->OnRequestMessage();
483 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
485 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
486 if (pSelectionPanel != null)
488 pSelectionPanel->OnRequestMessage();
494 case IDA_CONTEXT_MENU_SHARE_EMAIL:
496 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
498 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
499 if (pEditorPanel != null)
501 pEditorPanel->OnRequestEmail();
504 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
506 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
507 if (pSelectionPanel != null)
509 pSelectionPanel->OnRequestEmail();
515 case IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
517 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
519 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
520 if (pListEditorPanel)
522 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
523 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
524 if (__isCopyOperation)
526 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
530 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
532 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
538 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
540 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
541 (pSceneManager->GetCurrentScene()->GetPanel());
543 if (pSelectionPanel != null)
545 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
546 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
547 if (__isCopyOperation)
549 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
553 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
555 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
562 case IDA_DELETE_POPUP_DEL:
565 __pDeletePopup->SetShowState(false);
566 __pDeletePopup->Invalidate(true);
568 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
570 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
571 if (pEditorPanel != null)
573 result r = pEditorPanel->OnRequestDelete();
576 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
580 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
582 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
583 (pSceneManager->GetCurrentScene()->GetPanel());
585 if (pSelectionPanel != null)
587 result r = pSelectionPanel->OnRequestDelete();
590 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
597 case IDA_DELETE_POPUP_CANCEL:
600 __pDeletePopup->SetShowState(false);
601 __pDeletePopup->Invalidate(true);
605 case IDA_CONTEXT_MENU_ROTATE_LEFT:
607 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
609 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
610 if (pEditorPanel != null)
612 RotateMode rotateMode = ROTATE_MODE_LEFT;
613 pEditorPanel->OnRequestRotate(rotateMode);
616 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
618 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
619 (pSceneManager->GetCurrentScene()->GetPanel());
621 if (pSelectionPanel != null)
623 RotateMode rotateMode = ROTATE_MODE_LEFT;
624 pSelectionPanel->OnRotateRequested(rotateMode);
630 case IDA_CONTEXT_MENU_ROTATE_RIGHT:
632 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
634 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
635 if (pEditorPanel != null)
637 RotateMode rotateMode = ROTATE_MODE_RIGHT;
638 pEditorPanel->OnRequestRotate(rotateMode);
641 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
644 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
645 (pSceneManager->GetCurrentScene()->GetPanel());
647 if (pSelectionPanel != null)
649 RotateMode rotateMode = ROTATE_MODE_RIGHT;
650 pSelectionPanel->OnRotateRequested(rotateMode);
656 case IDA_FOOTER_CONFIRM:
658 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
660 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
661 if (pEditorPanel != null)
663 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
666 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
668 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
669 if (pEditorPanel != null)
671 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
679 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
681 if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
682 (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
684 if (__pContentDirectoryList == null)
688 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
690 String* pDirectory = static_cast<String*>
691 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
693 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
694 (pSceneManager->GetCurrentScene()->GetPanel());
696 if (pEditorPanel != null)
699 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
700 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
701 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
702 if (__isCopyOperation)
704 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
705 __pFileMove->SetCopy();
708 result r = __pFileMove->StartTimer();
713 __isCopyOperation = false;
723 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
725 if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
726 (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
728 if (__pContentDirectoryList == null)
733 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
735 String* pDirectory = static_cast<String*>
736 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
738 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
739 (pSceneManager->GetCurrentScene()->GetPanel());
741 if (pSelectionPanel != null)
744 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
745 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
746 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
747 if (__isCopyOperation)
749 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
750 __pFileMove->SetCopy();
752 result r = __pFileMove->StartTimer();
757 __isCopyOperation = false;
770 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
774 FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
780 FileListEditorForm::GetOverlayStatus(void) const
786 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
789 __pPresentationModel->SetUpdateProgressStatus(false);
790 if (res != COMPLETE_SUCCESS)
792 MessageBox messageBox;
793 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_OPERATION_FAILED"), MSGBOX_STYLE_OK, 3000);
796 messageBox.ShowAndWait(modalResult);
798 SceneManager* pSceneManager = SceneManager::GetInstance();
799 AppAssert(pSceneManager);
800 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
805 FileListEditorForm::OnContentUpdated()
807 AppLogDebug("ENTER");
809 SceneManager* pSceneManager = SceneManager::GetInstance();
811 if(__pDeletePopup != null)
813 if(__pDeletePopup->IsVisible() == true)
815 __pDeletePopup->Destroy();
816 __pDeletePopup = null;
822 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
824 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
825 if (pEditorPanel != null)
827 pEditorPanel->CancelUpdateProgress();
830 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
832 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
833 if (pSelectionPanel != null)
835 pSelectionPanel->CancelUpdateProgress();
839 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
840 && pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
842 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
843 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
846 else if (_overlayMsg == false)
848 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
849 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
852 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
856 FileListEditorForm::SetUpPopup(void)
858 AppLogDebug("ENTER");
859 result r = E_SUCCESS;
861 if (__pDeletePopup != null)
863 delete __pDeletePopup;
864 __pDeletePopup = null;
867 __pDeletePopup = new (std::nothrow) Popup();
868 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
869 __pDeletePopup->SetPropagatedKeyEventListener(this);
871 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
873 Label* pLabelText = new (std::nothrow) Label();
874 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
875 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
876 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
877 pLabelText->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
878 __pDeletePopup->AddControl(pLabelText);
880 Button* pDeleteButton = new (std::nothrow) Button();
881 pDeleteButton->Construct(Rectangle(10, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
882 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
883 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
884 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
885 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
886 pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
887 pDeleteButton->AddActionEventListener(*this);
888 __pDeletePopup->AddControl(pDeleteButton);
890 Button* pButtonCancel = new (std::nothrow) Button();
891 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
892 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
893 pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
894 pButtonCancel->AddActionEventListener(*this);
895 __pDeletePopup->AddControl(pButtonCancel);
896 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
902 FileListEditorForm::SetTitleText(const String& titleText)
904 AppLogDebug("ENTER");
905 Header* pHeader = GetHeader();
906 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
907 pHeader->SetTitleText(titleText);
908 pHeader->Invalidate(true);
909 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
913 FileListEditorForm::RefreshFolderList(void)
915 AppLogDebug("ENTER");
916 ContentDirectory contentDirectory;
917 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
918 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
919 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
920 result r = contentDirectory.Construct(*pContentTypeList);
923 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
926 delete pContentTypeList;
928 if (__pContentDirectoryList != null)
930 delete __pContentDirectoryList;
932 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
933 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
934 String* pDirPath = null;
935 String* pDirName = null;
936 String mediaPath = RESERVED_MEDIA_PATH;
937 int length = mediaPath.GetLength();
938 mediaPath.Remove(length-1,1);
940 int loopCount = __pContentDirectoryList->GetCount();
941 for (int i = 0; i < loopCount; ++i)
943 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
944 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
946 if ( *pDirPath == mediaPath)
948 *pDirName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
949 __pContentDirectoryNameList->Add(pDirName);
953 __pContentDirectoryNameList->Add(pDirName);
957 __pOptionMenu->RemoveAllItems();
958 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
959 IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
961 loopCount = __pContentDirectoryNameList->GetCount();
963 for (int i = 0; i < loopCount; ++i)
965 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
967 if ( *pDirName != __pPresentationModel->GetCurrentAlbumName())
969 __pOptionMenu->AddItem(*(new (std::nothrow) String(*pDirName)),
970 IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
975 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
979 FileListEditorForm::OnFormBackRequested(Form& source)
981 AppLogDebug("ENTER");
983 SceneManager* pSceneManager = SceneManager::GetInstance();
984 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
986 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
988 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
990 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
992 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
994 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
999 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1001 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1003 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1005 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1007 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1009 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1011 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1013 if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true )
1015 __pShareContextMenu->SetShowState(false);
1019 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1020 (pSceneManager->GetCurrentScene()->GetPanel());
1021 if (pSelectionPanel != null)
1023 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1026 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1029 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1030 SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
1038 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1041 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1045 FileListEditorForm::SetFooterButtonsState(const bool enableState)
1047 AppLogDebug("ENTER");
1048 Footer* pFooter = GetFooter();
1049 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1051 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1053 if (enableState == true)
1055 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1056 pFooter->SetItemEnabled(0, true);
1060 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1061 pFooter->SetItemEnabled(0, false);
1066 if (enableState == true)
1068 pFooter->SetItemEnabled(0, true);
1069 pFooter->SetItemEnabled(1, true);
1073 pFooter->SetItemEnabled(0, false);
1074 pFooter->SetItemEnabled(1, false);
1077 pFooter->RequestRedraw(true);
1078 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1082 FileListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1084 SceneManager* pSceneManager = SceneManager::GetInstance();
1085 pSceneManager->GetCurrentScene();
1087 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1089 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1090 if (pEditorPanel != null)
1092 pEditorPanel->ChangeOrientation();
1095 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1097 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1098 if (pEditorPanel != null)
1100 pEditorPanel->ChangeOrientation();
1103 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1105 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1106 if (pEditorPanel != null)
1108 pEditorPanel->ChangeOrientation();
1111 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1113 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1114 if (pEditorPanel != null)
1116 pEditorPanel->ChangeOrientation();
1122 FileListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
1124 AppLogDebug("ENTER");
1126 if(keyEventInfo.GetKeyCode() == KEY_BACK)
1128 _overlayMsg = false;
1129 __pDeletePopup->SetShowState(false);
1130 __pDeletePopup->Invalidate(true);
1136 FileListEditorForm::MoveToAlbum(const String& destDirectory)
1138 AppLogDebug("ENTER");
1139 result r = E_FAILURE;
1140 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1141 if (albumName != EMPTY_SPACE)
1143 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1144 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1145 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1146 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1147 delete pDirectoryList;
1149 SceneManager* pSceneManager = SceneManager::GetInstance();
1150 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1153 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1159 FileListEditorForm::SelectAllPressed(void)
1161 SceneManager* pSceneManager = SceneManager::GetInstance();
1162 pSceneManager->GetCurrentScene();
1164 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1166 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1167 if (pEditorPanel != null)
1169 pEditorPanel->OnSelectAllPressed();
1172 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1174 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1175 if (pEditorPanel != null)
1177 pEditorPanel->OnSelectAllPressed();
1180 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1182 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1183 if (pEditorPanel != null)
1185 pEditorPanel->OnSelectAllPressed();
1188 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1190 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1191 if (pEditorPanel != null)
1193 pEditorPanel->OnSelectAllPressed();
1199 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1201 if (__pPopUp != NULL)
1203 __pPopUp->SetShowState(false);
1206 SceneManager* pSceneManager = SceneManager::GetInstance();
1210 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1212 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1213 if (pEditorPanel != null)
1215 pEditorPanel->OnRequestSlideShow();
1218 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1220 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1221 (pSceneManager->GetCurrentScene()->GetPanel());
1223 if (pSelectionPanel != null)
1225 pSelectionPanel->OnRequestSlideShow();
1229 else if (index == 1)
1231 SceneManager* pSceneManager = SceneManager::GetInstance();
1232 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1234 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
1239 FileListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1241 AppLogDebug("ENTER");
1242 __pPresentationModel->RemoveContentEventListener(this);
1243 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1247 FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1249 AppLogDebug("ENTER");
1250 __pPresentationModel->AddContentEventListener(this);
1251 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1255 FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
1258 SceneManager* pSceneManager = SceneManager::GetInstance();
1259 int checkedCount = 0;
1261 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1263 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1264 if (pEditorPanel != null)
1266 checkedCount = pEditorPanel->GetItemCheckedCount();
1269 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1271 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1272 if (pSelectionPanel != null)
1274 checkedCount = pSelectionPanel->GetItemCheckedCount();
1278 if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true )
1280 __pShareContextMenu->SetShowState(false);
1283 if ( checkedCount > 0)
1285 if ( __pOptionMenu == null )
1290 __pOptionMenu->RemoveAllItems();
1291 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
1292 IDA_CONTEXT_MENU_MORE_MOVE);
1293 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
1294 IDA_CONTEXT_MENU_MORE_COPY);
1296 if (checkedCount > 1)
1298 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
1299 IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
1302 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
1303 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
1305 __pOptionMenu->SetShowState(true);
1306 __pOptionMenu->Show();