2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file GlFileListEditorForm.cpp
19 * @brief This is the implementation file for FileListEditorForm class.
22 #include "GlAllListEditorPanel.h"
23 #include "GlAllListSelectionPanel.h"
24 #include "GlFileListEditorForm.h"
25 #include "GlFileListPresentationModel.h"
26 #include "GlGalleryApp.h"
27 #include "GlImageListEditorPanel.h"
28 #include "GlResourceManager.h"
29 #include "GlSlideSettingListener.h"
31 #include "GlVideoListEditorPanel.h"
32 #include "GlFileMoveTimer.h"
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Content;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43 using namespace Tizen::Base::Utility;
45 static const int GAP_W_POPUP_ITEM = 5;
46 static const int W_DELETE_POPUP = 600;
47 static const int H_DELETE_POPUP = 300;
48 static const int H_DELETE_LABEL = 180;
49 static const int Y_DELETE_BUTTON = 180;
50 static const int H_DELETE_BUTTON = 80;
52 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
53 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
54 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
56 FileListEditorForm::FileListEditorForm(void)
57 : __pContextMenuMore(null)
58 , __pContextMenuShare(null)
59 , __pContextEditorMenuMove(null)
60 , __pContextSelectionMenuMove(null)
61 , __pDeletePopup(null)
62 , __morePosition(Point(0, 0))
63 , __pContentDirectoryList(null)
64 , __pContentDirectoryNameList(null)
65 , __pPresentationModel(null)
67 ,__isCopyOperation(false)
71 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
74 FileListEditorForm::~FileListEditorForm(void)
77 if (__pContentDirectoryList != null)
79 delete __pContentDirectoryList;
81 if (__pContentDirectoryNameList != null)
83 delete __pContentDirectoryNameList;
86 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
90 FileListEditorForm::Initialize(void)
93 result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
94 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
100 FileListEditorForm::OnInitializing(void)
102 AppLogDebug("ENTER");
103 Header* pHeader = GetHeader();
104 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
106 __pPopUp = new (std::nothrow) SlideShowPopUp();
108 if (__pPopUp != null)
110 __pPopUp->Initialize();
111 __pPopUp->SetEventListner(this);
112 AddControl(*__pPopUp);
115 __pPresentationModel = FileListPresentationModel::GetInstance();
116 __pPresentationModel->ClearThumbnailRequests();
118 pHeader->SetStyle(HEADER_STYLE_TITLE);
119 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
121 if ((__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
122 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
124 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
125 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
126 ButtonItem selectAll;
127 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FILE_LIST_SELECT_ALL);
128 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
129 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
130 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
131 delete pNormalBitmap;
135 pHeader->AddActionEventListener(*this);
138 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
144 FileListEditorForm::InitializeFooter(void)
146 AppLogDebug("ENTER");
147 Footer* pFooter = GetFooter();
148 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
149 pFooter->RemoveAllItems();
151 result r = E_SUCCESS;
153 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
155 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
157 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
159 FooterItem footerConfirm;
160 footerConfirm.Construct(ACTION_ID_FOOTER_CONFIRM);
161 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
162 pFooter->AddItem(footerConfirm);
166 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
168 pFooter->SetBackButton();
169 SetFormBackEventListener(this);
173 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
175 ButtonItem footerMore;
176 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
177 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
178 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
180 if (pBitmapMore != null && pBitmapMoreDim != NULL)
182 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
183 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
185 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
188 delete pBitmapMoreDim;
190 FooterItem footerShare;
191 r = footerShare.Construct(ACTION_ID_FOOTER_SHARE);
192 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
193 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
194 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
196 if (pBitmapShare != null && pBitmapShareDim != null)
198 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
199 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
202 r = pFooter->AddItem(footerShare);
204 delete pBitmapShareDim;
205 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
207 FooterItem footerDelete;
208 r = footerDelete.Construct(ACTION_ID_FOOTER_DELETE);
209 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
210 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
211 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
213 if (pBitmapDelete != null && pBitmapDeleteDim != null)
215 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
216 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
219 r = pFooter->AddItem(footerDelete);
220 delete pBitmapDelete;
221 delete pBitmapDeleteDim;
222 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
224 pFooter->SetBackButton();
225 SetFormBackEventListener(this);
227 SceneManager* pSceneManager = SceneManager::GetInstance();
228 int checkedCount = 0;
230 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
232 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
233 if (pEditorPanel != null)
235 checkedCount = pEditorPanel->GetItemCheckedCount();
238 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
240 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
241 if (pSelectionPanel != null)
243 checkedCount = pSelectionPanel->GetItemCheckedCount();
247 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
249 if (__pContextMenuMore != null)
251 delete __pContextMenuMore;
252 __pContextMenuMore = null;
255 __pContextMenuMore = new (std::nothrow) ContextMenu();
256 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
258 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
259 ACTION_ID_CONTEXT_MENU_MORE_MOVE);
260 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
261 ACTION_ID_CONTEXT_MENU_MORE_COPY);
263 if (checkedCount > 1)
265 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"),
266 ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW);
269 __pContextMenuMore->SetShowState(false);
270 __pContextMenuMore->AddActionEventListener(*this);
272 __pContextMenuShare = new (std::nothrow) ContextMenu();
273 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
274 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
275 ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE);
276 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
277 ACTION_ID_CONTEXT_MENU_SHARE_EMAIL);
278 __pContextMenuShare->SetShowState(false);
279 __pContextMenuShare->AddActionEventListener(*this);
281 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
282 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
283 __pContextEditorMenuMove->AddActionEventListener(*this);
285 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
286 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
287 __pContextSelectionMenuMove->AddActionEventListener(*this);
289 if (__pContentDirectoryNameList != null)
291 delete __pContentDirectoryNameList;
292 __pContentDirectoryNameList = null;
298 pFooter->AddActionEventListener(*this);
299 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
305 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
307 AppLogDebug("ENTER");
308 if (fullPath == null)
310 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
314 String delim(DIRECTORY_SEPARATOR);
315 StringTokenizer st(fullPath,delim);
317 while (st.HasMoreTokens())
319 st.GetNextToken(token);
321 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
327 FileListEditorForm::OnTerminating(void)
329 AppLogDebug("ENTER");
331 if (__pContextMenuMore != null)
333 __pContextMenuMore->RemoveActionEventListener(*this);
334 delete __pContextMenuMore;
335 __pContextMenuMore = null;
338 if (__pContextMenuShare != null)
340 __pContextMenuShare->RemoveActionEventListener(*this);
341 delete __pContextMenuShare;
342 __pContextMenuShare = null;
345 if (__pContextEditorMenuMove != null)
347 __pContextEditorMenuMove->RemoveActionEventListener(*this);
348 delete __pContextEditorMenuMove;
349 __pContextEditorMenuMove = null;
352 if (__pContextSelectionMenuMove != null)
354 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
355 delete __pContextSelectionMenuMove;
356 __pContextSelectionMenuMove = null;
359 if (__pDeletePopup != null)
361 delete __pDeletePopup;
362 __pDeletePopup = null;
364 __overlayMsg = false;
365 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
371 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
373 AppLogDebug("ENTER(actionId=%d)", actionId);
374 SceneManager* pSceneManager = SceneManager::GetInstance();
375 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
379 case ACTION_ID_FILE_LIST_SELECT_ALL:
382 case ACTION_ID_FOOTER_MORE:
386 if (__pContextMenuMore->GetShowState() == false)
388 Rectangle rect = source.GetBounds();
389 __morePosition = Point(rect.width/8,rect.y);
390 __pContextMenuMore->SetAnchorPosition(Point(rect.width/8,rect.y));
391 __pContextMenuMore->SetShowState(true);
392 __pContextMenuMore->Show();
396 __pContextMenuMore->SetShowState(false);
400 case ACTION_ID_FOOTER_SHARE:
402 if (__pContextMenuShare->GetShowState() == false)
404 Rectangle rect = source.GetBounds();
405 __pContextMenuShare->SetAnchorPosition(Point(rect.width/8*3 ,rect.y));
406 __pContextMenuShare->SetShowState(true);
407 __pContextMenuShare->Show();
411 __pContextMenuShare->SetShowState(false);
415 case ACTION_ID_FOOTER_DELETE:
417 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
419 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
420 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
422 __pDeletePopup->SetShowState(true);
423 __pDeletePopup->Show();
427 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
429 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
430 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
432 __pDeletePopup->SetShowState(true);
433 __pDeletePopup->Show();
437 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
439 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
440 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
442 __pDeletePopup->SetShowState(true);
443 __pDeletePopup->Show();
447 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
449 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
450 (pSceneManager->GetCurrentScene()->GetPanel());
451 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
453 __pDeletePopup->SetShowState(true);
454 __pDeletePopup->Show();
460 case ACTION_ID_CONTEXT_MENU_MORE_EDIT:
464 case ACTION_ID_CONTEXT_MENU_MORE_ADD_TAG:
468 case ACTION_ID_CONTEXT_MENU_MORE_COPY:
469 case ACTION_ID_CONTEXT_MENU_MORE_MOVE:
471 if (actionId == ACTION_ID_CONTEXT_MENU_MORE_MOVE)
473 __isCopyOperation = false;
475 else if (actionId == ACTION_ID_CONTEXT_MENU_MORE_COPY)
477 __isCopyOperation = true;
480 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
482 if (__pContextEditorMenuMove->GetShowState() == false)
484 __pContextEditorMenuMove->SetAnchorPosition(__morePosition);
485 __pContextEditorMenuMove->SetShowState(true);
486 __pContextEditorMenuMove->Show();
490 __pContextEditorMenuMove->SetShowState(false);
493 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
495 if (__pContextSelectionMenuMove->GetShowState() == false)
497 __pContextSelectionMenuMove->SetAnchorPosition(__morePosition);
498 __pContextSelectionMenuMove->SetShowState(true);
499 __pContextSelectionMenuMove->Show();
503 __pContextSelectionMenuMove->SetShowState(false);
509 case ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW:
511 if (__pPopUp != null)
513 __pPopUp->SetShowState(true);
519 case ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE:
521 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
523 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
524 if (pEditorPanel != null)
526 pEditorPanel->OnRequestMessage();
529 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
531 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
532 if (pEditorPanel != null)
534 pEditorPanel->OnRequestMessage();
537 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
539 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
540 if (pEditorPanel != null)
542 pEditorPanel->OnRequestMessage();
546 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
548 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
549 if (pSelectionPanel != null)
551 pSelectionPanel->OnRequestMessage();
556 case ACTION_ID_CONTEXT_MENU_SHARE_EMAIL:
558 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
560 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
561 if (pEditorPanel != null)
563 pEditorPanel->OnRequestEmail();
566 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
568 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
569 if (pEditorPanel != null)
571 pEditorPanel->OnRequestEmail();
574 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
576 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
577 if (pEditorPanel != null)
579 pEditorPanel->OnRequestEmail();
583 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
585 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
586 if (pSelectionPanel != null)
588 pSelectionPanel->OnRequestEmail();
593 case ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
595 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
597 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
598 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
599 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
600 if(__isCopyOperation)
602 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
606 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
608 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
612 case ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
614 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
616 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
617 (pSceneManager->GetCurrentScene()->GetPanel());
618 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
619 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
620 if(__isCopyOperation)
622 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
626 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
628 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
632 case ACTION_ID_DELETE_POPUP_DEL:
634 __overlayMsg = false;
635 __pDeletePopup->SetShowState(false);
636 __pDeletePopup->Invalidate(true);
638 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
640 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
641 if (pEditorPanel != null)
643 result r = pEditorPanel->OnRequestDelete();
646 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
650 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
652 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
653 if (pEditorPanel != null)
655 pEditorPanel->OnRequestDelete();
658 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
660 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>
661 (pSceneManager->GetCurrentScene()->GetPanel());
663 if (pEditorPanel != null)
665 pEditorPanel->OnRequestDelete();
668 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
670 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
671 (pSceneManager->GetCurrentScene()->GetPanel());
673 if (pSelectionPanel != null)
675 result r = pSelectionPanel->OnRequestDelete();
678 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
684 case ACTION_ID_DELETE_POPUP_CANCEL:
686 __overlayMsg = false;
687 __pDeletePopup->SetShowState(false);
688 __pDeletePopup->Invalidate(true);
691 case ACTION_ID_FOOTER_CONFIRM:
693 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
695 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
696 if (pEditorPanel != null)
698 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
701 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
703 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
704 if (pEditorPanel != null)
706 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
713 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
715 if ((ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
716 (actionId <= ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
718 if (__pContentDirectoryList == null)
723 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
725 String* pDirectory = static_cast<String*>
726 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
728 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
729 (pSceneManager->GetCurrentScene()->GetPanel());
731 if (pEditorPanel != null)
734 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
735 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
736 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
737 if(__isCopyOperation)
739 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
740 __pFileMove->SetCopy();
743 result r = __pFileMove->StartTimer();
748 __isCopyOperation = false;
758 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
760 if ((ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
761 (actionId <= ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
763 if (__pContentDirectoryList == null)
768 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
770 String* pDirectory = static_cast<String*>
771 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
773 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
774 (pSceneManager->GetCurrentScene()->GetPanel());
776 if (pSelectionPanel != null)
779 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
780 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
781 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
782 if(__isCopyOperation)
784 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
785 __pFileMove->SetCopy();
787 result r = __pFileMove->StartTimer();
792 __isCopyOperation = false;
805 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
808 void FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
813 bool FileListEditorForm::GetOverlayStatus()
818 void FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
820 __overlayMsg = false;
821 __pPresentationModel->SetUpdateProgressStatus(false);
822 if (res != COMPLETE_SUCCESS)
824 MessageBox messageBox;
825 messageBox.Construct(L"", L"System error",
826 MSGBOX_STYLE_OK, 3000);
829 messageBox.ShowAndWait(modalResult);
830 __overlayMsg = false;
831 SceneManager* pSceneManager = SceneManager::GetInstance();
832 AppAssert(pSceneManager);
833 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
838 FileListEditorForm::OnContentUpdated()
840 AppLogDebug("ENTER");
842 if (__overlayMsg == false)
844 SceneManager* pSceneManager = SceneManager::GetInstance();
845 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
847 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
851 FileListEditorForm::SetUpPopup(void)
853 AppLogDebug("ENTER");
854 result r = E_SUCCESS;
856 if (__pDeletePopup != null)
858 delete __pDeletePopup;
859 __pDeletePopup = null;
862 __pDeletePopup = new (std::nothrow) Popup();
863 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
865 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
867 Label* pLabelText = new (std::nothrow) Label();
868 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
869 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
870 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
871 __pDeletePopup->AddControl(*pLabelText);
873 Button* pDeleteButton = new (std::nothrow) Button();
874 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
875 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
876 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
877 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
878 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
879 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
880 pDeleteButton->AddActionEventListener(*this);
881 __pDeletePopup->AddControl(*pDeleteButton);
883 Button* pButtonCancel = new (std::nothrow) Button();
884 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
885 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
886 pButtonCancel->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
887 pButtonCancel->AddActionEventListener(*this);
888 __pDeletePopup->AddControl(*pButtonCancel);
889 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
895 FileListEditorForm::SetTitleText(const String& titleText)
897 AppLogDebug("ENTER");
898 Header* pHeader = GetHeader();
899 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
900 pHeader->SetTitleText(titleText);
901 pHeader->Invalidate(true);
902 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
906 FileListEditorForm::RefreshFolderList(void)
908 AppLogDebug("ENTER");
909 ContentDirectory contentDirectory;
910 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
911 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
912 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
913 contentDirectory.Construct(*pContentTypeList);
914 delete pContentTypeList;
916 if (__pContentDirectoryList != null)
918 delete __pContentDirectoryList;
920 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
921 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
922 String* pDirPath = null;
923 String* pDirName = null;
925 int loopCount = __pContentDirectoryList->GetCount();
926 for (int i = 0; i < loopCount; ++i)
928 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
929 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
930 __pContentDirectoryNameList->Add(pDirName);
932 __pContextEditorMenuMove->RemoveAllItems();
933 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
934 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
935 __pContextSelectionMenuMove->RemoveAllItems();
936 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
937 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
939 loopCount = __pContentDirectoryNameList->GetCount();
940 for (int i = 0; i < loopCount; ++i)
942 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
943 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
944 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
945 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
946 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
948 __pContextEditorMenuMove->SetShowState(false);
949 __pContextSelectionMenuMove->SetShowState(false);
950 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
954 FileListEditorForm::OnFormBackRequested(Form& source)
956 AppLogDebug("ENTER");
958 SceneManager* pSceneManager = SceneManager::GetInstance();
959 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
961 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
963 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
965 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
967 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
969 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
974 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
976 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
978 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
980 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
982 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
984 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
986 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
988 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
989 (pSceneManager->GetCurrentScene()->GetPanel());
990 if (pSelectionPanel != null)
992 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
995 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
998 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
1003 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1006 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1010 FileListEditorForm::SetFooterButtonsState(bool enableState)
1012 AppLogDebug("ENTER");
1013 Footer* pFooter = GetFooter();
1014 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1016 if (enableState == true)
1018 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1019 pFooter->SetItemEnabled(0, true);
1020 pFooter->SetItemEnabled(1, true);
1024 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1025 pFooter->SetItemEnabled(0, false);
1026 pFooter->SetItemEnabled(1, false);
1029 pFooter->RequestRedraw(true);
1030 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1034 FileListEditorForm::MoveToAlbum(String& destDirectory)
1036 AppLogDebug("ENTER");
1037 result r = E_FAILURE;
1038 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1039 if (albumName != EMPTY_SPACE)
1041 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1042 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1043 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1044 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1045 delete pDirectoryList;
1047 SceneManager* pSceneManager = SceneManager::GetInstance();
1048 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1051 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1057 FileListEditorForm::SelectAllPressed(void)
1059 SceneManager* pSceneManager = SceneManager::GetInstance();
1060 pSceneManager->GetCurrentScene();
1062 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1064 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1065 if (pEditorPanel != null)
1067 pEditorPanel->SelectAllPressed();
1070 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1072 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1073 if (pEditorPanel != null)
1075 pEditorPanel->SelectAllPressed();
1078 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1080 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1081 if (pEditorPanel != null)
1083 pEditorPanel->SelectAllPressed();
1086 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1088 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1089 if (pEditorPanel != null)
1091 pEditorPanel->SelectAllPressed();
1097 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1099 if (__pPopUp != NULL)
1101 __pPopUp->SetShowState(false);
1104 SceneManager* pSceneManager = SceneManager::GetInstance();
1106 if (index == 0) // start slide show
1108 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1110 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1111 if (pEditorPanel != null)
1113 pEditorPanel->OnRequestSlideShow();
1116 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1118 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1119 (pSceneManager->GetCurrentScene()->GetPanel());
1121 if (pSelectionPanel != null)
1123 pSelectionPanel->OnRequestSlideShow();
1127 else if (index == 1) // go to settingsForm
1129 SceneManager* pSceneManager = SceneManager::GetInstance();
1130 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1132 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));