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