Fixed issue 55407
[apps/osp/Gallery.git] / src / GlFileListEditorForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                GlFileListEditorForm.cpp
19  * @brief               This is the implementation file for FileListEditorForm class.
20  */
21
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 "GlProgressAnimation.h"
29 #include "GlResourceManager.h"
30 #include "GlSlideSettingListener.h"
31 #include "GlSlideShowPopUp.h"
32 #include "GlTypes.h"
33 #include "GlVideoListEditorPanel.h"
34 #include "GlFileMoveTimer.h"
35
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Content;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::System;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Scenes;
45 using namespace Tizen::Base::Utility;
46
47 static const int GAP_W_POPUP_ITEM = 10;
48 static const int W_DELETE_POPUP = 688;
49 static const int H_DELETE_POPUP = 230;
50 static const int H_DELETE_LABEL = 80;
51 static const int Y_DELETE_BUTTON = 132;
52 static const int H_DELETE_BUTTON = 74;
53 static const int W_DELETE_BUTTON = 318;
54 static const int H_TOAST_LABEL = 48;
55 static const int Y_DELETE_LABEL = 32;
56
57 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
58 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
59 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
60
61 static const String RESERVED_MEDIA_PATH = Environment::GetMediaPath();
62
63 FileListEditorForm::FileListEditorForm(void)
64         : __pShareContextMenu(null)
65         , __pOptionMenu(null)
66         , __pDeletePopup(null)
67         , __morePosition(Point(0, 0))
68         , __pContentDirectoryList(null)
69         , __pContentDirectoryNameList(null)
70         , __pPopUp(null)
71         , __pFileMove(null)
72         , __isCopyOperation(false)
73         , __pPresentationModel(null)
74         , __isScanProgress(false)
75 {
76         AppLogDebug("ENTER");
77         _overlayMsg = false;
78         _pProgressAnim = null;
79         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
80 }
81
82 FileListEditorForm::~FileListEditorForm(void)
83 {
84         AppLogDebug("ENTER");
85         if (__pContentDirectoryList != null)
86         {
87                 __pContentDirectoryList->RemoveAll(true);
88                 delete __pContentDirectoryList;
89                 __pContentDirectoryList = null;
90         }
91
92         if (__pPopUp != null)
93         {
94                 delete __pPopUp;
95                 __pPopUp = null;
96         }
97
98         if (__pContentDirectoryNameList != null)
99         {
100                 __pContentDirectoryNameList->RemoveAll(true);
101                 delete __pContentDirectoryNameList;
102                 __pContentDirectoryNameList = null;
103         }
104         delete __pFileMove;
105         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
106 }
107
108 result
109 FileListEditorForm::Initialize(void)
110 {
111         AppLogDebug("ENTER");
112         result r = Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE | FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE);
113
114         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
115
116         return r;
117 }
118
119 void
120 FileListEditorForm::ShowAnimation()
121 {
122         Rectangle clientRect= GetClientAreaBounds();
123         Rectangle rect(0, 0, clientRect.width, clientRect.height);
124         _pProgressAnim = new (std::nothrow) ProgressAnimation;
125         _pProgressAnim->Construct(rect);
126         AddControl(_pProgressAnim);
127         _pProgressAnim->SetShowState(true);
128         GetFooter()->SetEnabled(false);
129         _pProgressAnim->AnimationStart();
130         _pProgressAnim->Draw();
131         _overlayMsg = true;
132 }
133
134 void
135 FileListEditorForm::StopAnimation(void)
136 {
137         if (_pProgressAnim)
138         {
139                 _pProgressAnim->AnimationStop();
140                 _pProgressAnim->SetShowState(false);
141                 RemoveControl(_pProgressAnim);
142                 GetFooter()->SetEnabled(true);
143                 _pProgressAnim = null;
144                 _overlayMsg = false;
145         }
146 }
147
148 result
149 FileListEditorForm::OnInitializing(void)
150 {
151         AppLogDebug("ENTER");
152         Header* pHeader = GetHeader();
153         TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
154
155         SetOrientation(ORIENTATION_AUTOMATIC);
156         AddOrientationEventListener(*this);
157
158         __pPresentationModel = FileListPresentationModel::GetInstance();
159         __pPresentationModel->ClearThumbnailRequests();
160
161         pHeader->SetStyle(HEADER_STYLE_TITLE);
162         pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
163
164         if ((__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
165                 && __pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_SINGLE) == false)
166         {
167                 Bitmap* pNormalBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL);
168                 Bitmap* pPressBitmap = ResourceManager::GetBitmapN(IDB_ICON_SELECT_ALL_PRESS);
169                 ButtonItem selectAll;
170                 selectAll.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FILE_LIST_SELECT_ALL);
171                 selectAll.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBitmap);
172                 selectAll.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pPressBitmap);
173                 pHeader->SetButton(BUTTON_POSITION_LEFT, selectAll);
174                 delete pNormalBitmap;
175                 delete pPressBitmap;
176         }
177
178         pHeader->AddActionEventListener(*this);
179
180         InitializeFooter();
181         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
182
183         return E_SUCCESS;
184 }
185
186 result
187 FileListEditorForm::InitializeFooter(void)
188 {
189         AppLogDebug("ENTER");
190         Footer* pFooter = GetFooter();
191         TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
192         pFooter->RemoveAllItems();
193
194         result r = E_SUCCESS;
195
196         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
197         {
198                 if (__pPresentationModel->GetAppControlSelectionMode() == APPCONTROL_SELECTION_MODE_MULTIPLE)
199                 {
200                         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
201
202                         FooterItem footerConfirm;
203                         footerConfirm.Construct(IDA_FOOTER_CONFIRM);
204                         footerConfirm.SetText(ResourceManager::GetString(L"IDS_COM_SK_DONE"));
205                         pFooter->AddItem(footerConfirm);
206                         pFooter->SetItemEnabled(0, false);
207                         pFooter->SetShowState(true);
208                         pFooter->Invalidate(true);
209                 }
210                 else
211                 {
212                         pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
213                         pFooter->SetShowState(false);
214                         pFooter->Invalidate(true);
215                 }
216
217                 SetFormBackEventListener(this);
218
219         }
220         else
221         {
222                 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
223                 SetFormMenuEventListener(this);
224
225                 FooterItem footerShare;
226                 r = footerShare.Construct(IDA_FOOTER_SHARE);
227                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
228                 Bitmap* pBitmapShare = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE);
229                 Bitmap* pBitmapShareDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_SHARE_DIM);
230
231                 if (pBitmapShare != null && pBitmapShareDim != null)
232                 {
233                         footerShare.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapShare);
234                         footerShare.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapShareDim);
235                 }
236
237                 r = pFooter->AddItem(footerShare);
238                 delete pBitmapShare;
239                 delete pBitmapShareDim;
240                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
241
242                 FooterItem footerDelete;
243                 r = footerDelete.Construct(IDA_FOOTER_DELETE);
244                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to construct footer item", GetErrorMessage(r));
245                 Bitmap* pBitmapDelete = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE);
246                 Bitmap* pBitmapDeleteDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_DELETE_DIM);
247
248                 if (pBitmapDelete != null && pBitmapDeleteDim != null)
249                 {
250                         footerDelete.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapDelete);
251                         footerDelete.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmapDeleteDim);
252                 }
253
254                 r = pFooter->AddItem(footerDelete);
255                 delete pBitmapDelete;
256                 delete pBitmapDeleteDim;
257                 TryReturn(r == E_SUCCESS, r, "[%s] Unable to add item", GetErrorMessage(r));
258
259                 SetFormBackEventListener(this);
260
261                 SceneManager* pSceneManager = SceneManager::GetInstance();
262                 int checkedCount = 0;
263
264                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
265                 {
266                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
267                         if (pEditorPanel != null)
268                         {
269                                 checkedCount = pEditorPanel->GetItemCheckedCount();
270                         }
271                 }
272                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
273                 {
274                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
275                         if (pSelectionPanel != null)
276                         {
277                                 checkedCount = pSelectionPanel->GetItemCheckedCount();
278                         }
279                 }
280
281                 AppLogDebug("GetItemCheckedCount(%d)", checkedCount);
282
283                 if (__pOptionMenu != null)
284                 {
285                         delete __pOptionMenu;
286                         __pOptionMenu = null;
287                 }
288
289                 __pOptionMenu = new (std::nothrow) OptionMenu();
290                 __pOptionMenu->Construct();
291                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
292                                 IDA_CONTEXT_MENU_MORE_MOVE);
293                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
294                                 IDA_CONTEXT_MENU_MORE_COPY);
295
296                 if (checkedCount > 1)
297                 {
298                         __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
299                                         IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
300                 }
301
302                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
303                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
304
305                 __pOptionMenu->AddActionEventListener(*this);
306
307                 if (__pContentDirectoryNameList != null)
308                 {
309                         __pContentDirectoryNameList->RemoveAll(true);
310                         delete __pContentDirectoryNameList;
311                         __pContentDirectoryNameList = null;
312                 }
313
314                 SetUpPopup();
315         }
316
317         pFooter->AddActionEventListener(*this);
318         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
319
320         return r;
321 }
322
323 String
324 FileListEditorForm::GetDirecotyNameFromFullPath(const String& fullPath)const
325 {
326         AppLogDebug("ENTER");
327         if (fullPath == null)
328         {
329                 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
330
331                 return null;
332         }
333         String delim(DIRECTORY_SEPARATOR);
334         StringTokenizer st(fullPath,delim);
335         String token;
336         while (st.HasMoreTokens())
337         {
338                 st.GetNextToken(token);
339         }
340         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
341
342         return token;
343 }
344
345 result
346 FileListEditorForm::OnTerminating(void)
347 {
348         AppLogDebug("ENTER");
349         __pPresentationModel->RemoveContentEventListener(this);
350
351         if (__pOptionMenu != null)
352         {
353                 __pOptionMenu->RemoveActionEventListener(*this);
354                 delete __pOptionMenu;
355                 __pOptionMenu = null;
356         }
357
358         if (__pShareContextMenu != null)
359         {
360                 __pShareContextMenu->RemoveActionEventListener(*this);
361                 delete __pShareContextMenu;
362                 __pShareContextMenu = null;
363         }
364
365         if (__pDeletePopup != null)
366         {
367                 delete __pDeletePopup;
368                 __pDeletePopup = null;
369         }
370         _overlayMsg = false;
371         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
372
373         return E_SUCCESS;
374 }
375
376 void
377 FileListEditorForm::OnActionPerformed(const Control& source, int actionId)
378 {
379         AppLogDebug("ENTER(actionId=%d)", actionId);
380         SceneManager* pSceneManager = SceneManager::GetInstance();
381         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
382
383         switch (actionId)
384         {
385         case IDA_FILE_LIST_SELECT_ALL:
386                 SelectAllPressed();
387         break;
388
389         case IDA_FOOTER_SHARE:
390         {
391                 if (__pShareContextMenu != NULL)
392                 {
393                         delete __pShareContextMenu;
394                         __pShareContextMenu = null;
395                 }
396
397                 Bitmap* pBitmapEmailContextItem = null;
398                 Bitmap* pBitmapMessageContextItem = null;
399                 pBitmapEmailContextItem = ResourceManager::GetBitmapN(IDB_IMAGE_CONTEXT_EMAIL_ICON);
400                 pBitmapMessageContextItem = ResourceManager::GetBitmapN(IDB_IMAGE_CONTEXT_MESSAGE_ICON);
401
402                 __pShareContextMenu = new (std::nothrow) ContextMenu();
403                 __pShareContextMenu->Construct(Point(GetClientAreaBounds().width/3 + 15, GetClientAreaBounds().height),
404                                 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
405
406                 if ( pBitmapMessageContextItem != null)
407                 {
408                         __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
409                                 IDA_CONTEXT_MENU_SHARE_MESSAGE, *pBitmapMessageContextItem, null, null);
410                         delete pBitmapMessageContextItem;
411                 }
412
413                 if ( pBitmapEmailContextItem != null)
414                 {
415                         __pShareContextMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"),
416                                 IDA_CONTEXT_MENU_SHARE_EMAIL, *pBitmapEmailContextItem, null, null);
417                         delete pBitmapEmailContextItem;
418                 }
419                 __pShareContextMenu->SetFocusable(true);
420                 __pShareContextMenu->AddActionEventListener(*this);
421
422
423                 Rectangle rect = source.GetBounds();
424
425                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
426                 {
427                         __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y));
428                 }
429                 else
430                 {
431                         __pShareContextMenu->SetAnchorPosition(Point(rect.width / 8 * 3, rect.y - H_TOAST_LABEL));
432                 }
433
434                 __pShareContextMenu->SetShowState(true);
435                 __pShareContextMenu->Show();
436
437         }
438         break;
439
440         case IDA_FOOTER_DELETE:
441         {
442                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
443                 {
444                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
445                         if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
446                         {
447                                 __pDeletePopup->SetShowState(true);
448                                 __pDeletePopup->Show();
449                                 _overlayMsg = true;
450                         }
451                 }
452                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
453                 {
454                         ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
455                         if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
456                         {
457                                 __pDeletePopup->SetShowState(true);
458                                 __pDeletePopup->Show();
459                                 _overlayMsg = true;
460                         }
461                 }
462                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
463                 {
464                         VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
465                         if (pEditorPanel != null && pEditorPanel->GetItemCheckedCount() > 0)
466                         {
467                                 __pDeletePopup->SetShowState(true);
468                                 __pDeletePopup->Show();
469                                 _overlayMsg = true;
470                         }
471                 }
472                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
473                 {
474                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
475                         (pSceneManager->GetCurrentScene()->GetPanel());
476                         if (pSelectionPanel != null && pSelectionPanel->GetItemCheckedCount() > 0)
477                         {
478                                 __pDeletePopup->SetShowState(true);
479                                 __pDeletePopup->Show();
480                                 _overlayMsg = true;
481                         }
482                 }
483         }
484         break;
485
486         case IDA_CONTEXT_MENU_MORE_EDIT:
487         {
488                 break;
489         }
490
491         case IDA_CONTEXT_MENU_MORE_ADD_TAG:
492         {
493                 break;
494         }
495
496         case IDA_CONTEXT_MENU_MORE_COPY:
497
498         case IDA_CONTEXT_MENU_MORE_MOVE:
499         {
500                 if (actionId == IDA_CONTEXT_MENU_MORE_MOVE)
501                 {
502                         __isCopyOperation = false;
503                 }
504                 else if (actionId == IDA_CONTEXT_MENU_MORE_COPY)
505                 {
506                         __isCopyOperation = true;
507                 }
508
509                 RefreshFolderList();
510
511                 __pOptionMenu->SetShowState(true);
512                 __pOptionMenu->Show();
513
514
515         }
516         break;
517
518         case IDA_CONTEXT_MENU_MORE_SLIDE_SHOW:
519         {
520                 if (__pPopUp != NULL)
521                 {
522                         delete __pPopUp;
523                         __pPopUp = NULL;
524                 }
525                 __pPopUp = new (std::nothrow) SlideShowPopUp();
526
527                 if (__pPopUp != null)
528                 {
529                         __pPopUp->Initialize();
530                         __pPopUp->SetEventListner(this);
531                         __pPopUp->SetShowState(true);
532                         __pPopUp->Show();
533                 }
534         }
535         break;
536
537         case IDA_CONTEXT_MENU_SHARE_MESSAGE:
538         {
539                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
540                 {
541                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
542                         if (pEditorPanel != null)
543                         {
544                                 pEditorPanel->OnRequestMessage();
545                         }
546                 }
547                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
548                 {
549                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
550                         if (pSelectionPanel != null)
551                         {
552                                 pSelectionPanel->OnRequestMessage();
553                         }
554                 }
555         }
556         break;
557
558         case IDA_CONTEXT_MENU_SHARE_EMAIL:
559         {
560                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
561                 {
562                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
563                         if (pEditorPanel != null)
564                         {
565                                 pEditorPanel->OnRequestEmail();
566                         }
567                 }
568                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
569                 {
570                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
571                         if (pSelectionPanel != null)
572                         {
573                                 pSelectionPanel->OnRequestEmail();
574                         }
575                 }
576         }
577         break;
578
579         case IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM:
580         {
581                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
582                 {
583                         AllListEditorPanel* pListEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
584                         if (pListEditorPanel)
585                         {
586                                 IList* pList = pListEditorPanel->GetItemCheckedIndexListN();
587                                 pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
588                                 if (__isCopyOperation)
589                                 {
590                                         pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
591                                 }
592                                 else
593                                 {
594                                         pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
595                                 }
596                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
597                         }
598
599                 }
600                 else
601                 {
602                         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
603                         {
604                                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
605                                 (pSceneManager->GetCurrentScene()->GetPanel());
606
607                                 if (pSelectionPanel != null)
608                                 {
609                                         IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
610                                         pList->InsertAt(new (std::nothrow) Integer(ALBUM_CREATE), ALBUM_FIRST_ELEMENT);
611                                         if (__isCopyOperation)
612                                         {
613                                                 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_COPY), ALBUM_SECOND_ELEMENT);
614                                         }
615                                         else
616                                         {
617                                                 pList->InsertAt(new (std::nothrow) Integer(FILE_ACTION_MOVE), ALBUM_SECOND_ELEMENT);
618                                         }
619                                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_NAME_EDITOR), pList);
620                                 }
621                         }
622                 }
623         }
624         break;
625
626         case IDA_DELETE_POPUP_DEL:
627         {
628                 _overlayMsg = false;
629                 __pDeletePopup->SetShowState(false);
630                 __pDeletePopup->Invalidate(true);
631
632                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
633                 {
634                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
635                         if (pEditorPanel != null)
636                         {
637                                 result r = pEditorPanel->OnRequestDelete();
638                                 if (IsFailed(r))
639                                 {
640                                         AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
641                                 }
642                         }
643                 }
644                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
645                 {
646                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
647                         (pSceneManager->GetCurrentScene()->GetPanel());
648
649                         if (pSelectionPanel != null)
650                         {
651                                 result r = pSelectionPanel->OnRequestDelete();
652                                 if (IsFailed(r))
653                                 {
654                                         AppLogDebug("OnRequestDelete failed with %s", GetErrorMessage(r));
655                                 }
656                         }
657                 }
658         }
659         break;
660
661         case IDA_DELETE_POPUP_CANCEL:
662         {
663                 _overlayMsg = false;
664                 __pDeletePopup->SetShowState(false);
665                 __pDeletePopup->Invalidate(true);
666         }
667         break;
668
669         case IDA_CONTEXT_MENU_ROTATE_LEFT:
670         {
671                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
672                 {
673                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
674                         if (pEditorPanel != null)
675                         {
676                                 RotateMode rotateMode = ROTATE_MODE_LEFT;
677                                 pEditorPanel->OnRequestRotate(rotateMode);
678                         }
679                 }
680                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
681                 {
682                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
683                         (pSceneManager->GetCurrentScene()->GetPanel());
684
685                         if (pSelectionPanel != null)
686                         {
687                                 RotateMode rotateMode = ROTATE_MODE_LEFT;
688                                 pSelectionPanel->OnRotateRequested(rotateMode);
689                         }
690                 }
691         }
692         break;
693
694         case IDA_CONTEXT_MENU_ROTATE_RIGHT:
695         {
696                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
697                 {
698                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
699                         if (pEditorPanel != null)
700                         {
701                                 RotateMode rotateMode = ROTATE_MODE_RIGHT;
702                                 pEditorPanel->OnRequestRotate(rotateMode);
703                         }
704                 }
705                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
706                 {
707
708                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
709                         (pSceneManager->GetCurrentScene()->GetPanel());
710
711                         if (pSelectionPanel != null)
712                         {
713                                 RotateMode rotateMode = ROTATE_MODE_RIGHT;
714                                 pSelectionPanel->OnRotateRequested(rotateMode);
715                         }
716                 }
717         }
718         break;
719
720         case IDA_FOOTER_CONFIRM:
721         {
722                 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
723                 {
724                         ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
725                         if (pEditorPanel != null)
726                         {
727                                 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
728                         }
729                 }
730                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
731                 {
732                         VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
733                         if (pEditorPanel != null)
734                         {
735                                 pEditorPanel->OnRequestAppExitWithMultipleSelectionAppControlResult();
736                         }
737                 }
738         }
739         break;
740
741         default:
742         {
743                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
744                 {
745                         if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
746                                         (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
747                         {
748                                 if (__pContentDirectoryList == null)
749                                 {
750                                         return;
751                                 }
752                                 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
753                                 {
754                                         String* pDirectory = static_cast<String*>
755                                         (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
756
757                                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>
758                                         (pSceneManager->GetCurrentScene()->GetPanel());
759
760                                         if (pEditorPanel != null)
761                                         {
762                                                 delete __pFileMove;
763                                                 IList* pItemIndexList = pEditorPanel->GetItemCheckedIndexListN();
764                                                 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
765                                                 if (__isCopyOperation)
766                                                 {
767                                                         __pFileMove->SetCopy();
768                                                 }
769
770                                                 result r = __pFileMove->StartTimer();
771                                                 if (IsFailed(r))
772                                                 {
773                                                         delete __pFileMove;
774                                                         __pFileMove = null;
775                                                         __isCopyOperation = false;
776                                                 }
777                                                 else
778                                                 {
779                                                         _overlayMsg = true;
780                                                 }
781                                         }
782                                 }
783                         }
784                 }
785                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
786                 {
787                         if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
788                                         (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
789                         {
790                                 if (__pContentDirectoryList == null)
791                                 {
792
793                                         return;
794                                 }
795                                 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
796                                 {
797                                         String* pDirectory = static_cast<String*>
798                                         (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
799
800                                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
801                                                 (pSceneManager->GetCurrentScene()->GetPanel());
802
803                                         if (pSelectionPanel != null)
804                                         {
805                                                 delete __pFileMove;
806                                                 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
807                                                 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
808                                                 if (__isCopyOperation)
809                                                 {
810                                                         __pFileMove->SetCopy();
811                                                 }
812                                                 result r = __pFileMove->StartTimer();
813                                                 if (IsFailed(r))
814                                                 {
815                                                         delete __pFileMove;
816                                                         __pFileMove = null;
817                                                         __isCopyOperation = false;
818                                                 }
819                                                 else
820                                                 {
821                                                         _overlayMsg = true;
822                                                 }
823                                         }
824                                 }
825                         }
826                 }
827                 break;
828         }
829         }
830         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
831 }
832
833 void
834 FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
835 {
836         Invalidate(true);
837 }
838
839
840 void
841 FileListEditorForm::OnScanDirStart()
842 {
843         AppLogDebug("ENTER");
844         GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, false);
845         __isScanProgress = true;
846         Invalidate(true);
847         AppLogDebug("ENTER");
848 }
849 void
850 FileListEditorForm::OnScanDirComplete()
851 {
852         AppLogDebug("ENTER");
853         GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
854         __isScanProgress = false;
855         Invalidate(true);
856         AppLogDebug("ENTER");
857 }
858
859
860 bool
861 FileListEditorForm::GetOverlayStatus(void) const
862 {
863         return _overlayMsg;
864 }
865
866 void
867 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
868 {
869         AppLogDebug("ENTER");
870         _overlayMsg = false;
871         __pPresentationModel->SetUpdateProgressStatus(false);
872         if (res != COMPLETE_SUCCESS)
873         {
874                 MessageBox messageBox;
875                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_OPERATION_FAILED"), MSGBOX_STYLE_OK, 3000);
876                 int modalResult = 0;
877                 _overlayMsg = true;
878                 messageBox.ShowAndWait(modalResult);
879                 _overlayMsg = false;
880                 SceneManager* pSceneManager = SceneManager::GetInstance();
881                 AppAssert(pSceneManager);
882                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
883         }
884         AppLogDebug("EXIT");
885 }
886
887 void
888 FileListEditorForm::OnContentUpdated()
889 {
890         AppLogDebug("ENTER");
891
892         SceneManager* pSceneManager = SceneManager::GetInstance();
893
894         if(__pDeletePopup != null)
895         {
896                 if(__pDeletePopup->IsVisible() == true)
897                 {
898                         __pDeletePopup->Destroy();
899                         __pDeletePopup = null;
900                         _overlayMsg = false;
901                         SetUpPopup();
902                 }
903         }
904
905         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
906         {
907                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
908                 if (pEditorPanel != null)
909                 {
910                         pEditorPanel->CancelUpdateProgress();
911                 }
912         }
913         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
914         {
915                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
916                 if (pSelectionPanel != null)
917                 {
918                         pSelectionPanel->CancelUpdateProgress();
919                 }
920         }
921
922         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
923                         && pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
924         {
925                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
926                                 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
927
928         }
929         else if (_overlayMsg == false)
930         {
931                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
932                                 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
933         }
934
935         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
936 }
937
938 result
939 FileListEditorForm::SetUpPopup(void)
940 {
941         AppLogDebug("ENTER");
942         result r = E_SUCCESS;
943
944         if (__pDeletePopup != null)
945         {
946                 delete __pDeletePopup;
947                 __pDeletePopup = null;
948         }
949
950         __pDeletePopup = new (std::nothrow) Popup();
951         __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
952         __pDeletePopup->SetPropagatedKeyEventListener(this);
953
954         Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
955
956         Label* pLabelText = new (std::nothrow) Label();
957         pLabelText->Construct(Rectangle(0, Y_DELETE_LABEL, popupClientBounds.width, H_DELETE_LABEL),
958                         ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
959         pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
960         pLabelText->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
961         __pDeletePopup->AddControl(pLabelText);
962
963         Button* pDeleteButton = new (std::nothrow) Button();
964         pDeleteButton->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON),
965                         ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
966         pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
967         pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
968         pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
969         pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
970         pDeleteButton->AddActionEventListener(*this);
971         __pDeletePopup->AddControl(pDeleteButton);
972
973         Button* pButtonCancel = new (std::nothrow) Button();
974         pButtonCancel->Construct(Rectangle(16, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON),
975                         ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
976         pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
977         pButtonCancel->AddActionEventListener(*this);
978         __pDeletePopup->AddControl(pButtonCancel);
979         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
980
981         return r;
982 }
983
984 void
985 FileListEditorForm::SetTitleText(const String& titleText)
986 {
987         AppLogDebug("ENTER");
988         Header* pHeader = GetHeader();
989         TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
990         pHeader->SetTitleText(titleText);
991         pHeader->Invalidate(true);
992         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
993 }
994
995 void
996 FileListEditorForm::RefreshFolderList(void)
997 {
998         AppLogDebug("ENTER");
999         ContentDirectory contentDirectory;
1000         IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1001         pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1002         pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1003         result r = contentDirectory.Construct(*pContentTypeList);
1004         if (r != E_SUCCESS)
1005         {
1006                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1007                 return;
1008         }
1009         delete pContentTypeList;
1010
1011         if (__pContentDirectoryList != null)
1012         {
1013                 __pContentDirectoryList->RemoveAll(true);
1014                 delete __pContentDirectoryList;
1015                 __pContentDirectoryList = null;
1016         }
1017         __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
1018
1019         if (__pContentDirectoryNameList != NULL)
1020         {
1021                 __pContentDirectoryNameList->RemoveAll(true);
1022                 delete __pContentDirectoryNameList;
1023                 __pContentDirectoryNameList = null;
1024         }
1025
1026         __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1027         String* pDirPath = null;
1028         String* pDirName = null;
1029         String mediaPath = RESERVED_MEDIA_PATH;
1030         int length = mediaPath.GetLength();
1031         mediaPath.Remove(length-1,1);
1032
1033         int loopCount = __pContentDirectoryList->GetCount();
1034         for (int i = 0; i < loopCount; ++i)
1035         {
1036                 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
1037                 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
1038
1039                 if (*pDirPath == mediaPath)
1040                 {
1041                         *pDirName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
1042                         __pContentDirectoryNameList->Add(pDirName);
1043                 }
1044                 else
1045                 {
1046                         __pContentDirectoryNameList->Add(pDirName);
1047                 }
1048         }
1049
1050                 __pOptionMenu->RemoveAllItems();
1051                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
1052                                 IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
1053
1054                 loopCount = __pContentDirectoryNameList->GetCount();
1055
1056                 String dirAllAlbums = L"All albums";
1057
1058                 for (int i = 0; i < loopCount; ++i)
1059                 {
1060                         pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
1061
1062                         if (*pDirName != __pPresentationModel->GetCurrentAlbumName() || *pDirName == dirAllAlbums)
1063                         {
1064                                 __pOptionMenu->AddItem(*(new (std::nothrow) String(*pDirName)),
1065                                                 IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
1066                         }
1067                 }
1068
1069
1070         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1071 }
1072
1073 void
1074 FileListEditorForm::OnFormBackRequested(Form& source)
1075 {
1076         AppLogDebug("ENTER");
1077
1078         if(__isScanProgress)
1079         {
1080                 return;
1081         }
1082
1083         SceneManager* pSceneManager = SceneManager::GetInstance();
1084         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
1085
1086         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1087         {
1088                 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1089                 {
1090                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1091                 }
1092                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1093                 {
1094                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1095                 }
1096         }
1097         else
1098         {
1099                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1100                 {
1101                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1102                 }
1103                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1104                 {
1105                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1106                 }
1107                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1108                 {
1109                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1110                 }
1111                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1112                 {
1113                         if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true)
1114                         {
1115                                 __pShareContextMenu->SetShowState(false);
1116                         }
1117                         else
1118                         {
1119                                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1120                                 (pSceneManager->GetCurrentScene()->GetPanel());
1121                                 if (pSelectionPanel != null)
1122                                 {
1123                                         IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1124                                         if (pList == null)
1125                                         {
1126                                                 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1127                                         }
1128
1129                                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1130                                                         SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
1131                                 }
1132                         }
1133                 }
1134                 else
1135                 {
1136                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1137                 }
1138         }
1139         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1140 }
1141
1142 void
1143 FileListEditorForm::SetFooterButtonsState(const bool enableState)
1144 {
1145         AppLogDebug("ENTER");
1146         Footer* pFooter = GetFooter();
1147         TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1148
1149         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1150         {
1151                 if (enableState == true)
1152                 {
1153                         pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1154                         pFooter->SetItemEnabled(0, true);
1155                 }
1156                 else
1157                 {
1158                         pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1159                         pFooter->SetItemEnabled(0, false);
1160                 }
1161         }
1162         else
1163         {
1164                 if (enableState == true)
1165                 {
1166                         pFooter->SetItemEnabled(0, true);
1167                         pFooter->SetItemEnabled(1, true);
1168                 }
1169                 else
1170                 {
1171                         pFooter->SetItemEnabled(0, false);
1172                         pFooter->SetItemEnabled(1, false);
1173                 }
1174         }
1175         pFooter->RequestRedraw(true);
1176         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1177 }
1178
1179 void
1180 FileListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1181 {
1182         AppLogDebug("ENTER");
1183         SceneManager* pSceneManager = SceneManager::GetInstance();
1184         pSceneManager->GetCurrentScene();
1185
1186         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1187         {
1188                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1189                 if (pEditorPanel != null)
1190                 {
1191                         pEditorPanel->ChangeOrientation();
1192                 }
1193         }
1194         else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1195         {
1196                 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1197                 if (pEditorPanel != null)
1198                 {
1199                         pEditorPanel->ChangeOrientation();
1200                 }
1201         }
1202         else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1203         {
1204                 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1205                 if (pEditorPanel != null)
1206                 {
1207                         pEditorPanel->ChangeOrientation();
1208                 }
1209         }
1210         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1211         {
1212                 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1213                 if (pEditorPanel != null)
1214                 {
1215                         pEditorPanel->ChangeOrientation();
1216                 }
1217         }
1218
1219         if (_pProgressAnim != null)
1220         {
1221                 _pProgressAnim->ChangeOrientation(Form::GetBounds());
1222                 _pProgressAnim->Invalidate(true);
1223         }
1224
1225         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1226 }
1227
1228 bool
1229 FileListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
1230 {
1231         AppLogDebug("ENTER");
1232
1233         if(keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
1234         {
1235                 _overlayMsg = false;
1236                 __pDeletePopup->SetShowState(false);
1237                 __pDeletePopup->Invalidate(true);
1238         }
1239         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1240
1241         return false;
1242 }
1243
1244 result
1245 FileListEditorForm::MoveToAlbum(const String& destDirectory)
1246 {
1247         AppLogDebug("ENTER");
1248         result r = E_FAILURE;
1249         String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1250         if (albumName != EMPTY_SPACE)
1251         {
1252                 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1253                 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1254                 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1255                 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1256                 delete pDirectoryList;
1257
1258                 SceneManager* pSceneManager = SceneManager::GetInstance();
1259                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1260                 r = E_SUCCESS;
1261         }
1262         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1263
1264         return r;
1265 }
1266
1267 void
1268 FileListEditorForm::SelectAllPressed(void)
1269 {
1270         SceneManager* pSceneManager = SceneManager::GetInstance();
1271         pSceneManager->GetCurrentScene();
1272
1273         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1274         {
1275                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1276                 if (pEditorPanel != null)
1277                 {
1278                         pEditorPanel->OnSelectAllPressed();
1279                 }
1280         }
1281         else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1282         {
1283                 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1284                 if (pEditorPanel != null)
1285                 {
1286                         pEditorPanel->OnSelectAllPressed();
1287                 }
1288         }
1289         else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1290         {
1291                 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1292                 if (pEditorPanel != null)
1293                 {
1294                         pEditorPanel->OnSelectAllPressed();
1295                 }
1296         }
1297         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1298         {
1299                 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1300                 if (pEditorPanel != null)
1301                 {
1302                         pEditorPanel->OnSelectAllPressed();
1303                 }
1304         }
1305 }
1306
1307 void
1308 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1309 {
1310         if (__pPopUp != NULL)
1311         {
1312                 __pPopUp->SetShowState(false);
1313         }
1314
1315         SceneManager* pSceneManager = SceneManager::GetInstance();
1316
1317         if (index == 0)
1318         {
1319                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1320                 {
1321                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1322                         if (pEditorPanel != null)
1323                         {
1324                                 pEditorPanel->OnRequestSlideShow();
1325                         }
1326                 }
1327                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1328                 {
1329                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1330                                         (pSceneManager->GetCurrentScene()->GetPanel());
1331
1332                         if (pSelectionPanel != null)
1333                         {
1334                                 pSelectionPanel->OnRequestSlideShow();
1335                         }
1336                 }
1337         }
1338         else if (index == 1)
1339         {
1340                 SceneManager* pSceneManager = SceneManager::GetInstance();
1341                 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1342
1343                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
1344         }
1345 }
1346
1347 void
1348 FileListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1349 {
1350         AppLogDebug("ENTER");
1351         __pPresentationModel->RemoveContentEventListener(this);
1352         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1353 }
1354
1355 void
1356 FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1357 {
1358         AppLogDebug("ENTER");
1359         __pPresentationModel->AddContentEventListener(this);
1360         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1361 }
1362
1363 void
1364 FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
1365 {
1366         if(__isScanProgress)
1367         {
1368                 return;
1369         }
1370
1371         SceneManager* pSceneManager = SceneManager::GetInstance();
1372         int checkedCount = 0;
1373
1374         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1375         {
1376                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1377                 if (pEditorPanel != null)
1378                 {
1379                         checkedCount = pEditorPanel->GetItemCheckedCount();
1380                 }
1381         }
1382         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1383         {
1384                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1385                 if (pSelectionPanel != null)
1386                 {
1387                         checkedCount = pSelectionPanel->GetItemCheckedCount();
1388                 }
1389         }
1390
1391         if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true)
1392         {
1393                 __pShareContextMenu->SetShowState(false);
1394         }
1395
1396         if (checkedCount > 0)
1397         {
1398                 if (__pOptionMenu == null)
1399                 {
1400                         return;
1401                 }
1402
1403                 __pOptionMenu->RemoveAllItems();
1404                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
1405                                 IDA_CONTEXT_MENU_MORE_MOVE);
1406                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
1407                                 IDA_CONTEXT_MENU_MORE_COPY);
1408
1409                 if (checkedCount > 1)
1410                 {
1411                         __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
1412                                         IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
1413                 }
1414
1415                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
1416                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
1417
1418                 __pOptionMenu->SetShowState(true);
1419                 __pOptionMenu->Show();
1420         }
1421 }