2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file GlFileListEditorForm.cpp
19 * @brief This is the implementation file for FileListEditorForm class.
22 #include "GlAllListEditorPanel.h"
23 #include "GlAllListSelectionPanel.h"
24 #include "GlFileListEditorForm.h"
25 #include "GlFileListPresentationModel.h"
26 #include "GlGalleryApp.h"
27 #include "GlImageListEditorPanel.h"
28 #include "GlResourceManager.h"
29 #include "GlSlideSettingListener.h"
31 #include "GlVideoListEditorPanel.h"
32 #include "GlFileMoveTimer.h"
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Content;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43 using namespace Tizen::Base::Utility;
45 static const int GAP_W_POPUP_ITEM = 5;
46 static const int W_DELETE_POPUP = 600;
47 static const int H_DELETE_POPUP = 300;
48 static const int H_DELETE_LABEL = 180;
49 static const int Y_DELETE_BUTTON = 180;
50 static const int H_DELETE_BUTTON = 80;
52 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
53 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
54 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
56 FileListEditorForm::FileListEditorForm(void)
57 : __pContextMenuMore(null)
58 , __pContextMenuShare(null)
59 , __pContextEditorMenuMove(null)
60 , __pContextSelectionMenuMove(null)
61 , __pDeletePopup(null)
62 , __morePosition(Point(0, 0))
63 , __pContentDirectoryList(null)
64 , __pContentDirectoryNameList(null)
65 , __pPresentationModel(null)
67 ,__isCopyOperation(false)
71 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
74 FileListEditorForm::~FileListEditorForm(void)
77 if (__pContentDirectoryList != null)
79 delete __pContentDirectoryList;
81 if (__pContentDirectoryNameList != null)
83 delete __pContentDirectoryNameList;
86 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
90 FileListEditorForm::Initialize(void)
93 result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
94 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
100 FileListEditorForm::OnInitializing(void)
102 AppLogDebug("ENTER");
103 Header* pHeader = GetHeader();
104 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
106 __pPopUp = new (std::nothrow) SlideShowPopUp();
108 if (__pPopUp != null)
110 __pPopUp->Initialize();
111 __pPopUp->SetEventListner(this);
112 AddControl(*__pPopUp);
115 __pPresentationModel = FileListPresentationModel::GetInstance();
116 __pPresentationModel->ClearThumbnailRequests();
118 pHeader->SetStyle(HEADER_STYLE_TITLE);
119 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
121 if ((__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK
122 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
124 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
125 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
126 ButtonItem selectAll;
127 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FILE_LIST_SELECT_ALL);
128 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
129 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
130 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
131 delete pNormalBitmap;
135 pHeader->AddActionEventListener(*this);
138 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
144 FileListEditorForm::InitializeFooter(void)
146 AppLogDebug("ENTER");
147 Footer* pFooter = GetFooter();
148 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
149 pFooter->RemoveAllItems();
151 result r = E_SUCCESS;
153 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
155 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
157 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
159 FooterItem footerConfirm;
160 footerConfirm.Construct(ACTION_ID_FOOTER_CONFIRM);
161 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
162 pFooter->AddItem(footerConfirm);
166 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
168 pFooter->SetBackButton();
169 SetFormBackEventListener(this);
173 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
175 ButtonItem footerMore;
176 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
177 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
178 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
180 if (pBitmapMore != null && pBitmapMoreDim != NULL)
182 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
183 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
185 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
188 delete pBitmapMoreDim;
190 FooterItem footerShare;
191 r = footerShare.Construct(ACTION_ID_FOOTER_SHARE);
192 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
193 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
194 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
196 if (pBitmapShare != null && pBitmapShareDim != null)
198 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
199 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
202 r = pFooter->AddItem(footerShare);
204 delete pBitmapShareDim;
205 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
207 FooterItem footerDelete;
208 r = footerDelete.Construct(ACTION_ID_FOOTER_DELETE);
209 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
210 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
211 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
213 if (pBitmapDelete != null && pBitmapDeleteDim != null)
215 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
216 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
219 r = pFooter->AddItem(footerDelete);
220 delete pBitmapDelete;
221 delete pBitmapDeleteDim;
222 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
224 pFooter->SetBackButton();
225 SetFormBackEventListener(this);
227 SceneManager* pSceneManager = SceneManager::GetInstance();
228 int checkedCount = 0;
230 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
232 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
233 if (pEditorPanel != null)
235 checkedCount = pEditorPanel->GetItemCheckedCount();
238 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
240 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
241 if (pSelectionPanel != null)
243 checkedCount = pSelectionPanel->GetItemCheckedCount();
247 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
249 if (__pContextMenuMore != null)
251 delete __pContextMenuMore;
252 __pContextMenuMore = null;
255 __pContextMenuMore = new (std::nothrow) ContextMenu();
256 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
258 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
259 ACTION_ID_CONTEXT_MENU_MORE_MOVE);
260 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
261 ACTION_ID_CONTEXT_MENU_MORE_COPY);
263 if (checkedCount > 1)
265 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"),
266 ACTION_ID_CONTEXT_MENU_MORE_SLIDE_SHOW);
269 __pContextMenuMore->AddItem(L"Rotate to CCW",ACTION_ID_CONTEXT_MENU_ROTATE_CCW);
270 __pContextMenuMore->AddItem(L"Rotate to CW",ACTION_ID_CONTEXT_MENU_ROTATE_CW);
272 __pContextMenuMore->SetShowState(false);
273 __pContextMenuMore->AddActionEventListener(*this);
275 __pContextMenuShare = new (std::nothrow) ContextMenu();
276 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
277 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
278 ACTION_ID_CONTEXT_MENU_SHARE_MESSAGE);
279 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
280 ACTION_ID_CONTEXT_MENU_SHARE_EMAIL);
281 __pContextMenuShare->SetShowState(false);
282 __pContextMenuShare->AddActionEventListener(*this);
284 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
285 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
286 __pContextEditorMenuMove->AddActionEventListener(*this);
288 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
289 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
290 __pContextSelectionMenuMove->AddActionEventListener(*this);
292 if (__pContentDirectoryNameList != null)
294 delete __pContentDirectoryNameList;
295 __pContentDirectoryNameList = null;
301 pFooter->AddActionEventListener(*this);
302 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
308 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
310 AppLogDebug("ENTER");
311 if (fullPath == null)
313 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
317 String delim(DIRECTORY_SEPARATOR);
318 StringTokenizer st(fullPath,delim);
320 while (st.HasMoreTokens())
322 st.GetNextToken(token);
324 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
330 FileListEditorForm::OnTerminating(void)
332 AppLogDebug("ENTER");
334 if (__pContextMenuMore != null)
336 __pContextMenuMore->RemoveActionEventListener(*this);
337 delete __pContextMenuMore;
338 __pContextMenuMore = null;
341 if (__pContextMenuShare != null)
343 __pContextMenuShare->RemoveActionEventListener(*this);
344 delete __pContextMenuShare;
345 __pContextMenuShare = null;
348 if (__pContextEditorMenuMove != null)
350 __pContextEditorMenuMove->RemoveActionEventListener(*this);
351 delete __pContextEditorMenuMove;
352 __pContextEditorMenuMove = null;
355 if (__pContextSelectionMenuMove != null)
357 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
358 delete __pContextSelectionMenuMove;
359 __pContextSelectionMenuMove = null;
362 if (__pDeletePopup != null)
364 delete __pDeletePopup;
365 __pDeletePopup = null;
367 __overlayMsg = false;
368 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
374 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
376 AppLogDebug("ENTER(actionId=%d)", actionId);
377 SceneManager* pSceneManager = SceneManager::GetInstance();
378 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
382 case ACTION_ID_FILE_LIST_SELECT_ALL:
385 case ACTION_ID_FOOTER_MORE:
389 if (__pContextMenuMore->GetShowState() == false)
391 Rectangle rect = source.GetBounds();
392 __morePosition = Point(rect.width/8,rect.y);
393 __pContextMenuMore->SetAnchorPosition(Point(rect.width/8,rect.y));
394 __pContextMenuMore->SetShowState(true);
395 __pContextMenuMore->Show();
399 __pContextMenuMore->SetShowState(false);
403 case ACTION_ID_FOOTER_SHARE:
405 if (__pContextMenuShare->GetShowState() == false)
407 Rectangle rect = source.GetBounds();
408 __pContextMenuShare->SetAnchorPosition(Point(rect.width/8*3 ,rect.y));
409 __pContextMenuShare->SetShowState(true);
410 __pContextMenuShare->Show();
414 __pContextMenuShare->SetShowState(false);
418 case ACTION_ID_FOOTER_DELETE:
420 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
422 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
423 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
425 __pDeletePopup->SetShowState(true);
426 __pDeletePopup->Show();
430 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
432 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
433 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
435 __pDeletePopup->SetShowState(true);
436 __pDeletePopup->Show();
440 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
442 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
443 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
445 __pDeletePopup->SetShowState(true);
446 __pDeletePopup->Show();
450 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
452 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
453 (pSceneManager->GetCurrentScene()->GetPanel());
454 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
456 __pDeletePopup->SetShowState(true);
457 __pDeletePopup->Show();
463 case ACTION_ID_CONTEXT_MENU_MORE_EDIT:
467 case ACTION_ID_CONTEXT_MENU_MORE_ADD_TAG:
471 case ACTION_ID_CONTEXT_MENU_MORE_COPY:
472 case ACTION_ID_CONTEXT_MENU_MORE_MOVE:
474 if (actionId == ACTION_ID_CONTEXT_MENU_MORE_MOVE)
476 __isCopyOperation = false;
478 else if (actionId == ACTION_ID_CONTEXT_MENU_MORE_COPY)
480 __isCopyOperation = true;
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 if (pListEditorPanel)
603 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
604 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
605 if(__isCopyOperation)
607 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
611 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
613 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
619 case ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
621 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
623 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
624 (pSceneManager->GetCurrentScene()->GetPanel());
625 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
626 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
627 if(__isCopyOperation)
629 pList->InsertAt(new (std::nothrow) Integer(FILE_COPY_ACTION), ALBUM_SECOND_ELEMENT);
633 pList->InsertAt(new (std::nothrow) Integer(FILE_MOVE_ACTION), ALBUM_SECOND_ELEMENT);
635 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
639 case ACTION_ID_DELETE_POPUP_DEL:
641 __overlayMsg = false;
642 __pDeletePopup->SetShowState(false);
643 __pDeletePopup->Invalidate(true);
645 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
647 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
648 if (pEditorPanel != null)
650 result r = pEditorPanel->OnRequestDelete();
653 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
657 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
659 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
660 if (pEditorPanel != null)
662 pEditorPanel->OnRequestDelete();
665 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
667 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>
668 (pSceneManager->GetCurrentScene()->GetPanel());
670 if (pEditorPanel != null)
672 pEditorPanel->OnRequestDelete();
675 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
677 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
678 (pSceneManager->GetCurrentScene()->GetPanel());
680 if (pSelectionPanel != null)
682 result r = pSelectionPanel->OnRequestDelete();
685 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
691 case ACTION_ID_DELETE_POPUP_CANCEL:
693 __overlayMsg = false;
694 __pDeletePopup->SetShowState(false);
695 __pDeletePopup->Invalidate(true);
699 case ACTION_ID_CONTEXT_MENU_ROTATE_CCW:
701 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
704 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
705 if (pEditorPanel != null)
707 RotateMode rotateMode = ROTATE_MODE_LEFT;
708 pEditorPanel->OnRotateRequested(rotateMode);
711 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
714 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
715 (pSceneManager->GetCurrentScene()->GetPanel());
717 if (pSelectionPanel != null)
719 RotateMode rotateMode = ROTATE_MODE_LEFT;
720 pSelectionPanel->OnRotateRequested(rotateMode);
728 case ACTION_ID_CONTEXT_MENU_ROTATE_CW:
730 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
732 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
733 if (pEditorPanel != null)
735 RotateMode rotateMode = ROTATE_MODE_RIGHT;
736 pEditorPanel->OnRotateRequested(rotateMode);
739 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
742 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
743 (pSceneManager->GetCurrentScene()->GetPanel());
745 if (pSelectionPanel != null)
747 RotateMode rotateMode = ROTATE_MODE_RIGHT;
748 pSelectionPanel->OnRotateRequested(rotateMode);
755 case ACTION_ID_FOOTER_CONFIRM:
757 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
759 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
760 if (pEditorPanel != null)
762 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
765 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
767 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
768 if (pEditorPanel != null)
770 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
777 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
779 if ((ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
780 (actionId <= ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
782 if (__pContentDirectoryList == null)
787 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
789 String* pDirectory = static_cast<String*>
790 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
792 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
793 (pSceneManager->GetCurrentScene()->GetPanel());
795 if (pEditorPanel != null)
798 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
799 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
800 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
801 if(__isCopyOperation)
803 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
804 __pFileMove->SetCopy();
807 result r = __pFileMove->StartTimer();
812 __isCopyOperation = false;
822 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
824 if ((ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
825 (actionId <= ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
827 if (__pContentDirectoryList == null)
832 if (__pContentDirectoryList->GetCount() > actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
834 String* pDirectory = static_cast<String*>
835 (__pContentDirectoryList->GetAt(actionId - ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
837 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
838 (pSceneManager->GetCurrentScene()->GetPanel());
840 if (pSelectionPanel != null)
843 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
844 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
845 __pFileMove = new FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
846 if(__isCopyOperation)
848 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
849 __pFileMove->SetCopy();
851 result r = __pFileMove->StartTimer();
856 __isCopyOperation = false;
869 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
872 void FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
877 bool FileListEditorForm::GetOverlayStatus()
882 void FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
884 __overlayMsg = false;
885 __pPresentationModel->SetUpdateProgressStatus(false);
886 if (res != COMPLETE_SUCCESS)
888 MessageBox messageBox;
889 messageBox.Construct(L"", L"System error",
890 MSGBOX_STYLE_OK, 3000);
893 messageBox.ShowAndWait(modalResult);
894 __overlayMsg = false;
895 SceneManager* pSceneManager = SceneManager::GetInstance();
896 AppAssert(pSceneManager);
897 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
902 FileListEditorForm::OnContentUpdated()
904 AppLogDebug("ENTER");
906 if (__overlayMsg == false)
908 SceneManager* pSceneManager = SceneManager::GetInstance();
909 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
911 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
915 FileListEditorForm::SetUpPopup(void)
917 AppLogDebug("ENTER");
918 result r = E_SUCCESS;
920 if (__pDeletePopup != null)
922 delete __pDeletePopup;
923 __pDeletePopup = null;
926 __pDeletePopup = new (std::nothrow) Popup();
927 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
929 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
931 Label* pLabelText = new (std::nothrow) Label();
932 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
933 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
934 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
935 __pDeletePopup->AddControl(*pLabelText);
937 Button* pDeleteButton = new (std::nothrow) Button();
938 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
939 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
940 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
941 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
942 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
943 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
944 pDeleteButton->AddActionEventListener(*this);
945 __pDeletePopup->AddControl(*pDeleteButton);
947 Button* pButtonCancel = new (std::nothrow) Button();
948 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
949 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
950 pButtonCancel->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
951 pButtonCancel->AddActionEventListener(*this);
952 __pDeletePopup->AddControl(*pButtonCancel);
953 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
959 FileListEditorForm::SetTitleText(const String& titleText)
961 AppLogDebug("ENTER");
962 Header* pHeader = GetHeader();
963 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
964 pHeader->SetTitleText(titleText);
965 pHeader->Invalidate(true);
966 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
970 FileListEditorForm::RefreshFolderList(void)
972 AppLogDebug("ENTER");
973 ContentDirectory contentDirectory;
974 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
975 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
976 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
977 result r = contentDirectory.Construct(*pContentTypeList);
980 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
983 delete pContentTypeList;
985 if (__pContentDirectoryList != null)
987 delete __pContentDirectoryList;
989 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
990 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
991 String* pDirPath = null;
992 String* pDirName = null;
994 int loopCount = __pContentDirectoryList->GetCount();
995 for (int i = 0; i < loopCount; ++i)
997 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
998 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
999 __pContentDirectoryNameList->Add(pDirName);
1001 __pContextEditorMenuMove->RemoveAllItems();
1002 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
1003 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
1004 __pContextSelectionMenuMove->RemoveAllItems();
1005 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
1006 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
1008 loopCount = __pContentDirectoryNameList->GetCount();
1009 for (int i = 0; i < loopCount; ++i)
1011 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
1012 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
1013 ACTION_ID_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
1014 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
1015 ACTION_ID_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
1017 __pContextEditorMenuMove->SetShowState(false);
1018 __pContextSelectionMenuMove->SetShowState(false);
1019 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1023 FileListEditorForm::OnFormBackRequested(Form& source)
1025 AppLogDebug("ENTER");
1027 SceneManager* pSceneManager = SceneManager::GetInstance();
1028 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
1030 if (__pPresentationModel->GetAppControlMode() == APP_CONTROL_MODE_PICK)
1032 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1034 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1036 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1038 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1043 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1045 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1047 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1049 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1051 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1053 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1055 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1057 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1058 (pSceneManager->GetCurrentScene()->GetPanel());
1059 if (pSelectionPanel != null)
1061 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1064 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1067 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
1072 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1075 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1079 FileListEditorForm::SetFooterButtonsState(bool enableState)
1081 AppLogDebug("ENTER");
1082 Footer* pFooter = GetFooter();
1083 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1085 if (enableState == true)
1087 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1088 pFooter->SetItemEnabled(0, true);
1089 pFooter->SetItemEnabled(1, true);
1093 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1094 pFooter->SetItemEnabled(0, false);
1095 pFooter->SetItemEnabled(1, false);
1098 pFooter->RequestRedraw(true);
1099 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1103 FileListEditorForm::MoveToAlbum(String& destDirectory)
1105 AppLogDebug("ENTER");
1106 result r = E_FAILURE;
1107 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1108 if (albumName != EMPTY_SPACE)
1110 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1111 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1112 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1113 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1114 delete pDirectoryList;
1116 SceneManager* pSceneManager = SceneManager::GetInstance();
1117 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1120 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1126 FileListEditorForm::SelectAllPressed(void)
1128 SceneManager* pSceneManager = SceneManager::GetInstance();
1129 pSceneManager->GetCurrentScene();
1131 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1133 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1134 if (pEditorPanel != null)
1136 pEditorPanel->SelectAllPressed();
1139 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1141 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1142 if (pEditorPanel != null)
1144 pEditorPanel->SelectAllPressed();
1147 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1149 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1150 if (pEditorPanel != null)
1152 pEditorPanel->SelectAllPressed();
1155 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1157 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1158 if (pEditorPanel != null)
1160 pEditorPanel->SelectAllPressed();
1166 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1168 if (__pPopUp != NULL)
1170 __pPopUp->SetShowState(false);
1173 SceneManager* pSceneManager = SceneManager::GetInstance();
1175 if (index == 0) // start slide show
1177 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1179 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1180 if (pEditorPanel != null)
1182 pEditorPanel->OnRequestSlideShow();
1185 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1187 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1188 (pSceneManager->GetCurrentScene()->GetPanel());
1190 if (pSelectionPanel != null)
1192 pSelectionPanel->OnRequestSlideShow();
1196 else if (index == 1) // go to settingsForm
1198 SceneManager* pSceneManager = SceneManager::GetInstance();
1199 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1201 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));