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"
30 #include "GlSlideShowPopUp.h"
32 #include "GlVideoListEditorPanel.h"
33 #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;
51 static const int H_TOAST_LABEL = 48;
53 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
54 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
55 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
57 FileListEditorForm::FileListEditorForm(void)
58 : __pContextMenuMore(null)
59 , __pContextMenuShare(null)
60 , __pContextEditorMenuMove(null)
61 , __pContextSelectionMenuMove(null)
62 , __pDeletePopup(null)
63 , __morePosition(Point(0, 0))
64 , __pContentDirectoryList(null)
65 , __pContentDirectoryNameList(null)
68 , __isCopyOperation(false)
69 , __pPresentationModel(null)
73 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
76 FileListEditorForm::~FileListEditorForm(void)
79 if (__pContentDirectoryList != null)
81 delete __pContentDirectoryList;
84 if (__pContentDirectoryNameList != null)
86 delete __pContentDirectoryNameList;
89 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
93 FileListEditorForm::Initialize(void)
96 result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
97 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
103 FileListEditorForm::OnInitializing(void)
105 AppLogDebug("ENTER");
106 Header* pHeader = GetHeader();
107 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
109 __pPopUp = new (std::nothrow) SlideShowPopUp();
111 if (__pPopUp != null)
113 __pPopUp->Initialize();
114 __pPopUp->SetEventListner(this);
115 AddControl(*__pPopUp);
118 __pPresentationModel = FileListPresentationModel::GetInstance();
119 __pPresentationModel->ClearThumbnailRequests();
121 pHeader->SetStyle(HEADER_STYLE_TITLE);
122 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
124 if ((__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
125 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
127 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
128 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
129 ButtonItem selectAll;
130 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FILE_LIST_SELECT_ALL);
131 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
132 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
133 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
134 delete pNormalBitmap;
138 pHeader->AddActionEventListener(*this);
141 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
147 FileListEditorForm::InitializeFooter(void)
149 AppLogDebug("ENTER");
150 Footer* pFooter = GetFooter();
151 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
152 pFooter->RemoveAllItems();
154 result r = E_SUCCESS;
156 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
158 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
160 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
162 FooterItem footerConfirm;
163 footerConfirm.Construct(IDA_FOOTER_CONFIRM);
164 footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
165 pFooter->AddItem(footerConfirm);
166 pFooter->SetItemEnabled(0, false);
170 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
172 pFooter->SetBackButton();
173 SetFormBackEventListener(this);
177 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
179 ButtonItem footerMore;
180 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
181 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
182 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
184 if (pBitmapMore != null && pBitmapMoreDim != NULL)
186 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
187 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
189 pFooter->SetButton(BUTTON_POSITION_LEFT,footerMore);
192 delete pBitmapMoreDim;
194 FooterItem footerShare;
195 r = footerShare.Construct(IDA_FOOTER_SHARE);
196 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
197 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
198 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
200 if (pBitmapShare != null && pBitmapShareDim != null)
202 footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
203 footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
206 r = pFooter->AddItem(footerShare);
208 delete pBitmapShareDim;
209 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
211 FooterItem footerDelete;
212 r = footerDelete.Construct(IDA_FOOTER_DELETE);
213 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
214 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
215 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
217 if (pBitmapDelete != null && pBitmapDeleteDim != null)
219 footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
220 footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
223 r = pFooter->AddItem(footerDelete);
224 delete pBitmapDelete;
225 delete pBitmapDeleteDim;
226 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
228 pFooter->SetBackButton();
229 SetFormBackEventListener(this);
231 SceneManager* pSceneManager = SceneManager::GetInstance();
232 int checkedCount = 0;
234 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
236 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
237 if (pEditorPanel != null)
239 checkedCount = pEditorPanel->GetItemCheckedCount();
242 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
244 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
245 if (pSelectionPanel != null)
247 checkedCount = pSelectionPanel->GetItemCheckedCount();
251 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
253 if (__pContextMenuMore != null)
255 delete __pContextMenuMore;
256 __pContextMenuMore = null;
259 __pContextMenuMore = new (std::nothrow) ContextMenu();
260 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
262 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
263 IDA_CONTEXT_MENU_MORE_MOVE);
264 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
265 IDA_CONTEXT_MENU_MORE_COPY);
267 if (checkedCount > 1)
269 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
270 IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
273 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
274 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
276 __pContextMenuMore->SetShowState(false);
277 __pContextMenuMore->AddActionEventListener(*this);
279 __pContextMenuShare = new (std::nothrow) ContextMenu();
280 __pContextMenuShare->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
281 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
282 IDA_CONTEXT_MENU_SHARE_MESSAGE);
283 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
284 IDA_CONTEXT_MENU_SHARE_EMAIL);
285 __pContextMenuShare->SetShowState(false);
286 __pContextMenuShare->AddActionEventListener(*this);
288 __pContextEditorMenuMove = new (std::nothrow) ContextMenu();
289 __pContextEditorMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
290 __pContextEditorMenuMove->AddActionEventListener(*this);
292 __pContextSelectionMenuMove = new (std::nothrow) ContextMenu();
293 __pContextSelectionMenuMove->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
294 __pContextSelectionMenuMove->AddActionEventListener(*this);
296 if (__pContentDirectoryNameList != null)
298 delete __pContentDirectoryNameList;
299 __pContentDirectoryNameList = null;
305 pFooter->AddActionEventListener(*this);
306 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
312 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
314 AppLogDebug("ENTER");
315 if (fullPath == null)
317 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
321 String delim(DIRECTORY_SEPARATOR);
322 StringTokenizer st(fullPath,delim);
324 while (st.HasMoreTokens())
326 st.GetNextToken(token);
328 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
334 FileListEditorForm::OnTerminating(void)
336 AppLogDebug("ENTER");
337 __pPresentationModel->RemoveContentEventListener(this);
338 if (__pContextMenuMore != null)
340 __pContextMenuMore->RemoveActionEventListener(*this);
341 delete __pContextMenuMore;
342 __pContextMenuMore = null;
345 if (__pContextMenuShare != null)
347 __pContextMenuShare->RemoveActionEventListener(*this);
348 delete __pContextMenuShare;
349 __pContextMenuShare = null;
352 if (__pContextEditorMenuMove != null)
354 __pContextEditorMenuMove->RemoveActionEventListener(*this);
355 delete __pContextEditorMenuMove;
356 __pContextEditorMenuMove = null;
359 if (__pContextSelectionMenuMove != null)
361 __pContextSelectionMenuMove->RemoveActionEventListener(*this);
362 delete __pContextSelectionMenuMove;
363 __pContextSelectionMenuMove = null;
366 if (__pDeletePopup != null)
368 delete __pDeletePopup;
369 __pDeletePopup = null;
372 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
378 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
380 AppLogDebug("ENTER(actionId=%d)", actionId);
381 SceneManager* pSceneManager = SceneManager::GetInstance();
382 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
386 case IDA_FILE_LIST_SELECT_ALL:
390 case IDA_FOOTER_MORE:
394 if (__pContextMenuMore->GetShowState() == false)
396 Rectangle rect = source.GetBounds();
397 __morePosition = Point(rect.width / 8, rect.y);
398 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
400 __pContextMenuMore->SetAnchorPosition(Point(rect.width / 10, rect.y));
404 __pContextMenuMore->SetAnchorPosition(Point(rect.width / 10, rect.y - H_TOAST_LABEL));
406 __pContextMenuMore->SetShowState(true);
407 __pContextMenuMore->Show();
411 __pContextMenuMore->SetShowState(false);
416 case IDA_FOOTER_SHARE:
418 if (__pContextMenuShare->GetShowState() == false)
420 Rectangle rect = source.GetBounds();
421 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
423 __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
427 __pContextMenuShare->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
429 __pContextMenuShare->SetShowState(true);
430 __pContextMenuShare->Show();
434 __pContextMenuShare->SetShowState(false);
439 case IDA_FOOTER_DELETE:
441 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
443 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
444 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
446 __pDeletePopup->SetShowState(true);
447 __pDeletePopup->Show();
451 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
453 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
454 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
456 __pDeletePopup->SetShowState(true);
457 __pDeletePopup->Show();
461 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
463 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
464 if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
466 __pDeletePopup->SetShowState(true);
467 __pDeletePopup->Show();
471 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
473 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
474 (pSceneManager->GetCurrentScene()->GetPanel());
475 if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
477 __pDeletePopup->SetShowState(true);
478 __pDeletePopup->Show();
485 case IDA_CONTEXT_MENU_MORE_EDIT:
490 case IDA_CONTEXT_MENU_MORE_ADD_TAG:
495 case IDA_CONTEXT_MENU_MORE_COPY:
497 case IDA_CONTEXT_MENU_MORE_MOVE:
499 if (actionId == IDA_CONTEXT_MENU_MORE_MOVE)
501 __isCopyOperation = false;
503 else if (actionId == IDA_CONTEXT_MENU_MORE_COPY)
505 __isCopyOperation = true;
508 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
510 if (__pContextEditorMenuMove->GetShowState() == false)
512 __pContextEditorMenuMove->SetAnchorPosition(Point(__morePosition.x, __morePosition.y - 48));
513 __pContextEditorMenuMove->SetShowState(true);
514 __pContextEditorMenuMove->Show();
518 __pContextEditorMenuMove->SetShowState(false);
521 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
523 if (__pContextSelectionMenuMove->GetShowState() == false)
525 __pContextSelectionMenuMove->SetAnchorPosition(__morePosition);
526 __pContextSelectionMenuMove->SetShowState(true);
527 __pContextSelectionMenuMove->Show();
531 __pContextSelectionMenuMove->SetShowState(false);
537 case IDA_CONTEXT_MENU_MORE_SLIDE_SHOW:
539 if (__pPopUp != null)
541 __pPopUp->SetShowState(true);
547 case IDA_CONTEXT_MENU_SHARE_MESSAGE:
549 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
551 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
552 if (pEditorPanel != null)
554 pEditorPanel->OnRequestMessage();
557 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
559 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
560 if (pSelectionPanel != null)
562 pSelectionPanel->OnRequestMessage();
568 case IDA_CONTEXT_MENU_SHARE_EMAIL:
570 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
572 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
573 if (pEditorPanel != null)
575 pEditorPanel->OnRequestEmail();
578 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
580 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
581 if (pSelectionPanel != null)
583 pSelectionPanel->OnRequestEmail();
589 case IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
591 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
593 AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
594 if (pListEditorPanel)
596 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
597 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
598 if (__isCopyOperation)
600 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
604 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
606 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
613 case IDA_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM:
615 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
617 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
618 (pSceneManager->GetCurrentScene()->GetPanel());
620 if (pSelectionPanel != null)
622 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
623 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
624 if (__isCopyOperation)
626 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
630 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
632 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
638 case IDA_DELETE_POPUP_DEL:
641 __pDeletePopup->SetShowState(false);
642 __pDeletePopup->Invalidate(true);
644 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
646 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
647 if (pEditorPanel != null)
649 result r = pEditorPanel->OnRequestDelete();
652 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
656 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
658 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
659 (pSceneManager->GetCurrentScene()->GetPanel());
661 if (pSelectionPanel != null)
663 result r = pSelectionPanel->OnRequestDelete();
666 AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
673 case IDA_DELETE_POPUP_CANCEL:
676 __pDeletePopup->SetShowState(false);
677 __pDeletePopup->Invalidate(true);
681 case IDA_CONTEXT_MENU_ROTATE_LEFT:
683 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
685 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
686 if (pEditorPanel != null)
688 RotateMode rotateMode = ROTATE_MODE_LEFT;
689 pEditorPanel->OnRequestRotate(rotateMode);
692 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
694 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
695 (pSceneManager->GetCurrentScene()->GetPanel());
697 if (pSelectionPanel != null)
699 RotateMode rotateMode = ROTATE_MODE_LEFT;
700 pSelectionPanel->OnRotateRequested(rotateMode);
706 case IDA_CONTEXT_MENU_ROTATE_RIGHT:
708 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
710 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
711 if (pEditorPanel != null)
713 RotateMode rotateMode = ROTATE_MODE_RIGHT;
714 pEditorPanel->OnRequestRotate(rotateMode);
717 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
720 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
721 (pSceneManager->GetCurrentScene()->GetPanel());
723 if (pSelectionPanel != null)
725 RotateMode rotateMode = ROTATE_MODE_RIGHT;
726 pSelectionPanel->OnRotateRequested(rotateMode);
732 case IDA_FOOTER_CONFIRM:
734 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
736 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
737 if (pEditorPanel != null)
739 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
742 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
744 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
745 if (pEditorPanel != null)
747 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
755 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
757 if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
758 (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
760 if (__pContentDirectoryList == null)
764 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
766 String* pDirectory = static_cast<String*>
767 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
769 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
770 (pSceneManager->GetCurrentScene()->GetPanel());
772 if (pEditorPanel != null)
775 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
776 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
777 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
778 if (__isCopyOperation)
780 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
781 __pFileMove->SetCopy();
784 result r = __pFileMove->StartTimer();
789 __isCopyOperation = false;
799 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
801 if ((IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START <= actionId) &&
802 (actionId <= IDA_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM + 1000))
804 if (__pContentDirectoryList == null)
809 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START)
811 String* pDirectory = static_cast<String*>
812 (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START));
814 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
815 (pSceneManager->GetCurrentScene()->GetPanel());
817 if (pSelectionPanel != null)
820 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
821 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel);
822 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
823 if (__isCopyOperation)
825 AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
826 __pFileMove->SetCopy();
828 result r = __pFileMove->StartTimer();
833 __isCopyOperation = false;
846 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
850 FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
856 FileListEditorForm::GetOverlayStatus(void) const
862 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
865 __pPresentationModel->SetUpdateProgressStatus(false);
866 if (res != COMPLETE_SUCCESS)
868 MessageBox messageBox;
869 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_OPERATION_FAILED"), MSGBOX_STYLE_OK, 3000);
872 messageBox.ShowAndWait(modalResult);
874 SceneManager* pSceneManager = SceneManager::GetInstance();
875 AppAssert(pSceneManager);
876 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
881 FileListEditorForm::OnContentUpdated()
883 AppLogDebug("ENTER");
885 SceneManager* pSceneManager = SceneManager::GetInstance();
887 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
888 && pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
890 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
893 else if (_overlayMsg == false)
895 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
898 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
902 FileListEditorForm::SetUpPopup(void)
904 AppLogDebug("ENTER");
905 result r = E_SUCCESS;
907 if (__pDeletePopup != null)
909 delete __pDeletePopup;
910 __pDeletePopup = null;
913 __pDeletePopup = new (std::nothrow) Popup();
914 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
916 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
918 Label* pLabelText = new (std::nothrow) Label();
919 pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
920 ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
921 pLabelText->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
922 __pDeletePopup->AddControl(*pLabelText);
924 Button* pDeleteButton = new (std::nothrow) Button();
925 pDeleteButton->Construct(Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
926 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
927 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
928 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
929 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
930 pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
931 pDeleteButton->AddActionEventListener(*this);
932 __pDeletePopup->AddControl(*pDeleteButton);
934 Button* pButtonCancel = new (std::nothrow) Button();
935 pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
936 popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
937 pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
938 pButtonCancel->AddActionEventListener(*this);
939 __pDeletePopup->AddControl(*pButtonCancel);
940 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
946 FileListEditorForm::SetTitleText(const String& titleText)
948 AppLogDebug("ENTER");
949 Header* pHeader = GetHeader();
950 TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
951 pHeader->SetTitleText(titleText);
952 pHeader->Invalidate(true);
953 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
957 FileListEditorForm::RefreshFolderList(void)
959 AppLogDebug("ENTER");
960 ContentDirectory contentDirectory;
961 IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
962 pContentTypeList->Add(CONTENT_TYPE_IMAGE);
963 pContentTypeList->Add(CONTENT_TYPE_VIDEO);
964 result r = contentDirectory.Construct(*pContentTypeList);
967 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
970 delete pContentTypeList;
972 if (__pContentDirectoryList != null)
974 delete __pContentDirectoryList;
976 __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
977 __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
978 String* pDirPath = null;
979 String* pDirName = null;
981 int loopCount = __pContentDirectoryList->GetCount();
982 for (int i = 0; i < loopCount; ++i)
984 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
985 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
986 __pContentDirectoryNameList->Add(pDirName);
988 __pContextEditorMenuMove->RemoveAllItems();
989 __pContextEditorMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
990 IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
991 __pContextSelectionMenuMove->RemoveAllItems();
992 __pContextSelectionMenuMove->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
993 IDA_CONTEXTMENU_SELECTION_MOVE_CREATE_ALBUM);
995 loopCount = __pContentDirectoryNameList->GetCount();
996 for (int i = 0; i < loopCount; ++i)
998 pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
999 __pContextEditorMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
1000 IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
1001 __pContextSelectionMenuMove->AddItem(*(new (std::nothrow) String(*pDirName)),
1002 IDA_CONTEXTMENU_SELECTION_MOVE_ALBUM_ARRAY_START + i);
1004 __pContextEditorMenuMove->SetShowState(false);
1005 __pContextSelectionMenuMove->SetShowState(false);
1006 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1010 FileListEditorForm::OnFormBackRequested(Form& source)
1012 AppLogDebug("ENTER");
1014 SceneManager* pSceneManager = SceneManager::GetInstance();
1015 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
1017 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1019 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1021 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1023 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1025 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1030 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1032 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1034 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1036 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1038 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1040 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1042 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1044 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1045 (pSceneManager->GetCurrentScene()->GetPanel());
1046 if (pSelectionPanel != null)
1048 IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1051 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1054 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST_EDITOR), pList);
1059 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1062 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1066 FileListEditorForm::SetFooterButtonsState(const bool enableState)
1068 AppLogDebug("ENTER");
1069 Footer* pFooter = GetFooter();
1070 TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1072 if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1074 if (enableState == true)
1076 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1077 pFooter->SetItemEnabled(0, true);
1081 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1082 pFooter->SetItemEnabled(0, false);
1088 if (enableState == true)
1090 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1091 pFooter->SetItemEnabled(0, true);
1092 pFooter->SetItemEnabled(1, true);
1096 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1097 pFooter->SetItemEnabled(0, false);
1098 pFooter->SetItemEnabled(1, false);
1101 pFooter->RequestRedraw(true);
1102 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1106 FileListEditorForm::MoveToAlbum(const String& destDirectory)
1108 AppLogDebug("ENTER");
1109 result r = E_FAILURE;
1110 String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1111 if (albumName != EMPTY_SPACE)
1113 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1114 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1115 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1116 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1117 delete pDirectoryList;
1119 SceneManager* pSceneManager = SceneManager::GetInstance();
1120 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1123 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1129 FileListEditorForm::SelectAllPressed(void)
1131 SceneManager* pSceneManager = SceneManager::GetInstance();
1132 pSceneManager->GetCurrentScene();
1134 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1136 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1137 if (pEditorPanel != null)
1139 pEditorPanel->OnSelectAllPressed();
1142 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1144 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1145 if (pEditorPanel != null)
1147 pEditorPanel->OnSelectAllPressed();
1150 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1152 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1153 if (pEditorPanel != null)
1155 pEditorPanel->OnSelectAllPressed();
1158 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1160 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1161 if (pEditorPanel != null)
1163 pEditorPanel->OnSelectAllPressed();
1169 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1171 if (__pPopUp != NULL)
1173 __pPopUp->SetShowState(false);
1176 SceneManager* pSceneManager = SceneManager::GetInstance();
1180 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1182 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1183 if (pEditorPanel != null)
1185 pEditorPanel->OnRequestSlideShow();
1188 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1190 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1191 (pSceneManager->GetCurrentScene()->GetPanel());
1193 if (pSelectionPanel != null)
1195 pSelectionPanel->OnRequestSlideShow();
1199 else if (index == 1)
1201 SceneManager* pSceneManager = SceneManager::GetInstance();
1202 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1204 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
1209 FileListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1211 AppLogDebug("ENTER");
1212 __pPresentationModel->RemoveContentEventListener(this);
1213 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1217 FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1219 AppLogDebug("ENTER");
1220 __pPresentationModel->AddContentEventListener(this);
1221 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));