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();
117 //__pPresentationModel->AddContentEventListener(this);
119 pHeader->SetStyle(HEADER_STYLE_TITLE);
120 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
122 if ((__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
123 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
125 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
126 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
127 ButtonItem selectAll;
128 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FILE_LIST_SELECT_ALL);
129 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
130 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
131 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
132 delete pNormalBitmap;
136 pHeader->AddActionEventListener(*this);
139 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
145 FileListEditorForm::InitializeFooter(void)
147 AppLogDebug("ENTER");
148 Footer* pFooter = GetFooter();
149 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
150 pFooter->RemoveAllItems();
152 result r = E_SUCCESS;
154 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
156 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
158 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
160 FooterItem footerConfirm;
161 footerConfirm.Construct(ACTION_ID_FOOTER_CONFIRM);
162 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
163 pFooter->AddItem(footerConfirm);
167 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
169 pFooter->SetBackButton();
170 SetFormBackEventListener(this);
174 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
176 ButtonItem footerMore;
177 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
178 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
179 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
181 if (pBitmapMore != null && pBitmapMoreDim != NULL)
183 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
184 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
186 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
189 delete pBitmapMoreDim;
191 FooterItem footerShare;
192 r = footerShare.Construct(ACTION_ID_FOOTER_SHARE);
193 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
194 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
195 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
197 if (pBitmapShare != null && pBitmapShareDim != null)
199 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
200 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
203 r = pFooter->AddItem(footerShare);
205 delete pBitmapShareDim;
206 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
208 FooterItem footerDelete;
209 r = footerDelete.Construct(ACTION_ID_FOOTER_DELETE);
210 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
211 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
212 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
214 if (pBitmapDelete != null && pBitmapDeleteDim != null)
216 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
217 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
220 r = pFooter->AddItem(footerDelete);
221 delete pBitmapDelete;
222 delete pBitmapDeleteDim;
223 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
225 pFooter->SetBackButton();
226 SetFormBackEventListener(this);
228 SceneManager* pSceneManager = SceneManager::GetInstance();
229 int checkedCount = 0;
231 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
233 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
234 if (pEditorPanel != null)
236 checkedCount = pEditorPanel->GetItemCheckedCount();
239 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
241 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
242 if (pSelectionPanel != null)
244 checkedCount = pSelectionPanel->GetItemCheckedCount();
248 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
250 if (__pContextMenuMore != null)
252 delete __pContextMenuMore;
253 __pContextMenuMore = null;
256 __pContextMenuMore = new (std::nothrow) ContextMenu();
257 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
259 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
260 ACTION_ID_CONTEXT_MENU_MORE_MOVE);
261 __pContextMenuMore->AddItem((L"Copy"),
262 ACTION_ID_CONTEXT_MENU_MORE_COPY);
264 if (checkedCount > 1)
266 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"),
267 ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW);
270 __pContextMenuMore->SetShowState(false);
271 __pContextMenuMore->AddActionEventListener(*this);
273 __pContextMenuShare = new (std::nothrow) ContextMenu();
274 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
275 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
276 ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE);
277 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
278 ACTION_ID_CONTEXT_MENU_SHARE_EMAIL);
279 __pContextMenuShare->SetShowState(false);
280 __pContextMenuShare->AddActionEventListener(*this);
282 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
283 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
284 __pContextEditorMenuMove->AddActionEventListener(*this);
286 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
287 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
288 __pContextSelectionMenuMove->AddActionEventListener(*this);
290 if (__pContentDirectoryNameList != null)
292 delete __pContentDirectoryNameList;
293 __pContentDirectoryNameList = null;
299 pFooter->AddActionEventListener(*this);
300 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
306 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
308 AppLogDebug("ENTER");
309 if (fullPath == null)
311 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
315 String delim(DIRECTORY_SEPARATOR);
316 StringTokenizer st(fullPath,delim);
318 while (st.HasMoreTokens())
320 st.GetNextToken(token);
322 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
328 FileListEditorForm::OnTerminating(void)
330 AppLogDebug("ENTER");
332 //__pPresentationModel->RemoveContentEventListener(this);
333 if (__pContextMenuMore != null)
335 __pContextMenuMore->RemoveActionEventListener(*this);
336 delete __pContextMenuMore;
337 __pContextMenuMore = null;
340 if (__pContextMenuShare != null)
342 __pContextMenuShare->RemoveActionEventListener(*this);
343 delete __pContextMenuShare;
344 __pContextMenuShare = null;
347 if (__pContextEditorMenuMove != null)
349 __pContextEditorMenuMove->RemoveActionEventListener(*this);
350 delete __pContextEditorMenuMove;
351 __pContextEditorMenuMove = null;
354 if (__pContextSelectionMenuMove != null)
356 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
357 delete __pContextSelectionMenuMove;
358 __pContextSelectionMenuMove = null;
361 if (__pDeletePopup != null)
363 delete __pDeletePopup;
364 __pDeletePopup = null;
366 __overlayMsg = false;
367 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
373 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
375 AppLogDebug("ENTER(actionId=%d)", actionId);
376 SceneManager* pSceneManager = SceneManager::GetInstance();
377 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
381 case ACTION_ID_FILE_LIST_SELECT_ALL:
384 case ACTION_ID_FOOTER_MORE:
388 if (__pContextMenuMore->GetShowState() == false)
390 Rectangle rect = source.GetBounds();
391 __morePosition = Point(rect.width/8,rect.y);
392 __pContextMenuMore->SetAnchorPosition(Point(rect.width/8,rect.y));
393 __pContextMenuMore->SetShowState(true);
394 __pContextMenuMore->Show();
398 __pContextMenuMore->SetShowState(false);
402 case ACTION_ID_FOOTER_SHARE:
404 if (__pContextMenuShare->GetShowState() == false)
406 Rectangle rect = source.GetBounds();
407 __pContextMenuShare->SetAnchorPosition(Point(rect.width/8*3 ,rect.y));
408 __pContextMenuShare->SetShowState(true);
409 __pContextMenuShare->Show();
413 __pContextMenuShare->SetShowState(false);
417 case ACTION_ID_FOOTER_DELETE:
419 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
421 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
422 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
424 __pDeletePopup->SetShowState(true);
425 __pDeletePopup->Show();
429 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
431 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
432 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
434 __pDeletePopup->SetShowState(true);
435 __pDeletePopup->Show();
439 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
441 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
442 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
444 __pDeletePopup->SetShowState(true);
445 __pDeletePopup->Show();
449 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
451 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
452 (pSceneManager->GetCurrentScene()->GetPanel());
453 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
455 __pDeletePopup->SetShowState(true);
456 __pDeletePopup->Show();
462 case ACTION_ID_CONTEXT_MENU_MORE_EDIT:
466 case ACTION_ID_CONTEXT_MENU_MORE_ADD_TAG:
470 case ACTION_ID_CONTEXT_MENU_MORE_COPY:
472 //__pFileMove->SetCopy();
473 __isCopyOperation = true;
474 //Fall through to next case.
476 case ACTION_ID_CONTEXT_MENU_MORE_MOVE:
478 if(actionId == ACTION_ID_CONTEXT_MENU_MORE_MOVE)
480 __isCopyOperation = false;
483 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
485 if (__pContextEditorMenuMove->GetShowState() == false)
487 __pContextEditorMenuMove->SetAnchorPosition(__morePosition);
488 __pContextEditorMenuMove->SetShowState(true);
489 __pContextEditorMenuMove->Show();
493 __pContextEditorMenuMove->SetShowState(false);
496 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
498 if (__pContextSelectionMenuMove->GetShowState() == false)
500 __pContextSelectionMenuMove->SetAnchorPosition(__morePosition);
501 __pContextSelectionMenuMove->SetShowState(true);
502 __pContextSelectionMenuMove->Show();
506 __pContextSelectionMenuMove->SetShowState(false);
512 case ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW:
514 if (__pPopUp != null)
516 __pPopUp->SetShowState(true);
522 case ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE:
524 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
526 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
527 if (pEditorPanel != null)
529 pEditorPanel->OnRequestMessage();
532 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
534 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
535 if (pEditorPanel != null)
537 pEditorPanel->OnRequestMessage();
540 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
542 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
543 if (pEditorPanel != null)
545 pEditorPanel->OnRequestMessage();
549 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
551 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
552 if (pSelectionPanel != null)
554 pSelectionPanel->OnRequestMessage();
559 case ACTION_ID_CONTEXT_MENU_SHARE_EMAIL:
561 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
563 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
564 if (pEditorPanel != null)
566 pEditorPanel->OnRequestEmail();
569 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
571 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
572 if (pEditorPanel != null)
574 pEditorPanel->OnRequestEmail();
577 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
579 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
580 if (pEditorPanel != null)
582 pEditorPanel->OnRequestEmail();
586 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
588 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
589 if (pSelectionPanel != null)
591 pSelectionPanel->OnRequestEmail();
596 case ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
598 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
600 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
601 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
602 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
603 if(__isCopyOperation)
605 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
609 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
611 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
615 case ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
617 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
619 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
620 (pSceneManager->GetCurrentScene()->GetPanel());
621 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
622 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
623 if(__isCopyOperation)
625 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
629 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
631 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
635 case ACTION_ID_DELETE_POPUP_DEL:
637 __overlayMsg = false;
638 __pDeletePopup->SetShowState(false);
639 __pDeletePopup->Invalidate(true);
641 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
643 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
644 if (pEditorPanel != null)
646 result r = pEditorPanel->OnRequestDelete();
649 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
653 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
655 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
656 if (pEditorPanel != null)
658 pEditorPanel->OnRequestDelete();
661 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
663 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>
664 (pSceneManager->GetCurrentScene()->GetPanel());
666 if (pEditorPanel != null)
668 pEditorPanel->OnRequestDelete();
671 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
673 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
674 (pSceneManager->GetCurrentScene()->GetPanel());
676 if (pSelectionPanel != null)
678 result r = pSelectionPanel->OnRequestDelete();
681 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
687 case ACTION_ID_DELETE_POPUP_CANCEL:
689 __overlayMsg = false;
690 __pDeletePopup->SetShowState(false);
691 __pDeletePopup->Invalidate(true);
694 case ACTION_ID_FOOTER_CONFIRM:
696 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
698 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
699 if (pEditorPanel != null)
701 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
704 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
706 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
707 if (pEditorPanel != null)
709 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
716 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
718 if ((ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
719 (actionId <= ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
721 if (__pContentDirectoryList == null)
726 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
728 String* pDirectory = static_cast<String*>
729 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
731 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
732 (pSceneManager->GetCurrentScene()->GetPanel());
734 if (pEditorPanel != null)
737 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
738 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
739 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
740 if(__isCopyOperation)
742 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
743 __pFileMove->SetCopy();
746 result r = __pFileMove->StartTimer();
751 __isCopyOperation = false;
761 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
763 if ((ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
764 (actionId <= ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
766 if (__pContentDirectoryList == null)
771 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
773 String* pDirectory = static_cast<String*>
774 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
776 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
777 (pSceneManager->GetCurrentScene()->GetPanel());
779 if (pSelectionPanel != null)
782 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
783 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
784 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
785 if(__isCopyOperation)
787 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
788 __pFileMove->SetCopy();
790 result r = __pFileMove->StartTimer();
795 __isCopyOperation = false;
808 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
811 void FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
816 bool FileListEditorForm::GetOverlayStatus()
821 void FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
823 __overlayMsg = false;
824 __pPresentationModel->SetUpdateProgressStatus(false);
825 if (res != COMPLETE_SUCCESS)
827 MessageBox messageBox;
828 messageBox.Construct(L"", L"System error",
829 MSGBOX_STYLE_OK, 3000);
832 messageBox.ShowAndWait(modalResult);
833 __overlayMsg = false;
834 SceneManager* pSceneManager = SceneManager::GetInstance();
835 AppAssert(pSceneManager);
836 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
841 FileListEditorForm::OnContentUpdated()
843 AppLogDebug("ENTER");
845 if (__overlayMsg == false)
847 SceneManager* pSceneManager = SceneManager::GetInstance();
848 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
850 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
854 FileListEditorForm::SetUpPopup(void)
856 AppLogDebug("ENTER");
857 result r = E_SUCCESS;
859 if (__pDeletePopup != null)
861 delete __pDeletePopup;
862 __pDeletePopup = null;
865 __pDeletePopup = new (std::nothrow) Popup();
866 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
868 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
870 Label* pLabelText = new (std::nothrow) Label();
871 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
872 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
873 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
874 __pDeletePopup->AddControl(*pLabelText);
876 Button* pDeleteButton = new (std::nothrow) Button();
877 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
878 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
879 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
880 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
881 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
882 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
883 pDeleteButton->AddActionEventListener(*this);
884 __pDeletePopup->AddControl(*pDeleteButton);
886 Button* pButtonCancel = new (std::nothrow) Button();
887 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
888 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
889 pButtonCancel->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
890 pButtonCancel->AddActionEventListener(*this);
891 __pDeletePopup->AddControl(*pButtonCancel);
892 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
898 FileListEditorForm::SetTitleText(const String& titleText)
900 AppLogDebug("ENTER");
901 Header* pHeader = GetHeader();
902 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
903 pHeader->SetTitleText(titleText);
904 pHeader->Invalidate(true);
905 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
909 FileListEditorForm::RefreshFolderList(void)
911 AppLogDebug("ENTER");
912 ContentDirectory contentDirectory;
913 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
914 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
915 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
916 contentDirectory.Construct(*pContentTypeList);
917 delete pContentTypeList;
919 if (__pContentDirectoryList != null)
921 delete __pContentDirectoryList;
923 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
924 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
925 String* pDirPath = null;
926 String* pDirName = null;
928 int loopCount = __pContentDirectoryList->GetCount();
929 for (int i = 0; i < loopCount; ++i)
931 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
932 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
933 __pContentDirectoryNameList->Add(pDirName);
935 __pContextEditorMenuMove->RemoveAllItems();
936 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
937 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
938 __pContextSelectionMenuMove->RemoveAllItems();
939 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
940 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
942 loopCount = __pContentDirectoryNameList->GetCount();
943 for (int i = 0; i < loopCount; ++i)
945 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
946 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
947 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
948 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
949 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
951 __pContextEditorMenuMove->SetShowState(false);
952 __pContextSelectionMenuMove->SetShowState(false);
953 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
957 FileListEditorForm::OnFormBackRequested(Form& source)
959 AppLogDebug("ENTER");
961 SceneManager* pSceneManager = SceneManager::GetInstance();
962 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
964 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
966 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
968 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
970 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
972 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
977 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
979 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
981 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
983 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
985 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
987 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
989 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
991 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
992 (pSceneManager->GetCurrentScene()->GetPanel());
993 if (pSelectionPanel != null)
995 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
998 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1001 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
1006 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1009 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1013 FileListEditorForm::SetFooterButtonsState(bool enableState)
1015 AppLogDebug("ENTER");
1016 Footer* pFooter = GetFooter();
1017 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1019 if (enableState == true)
1021 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1022 pFooter->SetItemEnabled(0, true);
1023 pFooter->SetItemEnabled(1, true);
1027 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1028 pFooter->SetItemEnabled(0, false);
1029 pFooter->SetItemEnabled(1, false);
1032 pFooter->RequestRedraw(true);
1033 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1037 FileListEditorForm::MoveToAlbum(String& destDirectory)
1039 AppLogDebug("ENTER");
1040 result r = E_FAILURE;
1041 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1042 if (albumName != EMPTY_SPACE)
1044 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1045 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1046 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1047 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1048 delete pDirectoryList;
1050 SceneManager* pSceneManager = SceneManager::GetInstance();
1051 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1054 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1060 FileListEditorForm::SelectAllPressed(void)
1062 SceneManager* pSceneManager = SceneManager::GetInstance();
1063 pSceneManager->GetCurrentScene();
1065 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1067 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1068 if (pEditorPanel != null)
1070 pEditorPanel->SelectAllPressed();
1073 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1075 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1076 if (pEditorPanel != null)
1078 pEditorPanel->SelectAllPressed();
1081 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1083 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1084 if (pEditorPanel != null)
1086 pEditorPanel->SelectAllPressed();
1089 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1091 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1092 if (pEditorPanel != null)
1094 pEditorPanel->SelectAllPressed();
1100 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1102 if (__pPopUp != NULL)
1104 __pPopUp->SetShowState(false);
1107 SceneManager* pSceneManager = SceneManager::GetInstance();
1109 if (index == 0) // start slide show
1111 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1113 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1114 if (pEditorPanel != null)
1116 pEditorPanel->OnRequestSlideShow();
1119 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1121 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1122 (pSceneManager->GetCurrentScene()->GetPanel());
1124 if (pSelectionPanel != null)
1126 pSelectionPanel->OnRequestSlideShow();
1130 else if (index == 1) // go to settingsForm
1132 SceneManager* pSceneManager = SceneManager::GetInstance();
1133 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1135 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));