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 result r = __pFileMove->StartTimer();
725 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
727 if ((ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
728 (actionId <= ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
730 if (__pContentDirectoryList == null)
735 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
737 String* pDirectory = static_cast<String*>
738 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
740 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
741 (pSceneManager->GetCurrentScene()->GetPanel());
743 if (pSelectionPanel != null)
746 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
747 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
748 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
749 result r = __pFileMove->StartTimer();
766 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
769 void FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
774 bool FileListEditorForm::GetOverlayStatus()
779 void FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
781 __overlayMsg = false;
782 if (res != COMPLETE_SUCCESS)
784 MessageBox messageBox;
785 messageBox.Construct(L"", L"System error",
786 MSGBOX_STYLE_OK, 3000);
789 messageBox.ShowAndWait(modalResult);
790 __overlayMsg = false;
791 SceneManager* pSceneManager = SceneManager::GetInstance();
792 AppAssert(pSceneManager);
793 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
798 FileListEditorForm::OnContentUpdated()
800 AppLogDebug("ENTER");
801 if (__overlayMsg == false)
803 SceneManager* pSceneManager = SceneManager::GetInstance();
804 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
806 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
810 FileListEditorForm::SetUpPopup(void)
812 AppLogDebug("ENTER");
813 result r = E_SUCCESS;
815 if (__pDeletePopup != null)
817 delete __pDeletePopup;
818 __pDeletePopup = null;
821 __pDeletePopup = new (std::nothrow) Popup();
822 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
824 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
826 Label* pLabelText = new (std::nothrow) Label();
827 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
828 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
829 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
830 __pDeletePopup->AddControl(*pLabelText);
832 Button* pDeleteButton = new (std::nothrow) Button();
833 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
834 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
835 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
836 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
837 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
838 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
839 pDeleteButton->AddActionEventListener(*this);
840 __pDeletePopup->AddControl(*pDeleteButton);
842 Button* pButtonCancel = new (std::nothrow) Button();
843 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
844 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
845 pButtonCancel->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
846 pButtonCancel->AddActionEventListener(*this);
847 __pDeletePopup->AddControl(*pButtonCancel);
848 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
854 FileListEditorForm::SetTitleText(const String& titleText)
856 AppLogDebug("ENTER");
857 Header* pHeader = GetHeader();
858 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
859 pHeader->SetTitleText(titleText);
860 pHeader->Invalidate(true);
861 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
865 FileListEditorForm::RefreshFolderList(void)
867 AppLogDebug("ENTER");
868 ContentDirectory contentDirectory;
869 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
870 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
871 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
872 contentDirectory.Construct(*pContentTypeList);
873 delete pContentTypeList;
875 if (__pContentDirectoryList != null)
877 delete __pContentDirectoryList;
879 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
880 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
881 String* pDirPath = null;
882 String* pDirName = null;
884 int loopCount = __pContentDirectoryList->GetCount();
885 for (int i = 0; i < loopCount; ++i)
887 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
888 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
889 __pContentDirectoryNameList->Add(pDirName);
891 __pContextEditorMenuMove->RemoveAllItems();
892 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
893 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
894 __pContextSelectionMenuMove->RemoveAllItems();
895 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
896 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
898 loopCount = __pContentDirectoryNameList->GetCount();
899 for (int i = 0; i < loopCount; ++i)
901 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
902 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
903 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
904 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
905 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
907 __pContextEditorMenuMove->SetShowState(false);
908 __pContextSelectionMenuMove->SetShowState(false);
909 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
913 FileListEditorForm::OnFormBackRequested(Form& source)
915 AppLogDebug("ENTER");
917 SceneManager* pSceneManager = SceneManager::GetInstance();
918 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
920 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
922 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
924 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
926 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
928 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
933 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
935 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
937 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
939 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
941 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
943 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
945 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
947 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
948 (pSceneManager->GetCurrentScene()->GetPanel());
949 if (pSelectionPanel != null)
951 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
954 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
957 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
962 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
965 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
969 FileListEditorForm::SetFooterButtonsState(bool enableState)
971 AppLogDebug("ENTER");
972 Footer* pFooter = GetFooter();
973 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
975 if (enableState == true)
977 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
978 pFooter->SetItemEnabled(0, true);
979 pFooter->SetItemEnabled(1, true);
983 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
984 pFooter->SetItemEnabled(0, false);
985 pFooter->SetItemEnabled(1, false);
988 pFooter->RequestRedraw(true);
989 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
993 FileListEditorForm::MoveToAlbum(String& destDirectory)
995 AppLogDebug("ENTER");
996 result r = E_FAILURE;
997 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
998 if (albumName != EMPTY_SPACE)
1000 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1001 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1002 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1003 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1004 delete pDirectoryList;
1006 SceneManager* pSceneManager = SceneManager::GetInstance();
1007 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1010 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1016 FileListEditorForm::SelectAllPressed(void)
1018 SceneManager* pSceneManager = SceneManager::GetInstance();
1019 pSceneManager->GetCurrentScene();
1021 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1023 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1024 if (pEditorPanel != null)
1026 pEditorPanel->SelectAllPressed();
1029 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1031 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1032 if (pEditorPanel != null)
1034 pEditorPanel->SelectAllPressed();
1037 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1039 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1040 if (pEditorPanel != null)
1042 pEditorPanel->SelectAllPressed();
1045 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1047 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1048 if (pEditorPanel != null)
1050 pEditorPanel->SelectAllPressed();
1056 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1059 if ( __pPopUp != NULL)
1061 __pPopUp->SetShowState(false);
1064 SceneManager* pSceneManager = SceneManager::GetInstance();
1066 if (index == 0) // start slide show
1068 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1070 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1071 if (pEditorPanel != null)
1073 pEditorPanel->OnRequestSlideShow();
1076 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1078 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1079 (pSceneManager->GetCurrentScene()->GetPanel());
1081 if (pSelectionPanel != null)
1083 pSelectionPanel->OnRequestSlideShow();
1088 else if (index == 1) // go to settingsForm
1090 SceneManager* pSceneManager = SceneManager::GetInstance();
1091 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1093 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));