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