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