Back key enabled for popup
[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         __pDeletePopup->SetPropagatedKeyEventListener(this);
870
871         Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
872
873         Label* pLabelText = new (std::nothrow) Label();
874         pLabelText->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
875                         ResourceManager::GetString(L"IDS_COM_POP_DELETE_Q"));
876         pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
877         pLabelText->SetTextConfig(34,LABEL_TEXT_STYLE_BOLD);
878         __pDeletePopup->AddControl(pLabelText);
879
880         Button* pDeleteButton = new (std::nothrow) Button();
881         pDeleteButton->Construct(Rectangle(10, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON),
882                         ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
883         pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
884         pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
885         pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
886         pDeleteButton->SetActionId(IDA_DELETE_POPUP_DEL);
887         pDeleteButton->AddActionEventListener(*this);
888         __pDeletePopup->AddControl(pDeleteButton);
889
890         Button* pButtonCancel = new (std::nothrow) Button();
891         pButtonCancel->Construct(Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM, Y_DELETE_BUTTON,
892                         popupClientBounds.width / 2 - GAP_W_POPUP_ITEM -10, H_DELETE_BUTTON), ResourceManager::GetString(L"IDS_COM_POP_CANCEL"));
893         pButtonCancel->SetActionId(IDA_DELETE_POPUP_CANCEL);
894         pButtonCancel->AddActionEventListener(*this);
895         __pDeletePopup->AddControl(pButtonCancel);
896         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
897
898         return r;
899 }
900
901 void
902 FileListEditorForm::SetTitleText(const String& titleText)
903 {
904         AppLogDebug("ENTER");
905         Header* pHeader = GetHeader();
906         TryReturnVoid(pHeader != null, "[%s] fail to get the header.", GetErrorMessage(GetLastResult()));
907         pHeader->SetTitleText(titleText);
908         pHeader->Invalidate(true);
909         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
910 }
911
912 void
913 FileListEditorForm::RefreshFolderList(void)
914 {
915         AppLogDebug("ENTER");
916         ContentDirectory contentDirectory;
917         IListT<ContentType>* pContentTypeList = new (std::nothrow) ArrayListT<ContentType>();
918         pContentTypeList->Add(CONTENT_TYPE_IMAGE);
919         pContentTypeList->Add(CONTENT_TYPE_VIDEO);
920         result r = contentDirectory.Construct(*pContentTypeList);
921         if (r != E_SUCCESS)
922         {
923                 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
924                 return;
925         }
926         delete pContentTypeList;
927
928         if (__pContentDirectoryList != null)
929         {
930                 delete __pContentDirectoryList;
931         }
932         __pContentDirectoryList = contentDirectory.GetContentDirectoryPathListN(SORT_ORDER_NONE);
933         __pContentDirectoryNameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
934         String* pDirPath = null;
935         String* pDirName = null;
936         String mediaPath = RESERVED_MEDIA_PATH;
937         int length = mediaPath.GetLength();
938         mediaPath.Remove(length-1,1);
939
940         int loopCount = __pContentDirectoryList->GetCount();
941         for (int i = 0; i < loopCount; ++i)
942         {
943                 pDirPath = static_cast<String*>(__pContentDirectoryList->GetAt(i));
944                 pDirName = new (std::nothrow) String(GetDirecotyNameFromFullPath(*pDirPath));
945
946                 if ( *pDirPath == mediaPath)
947                 {
948                         *pDirName = ResourceManager::GetString(L"IDS_MEDIABR_POP_NO_NAME");
949                         __pContentDirectoryNameList->Add(pDirName);
950                 }
951                 else
952                 {
953                         __pContentDirectoryNameList->Add(pDirName);
954                 }
955         }
956
957                 __pOptionMenu->RemoveAllItems();
958                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_CREATE_ALBUM"),
959                                 IDA_CONTEXTMENU_EDITOR_MOVE_CREATE_ALBUM);
960
961                 loopCount = __pContentDirectoryNameList->GetCount();
962
963                 for (int i = 0; i < loopCount; ++i)
964                 {
965                         pDirName = static_cast<String*>(__pContentDirectoryNameList->GetAt(i));
966
967                         if ( *pDirName != __pPresentationModel->GetCurrentAlbumName())
968                         {
969                                 __pOptionMenu->AddItem(*(new (std::nothrow) String(*pDirName)),
970                                                 IDA_CONTEXTMENU_EDITOR_MOVE_ALBUM_ARRAY_START + i);
971                         }
972                 }
973
974
975         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
976 }
977
978 void
979 FileListEditorForm::OnFormBackRequested(Form& source)
980 {
981         AppLogDebug("ENTER");
982
983         SceneManager* pSceneManager = SceneManager::GetInstance();
984         TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager.", GetErrorMessage(GetLastResult()));
985
986         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
987         {
988                 if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
989                 {
990                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
991                 }
992                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
993                 {
994                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
995                 }
996         }
997         else
998         {
999                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1000                 {
1001                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1002                 }
1003                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1004                 {
1005                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_IMAGE_LIST));
1006                 }
1007                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1008                 {
1009                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_VIDEO_LIST));
1010                 }
1011                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1012                 {
1013                         if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true )
1014                         {
1015                                 __pShareContextMenu->SetShowState(false);
1016                         }
1017                         else
1018                         {
1019                                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1020                                 (pSceneManager->GetCurrentScene()->GetPanel());
1021                                 if (pSelectionPanel != null)
1022                                 {
1023                                         IList* pList = pSelectionPanel->GetItemCheckedIndexListN();
1024                                         if (pList == null)
1025                                         {
1026                                                 pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1027                                         }
1028
1029                                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1030                                                         SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_DESTROY), pList);
1031
1032
1033                                 }
1034                         }
1035                 }
1036                 else
1037                 {
1038                         pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALL_LIST));
1039                 }
1040         }
1041         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1042 }
1043
1044 void
1045 FileListEditorForm::SetFooterButtonsState(const bool enableState)
1046 {
1047         AppLogDebug("ENTER");
1048         Footer* pFooter = GetFooter();
1049         TryReturnVoid(pFooter != null, "[%s] fail to get the footer.", GetErrorMessage(GetLastResult()));
1050
1051         if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
1052         {
1053                 if (enableState == true)
1054                 {
1055                         pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1056                         pFooter->SetItemEnabled(0, true);
1057                 }
1058                 else
1059                 {
1060                         pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
1061                         pFooter->SetItemEnabled(0, false);
1062                 }
1063         }
1064         else
1065         {
1066                 if (enableState == true)
1067                 {
1068                         pFooter->SetItemEnabled(0, true);
1069                         pFooter->SetItemEnabled(1, true);
1070                 }
1071                 else
1072                 {
1073                         pFooter->SetItemEnabled(0, false);
1074                         pFooter->SetItemEnabled(1, false);
1075                 }
1076         }
1077         pFooter->RequestRedraw(true);
1078         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1079 }
1080
1081 void
1082 FileListEditorForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
1083 {
1084         SceneManager* pSceneManager = SceneManager::GetInstance();
1085         pSceneManager->GetCurrentScene();
1086
1087         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1088         {
1089                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1090                 if (pEditorPanel != null)
1091                 {
1092                         pEditorPanel->ChangeOrientation();
1093                 }
1094         }
1095         else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1096         {
1097                 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1098                 if (pEditorPanel != null)
1099                 {
1100                         pEditorPanel->ChangeOrientation();
1101                 }
1102         }
1103         else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1104         {
1105                 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1106                 if (pEditorPanel != null)
1107                 {
1108                         pEditorPanel->ChangeOrientation();
1109                 }
1110         }
1111         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1112         {
1113                 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1114                 if (pEditorPanel != null)
1115                 {
1116                         pEditorPanel->ChangeOrientation();
1117                 }
1118         }
1119 }
1120
1121 bool
1122 FileListEditorForm::OnKeyReleased(Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
1123 {
1124         AppLogDebug("ENTER");
1125
1126         if(keyEventInfo.GetKeyCode() == KEY_BACK)
1127         {
1128                 _overlayMsg = false;
1129                 __pDeletePopup->SetShowState(false);
1130                 __pDeletePopup->Invalidate(true);
1131         }
1132         return true;
1133 }
1134
1135 result
1136 FileListEditorForm::MoveToAlbum(const String& destDirectory)
1137 {
1138         AppLogDebug("ENTER");
1139         result r = E_FAILURE;
1140         String albumName = __pPresentationModel->ConvertToAlbumName(destDirectory);
1141         if (albumName != EMPTY_SPACE)
1142         {
1143                 IList* pDirectoryList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1144                 pDirectoryList->Add(new (std::nothrow) String(destDirectory));
1145                 __pPresentationModel->SetCurrentAlbumInfo(albumName, *pDirectoryList);
1146                 __pPresentationModel->SetCurrentAlbumContentType(CONTENT_TYPE_ALL);
1147                 delete pDirectoryList;
1148
1149                 SceneManager* pSceneManager = SceneManager::GetInstance();
1150                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST));
1151                 r = E_SUCCESS;
1152         }
1153         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1154
1155         return r;
1156 }
1157
1158 void
1159 FileListEditorForm::SelectAllPressed(void)
1160 {
1161         SceneManager* pSceneManager = SceneManager::GetInstance();
1162         pSceneManager->GetCurrentScene();
1163
1164         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1165         {
1166                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1167                 if (pEditorPanel != null)
1168                 {
1169                         pEditorPanel->OnSelectAllPressed();
1170                 }
1171         }
1172         else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST_EDITOR)
1173         {
1174                 ImageListEditorPanel* pEditorPanel = dynamic_cast<ImageListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1175                 if (pEditorPanel != null)
1176                 {
1177                         pEditorPanel->OnSelectAllPressed();
1178                 }
1179         }
1180         else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST_EDITOR)
1181         {
1182                 VideoListEditorPanel* pEditorPanel = dynamic_cast<VideoListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1183                 if (pEditorPanel != null)
1184                 {
1185                         pEditorPanel->OnSelectAllPressed();
1186                 }
1187         }
1188         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1189         {
1190                 AllListSelectionPanel* pEditorPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1191                 if (pEditorPanel != null)
1192                 {
1193                         pEditorPanel->OnSelectAllPressed();
1194                 }
1195         }
1196 }
1197
1198 void
1199 FileListEditorForm::OnSlideSettingPopUpItemSelected(int index)
1200 {
1201         if (__pPopUp != NULL)
1202         {
1203                 __pPopUp->SetShowState(false);
1204         }
1205
1206         SceneManager* pSceneManager = SceneManager::GetInstance();
1207
1208         if (index == 0)
1209         {
1210                 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1211                 {
1212                         AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1213                         if (pEditorPanel != null)
1214                         {
1215                                 pEditorPanel->OnRequestSlideShow();
1216                         }
1217                 }
1218                 else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1219                 {
1220                         AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>
1221                                         (pSceneManager->GetCurrentScene()->GetPanel());
1222
1223                         if (pSelectionPanel != null)
1224                         {
1225                                 pSelectionPanel->OnRequestSlideShow();
1226                         }
1227                 }
1228         }
1229         else if (index == 1)
1230         {
1231                 SceneManager* pSceneManager = SceneManager::GetInstance();
1232                 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
1233
1234                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
1235         }
1236 }
1237
1238 void
1239 FileListEditorForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
1240 {
1241         AppLogDebug("ENTER");
1242         __pPresentationModel->RemoveContentEventListener(this);
1243         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1244 }
1245
1246 void
1247 FileListEditorForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
1248 {
1249         AppLogDebug("ENTER");
1250         __pPresentationModel->AddContentEventListener(this);
1251         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1252 }
1253
1254 void
1255 FileListEditorForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
1256 {
1257
1258         SceneManager* pSceneManager = SceneManager::GetInstance();
1259         int checkedCount = 0;
1260
1261         if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_EDITOR)
1262         {
1263                 AllListEditorPanel* pEditorPanel = dynamic_cast<AllListEditorPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1264                 if (pEditorPanel != null)
1265                 {
1266                         checkedCount = pEditorPanel->GetItemCheckedCount();
1267                 }
1268         }
1269         else if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST_SELECTION)
1270         {
1271                 AllListSelectionPanel* pSelectionPanel = dynamic_cast<AllListSelectionPanel*>(pSceneManager->GetCurrentScene()->GetPanel());
1272                 if (pSelectionPanel != null)
1273                 {
1274                         checkedCount = pSelectionPanel->GetItemCheckedCount();
1275                 }
1276         }
1277
1278         if (__pShareContextMenu != null && __pShareContextMenu->GetShowState() == true )
1279         {
1280                 __pShareContextMenu->SetShowState(false);
1281         }
1282
1283         if ( checkedCount > 0)
1284         {
1285                 if ( __pOptionMenu == null )
1286                 {
1287                         return ;
1288                 }
1289
1290                 __pOptionMenu->RemoveAllItems();
1291                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MOVE"),
1292                                 IDA_CONTEXT_MENU_MORE_MOVE);
1293                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_COPY"),
1294                                 IDA_CONTEXT_MENU_MORE_COPY);
1295
1296                 if (checkedCount > 1)
1297                 {
1298                         __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"),
1299                                         IDA_CONTEXT_MENU_MORE_SLIDE_SHOW);
1300                 }
1301
1302                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_LEFT"),IDA_CONTEXT_MENU_ROTATE_LEFT);
1303                 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_ROTATE_RIGHT"),IDA_CONTEXT_MENU_ROTATE_RIGHT);
1304
1305                 __pOptionMenu->SetShowState(true);
1306                 __pOptionMenu->Show();
1307
1308         }
1309 }