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)
70 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
73 FileListEditorForm::~FileListEditorForm(void)
76 if (__pContentDirectoryList != null)
78 delete __pContentDirectoryList;
80 if (__pContentDirectoryNameList != null)
82 delete __pContentDirectoryNameList;
85 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
89 FileListEditorForm::Initialize(void)
92 result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
93 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
99 FileListEditorForm::OnInitializing(void)
101 AppLogDebug("ENTER");
102 Header* pHeader = GetHeader();
103 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
105 __pPopUp = new (std::nothrow) SlideShowPopUp();
107 if (__pPopUp != null)
109 __pPopUp->Initialize();
110 __pPopUp->SetEventListner(this);
111 AddControl(*__pPopUp);
114 __pPresentationModel = FileListPresentationModel::GetInstance();
115 __pPresentationModel->ClearThumbnailRequests();
116 __pPresentationModel->AddContentEventListener(this);
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);
261 if (checkedCount > 1)
263 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"),
264 ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW);
267 __pContextMenuMore->SetShowState(false);
268 __pContextMenuMore->AddActionEventListener(*this);
270 __pContextMenuShare = new (std::nothrow) ContextMenu();
271 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
272 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
273 ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE);
274 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
275 ACTION_ID_CONTEXT_MENU_SHARE_EMAIL);
276 __pContextMenuShare->SetShowState(false);
277 __pContextMenuShare->AddActionEventListener(*this);
279 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
280 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
281 __pContextEditorMenuMove->AddActionEventListener(*this);
283 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
284 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
285 __pContextSelectionMenuMove->AddActionEventListener(*this);
287 if (__pContentDirectoryNameList != null)
289 delete __pContentDirectoryNameList;
290 __pContentDirectoryNameList = null;
296 pFooter->AddActionEventListener(*this);
297 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
303 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
305 AppLogDebug("ENTER");
306 if (fullPath == null)
308 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
312 String delim(DIRECTORY_SEPARATOR);
313 StringTokenizer st(fullPath,delim);
315 while (st.HasMoreTokens())
317 st.GetNextToken(token);
319 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
325 FileListEditorForm::OnTerminating(void)
327 AppLogDebug("ENTER");
329 __pPresentationModel->RemoveContentEventListener(this);
330 if (__pContextMenuMore != null)
332 __pContextMenuMore->RemoveActionEventListener(*this);
333 delete __pContextMenuMore;
334 __pContextMenuMore = null;
337 if (__pContextMenuShare != null)
339 __pContextMenuShare->RemoveActionEventListener(*this);
340 delete __pContextMenuShare;
341 __pContextMenuShare = null;
344 if (__pContextEditorMenuMove != null)
346 __pContextEditorMenuMove->RemoveActionEventListener(*this);
347 delete __pContextEditorMenuMove;
348 __pContextEditorMenuMove = null;
351 if (__pContextSelectionMenuMove != null)
353 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
354 delete __pContextSelectionMenuMove;
355 __pContextSelectionMenuMove = null;
358 if (__pDeletePopup != null)
360 delete __pDeletePopup;
361 __pDeletePopup = null;
363 __overlayMsg = false;
364 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
370 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
372 AppLogDebug("ENTER(actionId=%d)", actionId);
373 SceneManager* pSceneManager = SceneManager::GetInstance();
374 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
378 case ACTION_ID_FILE_LIST_SELECT_ALL:
381 case ACTION_ID_FOOTER_MORE:
385 if (__pContextMenuMore->GetShowState() == false)
387 Rectangle rect = source.GetBounds();
388 __morePosition = Point(rect.width/8,rect.y);
389 __pContextMenuMore->SetAnchorPosition(Point(rect.width/8,rect.y));
390 __pContextMenuMore->SetShowState(true);
391 __pContextMenuMore->Show();
395 __pContextMenuMore->SetShowState(false);
399 case ACTION_ID_FOOTER_SHARE:
401 if (__pContextMenuShare->GetShowState() == false)
403 Rectangle rect = source.GetBounds();
404 __pContextMenuShare->SetAnchorPosition(Point(rect.width/8*3 ,rect.y));
405 __pContextMenuShare->SetShowState(true);
406 __pContextMenuShare->Show();
410 __pContextMenuShare->SetShowState(false);
414 case ACTION_ID_FOOTER_DELETE:
416 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
418 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
419 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
421 __pDeletePopup->SetShowState(true);
422 __pDeletePopup->Show();
426 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
428 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
429 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
431 __pDeletePopup->SetShowState(true);
432 __pDeletePopup->Show();
436 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
438 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
439 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
441 __pDeletePopup->SetShowState(true);
442 __pDeletePopup->Show();
446 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
448 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
449 (pSceneManager->GetCurrentScene()->GetPanel());
450 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
452 __pDeletePopup->SetShowState(true);
453 __pDeletePopup->Show();
459 case ACTION_ID_CONTEXT_MENU_MORE_EDIT:
463 case ACTION_ID_CONTEXT_MENU_MORE_ADD_TAG:
467 case ACTION_ID_CONTEXT_MENU_MORE_MOVE:
470 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
472 if (__pContextEditorMenuMove->GetShowState() == false)
474 __pContextEditorMenuMove->SetAnchorPosition(__morePosition);
475 __pContextEditorMenuMove->SetShowState(true);
476 __pContextEditorMenuMove->Show();
480 __pContextEditorMenuMove->SetShowState(false);
483 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
485 if (__pContextSelectionMenuMove->GetShowState() == false)
487 __pContextSelectionMenuMove->SetAnchorPosition(__morePosition);
488 __pContextSelectionMenuMove->SetShowState(true);
489 __pContextSelectionMenuMove->Show();
493 __pContextSelectionMenuMove->SetShowState(false);
499 case ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW:
501 if (__pPopUp != null)
503 __pPopUp->SetShowState(true);
509 case ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE:
511 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
513 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
514 if (pEditorPanel != null)
516 pEditorPanel->OnRequestMessage();
519 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
521 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
522 if (pEditorPanel != null)
524 pEditorPanel->OnRequestMessage();
527 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
529 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
530 if (pEditorPanel != null)
532 pEditorPanel->OnRequestMessage();
536 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
538 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
539 if (pSelectionPanel != null)
541 pSelectionPanel->OnRequestMessage();
546 case ACTION_ID_CONTEXT_MENU_SHARE_EMAIL:
548 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
550 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
551 if (pEditorPanel != null)
553 pEditorPanel->OnRequestEmail();
556 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
558 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
559 if (pEditorPanel != null)
561 pEditorPanel->OnRequestEmail();
564 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
566 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
567 if (pEditorPanel != null)
569 pEditorPanel->OnRequestEmail();
573 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
575 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
576 if (pSelectionPanel != null)
578 pSelectionPanel->OnRequestEmail();
583 case ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
585 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
587 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
588 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
589 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
590 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
594 case ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
596 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
598 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
599 (pSceneManager->GetCurrentScene()->GetPanel());
600 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
601 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
602 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
606 case ACTION_ID_DELETE_POPUP_DEL:
608 __overlayMsg = false;
609 __pDeletePopup->SetShowState(false);
610 __pDeletePopup->Invalidate(true);
612 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
614 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
615 if (pEditorPanel != null)
617 result r = pEditorPanel->OnRequestDelete();
620 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
624 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
626 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
627 if (pEditorPanel != null)
629 pEditorPanel->OnRequestDelete();
632 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
634 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>
635 (pSceneManager->GetCurrentScene()->GetPanel());
637 if (pEditorPanel != null)
639 pEditorPanel->OnRequestDelete();
642 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
644 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
645 (pSceneManager->GetCurrentScene()->GetPanel());
647 if (pSelectionPanel != null)
649 result r = pSelectionPanel->OnRequestDelete();
652 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
658 case ACTION_ID_DELETE_POPUP_CANCEL:
660 __overlayMsg = false;
661 __pDeletePopup->SetShowState(false);
662 __pDeletePopup->Invalidate(true);
665 case ACTION_ID_FOOTER_CONFIRM:
667 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
669 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
670 if (pEditorPanel != null)
672 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
675 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
677 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
678 if (pEditorPanel != null)
680 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
687 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
689 if ((ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
690 (actionId <= ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
692 if (__pContentDirectoryList == null)
697 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
699 String* pDirectory = static_cast<String*>
700 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
702 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
703 (pSceneManager->GetCurrentScene()->GetPanel());
705 if (pEditorPanel != null)
708 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
709 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
710 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
711 __pPresentationModel->SetUpdateProgressStatus(true);
712 result r = __pFileMove->StartTimer();
726 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
728 if ((ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
729 (actionId <= ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
731 if (__pContentDirectoryList == null)
736 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
738 String* pDirectory = static_cast<String*>
739 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
741 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
742 (pSceneManager->GetCurrentScene()->GetPanel());
744 if (pSelectionPanel != null)
747 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
748 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
749 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
750 __pPresentationModel->SetUpdateProgressStatus(true);
751 result r = __pFileMove->StartTimer();
768 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
771 void FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
776 bool FileListEditorForm::GetOverlayStatus()
781 void FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
783 __overlayMsg = false;
784 __pPresentationModel->SetUpdateProgressStatus(false);
785 if (res != COMPLETE_SUCCESS)
787 MessageBox messageBox;
788 messageBox.Construct(L"", L"System error",
789 MSGBOX_STYLE_OK, 3000);
792 messageBox.ShowAndWait(modalResult);
793 __overlayMsg = false;
794 SceneManager* pSceneManager = SceneManager::GetInstance();
795 AppAssert(pSceneManager);
796 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
801 FileListEditorForm::OnContentUpdated()
803 AppLogDebug("ENTER");
805 if (__overlayMsg == false)
807 SceneManager* pSceneManager = SceneManager::GetInstance();
808 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
810 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
814 FileListEditorForm::SetUpPopup(void)
816 AppLogDebug("ENTER");
817 result r = E_SUCCESS;
819 if (__pDeletePopup != null)
821 delete __pDeletePopup;
822 __pDeletePopup = null;
825 __pDeletePopup = new (std::nothrow) Popup();
826 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
828 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
830 Label* pLabelText = new (std::nothrow) Label();
831 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
832 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
833 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
834 __pDeletePopup->AddControl(*pLabelText);
836 Button* pDeleteButton = new (std::nothrow) Button();
837 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
838 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
839 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
840 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
841 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
842 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
843 pDeleteButton->AddActionEventListener(*this);
844 __pDeletePopup->AddControl(*pDeleteButton);
846 Button* pButtonCancel = new (std::nothrow) Button();
847 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
848 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
849 pButtonCancel->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
850 pButtonCancel->AddActionEventListener(*this);
851 __pDeletePopup->AddControl(*pButtonCancel);
852 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
858 FileListEditorForm::SetTitleText(const String& titleText)
860 AppLogDebug("ENTER");
861 Header* pHeader = GetHeader();
862 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
863 pHeader->SetTitleText(titleText);
864 pHeader->Invalidate(true);
865 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
869 FileListEditorForm::RefreshFolderList(void)
871 AppLogDebug("ENTER");
872 ContentDirectory contentDirectory;
873 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
874 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
875 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
876 contentDirectory.Construct(*pContentTypeList);
877 delete pContentTypeList;
879 if (__pContentDirectoryList != null)
881 delete __pContentDirectoryList;
883 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
884 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
885 String* pDirPath = null;
886 String* pDirName = null;
888 int loopCount = __pContentDirectoryList->GetCount();
889 for (int i = 0; i < loopCount; ++i)
891 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
892 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
893 __pContentDirectoryNameList->Add(pDirName);
895 __pContextEditorMenuMove->RemoveAllItems();
896 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
897 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
898 __pContextSelectionMenuMove->RemoveAllItems();
899 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
900 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
902 loopCount = __pContentDirectoryNameList->GetCount();
903 for (int i = 0; i < loopCount; ++i)
905 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
906 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
907 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
908 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
909 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
911 __pContextEditorMenuMove->SetShowState(false);
912 __pContextSelectionMenuMove->SetShowState(false);
913 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
917 FileListEditorForm::OnFormBackRequested(Form& source)
919 AppLogDebug("ENTER");
921 SceneManager* pSceneManager = SceneManager::GetInstance();
922 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
924 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
926 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
928 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
930 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
932 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
937 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
939 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
941 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
943 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
945 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
947 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
949 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
951 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
952 (pSceneManager->GetCurrentScene()->GetPanel());
953 if (pSelectionPanel != null)
955 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
958 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
961 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
966 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
969 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
973 FileListEditorForm::SetFooterButtonsState(bool enableState)
975 AppLogDebug("ENTER");
976 Footer* pFooter = GetFooter();
977 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
979 if (enableState == true)
981 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
982 pFooter->SetItemEnabled(0, true);
983 pFooter->SetItemEnabled(1, true);
987 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
988 pFooter->SetItemEnabled(0, false);
989 pFooter->SetItemEnabled(1, false);
992 pFooter->RequestRedraw(true);
993 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
997 FileListEditorForm::MoveToAlbum(String& destDirectory)
999 AppLogDebug("ENTER");
1000 result r = E_FAILURE;
1001 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1002 if (albumName != EMPTY_SPACE)
1004 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1005 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1006 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1007 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1008 delete pDirectoryList;
1010 SceneManager* pSceneManager = SceneManager::GetInstance();
1011 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1014 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1020 FileListEditorForm::SelectAllPressed(void)
1022 SceneManager* pSceneManager = SceneManager::GetInstance();
1023 pSceneManager->GetCurrentScene();
1025 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1027 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1028 if (pEditorPanel != null)
1030 pEditorPanel->SelectAllPressed();
1033 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1035 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1036 if (pEditorPanel != null)
1038 pEditorPanel->SelectAllPressed();
1041 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1043 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1044 if (pEditorPanel != null)
1046 pEditorPanel->SelectAllPressed();
1049 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1051 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1052 if (pEditorPanel != null)
1054 pEditorPanel->SelectAllPressed();
1060 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1062 if (__pPopUp != NULL)
1064 __pPopUp->SetShowState(false);
1067 SceneManager* pSceneManager = SceneManager::GetInstance();
1069 if (index == 0) // start slide show
1071 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1073 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1074 if (pEditorPanel != null)
1076 pEditorPanel->OnRequestSlideShow();
1079 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1081 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1082 (pSceneManager->GetCurrentScene()->GetPanel());
1084 if (pSelectionPanel != null)
1086 pSelectionPanel->OnRequestSlideShow();
1090 else if (index == 1) // go to settingsForm
1092 SceneManager* pSceneManager = SceneManager::GetInstance();
1093 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1095 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));