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