Fixed issue 52517
[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                                                 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel , __isCopyOperation);
765                                                 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
766                                                 if (__isCopyOperation)
767                                                 {
768                                                         AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
769                                                         __pFileMove->SetCopy();
770                                                 }
771
772                                                 result r = __pFileMove->StartTimer();
773                                                 if (IsFailed(r))
774                                                 {
775                                                         delete __pFileMove;
776                                                         __pFileMove = null;
777                                                         __isCopyOperation = false;
778                                                 }
779                                                 else
780                                                 {
781                                                         _overlayMsg = true;
782                                                 }
783                                         }
784                                 }
785                         }
786                 }
787                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
788                 {
789                         if ((IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START <= actionId) &&
790                                         (actionId <= IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM + 1000))
791                         {
792                                 if (__pContentDirectoryList == null)
793                                 {
794
795                                         return;
796                                 }
797                                 if (__pContentDirectoryList->GetCount() > actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START)
798                                 {
799                                         String* pDirectory = static_cast<String*>
800                                         (__pContentDirectoryList->GetAt(actionId - IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START));
801
802                                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
803                                                 (pSceneManager->GetCurrentScene()->GetPanel());
804
805                                         if (pSelectionPanel != null)
806                                         {
807                                                 delete __pFileMove;
808                                                 IList* pItemIndexList = pSelectionPanel->GetItemCheckedIndexListN();
809                                                 GetMoveFileIndexList(*pDirectory, pItemIndexList, __pPresentationModel , __isCopyOperation);
810                                                 __pFileMove = new (std::nothrow) FileMoveTimer(*pDirectory, pItemIndexList, __pPresentationModel, this);
811                                                 if (__isCopyOperation)
812                                                 {
813                                                         AppLogDebug("Rash: Setting to Copy in FileListEditorForm");
814                                                         __pFileMove->SetCopy();
815                                                 }
816                                                 result r = __pFileMove->StartTimer();
817                                                 if (IsFailed(r))
818                                                 {
819                                                         delete __pFileMove;
820                                                         __pFileMove = null;
821                                                         __isCopyOperation = false;
822                                                 }
823                                                 else
824                                                 {
825                                                         _overlayMsg = true;
826                                                 }
827                                         }
828                                 }
829                         }
830                 }
831                 break;
832         }
833         }
834         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
835 }
836
837 void
838 FileListEditorForm::OnFileOpInvalidate(enum FileActionMode actionId)
839 {
840         Invalidate(true);
841 }
842
843
844 void
845 FileListEditorForm::OnScanDirStart()
846 {
847         AppLogDebug("ENTER");
848         GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, false);
849         __isScanProgress = true;
850         Invalidate(true);
851         AppLogDebug("ENTER");
852 }
853 void
854 FileListEditorForm::OnScanDirComplete()
855 {
856         AppLogDebug("ENTER");
857         GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
858         __isScanProgress = false;
859         Invalidate(true);
860         AppLogDebug("ENTER");
861 }
862
863
864 bool
865 FileListEditorForm::GetOverlayStatus(void) const
866 {
867         return _overlayMsg;
868 }
869
870 void
871 FileListEditorForm::OnFileOpComplete(enum FileActionMode actionId, enum FileActionCompleteRes res)
872 {
873         AppLogDebug("ENTER");
874         _overlayMsg = false;
875         __pPresentationModel->SetUpdateProgressStatus(false);
876         if (res != COMPLETE_SUCCESS)
877         {
878                 MessageBox messageBox;
879                 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_BODY_OPERATION_FAILED"), MSGBOX_STYLE_OK, 3000);
880                 int modalResult = 0;
881                 _overlayMsg = true;
882                 messageBox.ShowAndWait(modalResult);
883                 _overlayMsg = false;
884                 SceneManager* pSceneManager = SceneManager::GetInstance();
885                 AppAssert(pSceneManager);
886                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
887         }
888         AppLogDebug("EXIT");
889 }
890
891 void
892 FileListEditorForm::OnContentUpdated()
893 {
894         AppLogDebug("ENTER");
895
896         SceneManager* pSceneManager = SceneManager::GetInstance();
897
898         if(__pDeletePopup != null)
899         {
900                 if(__pDeletePopup->IsVisible() == true)
901                 {
902                         __pDeletePopup->Destroy();
903                         __pDeletePopup = null;
904                         _overlayMsg = false;
905                         SetUpPopup();
906                 }
907         }
908
909         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
910         {
911                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
912                 if (pEditorPanel != null)
913                 {
914                         pEditorPanel->CancelUpdateProgress();
915                 }
916         }
917         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
918         {
919                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
920                 if (pSelectionPanel != null)
921                 {
922                         pSelectionPanel->CancelUpdateProgress();
923                 }
924         }
925
926         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK
927                         && pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
928         {
929                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
930                                 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
931
932         }
933         else if (_overlayMsg == false)
934         {
935                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
936                                 SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
937         }
938
939         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
940 }
941
942 result
943 FileListEditorForm::SetUpPopup(void)
944 {
945         AppLogDebug("ENTER");
946         result r = E_SUCCESS;
947
948         if (__pDeletePopup != null)
949         {
950                 delete __pDeletePopup;
951                 __pDeletePopup = null;
952         }
953
954         __pDeletePopup = new (std::nothrow) Popup();
955         __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
956         __pDeletePopup->SetPropagatedKeyEventListener(this);
957
958         Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
959
960         Label* pLabelText = new (std::nothrow) Label();
961         pLabelText->Construct(Rectangle(0, Y_DELETE_LABEL, popupClientBounds.width, H_DELETE_LABEL),
962                         ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
963         pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
964         pLabelText->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
965         __pDeletePopup->AddControl(pLabelText);
966
967         Button* pDeleteButton = new (std::nothrow) Button();
968         pDeleteButton->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON),
969                         ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
970         pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
971         pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
972         pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
973         pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
974         pDeleteButton->AddActionEventListener(*this);
975         __pDeletePopup->AddControl(pDeleteButton);
976
977         Button* pButtonCancel = new (std::nothrow) Button();
978         pButtonCancel->Construct(Rectangle(16, Y_DELETE_BUTTON, W_DELETE_BUTTON, H_DELETE_BUTTON),
979                         ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
980         pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
981         pButtonCancel->AddActionEventListener(*this);
982         __pDeletePopup->AddControl(pButtonCancel);
983         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
984
985         return r;
986 }
987
988 void
989 FileListEditorForm::SetTitleText(const String& titleText)
990 {
991         AppLogDebug("ENTER");
992         Header* pHeader = GetHeader();
993         TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
994         pHeader->SetTitleText(titleText);
995         pHeader->Invalidate(true);
996         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
997 }
998
999 void
1000 FileListEditorForm::RefreshFolderList(void)
1001 {
1002         AppLogDebug("ENTER");
1003         ContentDirectory contentDirectory;
1004         IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
1005         pContentTypeList->Add(CONTENT_TYPE_IMAGE);
1006         pContentTypeList->Add(CONTENT_TYPE_VIDEO);
1007         result r = contentDirectory.Construct(*pContentTypeList);
1008         if (r != E_SUCCESS)
1009         {
1010                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1011                 return;
1012         }
1013         delete pContentTypeList;
1014
1015         if (__pContentDirectoryList != null)
1016         {
1017                 __pContentDirectoryList->RemoveAll(true);
1018                 delete __pContentDirectoryList;
1019                 __pContentDirectoryList = null;
1020         }
1021         __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
1022
1023         if (__pContentDirectoryNameList != NULL)
1024         {
1025                 __pContentDirectoryNameList->RemoveAll(true);
1026                 delete __pContentDirectoryNameList;
1027                 __pContentDirectoryNameList = null;
1028         }
1029
1030         __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1031         String* pDirPath = null;
1032         String* pDirName = null;
1033         String mediaPath = RESERVED_MEDIA_PATH;
1034         int length = mediaPath.GetLength();
1035         mediaPath.Remove(length-1,1);
1036
1037         int loopCount = __pContentDirectoryList->GetCount();
1038         for (int i = 0; i < loopCount; ++i)
1039         {
1040                 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
1041                 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
1042
1043                 if (*pDirPath == mediaPath)
1044                 {
1045                         *pDirName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
1046                         __pContentDirectoryNameList->Add(pDirName);
1047                 }
1048                 else
1049                 {
1050                         __pContentDirectoryNameList->Add(pDirName);
1051                 }
1052         }
1053
1054                 __pOptionMenu->RemoveAllItems();
1055                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
1056                                 IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
1057
1058                 loopCount = __pContentDirectoryNameList->GetCount();
1059
1060                 String dirAllAlbums = L"All albums";
1061
1062                 for (int i = 0; i < loopCount; ++i)
1063                 {
1064                         pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
1065
1066                         if (*pDirName != __pPresentationModel->GetCurrentAlbumName() || *pDirName == dirAllAlbums)
1067                         {
1068                                 __pOptionMenu->AddItem(*(new (std::nothrow) String(*pDirName)),
1069                                                 IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
1070                         }
1071                 }
1072
1073
1074         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1075 }
1076
1077 void
1078 FileListEditorForm::OnFormBackRequested(Form& source)
1079 {
1080         AppLogDebug("ENTER");
1081
1082         if(__isScanProgress)
1083         {
1084                 return;
1085         }
1086
1087         SceneManager* pSceneManager = SceneManager::GetInstance();
1088         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
1089
1090         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1091         {
1092                 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1093                 {
1094                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1095                 }
1096                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1097                 {
1098                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
1099                 }
1100         }
1101         else
1102         {
1103                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1104                 {
1105                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1106                 }
1107                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1108                 {
1109                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1110                 }
1111                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1112                 {
1113                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1114                 }
1115                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1116                 {
1117                         if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true)
1118                         {
1119                                 __pShareContextMenu->SetShowState(false);
1120                         }
1121                         else
1122                         {
1123                                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1124                                 (pSceneManager->GetCurrentScene()->GetPanel());
1125                                 if (pSelectionPanel != null)
1126                                 {
1127                                         IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1128                                         if (pList == null)
1129                                         {
1130                                                 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1131                                         }
1132
1133                                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1134                                                         SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
1135                                 }
1136                         }
1137                 }
1138                 else
1139                 {
1140                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1141                 }
1142         }
1143         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1144 }
1145
1146 void
1147 FileListEditorForm::SetFooterButtonsState(const bool enableState)
1148 {
1149         AppLogDebug("ENTER");
1150         Footer* pFooter = GetFooter();
1151         TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1152
1153         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1154         {
1155                 if (enableState == true)
1156                 {
1157                         pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1158                         pFooter->SetItemEnabled(0, true);
1159                 }
1160                 else
1161                 {
1162                         pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1163                         pFooter->SetItemEnabled(0, false);
1164                 }
1165         }
1166         else
1167         {
1168                 if (enableState == true)
1169                 {
1170                         pFooter->SetItemEnabled(0, true);
1171                         pFooter->SetItemEnabled(1, true);
1172                 }
1173                 else
1174                 {
1175                         pFooter->SetItemEnabled(0, false);
1176                         pFooter->SetItemEnabled(1, false);
1177                 }
1178         }
1179         pFooter->RequestRedraw(true);
1180         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1181 }
1182
1183 void
1184 FileListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1185 {
1186         AppLogDebug("ENTER");
1187         SceneManager* pSceneManager = SceneManager::GetInstance();
1188         pSceneManager->GetCurrentScene();
1189
1190         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1191         {
1192                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1193                 if (pEditorPanel != null)
1194                 {
1195                         pEditorPanel->ChangeOrientation();
1196                 }
1197         }
1198         else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1199         {
1200                 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1201                 if (pEditorPanel != null)
1202                 {
1203                         pEditorPanel->ChangeOrientation();
1204                 }
1205         }
1206         else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1207         {
1208                 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1209                 if (pEditorPanel != null)
1210                 {
1211                         pEditorPanel->ChangeOrientation();
1212                 }
1213         }
1214         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1215         {
1216                 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1217                 if (pEditorPanel != null)
1218                 {
1219                         pEditorPanel->ChangeOrientation();
1220                 }
1221         }
1222
1223         if (_pProgressAnim != null)
1224         {
1225                 _pProgressAnim->ChangeOrientation(Form::GetBounds());
1226                 _pProgressAnim->Invalidate(true);
1227         }
1228
1229         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1230 }
1231
1232 bool
1233 FileListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
1234 {
1235         AppLogDebug("ENTER");
1236
1237         if(keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
1238         {
1239                 _overlayMsg = false;
1240                 __pDeletePopup->SetShowState(false);
1241                 __pDeletePopup->Invalidate(true);
1242         }
1243         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1244
1245         return false;
1246 }
1247
1248 result
1249 FileListEditorForm::MoveToAlbum(const String& destDirectory)
1250 {
1251         AppLogDebug("ENTER");
1252         result r = E_FAILURE;
1253         String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1254         if (albumName != EMPTY_SPACE)
1255         {
1256                 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1257                 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1258                 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1259                 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1260                 delete pDirectoryList;
1261
1262                 SceneManager* pSceneManager = SceneManager::GetInstance();
1263                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1264                 r = E_SUCCESS;
1265         }
1266         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1267
1268         return r;
1269 }
1270
1271 void
1272 FileListEditorForm::SelectAllPressed(void)
1273 {
1274         SceneManager* pSceneManager = SceneManager::GetInstance();
1275         pSceneManager->GetCurrentScene();
1276
1277         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1278         {
1279                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1280                 if (pEditorPanel != null)
1281                 {
1282                         pEditorPanel->OnSelectAllPressed();
1283                 }
1284         }
1285         else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1286         {
1287                 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1288                 if (pEditorPanel != null)
1289                 {
1290                         pEditorPanel->OnSelectAllPressed();
1291                 }
1292         }
1293         else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1294         {
1295                 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1296                 if (pEditorPanel != null)
1297                 {
1298                         pEditorPanel->OnSelectAllPressed();
1299                 }
1300         }
1301         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1302         {
1303                 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1304                 if (pEditorPanel != null)
1305                 {
1306                         pEditorPanel->OnSelectAllPressed();
1307                 }
1308         }
1309 }
1310
1311 void
1312 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1313 {
1314         if (__pPopUp != NULL)
1315         {
1316                 __pPopUp->SetShowState(false);
1317         }
1318
1319         SceneManager* pSceneManager = SceneManager::GetInstance();
1320
1321         if (index == 0)
1322         {
1323                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1324                 {
1325                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1326                         if (pEditorPanel != null)
1327                         {
1328                                 pEditorPanel->OnRequestSlideShow();
1329                         }
1330                 }
1331                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1332                 {
1333                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1334                                         (pSceneManager->GetCurrentScene()->GetPanel());
1335
1336                         if (pSelectionPanel != null)
1337                         {
1338                                 pSelectionPanel->OnRequestSlideShow();
1339                         }
1340                 }
1341         }
1342         else if (index == 1)
1343         {
1344                 SceneManager* pSceneManager = SceneManager::GetInstance();
1345                 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1346
1347                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
1348         }
1349 }
1350
1351 void
1352 FileListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1353 {
1354         AppLogDebug("ENTER");
1355         __pPresentationModel->RemoveContentEventListener(this);
1356         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1357 }
1358
1359 void
1360 FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1361 {
1362         AppLogDebug("ENTER");
1363         __pPresentationModel->AddContentEventListener(this);
1364         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1365 }
1366
1367 void
1368 FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
1369 {
1370         if(__isScanProgress)
1371         {
1372                 return;
1373         }
1374
1375         SceneManager* pSceneManager = SceneManager::GetInstance();
1376         int checkedCount = 0;
1377
1378         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1379         {
1380                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1381                 if (pEditorPanel != null)
1382                 {
1383                         checkedCount = pEditorPanel->GetItemCheckedCount();
1384                 }
1385         }
1386         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1387         {
1388                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1389                 if (pSelectionPanel != null)
1390                 {
1391                         checkedCount = pSelectionPanel->GetItemCheckedCount();
1392                 }
1393         }
1394
1395         if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true)
1396         {
1397                 __pShareContextMenu->SetShowState(false);
1398         }
1399
1400         if (checkedCount > 0)
1401         {
1402                 if (__pOptionMenu == null)
1403                 {
1404                         return;
1405                 }
1406
1407                 __pOptionMenu->RemoveAllItems();
1408                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
1409                                 IDA_CONTEXT_MENU_MORE_MOVE);
1410                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
1411                                 IDA_CONTEXT_MENU_MORE_COPY);
1412
1413                 if (checkedCount > 1)
1414                 {
1415                         __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
1416                                         IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
1417                 }
1418
1419                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
1420                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
1421
1422                 __pOptionMenu->SetShowState(true);
1423                 __pOptionMenu->Show();
1424         }
1425 }