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