NABI_Se issue fixes
[apps/osp/MyFiles.git] / src / MfSubBaseFolderEntryForm.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: MfSubBaseFolderEntryForm.cpp
19  * @brief: This file contains the implementation of SubBaseFolderEntryForm class, which acts as a base form for
20  * the TopMostFileFolderListForm and SubFileFolderListForm.
21  */
22
23 #include "MfSubBaseFolderEntryForm.h"
24
25 using namespace Tizen::App;
26 using namespace Tizen::App::Package;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Base::Utility;
30 using namespace Tizen::Content;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Io;
33 using namespace Tizen::Locales;
34 using namespace Tizen::Media;
35 using namespace Tizen::System;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39
40 SubBaseFolderEntryForm::SubBaseFolderEntryForm(void)
41 : _pFileEventManager(null)
42 , _pPackageManager(null)
43 , _pFilenames(null)
44 , _pCancelDeletion(null)
45 , _pCancelSortBy(null)
46 , _pCancelViewAs(null)
47 , _pDeleteFile(null)
48 , _pFileProgressingCancelButton(null)
49 , _pIconListViewContextMenu(null)
50 , _pMoreContextMenu(null)
51 , _pFooter(null)
52 , _pEdit(null)
53 , _pMore(null)
54 , _pSearch(null)
55 , _pSortBy(null)
56 , _pShare(null)
57 , _pIconListView(null)
58 , _pFileProgressingHeaderLabel(null)
59 , _pFileProgressingLabel(null)
60 , _pLabelDisplayPath(null)
61 , _pItemContext(null)
62 , _pListView(null)
63 , _pSortByListView(null)
64 , _pViewAsListView(null)
65 , _pOptionMenu(null)
66 , _pDeleteConfirmationPopUp(null)
67 , _pFileProgressingPopup(null)
68 , _pSortByPopup(null)
69 , _pViewAsPopup(null)
70 , _pLongPressGestureDetector(null)
71 , _pBaseItemProvider(null)
72 , _pCustomListViewForPopup(null)
73 , _pFileManager(null)
74 , _pFolderEntryPM(null)
75 , _pMediaMetaData(null)
76 , _pThumbnailItemProvider(null)
77 , _pThumbnailManager(null)
78 {
79         _bIsTopLevelDirectory = false;
80         _bIsDirectoryEmpty = false;
81         _bBackFromAppControl = false;
82         _bIsDeleteFromContextSwipe = false;
83         _bIsFileEventOccured = false;
84
85         _pathOfSelectedFile = L"";
86
87         _flagViewAsStatus = 0;
88         _indexToDelete = 0;
89         _indexTracker = 0;
90         _listItemCount = 0;
91         _renameIndex = 0;
92         _renameOrCreate = 0;
93         _currentIndex = 0;
94         _selectedItemIndex = -1;
95 }
96
97 SubBaseFolderEntryForm::~SubBaseFolderEntryForm(void)
98 {
99         AppLogDebug("Entry");
100
101         if (_pFolderEntryPM != null)
102         {
103                 delete _pFolderEntryPM;
104         }
105
106         if (_pMoreContextMenu != null)
107         {
108                 delete _pMoreContextMenu;
109         }
110
111         if (_pOptionMenu != null)
112         {
113                 delete _pOptionMenu;
114         }
115
116         if (_pViewAsPopup != null)
117         {
118                 delete _pViewAsPopup;
119         }
120
121         if (_pDeleteConfirmationPopUp != null)
122         {
123                 delete _pDeleteConfirmationPopUp;
124         }
125
126         if (_pCustomListViewForPopup != null)
127         {
128                 delete _pCustomListViewForPopup;
129         }
130
131         if (_pMediaMetaData != null)
132         {
133                 delete _pMediaMetaData;
134         }
135
136         if (_pSortByPopup != null)
137         {
138                 delete _pSortByPopup;
139         }
140
141         if (_pFileProgressingPopup != null)
142         {
143                 delete _pFileProgressingPopup;
144         }
145
146         if (_pThumbnailItemProvider != null)
147         {
148                 delete _pThumbnailItemProvider;
149         }
150
151         if (_pBaseItemProvider != null)
152         {
153                 delete _pBaseItemProvider;
154         }
155
156         if (_pEdit != null)
157         {
158                 delete _pEdit;
159         }
160
161         if (_pSortBy != null)
162         {
163                 delete _pSortBy;
164         }
165
166         if (_pSearch != null)
167         {
168                 delete _pSearch;
169         }
170
171         if (_pMore != null)
172         {
173                 delete _pMore;
174         }
175
176         if (_pFileEventManager != null)
177         {
178                 delete _pFileEventManager;
179         }
180
181         if (_pIconListViewContextMenu != null)
182         {
183                 delete _pIconListViewContextMenu;
184         }
185 }
186
187 SubBaseFolderEntryForm&
188 SubBaseFolderEntryForm::operator =(const SubBaseFolderEntryForm& pSubBaseFolderEntryForm)
189 {
190         return *this;
191 }
192
193 SubBaseFolderEntryForm::SubBaseFolderEntryForm(const SubBaseFolderEntryForm& pSubBaseFolderEntryForm)
194 {
195         //Do Nothing
196 }
197
198 result
199 SubBaseFolderEntryForm::CreateFooterControls(void)
200 {
201         AppLogDebug("ENTER");
202         //Create Footer and controls contained within the footer
203         result r = E_SUCCESS;
204
205         AppResource* pAppResource = null;
206
207         String buttonEdit;
208         String buttonShare;
209         ButtonItem footerItemMenu;
210
211         pAppResource = Application::GetInstance()->GetAppResource();
212
213         if (pAppResource != null)
214         {
215                 pAppResource->GetString(L"IDS_MF_SK3_EDIT", buttonEdit);
216                 pAppResource->GetString(L"IDS_COM_BUTTON_SHARE", buttonShare);
217         }
218         //Edit
219         if(_pEdit == null)
220         {
221                 _pEdit = new (std::nothrow) FooterItem();
222                 _pEdit->Construct(IDA_BTN_EDIT);
223                 _pEdit->SetText(buttonEdit);
224         }
225
226         if (_pShare == null)
227         {
228                 _pShare = new (std::nothrow) FooterItem();
229                 _pShare->Construct(IDA_BTN_SHARE);
230                 _pShare->SetText(buttonShare);
231         }
232
233         //Get the Footer and set the FooterItems.
234         _pFooter = GetFooter();
235         if (_pFooter != null)
236         {
237                 _pFooter->RemoveAllButtons();
238                 _pFooter->RemoveAllItems();
239
240                 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
241                 _pFooter->AddItem(*_pEdit);
242                 _pFooter->AddItem(*_pShare);
243
244                 //Set am ActionEventListener to the Footer
245                 _pFooter->AddActionEventListener(*this);
246                 _pFooter->SetItemEnabled(0, false);
247                 _pFooter->SetItemEnabled(1, false);
248                 _pFooter->Invalidate(true);
249         }
250
251         return r;
252 }
253
254 result
255 SubBaseFolderEntryForm::CreateDeleteConfirmationPopUp(void)
256 {
257         result r = E_SUCCESS;
258         Rectangle popupBounds;
259
260         //Create a new popup control
261         _pDeleteConfirmationPopUp = new (std::nothrow) Popup();
262         _pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
263
264         _pDeleteFile = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
265         TryCatch(_pDeleteFile != null, , "MfMyFilesApp::Button For Popup not created!");
266
267         _pDeleteFile->SetActionId(IDA_DELETE_FILE);
268         _pDeleteFile->AddActionEventListener(*this);
269         _pDeleteFile->SetShowState(true);
270
271         _pCancelDeletion = static_cast< Button* >(_pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
272         TryCatch(_pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
273
274         _pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
275         _pCancelDeletion->AddActionEventListener(*this);
276         _pCancelDeletion->SetShowState(true);
277
278         return r;
279
280 CATCH:
281
282         if (_pDeleteConfirmationPopUp != null)
283         {
284                 delete _pDeleteConfirmationPopUp;
285                 _pDeleteConfirmationPopUp = null;
286         }
287
288         return r;
289 }
290
291 void
292 SubBaseFolderEntryForm::ShowSortByPopup(void)
293 {
294
295         CreateSortByPopup();
296
297         //Set the showstate of the popup to true. so that it's displayed on the form.
298         if (_pSortByPopup != null)
299         {
300                 _pSortByPopup->SetShowState(true);
301                 _pSortByPopup->Invalidate(true);
302                 _pSortByPopup->Show();
303         }
304
305         SetDefaultSelectionForSortByPopUp();
306
307 }
308
309 void
310 SubBaseFolderEntryForm::HideSortByPopup(void)
311 {
312         //Set the showstate of the popup to false. so that it's hidden on the form.
313         if (_pSortByPopup != null && _pSortByPopup->IsVisible())
314         {
315                 _pSortByPopup->SetShowState(false);
316         }
317
318 }
319
320 void
321 SubBaseFolderEntryForm::LoadRenameForm(int index)
322 {
323         result r = E_SUCCESS;
324         _renameOrCreate = SELECT_RENAME;
325         ArrayList* pArg = null;
326         Integer* pSourceSelected = null;
327         SceneManager* pSceneManager = null;
328         DirectoryEntry* pDirectory = null;
329
330         if(_pFilenames != null)
331         {
332                 pDirectory = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
333                 TryCatch(pDirectory != null, , "failed to allocate memeory to cast to DirectoryEntry");
334         }
335
336         pArg = new (std::nothrow) ArrayList();
337         r = pArg->Construct();
338
339         pSourceSelected = new (std::nothrow) Integer(_renameOrCreate);
340
341         pArg->Add(pSourceSelected);
342         TryCatch(r == E_SUCCESS, , "failed to construct parg");
343
344         //pArg->Add(__rootMediaPath);
345         pArg->Add(pDirectory);
346         TryCatch(r == E_SUCCESS, , "failed to construct parg");
347
348         pSceneManager = SceneManager::GetInstance();
349         TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
350
351         //pSceneManager->GoForward(SCENE_RENAME_FORM, pArg, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
352         r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
353
354         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
355         return;
356
357         CATCH:
358         if (pSourceSelected != null)
359         {
360                 delete pSourceSelected;
361                 pSourceSelected = null;
362         }
363         if (pDirectory != null)
364         {
365                 delete pDirectory;
366                 pDirectory = null;
367         }
368         if (pArg != null)
369         {
370                 delete pArg;
371                 pArg = null;
372         }
373 }
374
375 void
376 SubBaseFolderEntryForm::LoadSearchForm(void)
377 {
378         ArrayList* pTopLevelDirectoryList = null;
379         ArrayList* pFilepathList = null;
380         SceneManager* pSceneManager = null;
381
382         pTopLevelDirectoryList= new (std::nothrow) ArrayList();
383         if (pTopLevelDirectoryList != null && _pFilenames != null)
384         {
385                 pFilepathList = new (std::nothrow) ArrayList();
386                 if (pFilepathList != null)
387                 {
388                         pFilepathList->Construct();
389                         pFilepathList->AddItems(*_pFilenames);
390                         pTopLevelDirectoryList->Add(pFilepathList);
391                 }
392         }
393
394         TryCatch(pTopLevelDirectoryList != null, , "failed to Get SceneManager instance");
395
396         pSceneManager = SceneManager::GetInstance();
397         TryCatch(pSceneManager != null, , "failed to Get SceneManager instance");
398
399         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pTopLevelDirectoryList);
400
401         return;
402 CATCH:
403
404
405         if (pFilepathList != null)
406         {
407                 delete pFilepathList;
408                 pFilepathList = null;
409         }
410
411         if (pTopLevelDirectoryList != null)
412         {
413                 delete pTopLevelDirectoryList;
414                 pTopLevelDirectoryList = null;
415         }
416 }
417
418 void
419 SubBaseFolderEntryForm::ShowViewAsPopup(void)
420 {
421         //Call functions to create the popups.
422         CreateViewAsPopupControl();
423
424         //Set the showstate of the popup to true. so that it's displayed on the form.
425         if (_pViewAsPopup != null)
426         {
427                 _pViewAsPopup->SetShowState(true);
428                 _pViewAsPopup->Show();
429         }
430
431         SetDefaultSelectionForViewAsPopUp();
432 }
433
434 void
435 SubBaseFolderEntryForm::HideViewAsPopup(void)
436 {
437         //Set the showstate of the popup to false. so that it's hidden on the form.
438         if (_pViewAsPopup != null && _pViewAsPopup->IsVisible())
439         {
440                 _pViewAsPopup->SetShowState(false);
441         }
442 }
443
444 void
445 SubBaseFolderEntryForm::LoadCreateFolderForm(void)
446 {
447         //Load the CreateFolder view in the current directory.
448         result r = E_SUCCESS;
449         Integer* pSourceSelected = null;
450         SceneManager* pSceneManager = null;
451         ArrayList* pArg = null;
452
453         pSourceSelected = new (std::nothrow) Integer(SELECT_CREATE_FOLDER);
454
455         pArg = new (std::nothrow) ArrayList();
456         TryCatch(pArg != null, , "Failed to allocate memory for  pArg");
457
458         r = pArg->Construct();
459         TryCatch(r == E_SUCCESS, , "failed to construct parg");
460
461         r = pArg->Add(pSourceSelected);
462         TryCatch(r == E_SUCCESS, , "Failed to Add Arguments pArg");
463
464         pSceneManager = SceneManager::GetInstance();
465         TryCatch(pSceneManager != null, , "failed to construct parg");
466
467         //pSceneManager->GoForward(SCENE_CREATE_FOLDER_FORM, pArg, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
468         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
469         return;
470
471 CATCH:
472
473         if (pSourceSelected != null)
474         {
475                 delete pSourceSelected;
476         }
477
478         if (pArg != null)
479         {
480                 delete pArg;
481         }
482 }
483
484 void
485 SubBaseFolderEntryForm::LoadDetailForm(Tizen::Base::String& Fullpath)
486 {
487         result r = E_SUCCESS;
488
489         SceneManager* pSceneManager = null;
490         ArrayList* pList = null;
491         String* pFullFilePath = null;
492
493         pList = new (std::nothrow) ArrayList();
494         TryCatch(pList != null, , "Failed to allocate memory for  pList");
495
496         r = pList->Construct();
497         TryCatch(r == E_SUCCESS, , "Failed to Add Construct pList");
498
499         pFullFilePath = new (std::nothrow) String(Fullpath);
500         TryCatch(pFullFilePath != null, , "Failed to allocate memory for  pFullFilePath");
501
502         r = pList->Add(pFullFilePath);
503         TryCatch(r == E_SUCCESS, , "Failed to Add Arguments pList");
504
505         pSceneManager = SceneManager::GetInstance();
506         TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
507
508         //pSceneManager->GoForward(SCENE_FILE_DETAIL_FORM, pList, SCENE_TRANSITION_ANIMATION_TYPE_LEFT);
509         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
510         AppLogDebug("Exit: %s", GetErrorMessage(r));
511         return;
512 CATCH:
513
514         AppLogDebug("Exit: %s", GetErrorMessage(r));
515         if (pFullFilePath != null)
516         {
517                 delete pFullFilePath;
518                 pFullFilePath = null;
519         }
520
521         if (pList != null)
522         {
523                 pList->RemoveAll();
524                 delete pList;
525                 pList = null;
526         }
527 }
528
529 void
530 SubBaseFolderEntryForm::LoadEditForm(void)
531 {
532         AppLogDebug("ENTER");
533         //__pFileListPM->SetFileEventListener(null);
534         SceneManager* pSceneManager = SceneManager::GetInstance();
535         ArrayList* pArgs = null;
536
537         pArgs = new (std::nothrow) ArrayList();
538         //pArgs->Construct();
539
540         if (pArgs != null)
541         {
542                 pArgs->Construct();
543
544                 pArgs->Add(* new (std::nothrow) Integer(_editOrShare));
545
546                 pArgs->Add(*_pFolderEntryPM);
547         }
548
549         if (pSceneManager != null)
550         {
551                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_EDIT_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
552         }
553
554         if (pArgs != null)
555         {
556                 pArgs->RemoveAll();
557                 delete pArgs;
558                 pArgs = null;
559         }
560         AppLogDebug("EXIT");
561         return;
562 }
563
564 void
565 SubBaseFolderEntryForm::ShowFileProgressingPopup(void)
566 {
567         CreateFileProgressingPopup();
568
569         if (_pFileProgressingPopup != null)
570         {
571                 _pFileProgressingPopup->SetShowState(true);
572                 _pFileProgressingPopup->Show();
573         }
574 }
575
576 void
577 SubBaseFolderEntryForm::HideFileProgressingPopup(void)
578 {
579         if (_pFileProgressingPopup != null)
580         {
581                 _pFileProgressingPopup->SetShowState(false);
582
583                 if (_pFileProgressingPopup != null)
584                 {
585                         delete _pFileProgressingPopup;
586                         _pFileProgressingPopup = null;
587                 }
588         }
589 }
590
591 result
592 SubBaseFolderEntryForm::CreateFileProgressingPopup(void)
593 {
594         AppLogDebug("Enter");
595         result r = E_SUCCESS;
596         //String popUpTitle;
597         String deleting;
598         //String fileProgress;
599
600         if (_pFileProgressingPopup != null)
601         {
602                 AppLogDebug("_pFileProgressingPopup is not null");
603                 return r;
604         }
605
606         AppResource* pAppResource = null;
607         pAppResource = UiApp::GetInstance()->GetAppResource();
608         TryCatch(pAppResource != null, , "Failed to fetch AppResource");
609
610         //pAppResource->GetString(L"IDS_FILE_PROCESSING", popUpTitle);
611         pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
612         //pAppResource->GetString(L"IDS_FILE_PROGRESS", fileProgress);
613
614         _pFileProgressingPopup = new (std::nothrow) Popup();
615         _pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
616         TryCatch(_pFileProgressingPopup != null, , "Failed to allocate memory to FileProgressing Popup.");
617
618         //_pFileProgressingPopup->SetTitleText(popUpTitle); //Not in UI
619
620
621         _pFileProgressingCancelButton = static_cast< Button* >(_pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
622         TryCatch(_pFileProgressingCancelButton != null, , "Failed to fetch _pFileProgressingCancelButton.");
623
624         _pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
625         _pFileProgressingCancelButton->AddActionEventListener(*this);
626         _pFileProgressingCancelButton->SetShowState(true);
627
628         _pFileProgressingProgress = static_cast< Progress* >(_pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
629         TryCatch(_pFileProgressingProgress != null, , "Failed to fetch _pFileProgressingProgress.");
630
631         _pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
632         _pFileProgressingProgress->SetValue(0);
633
634         _pFileProgressingHeaderLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
635         TryCatch(_pFileProgressingHeaderLabel != null, , "Failed to fetch _pFileProgressingHeaderLabel.");
636
637         _pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
638         _pFileProgressingHeaderLabel->SetText(deleting);
639         _pFileProgressingHeaderLabel->SetShowState(true);
640         _pFileProgressingHeaderLabel->Invalidate(true);
641
642
643         _pFileProgressingLabel = static_cast< Label* >(_pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
644         TryCatch(_pFileProgressingLabel != null, , "Failed to fetch _pFileProgressingLabel.");
645
646         _pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
647         //_pFileProgressingLabel->SetText(fileProgress);
648         _pFileProgressingLabel->SetShowState(true);
649
650
651         return r;
652
653         CATCH:
654
655         if (_pFileProgressingPopup != null)
656         {
657                 delete _pFileProgressingPopup;
658                 _pFileProgressingPopup = null;
659         }
660         return r;
661 }
662
663
664 void
665 SubBaseFolderEntryForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
666 {
667         int x_FooterPosition = 0;
668         int y_FooterPosition = 0;
669         int x_ContextMenu = 0;
670         int y_ContextMenu = 0;
671
672         Rectangle listViewBounds(GetClientAreaBounds().x, H_DISPLAY_PATH_LABEL, GetClientAreaBounds().width, GetClientAreaBounds().height);
673         Rectangle labelBounds(GetClientAreaBounds().x, 0, GetClientAreaBounds().width, H_DISPLAY_PATH_LABEL);
674
675         _pFooter = GetFooter();
676         if (_pFooter != null)
677         {
678                 _pFooter->GetPosition(x_FooterPosition, y_FooterPosition);
679         }
680
681         x_ContextMenu = x_FooterPosition + 3 * (listViewBounds.width / 4);
682         y_ContextMenu = y_FooterPosition;
683
684         switch (orientationStatus)
685         {
686         case ORIENTATION_STATUS_PORTRAIT:
687         {
688                 if (_pListView != null)
689                 {
690                         _pListView->SetBounds(listViewBounds);
691                 }
692                 if (_pIconListView != null)
693                 {
694                         _pIconListView->SetBounds(listViewBounds);
695                 }
696                 if (_pMoreContextMenu != null)
697                 {
698                         _pMoreContextMenu->SetAnchorPosition(Point(x_ContextMenu, y_ContextMenu));
699                 }
700                 /*              if (__pLabelDisplayPath != null)
701                 {
702                     __pLabelDisplayPath->SetBounds(labelBounds);
703                 }*/
704         }
705         break;
706
707         case ORIENTATION_STATUS_LANDSCAPE:
708         {
709                 if (_pListView != null)
710                 {
711                         _pListView->SetBounds(listViewBounds);
712                 }
713                 if (_pIconListView != null)
714                 {
715                         _pIconListView->SetBounds(listViewBounds);
716                 }
717                 if (_pMoreContextMenu != null)
718                 {
719                         _pMoreContextMenu->SetAnchorPosition(Point(x_ContextMenu, y_ContextMenu));
720                 }
721                 /*              if (__pLabelDisplayPath != null)
722                 {
723                     __pLabelDisplayPath->SetBounds(labelBounds);
724                 }*/
725         }
726         break;
727
728         default:
729         {
730                 //Do Nothing
731         }
732         break;
733         }
734
735         Invalidate(true);
736 }
737
738 void
739 SubBaseFolderEntryForm::OnFileManagingStart(void)
740 {
741         ShowFileProgressingPopup();
742 }
743
744 void
745 SubBaseFolderEntryForm::OnFileManagingStop(FileManagingResult fileManagingResult)
746 {
747         //Empty Implementation.
748 }
749
750 void
751 SubBaseFolderEntryForm::HideFileExtension(void)
752 {
753         int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
754         String viewStyleKeyName(L"ListDisplayType");
755
756         result r = E_SUCCESS;
757
758         AppRegistry* pAppRegistry = null;
759         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
760
761
762         if (pAppRegistry != null)
763         {
764                 r = pAppRegistry->Set(_extensionKeyName, hideExtensionKeyValue);
765                 r = pAppRegistry->Save();
766
767                 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
768         }
769
770         if (_pMoreContextMenu != null)
771         {
772                 r = _pMoreContextMenu->SetItemAt(2, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
773                 AppLogDebug("error %s", GetErrorMessage(r));
774         }
775
776         if (_pOptionMenu != null)
777         {
778                 r = _pOptionMenu->SetItemAt(3, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
779                 AppLogDebug("error %s", GetErrorMessage(r));
780         }
781
782         //Update the corresponding List.
783         if (listViewDisplayType == VIEW_TYPE_AS_THUMBNAILS)
784         {
785                 if (_pIconListView != null)
786                 {
787                         _pIconListView->SetShowState(true);
788                         _pIconListView->UpdateList();
789                 }
790         }
791         else
792         {
793                 if (_pListView != null)
794                 {
795                         _pListView->UpdateList();
796                         _pListView->SetShowState(true);
797                 }
798         }
799
800         if (_pMoreContextMenu != null)
801         {
802                 delete _pMoreContextMenu;
803                 _pMoreContextMenu = null;
804         }
805
806         Invalidate(true);
807
808         AppLogDebug("Exit : %s", GetErrorMessage(r));
809 }
810
811 void
812 SubBaseFolderEntryForm::ShowFileExtension(void)
813 {
814         int listViewDisplayType = VIEW_TYPE_AS_NORMAL_LIST;
815         String viewStyleKeyName(L"ListDisplayType");
816
817         result r = E_SUCCESS;
818
819         AppRegistry* pAppRegistry = null;
820         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
821
822         if (pAppRegistry != null)
823         {
824                 r = pAppRegistry->Set(_extensionKeyName, showExtensionKeyValue);
825                 r = pAppRegistry->Save();
826
827                 r = pAppRegistry->Get(viewStyleKeyName, listViewDisplayType);
828         }
829
830         if (_pMoreContextMenu != null)
831         {
832                 r = _pMoreContextMenu->SetItemAt(2, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
833                 AppLogDebug("error %s", GetErrorMessage(r));
834         }
835
836         if (_pOptionMenu != null)
837         {
838                 r = _pOptionMenu->SetItemAt(3, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
839                 AppLogDebug("error %s", GetErrorMessage(r));
840         }
841         if (listViewDisplayType == VIEW_TYPE_AS_THUMBNAILS)
842         {
843                 if (_pIconListView != null)
844                 {
845                         _pIconListView->UpdateList();
846                         _pIconListView->SetShowState(true);
847                 }
848         }
849         else
850         {
851                 if (_pListView != null)
852                 {
853                         _pListView->UpdateList();
854                         _pListView->SetShowState(true);
855                 }
856         }
857
858         if (_pMoreContextMenu != null)
859         {
860                 delete _pMoreContextMenu;
861                 _pMoreContextMenu = null;
862         }
863
864         Invalidate(true);
865         AppLogDebug("Exit: %s", GetErrorMessage(r));
866 }
867
868
869 void
870 SubBaseFolderEntryForm::HideDeleteConfirmationPopup(void)
871 {
872         if (_pDeleteConfirmationPopUp != null && _pDeleteConfirmationPopUp->IsVisible())
873         {
874                 _pDeleteConfirmationPopUp->SetShowState(false);
875         }
876 }
877
878 void
879 SubBaseFolderEntryForm::ShowDeleteConfirmationPopup(void)
880 {
881         CreateDeleteConfirmationPopUp();
882
883         if (_pDeleteConfirmationPopUp != null)
884         {
885                 _pDeleteConfirmationPopUp->SetShowState(true);
886                 _pDeleteConfirmationPopUp->Show();
887         }
888 }
889
890 result
891 SubBaseFolderEntryForm::CreateViewAsPopupControl(void)
892 {
893         AppLogDebug("ENTER");
894         //Creates a popup control for the ViewAs context item asking which view is to be shown
895
896         result r = E_SUCCESS;
897
898         if (_pViewAsPopup != null)
899         {
900                 AppLogDebug("_pViewAsPopup is not null");
901                 return r;
902         }
903
904         String viewAsPopupTitle;
905         String cancelButton;
906         String sortByPopupTitle;
907
908         //      Label* pViewAsPanelLabel = null;
909         //
910         //      Label* pViewAsPopupLabel = null;
911
912         //      Bitmap* pPanelBackground = null;
913         //      Bitmap* pPopUpBackground = null;
914
915         //      pPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
916         //      pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
917
918         //Create a new popup control
919         _pViewAsPopup = new (std::nothrow) Popup();
920         _pViewAsPopup->Construct(L"IDL_VIEW_AS_POPUP");
921
922         //The cancel button inside the popup, hides the popup when clicked.
923         _pCancelViewAs = static_cast< Button* >(_pViewAsPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
924         TryCatch(_pCancelViewAs != null, , "MfMyFilesApp::Button For Popup not created!");
925
926         _pCancelViewAs->SetActionId(IDA_BTN_POPUP_CANCEL);
927         _pCancelViewAs->AddActionEventListener(*this);
928         _pCancelViewAs->SetShowState(true);
929
930         //      pViewAsPanelLabel = static_cast< Label* >(_pViewAsPopup->GetControl(L"IDC_LABEL_BOTTOM_BACKGROUND", true));
931         //      TryCatch(pViewAsPanelLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
932         //
933         //      pViewAsPopupLabel = static_cast< Label* >(_pViewAsPopup->GetControl(L"IDC_LABEL_POPUP_BACKGROUND", true));
934         //      TryCatch(pViewAsPopupLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
935         //
936         //      pPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, pViewAsPanelLabel->GetWidth(), pViewAsPanelLabel->GetHeight());
937         //      pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, pViewAsPopupLabel->GetWidth(), pViewAsPopupLabel->GetHeight());
938         //
939         //      if (pPanelBackground != null)
940         //      {
941         //              pViewAsPanelLabel->SetBackgroundBitmap(*pPanelBackground);
942         //      }
943         //
944         //      if (pPopUpBackground != null)
945         //      {
946         //              pViewAsPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
947         //
948         //      }
949         //The listview control which is to be added inside the popup. The itemprovider and listener are
950         //implemented in another class because this class already contains an instance of Listview control
951         //attached to an ItemProvider.
952
953         _pViewAsPopup->SetControlAlwaysOnTop(*_pCancelViewAs, true);
954
955
956         _pViewAsListView = static_cast< ListView* >(_pViewAsPopup->GetControl(L"IDC_LISTVIEW_VIEW_AS", true));
957         TryCatch(_pViewAsListView != null, , "MfMyFilesApp::ListView Control For Popup not created!");
958
959         _pViewAsListView->SetShowState(true);
960         _pViewAsListView->AddListViewItemEventListener(*_pCustomListViewForPopup);
961         _pViewAsListView->SetItemProvider(*_pCustomListViewForPopup);
962         _pViewAsListView->SetName(L"VIEW_AS_LISTVIEW");
963         _pViewAsListView->SetItemDividerColor(Color::GetColor(COLOR_ID_GREY));
964
965         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
966
967         //      if (pPanelBackground != null)
968         //      {
969         //              delete pPanelBackground;
970         //              pPanelBackground = null;
971         //      }
972         //      if (pPopUpBackground != null)
973         //      {
974         //              delete pPopUpBackground;
975         //              pPopUpBackground = null;
976         //      }
977         return r;
978         CATCH:
979
980         if (_pViewAsPopup != null)
981         {
982                 delete _pViewAsPopup;
983                 _pViewAsPopup = null;
984         }
985
986         if (_pCustomListViewForPopup != null)
987         {
988                 delete _pCustomListViewForPopup;
989                 _pCustomListViewForPopup = null;
990         }
991         //
992         //      if (pPanelBackground != null)
993         //      {
994         //              delete pPanelBackground;
995         //              pPanelBackground = null;
996         //      }
997         //
998         //      if (pPopUpBackground != null)
999         //      {
1000         //              delete pPopUpBackground;
1001         //              pPopUpBackground = null;
1002         //      }
1003         return r;
1004 }
1005
1006 void
1007 SubBaseFolderEntryForm::ShowMoreContextMenu(void)
1008 {
1009         String extensionStatus;
1010
1011         AppRegistry* pAppRegistry = null;
1012         result r = E_SUCCESS;
1013         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1014
1015         //Show ContextMenu with More Options
1016         if (pAppRegistry != null)
1017         {
1018                 r = pAppRegistry->Get(_extensionKeyName, extensionStatus);
1019         }
1020
1021         if (_pMoreContextMenu != null)
1022         {
1023                 if (extensionStatus == _hideExtension)
1024                 {
1025                         r = _pMoreContextMenu->SetItemAt(2, _showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
1026                 }
1027                 else
1028                 {
1029                         r = _pMoreContextMenu->SetItemAt(2, _hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
1030                 }
1031
1032                 _pMoreContextMenu->SetShowState(true);
1033                 _pMoreContextMenu->Show();
1034         }
1035
1036         AppLogDebug("Exit: %s", GetErrorMessage(r));
1037 }
1038
1039 void
1040 SubBaseFolderEntryForm::OnListViewItemStateChangedNotify(ViewType listViewStyle)
1041 {
1042         AppLogDebug("ENTER");
1043
1044         int popupSource = POP_UP_VIEW_AS;
1045         int sortType = SORT_BY_TYPE_NAME_ASCENDING;
1046         int thumbnailRequestId = 0;
1047
1048         AppRegistry* pAppRegistry = null;
1049         String sortByKeyName(L"SortBy");
1050
1051         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1052
1053         if (_pCustomListViewForPopup != null)
1054         {
1055                 popupSource = _pCustomListViewForPopup->GetSelectionPopup();
1056         }
1057
1058         pAppRegistry->Get(sortByKeyName, sortType);
1059
1060         if (popupSource == POP_UP_VIEW_AS)
1061         {
1062                 _flagViewAsStatus = listViewStyle;
1063
1064                 if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_CATEGORY_SEARCH_FORM)
1065                 {
1066                         if (_pBaseItemProvider != null)
1067                         {
1068                                 _pBaseItemProvider->SetSecondaryBitmap();
1069                         }
1070                 }
1071
1072                 if (_pBaseItemProvider != null)
1073                 {
1074                         _pBaseItemProvider->GetFontSizeAndItemHeight();
1075                 }
1076
1077                 SwitchViewType();
1078
1079                 Invalidate(true);
1080
1081                 HideViewAsPopup();
1082         }
1083         else
1084         {
1085                 if (_pFolderEntryPM != null)
1086                 {
1087                         thumbnailRequestId = _pFolderEntryPM->GetCurrentReqId() + 1;
1088                         _pFolderEntryPM->SetCurrentReqId(thumbnailRequestId);
1089                         if (_pFolderEntryPM != null && _pFolderEntryPM->GetSourceForm() != CREATE_ITEM_SOURCE_SPLIT_PANEL_DIR_TREE)
1090                         {
1091                                 _pFolderEntryPM->SortFolderEntries();
1092                         }
1093                 }
1094                 HideSortByPopup();
1095                 if (_pListView != null && _pListView->IsVisible())
1096                 {
1097                         _pListView->UpdateList();
1098                 }
1099                 else if (_pIconListView != null && _pIconListView->GetShowState())
1100                 {
1101                         _pIconListView->UpdateList();
1102                 }
1103
1104                 if (_pFolderEntryPM != null)
1105                 {
1106                         _pFolderEntryPM->InitThumbnailManager();
1107                 }
1108
1109         }
1110
1111         if (_pMoreContextMenu != null)
1112         {
1113                 delete _pMoreContextMenu;
1114                 _pMoreContextMenu = null;
1115         }
1116 }
1117 void
1118 SubBaseFolderEntryForm::OnIconListViewItemStateChangeNotify()
1119 {
1120         if (_pIconListView != null && _pIconListView->GetShowState())
1121         {
1122                 _pIconListView->UpdateList();
1123         }
1124 }
1125 void
1126 SubBaseFolderEntryForm::OnFooterStateChangeNotify(void)
1127 {
1128         SetFooterVisibility();
1129
1130         _pFooter = GetFooter();
1131         if (_pFooter != null)
1132         {
1133                 _pFooter->Invalidate(true);
1134         }
1135 }
1136
1137 void
1138 SubBaseFolderEntryForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1139 {
1140         AppLogDebug("OnAppControlCompleteResponseReceived");
1141         result r = E_SUCCESS;
1142         CustomAppControl::GetInstance()->SetAppControlInUse(null);
1143
1144         if (GetLastResult() == E_FILE_NOT_FOUND)
1145         {
1146                 _pFolderEntryPM->RefreshFolderEntries();
1147                 if (_pListView != null && _pListView->IsVisible())
1148                 {
1149                         r = _pListView->UpdateList();
1150                 }
1151                 else if (_pIconListView != null && _pIconListView->GetShowState())
1152                 {
1153                         r = _pIconListView->UpdateList();
1154                 }
1155                 _pFolderEntryPM->InitThumbnailManager();
1156         }
1157 }
1158
1159 result
1160 SubBaseFolderEntryForm::SetDefaultSelectionForSortByPopUp(void)
1161 {
1162         result r = E_SUCCESS;
1163
1164         int defaultSortPopUpSelect = 0;
1165
1166         int sortType = SORT_BY_TYPE_NAME_ASCENDING;
1167
1168         int uncheckItem1 = 0;
1169         int uncheckItem2 = 0;
1170         int uncheckItem3 = 0;
1171         int uncheckItem4 = 0;
1172         int uncheckItem5 = 0;
1173
1174         String sortByKeyName(L"SortBy");
1175
1176         AppRegistry* pAppRegistry = null;
1177
1178         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1179
1180         r = pAppRegistry->Get(sortByKeyName, sortType);
1181         TryCatch(r == E_SUCCESS, , "Failed To Get Value From AppRegistry");
1182
1183         switch (sortType)
1184         {
1185
1186         case SORT_BY_TYPE_NAME_ASCENDING:
1187         {
1188                 defaultSortPopUpSelect = 0;
1189                 uncheckItem1 = 1;
1190                 uncheckItem2 = 2;
1191                 uncheckItem3 = 3;
1192                 uncheckItem4 = 4;
1193                 uncheckItem5 = 5;
1194         }
1195         break;
1196
1197         case SORT_BY_TYPE_NAME_DESCENDING:
1198         {
1199                 defaultSortPopUpSelect = 1;
1200                 uncheckItem1 = 0;
1201                 uncheckItem2 = 2;
1202                 uncheckItem3 = 3;
1203                 uncheckItem4 = 4;
1204                 uncheckItem5 = 5;
1205         }
1206         break;
1207
1208         case SORT_BY_TYPE_DATE_RECENT:
1209         {
1210                 defaultSortPopUpSelect = 2;
1211                 uncheckItem1 = 0;
1212                 uncheckItem2 = 1;
1213                 uncheckItem3 = 3;
1214                 uncheckItem4 = 4;
1215                 uncheckItem5 = 5;
1216
1217         }
1218         break;
1219
1220         case SORT_BY_TYPE_DATE_OLDEST:
1221         {
1222                 defaultSortPopUpSelect = 3;
1223                 uncheckItem1 = 0;
1224                 uncheckItem2 = 1;
1225                 uncheckItem3 = 2;
1226                 uncheckItem4 = 4;
1227                 uncheckItem5 = 5;
1228         }
1229         break;
1230
1231         case SORT_BY_TYPE_SIZE_ASCENDING:
1232         {
1233                 defaultSortPopUpSelect = 4;
1234                 uncheckItem1 = 0;
1235                 uncheckItem2 = 1;
1236                 uncheckItem3 = 2;
1237                 uncheckItem4 = 3;
1238                 uncheckItem5 = 5;
1239         }
1240         break;
1241
1242         case SORT_BY_TYPE_SIZE_DESCENDING:
1243         {
1244                 defaultSortPopUpSelect = 4;
1245                 uncheckItem1 = 0;
1246                 uncheckItem2 = 1;
1247                 uncheckItem3 = 2;
1248                 uncheckItem4 = 3;
1249                 uncheckItem5 = 5;
1250         }
1251         break;
1252
1253         case SORT_BY_TYPE_ASCENDING:
1254         {
1255                 defaultSortPopUpSelect = 5;
1256                 uncheckItem1 = 0;
1257                 uncheckItem2 = 1;
1258                 uncheckItem3 = 2;
1259                 uncheckItem4 = 3;
1260                 uncheckItem5 = 4;
1261
1262         }
1263         break;
1264
1265         case SORT_BY_TYPE_DESCENDING:
1266         {
1267                 defaultSortPopUpSelect = 5;
1268                 uncheckItem1 = 0;
1269                 uncheckItem2 = 1;
1270                 uncheckItem3 = 2;
1271                 uncheckItem4 = 3;
1272                 uncheckItem5 = 4;
1273
1274         }
1275         break;
1276
1277         default:
1278         {
1279                 defaultSortPopUpSelect = 0;
1280                 AppLogDebug("UnSupported case reached");
1281         }
1282         break;
1283         }
1284
1285         if (_pCustomListViewForPopup != null)
1286         {
1287                 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_SORT_BY);
1288         }
1289
1290         if (_pSortByPopup != null && _pSortByListView != null)
1291         {
1292                 _pSortByListView->UpdateList();
1293                 _pSortByListView->SetItemChecked(defaultSortPopUpSelect, true);
1294                 _pSortByListView->SetItemChecked(uncheckItem1, false);
1295                 _pSortByListView->SetItemChecked(uncheckItem2, false);
1296                 _pSortByListView->SetItemChecked(uncheckItem3, false);
1297                 _pSortByListView->SetItemChecked(uncheckItem4, false);
1298                 _pSortByListView->SetItemChecked(uncheckItem5, false);
1299
1300                 _pSortByListView->Invalidate(true);
1301         }
1302
1303         return r;
1304         CATCH:
1305         return r;
1306 }
1307
1308 void
1309 SubBaseFolderEntryForm::SwitchViewType(void)
1310 {
1311         String viewStyleKeyName(L"ListDisplayType");
1312
1313         switch (_flagViewAsStatus)
1314         {
1315
1316         case VIEW_TYPE_AS_DETAILED_LIST:
1317         {
1318                 if (_pIconListView != null )
1319                 {
1320                         _pIconListView->SetShowState(false);
1321                 }
1322                 if (_pListView != null)
1323                 {
1324                         _pListView->UpdateList();
1325                         if (_selectedItemIndex == -1)
1326                         {
1327                                 _pListView->ScrollToItem(0);
1328                         }
1329                         _pListView->SetShowState(true);
1330                 }
1331
1332         }
1333         break;
1334
1335         case VIEW_TYPE_AS_NORMAL_LIST:
1336         {
1337                 if (_pIconListView != null )
1338                 {
1339                         _pIconListView->SetShowState(false);
1340                 }
1341
1342                 if (_pListView != null)
1343                 {
1344                         _pListView->UpdateList();
1345                         if (_selectedItemIndex == -1)
1346                         {
1347                                 _pListView->ScrollToItem(0);
1348                         }
1349                         _pListView->SetShowState(true);
1350                 }
1351         }
1352         break;
1353
1354         case VIEW_TYPE_AS_THUMBNAILS:
1355         {
1356                 if (_pListView != null )
1357                 {
1358                         _pListView->SetShowState(false);
1359                 }
1360                 if (_pIconListView != null)
1361                 {
1362                         _pIconListView->UpdateList();
1363                         if (_selectedItemIndex == -1)
1364                         {
1365                                 _pIconListView->ScrollToItem(0);
1366                         }
1367                         _pIconListView->SetShowState(true);
1368                 }
1369         }
1370         break;
1371
1372         default:
1373         {
1374                 if (_pListView != null)
1375                 {
1376                         _pListView->UpdateList();
1377                 }
1378         }
1379         break;
1380         }
1381 }
1382
1383 void
1384 SubBaseFolderEntryForm::SetNextDisplayPath(void)
1385 {
1386         String displayPath;
1387         String delim(L"/");
1388         String token;
1389         String fullPath;
1390
1391         fullPath = FolderNavigationPresentationModel::GetCurrentPath();
1392
1393         StringTokenizer tokenizer(fullPath, delim);
1394
1395 #if 0
1396         DataBindingContext* pContext = null;
1397         pContext = GetDataBindingContextN();
1398 #endif
1399
1400         int Counter = 0;
1401         switch (_storageType)
1402         {
1403         case MEMORY_TYPE_PHONE:
1404         {
1405                 Counter = 3;
1406         }
1407         break;
1408
1409         case MEMORY_TYPE_SD_CARD:
1410         {
1411                 Counter = 3;
1412         }
1413         break;
1414
1415         default:
1416         {
1417                 Counter = 3;
1418         }
1419         break;
1420         }
1421
1422         //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1423         //it is the last token
1424         while (tokenizer.HasMoreTokens())
1425         {
1426                 if (Counter > 0)
1427                 {
1428                         Counter--;
1429                         tokenizer.GetNextToken(token);
1430                 }
1431                 else
1432                 {
1433                         tokenizer.GetNextToken(token);
1434                         displayPath.Append(token);
1435                         displayPath.Append(L"/");
1436
1437                 }
1438         }
1439
1440
1441         if (_pLabelDisplayPath != null)
1442         {
1443                 _displayPath.Append(displayPath);
1444
1445                 String displayPathToAppend(L"\x200E");
1446                 displayPathToAppend.Append(_displayPath);
1447
1448                 _pLabelDisplayPath->SetText(displayPathToAppend);
1449                 _pLabelDisplayPath->Invalidate(true);
1450         }
1451
1452 #if 0
1453         if (pContext != null)
1454         {
1455                 //UpdateBinding on the target label control.
1456                 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
1457         }
1458
1459         if (pContext != null)
1460         {
1461                 delete pContext;
1462         }
1463 #endif
1464
1465 }
1466
1467 FolderEntryPresentationModel*
1468 SubBaseFolderEntryForm::GetFolderEntryPresentationModel(void)
1469 {
1470         return _pFolderEntryPM;
1471 }
1472
1473 result
1474 SubBaseFolderEntryForm::DeleteFile(String& filePath)
1475 {
1476         AppLogDebug("ENTER");
1477         result r = E_SUCCESS;
1478
1479         //_pFolderEntryPM->SetFileEventListener(null);
1480         //((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1481
1482         _pFileManager->DeleteFolderEntries(&filePath);
1483
1484         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1485         return r;
1486 }
1487
1488 void
1489 SubBaseFolderEntryForm::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1490 {
1491         AppLogDebug("ENTER");
1492         DirectoryEntry* pDirStr = null;
1493         String fullPath;
1494
1495         switch (actionId)
1496         {
1497         case IDA_BTN_EDIT:
1498         {
1499                 _editOrShare = FILE_MANAGE_EDIT;
1500                 //If filenames is not empty then Load the edit form.
1501                 if (_pFilenames->GetCount() != 0)
1502                 {
1503                         //_pFolderEntryPM->SetFileEventListener(null);
1504
1505                         LoadEditForm();
1506                 }
1507         }
1508         break;
1509
1510         case IDA_BTN_SHARE:
1511         {
1512                 AppLogDebug("Share Button Clicked!");
1513
1514                 _editOrShare = FILE_MANAGE_SHARE;
1515                 if (_pFilenames->GetCount() != 0)
1516                 {
1517                         //_pFolderEntryPM->SetFileEventListener(null);
1518
1519                         LoadEditForm();
1520                 }
1521         }
1522         break;
1523
1524         case IDA_BTN_MORE:
1525         {
1526                 if (_pFilenames->GetCount() > 0)
1527                 {
1528                         CreateMoreContextMenu();
1529                         ShowMoreContextMenu();
1530                 }
1531         }
1532         break;
1533
1534         case IDA_CONTEXT_MENU_BTN_SORT_BY:
1535         {
1536                 //Show the SortBy PopUp.
1537                 if (_pCustomListViewForPopup != null)
1538                 {
1539                         _pCustomListViewForPopup->SetSelectionPopup(POP_UP_SORT_BY);
1540                 }
1541                 ShowSortByPopup();
1542         }
1543         break;
1544
1545         case IDA_CONTEXT_MENU_CREATE_FOLDER:
1546         {
1547                 //Load the CreateFolder Form.
1548                 //_pFolderEntryPM->SetFileEventListener(null);
1549                 _renameOrCreate = SELECT_CREATE_FOLDER;
1550
1551                 if (_pMoreContextMenu != null)
1552                 {
1553                         delete _pMoreContextMenu;
1554                         _pMoreContextMenu = null;
1555                 }
1556
1557                 LoadCreateFolderForm();
1558         }
1559         break;
1560
1561         case IDA_CONTEXT_MENU_VIEW_AS:
1562         {
1563                 //Show the ViewAs Popup
1564                 if (_pCustomListViewForPopup != null)
1565                 {
1566                         _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
1567                 }
1568
1569                 ShowViewAsPopup();
1570         }
1571         break;
1572
1573         case IDA_BTN_POPUP_CANCEL:
1574         {
1575                 //Hide the ViewAs PopUp and redraw the form.
1576                 HideViewAsPopup();
1577         }
1578         break;
1579
1580         case IDA_BTN_SORT_POPUP_CANCEL:
1581         {
1582                 //Hide the SortBy PopUp and redraw the form.
1583                 HideSortByPopup();
1584         }
1585         break;
1586
1587         case IDA_CONTEXT_MENU_BTN_SEARCH:
1588         {
1589                 //Load the SearchForm
1590                 LoadSearchForm();
1591         }
1592         break;
1593
1594         case IDA_DELETE_FILE:
1595         {
1596                 HideDeleteConfirmationPopup();
1597                 if (_pDeleteConfirmationPopUp != null)
1598                 {
1599                         delete _pDeleteConfirmationPopUp;
1600                         _pDeleteConfirmationPopUp = null;
1601                 }
1602                 _filePath.Clear();
1603
1604                 if (_pFilenames != null)
1605                 {
1606                         pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(_indexToDelete));
1607                 }
1608                 if (pDirStr != null)
1609                 {
1610                         _filePath = pDirStr->GetFullFilePath();
1611                 }
1612                 _indexTracker = _indexToDelete;
1613                 //Call the DeleteFile Function.
1614                 DeleteFile(_filePath);
1615         }
1616         break;
1617
1618         case IDA_CANCEL_DELETION:
1619         {
1620                 HideDeleteConfirmationPopup();
1621                 _bIsDeleteFromContextSwipe = false;
1622
1623                 if (_pDeleteConfirmationPopUp != null)
1624                 {
1625                         delete _pDeleteConfirmationPopUp;
1626                         _pDeleteConfirmationPopUp = null;
1627                 }
1628         }
1629         break;
1630
1631         case IDA_BTN_ANIMATION_POPUP_CANCEL:
1632         {
1633                 AppLogDebug("IDA_BTN_ANIMATION_POPUP_CANCEL");
1634                 HideFileProgressingPopup();
1635                 _pFileManager->ForceStopWorkerThread();
1636         }
1637         break;
1638
1639         case IDA_ICONLISTVIEW_DETAILS:
1640         {
1641                 if (_pIconListViewContextMenu != null)
1642                 {
1643                         delete _pIconListViewContextMenu;
1644                         _pIconListViewContextMenu = null;
1645                 }
1646
1647                 if (_bIsTopLevelDirectory == false)
1648                 {
1649                         if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1650                         {
1651                                 pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1652
1653                                 if (pDirStr != null)
1654                                 {
1655                                         fullPath = pDirStr->GetFullFilePath();
1656                                 }
1657                         }
1658                 }
1659                 else
1660                 {
1661                         switch (_currentIndex)
1662                         {
1663                         case 0:
1664                                 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath());
1665                                 fullPath = FolderNavigationPresentationModel::GetMediaPath();
1666                                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1667                                 break;
1668                         case 1:
1669                                 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath());
1670                                 fullPath = FolderNavigationPresentationModel::GetSdCardPath();
1671                                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1672
1673                                 break;
1674                         case 2:
1675                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath());
1676                                 fullPath = FolderNavigationPresentationModel::GetUsbPath();
1677                                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL);
1678                                 break;
1679                         }
1680                 }
1681
1682                 LoadDetailForm(fullPath);
1683         }
1684         break;
1685
1686         case IDA_ICONLISTVIEW_DELETE:
1687         {
1688                 _bIsDeleteFromContextSwipe = true;
1689
1690                 if (_pFileEventManager != null)
1691                 {
1692                         _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1693                 }
1694                 if (_pIconListViewContextMenu != null)
1695                 {
1696                         delete _pIconListViewContextMenu;
1697                         _pIconListViewContextMenu = null;
1698                 }
1699
1700                 ShowDeleteConfirmationPopup();
1701
1702                 _indexToDelete = _currentIndex;
1703
1704         }
1705         break;
1706
1707         case IDA_ICONLISTVIEW_RENAME:
1708         {
1709
1710                 if (_pFileEventManager != null)
1711                 {
1712                         _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1713                 }
1714
1715                 if (_pIconListViewContextMenu != null)
1716                 {
1717                         delete _pIconListViewContextMenu;
1718                         _pIconListViewContextMenu = null;
1719                 }
1720
1721                 if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1722                 {
1723                         pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1724
1725                         if (pDirStr != null)
1726                         {
1727                                 _currentFileName.Clear();
1728                                 _currentFileName = pDirStr->GetFileName();
1729                                 _pathOfSelectedFile = pDirStr->GetFullFilePath();
1730                         }
1731                 }
1732
1733                 _renameIndex = _currentIndex;
1734                 _renameOrCreate = SELECT_RENAME;
1735
1736                 //Load the Rename View of the item selected.
1737                 LoadRenameForm(_currentIndex);
1738         }
1739         break;
1740
1741         default:
1742         {
1743                 //Do Nothing.
1744         }
1745         break;
1746         }
1747 }
1748
1749 void
1750 SubBaseFolderEntryForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
1751 {
1752         DirectoryEntry* pDirStr = null;
1753         _selectedItemIndex = index;
1754         if (_pFilenames != null)
1755         {
1756                 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
1757
1758                 if (pDirStr != null)
1759                 {
1760                         switch (elementId)
1761                         {
1762                         case IDA_CONTEXT_DETAIL:
1763                         {
1764                                 _filePath.Clear();
1765                                 _filePath = pDirStr->GetFullFilePath();
1766                                 LoadDetailForm(_filePath);
1767                         }
1768                         break;
1769
1770                         case IDA_CONTEXT_RENAME:
1771                         {
1772                                 if (_pFileEventManager != null)
1773                                 {
1774                                         _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1775                                 }
1776
1777                                 _currentFileName.Clear();
1778                                 _currentFileName = pDirStr->GetFileName();
1779
1780                                 _pathOfSelectedFile = pDirStr->GetFullFilePath();
1781                                 _renameIndex = index;
1782                                 _renameOrCreate = SELECT_RENAME;
1783                                 //Load the Rename View of the item selected.
1784                                 LoadRenameForm(index);
1785                         }
1786                         break;
1787
1788                         case IDA_CONTEXT_DELETE:
1789                         {
1790                                 if (_pFileEventManager != null)
1791                                 {
1792                                         _pFileEventManager->RemovePath(FolderNavigationPresentationModel::GetCurrentPath());
1793                                 }
1794
1795                                 _bIsDeleteFromContextSwipe = true;
1796
1797                                 _indexToDelete = index;
1798
1799                                 ShowDeleteConfirmationPopup();
1800                         }
1801                         break;
1802
1803                         default:
1804                         {
1805                                 //Empty Implementation.
1806                         }
1807                         break;
1808                         }
1809                 }
1810         }
1811 }
1812
1813 void
1814 SubBaseFolderEntryForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1815 {
1816         result res = E_SUCCESS;
1817         AppLogDebug("Enter");
1818
1819         if (_pFolderEntryPM)
1820         {
1821                 if (pThumbReq != null)
1822                 {
1823                         if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
1824                         {
1825                                 if (pThumbReq->pBitmap != null)
1826                                 {
1827                                         delete pThumbReq->pBitmap;
1828                                 }
1829                                 return;
1830                         }
1831                 }
1832
1833                 if (pThumbReq != null)
1834                 {
1835                         if (pThumbReq->GetCurrentRequestId() != _pFolderEntryPM->GetCurrentReqId())
1836                         {
1837                                 if (pThumbReq->pBitmap != null)
1838                                 {
1839                                         delete pThumbReq->pBitmap;
1840                                 }
1841                                 AppLogDebug("mismatch in id so returning");
1842                                 return;
1843                         }
1844                 }
1845                 if (pThumbReq)
1846                 {
1847                         if (pThumbReq->iRquestId < _pFilenames->GetCount())
1848                         {
1849                                 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
1850                                 if (_pListView && _pListView->IsVisible())
1851                                 {
1852                                         res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1853                                 }
1854                                 else if (_pIconListView && _pIconListView->GetShowState())
1855                                 {
1856                                         res = _pIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1857                                 }
1858                         }
1859                         else
1860                                 AppLogDebug("Thumbnail Request is not valid");
1861                 }
1862                 else
1863                 {
1864                         _pFolderEntryPM->OnThumbnailResponseFailed();
1865                 }
1866         }
1867         AppLogDebug("Exit %s", GetErrorMessage(res));
1868         return;
1869 }
1870
1871 result
1872 SubBaseFolderEntryForm::CreateSortByPopup(void)
1873 {
1874         result r = E_SUCCESS;
1875
1876         if (_pSortByPopup != null)
1877         {
1878                 AppLogDebug("_pSortByPopup is not null");
1879                 return r;
1880         }
1881
1882         String cancelButton;
1883         String sortByPopupTitle;
1884
1885         //      Label* pSortByPanelLabel = null;
1886         //      Label* pSortByPopupLabel = null;
1887
1888         //      Bitmap* pPanelBackground = null;
1889         //      Bitmap* pPopUpBackground = null;
1890
1891         //      pPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
1892         //pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
1893         //      pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, 512, 632);
1894         //      pPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, 612, 96);
1895
1896         _pSortByPopup = new (std::nothrow) Popup();
1897         _pSortByPopup->Construct(L"IDL_SORT_BY_POPUP");
1898
1899         _pCancelSortBy = static_cast< Button* >(_pSortByPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1900         TryCatch(_pCancelSortBy != null, , "MfMyFilesApp::Button For Popup not created!");
1901
1902         _pCancelSortBy->SetActionId(IDA_BTN_SORT_POPUP_CANCEL);
1903         _pCancelSortBy->AddActionEventListener(*this);
1904         _pCancelSortBy->SetShowState(true);
1905
1906         //      pSortByPanelLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_PANEL_BACKGROUND", true));
1907         //      TryCatch(pSortByPanelLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1908         //
1909         //      pSortByPopupLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_POPUP_BACKGROUND", true));
1910         //      TryCatch(pSortByPopupLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1911         //
1912         //      if (pPanelBackground != null)
1913         //      {
1914         //              pSortByPanelLabel->SetBackgroundBitmap(*pPanelBackground);
1915         //      }
1916         //
1917         //      if (pPopUpBackground != null)
1918         //      {
1919         //              pSortByPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
1920         //
1921         //      }
1922
1923         _pSortByListView = static_cast< ListView* >(_pSortByPopup->GetControl(L"IDC_LISTVIEW_SORT_BY", true));
1924         TryCatch(_pSortByListView != null, , "MfMyFilesApp::ListView Control For Popup not created!");
1925
1926         _pSortByListView->SetShowState(true);
1927         _pSortByListView->AddListViewItemEventListener(*_pCustomListViewForPopup);
1928         _pSortByListView->SetItemProvider(*_pCustomListViewForPopup);
1929         _pSortByListView->SetName(L"SORT_BY_LISTVIEW");
1930         _pSortByListView->SetItemDividerColor(Color::GetColor(COLOR_ID_GREY));
1931
1932         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1933
1934         //      _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPanelLabel, true);
1935         //      _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPopupLabel, true);
1936         _pSortByPopup->SetControlAlwaysOnTop(*_pSortByListView, true);
1937         _pSortByPopup->SetControlAlwaysOnTop(*_pCancelSortBy, true);
1938
1939         //      if (pPanelBackground != null)
1940         //      {
1941         //              delete pPanelBackground;
1942         //              pPanelBackground = null;
1943         //      }
1944         //      if (pPopUpBackground != null)
1945         //      {
1946         //              delete pPopUpBackground;
1947         //              pPopUpBackground = null;
1948         //      }
1949         return r;
1950
1951         CATCH:
1952         if (_pCustomListViewForPopup != null)
1953         {
1954                 delete _pCustomListViewForPopup;
1955                 _pCustomListViewForPopup = null;
1956         }
1957
1958         if (_pSortByPopup != null)
1959         {
1960                 delete _pSortByPopup;
1961                 _pSortByPopup = null;
1962         }
1963
1964         //      if (pPanelBackground != null)
1965         //      {
1966         //              delete pPanelBackground;
1967         //              pPanelBackground = null;
1968         //      }
1969         //
1970         //      if (pPopUpBackground != null)
1971         //      {
1972         //              delete pPopUpBackground;
1973         //              pPopUpBackground = null;
1974         //      }
1975
1976         return r;
1977 }
1978
1979 result
1980 SubBaseFolderEntryForm::CreateMoreContextMenu(void)
1981 {
1982         result r = E_SUCCESS;
1983
1984         if (_pMoreContextMenu != null)
1985         {
1986                 return E_SUCCESS;
1987         }
1988
1989         int xPosition = 0;
1990         int yPosition = 0;
1991
1992         AppResource* pAppResource = null;
1993         AppRegistry* pAppRegistry = null;
1994
1995         String viewAs;
1996         String extensionVisibility;
1997         String sortBy;
1998         String search;
1999         String buttonCreateFolder;
2000
2001         Bitmap* pBitmapSortbyContextItem = null;
2002         Bitmap* pBitmapSearchContextItem = null;
2003         Bitmap* pBitmapCreateFolderContextItem = null;
2004
2005         pAppResource = Application::GetInstance()->GetAppResource();
2006
2007         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2008
2009         if (pAppResource != null)
2010         {
2011                 pAppResource->GetString(L"IDS_MF_OPT_VIEW_AS", viewAs);
2012                 pAppResource->GetString(L"IDS_MF_SK3_SORT_BY", sortBy);
2013                 pAppResource->GetString(L"IDS_MF_SK3_SEARCH", search);
2014                 pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", buttonCreateFolder);
2015                 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
2016                 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
2017                 pBitmapSortbyContextItem = pAppResource->GetBitmapN(IDB_POPUP_SORTBY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2018                 pBitmapSearchContextItem = pAppResource->GetBitmapN(IDB_POPUP_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2019                 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2020         }
2021
2022         pAppRegistry->Get(_extensionKeyName, extensionVisibility);
2023
2024         _pFooter = GetFooter();
2025         if (_pFooter != null)
2026         {
2027                 _pFooter->GetPosition(xPosition, yPosition);
2028         }
2029
2030         xPosition += 3 * (GetClientAreaBounds().width / 4);
2031
2032         //Create the ContextMenu
2033         _pMoreContextMenu = new (std::nothrow) ContextMenu();
2034         _pMoreContextMenu->Construct(Point(0, yPosition), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
2035         _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2036         _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2037
2038         if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_TOP_LEVEL_DIRECTORY_FORM)
2039         {
2040                 _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2041         }
2042         else
2043         {
2044                 if (_bIsDirectoryEmpty == false)
2045                 {
2046                         if (CheckSearchHistory() == false)
2047                         {
2048                                 _pMoreContextMenu->AddItem(search, IDA_CONTEXT_MENU_BTN_SEARCH, *pBitmapSearchContextItem, null, null);
2049                         }
2050
2051                         _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2052                         _pMoreContextMenu->AddItem(sortBy, IDA_CONTEXT_MENU_BTN_SORT_BY, *pBitmapSortbyContextItem, null, null);
2053
2054                         if (extensionVisibility == _hideExtension)
2055                         {
2056                                 _pMoreContextMenu->AddItem(_showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
2057                         }
2058                         else
2059                         {
2060                                 _pMoreContextMenu->AddItem(_hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
2061                         }
2062                 }
2063
2064                 if (SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2065                 {
2066                         _pMoreContextMenu->AddItem(buttonCreateFolder, IDA_CONTEXT_MENU_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
2067                 }
2068         }
2069
2070         //Set the ContextMenu's ActionEventListener
2071         _pMoreContextMenu->AddActionEventListener(*this);
2072         //_pMoreContextMenu->SetAnchorPosition(Point(xPosition, yPosition));
2073         _pMoreContextMenu->SetShowState(true);
2074
2075         delete pBitmapSortbyContextItem;
2076         delete pBitmapSearchContextItem;
2077         delete pBitmapCreateFolderContextItem;
2078         return r;
2079 }
2080
2081 result
2082 SubBaseFolderEntryForm::SetDefaultSelectionForViewAsPopUp(void)
2083 {
2084         result r = E_SUCCESS;
2085
2086         int defaultViewAsPopUpSelect = 0;
2087         int uncheckItem1 = 0;
2088         int uncheckItem2 = 0;
2089
2090         int viewType = VIEW_TYPE_AS_NONE;
2091         String viewStyleKeyName(L"ListDisplayType");
2092
2093         AppRegistry* pAppRegistry = null;
2094
2095         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2096
2097         r = pAppRegistry->Get(viewStyleKeyName, viewType);
2098
2099         switch (viewType)
2100         {
2101
2102         case VIEW_TYPE_AS_DETAILED_LIST:
2103         {
2104                 defaultViewAsPopUpSelect = 1;
2105                 uncheckItem1 = 0;
2106                 uncheckItem2 = 2;
2107         }
2108         break;
2109
2110         case VIEW_TYPE_AS_NORMAL_LIST:
2111         {
2112                 defaultViewAsPopUpSelect = 0;
2113                 uncheckItem1 = 1;
2114                 uncheckItem2 = 2;
2115         }
2116         break;
2117
2118         case VIEW_TYPE_AS_THUMBNAILS:
2119         {
2120                 defaultViewAsPopUpSelect = 2;
2121                 uncheckItem1 = 0;
2122                 uncheckItem2 = 1;
2123         }
2124         break;
2125
2126         default:
2127         {
2128                 //Empty Implementation.
2129         }
2130         break;
2131         }
2132
2133
2134         if (_pCustomListViewForPopup != null)
2135         {
2136                 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
2137         }
2138
2139         if (_pViewAsPopup != null && _pViewAsListView != null)
2140         {
2141                 _pViewAsListView->UpdateList();
2142                 _pViewAsListView->SetItemChecked(defaultViewAsPopUpSelect, true);
2143                 _pViewAsListView->SetItemChecked(uncheckItem1, false);
2144                 _pViewAsListView->SetItemChecked(uncheckItem2, false);
2145                 _pViewAsListView->Invalidate(true);
2146         }
2147         return r;
2148 }
2149
2150
2151 void
2152 SubBaseFolderEntryForm::SetFooterVisibility(void)
2153 {
2154         AppLogDebug("Entry");
2155         int folderCount=0, fileCount=0;
2156
2157         _pFooter = GetFooter();
2158
2159         if( _pFolderEntryPM )
2160                 _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), folderCount, fileCount);
2161
2162         if (folderCount ==0 && fileCount == 0)
2163         {
2164                 _bIsDirectoryEmpty = true;
2165                 _pFooter->SetItemEnabled(0, false);
2166                 _pFooter->SetItemEnabled(1, false);
2167         }
2168         else
2169         {
2170                 _bIsDirectoryEmpty = false;
2171                 _pFooter->SetItemEnabled(0, true);
2172
2173                 if (fileCount != 0)
2174                 {
2175                         _pFooter->SetItemEnabled(1, true);
2176                 }
2177                 else
2178                 {
2179                         _pFooter->SetItemEnabled(1, false);
2180                 }
2181
2182         }
2183         _pFooter->Invalidate(true);
2184 }
2185
2186 bool
2187 SubBaseFolderEntryForm::CheckSearchHistory(void)
2188 {
2189         bool searchHistoryStatus = false;
2190         int itemCount = 0;
2191         String searchScene;
2192         SceneManager* pSceneManager = SceneManager::GetInstance();
2193         IListT< SceneId >* pSceneList = pSceneManager->GetSceneHistoryN();
2194
2195         if (pSceneList != null)
2196         {
2197                 itemCount = pSceneList->GetCount() - 1;
2198                 pSceneList->GetAt(itemCount, searchScene);
2199                 while (searchScene != IDSCN_SEARCH_FORM && itemCount >= 0)
2200                 {
2201                         itemCount--;
2202                         pSceneList->GetAt(itemCount, searchScene);
2203                 }
2204         }
2205
2206         if (searchScene == IDSCN_SEARCH_FORM)
2207         {
2208                 AppLogDebug("Search scene present");
2209                 searchHistoryStatus = true;
2210         }
2211         else
2212         {
2213                 AppLogDebug("Search scene not present");
2214                 searchHistoryStatus = false;
2215         }
2216
2217         if(pSceneList)
2218         {
2219                 pSceneList->RemoveAll();
2220                 delete pSceneList;
2221                 pSceneList = null;
2222         }
2223         return searchHistoryStatus;
2224 }
2225
2226
2227 void
2228 SubBaseFolderEntryForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int     eventId)
2229 {
2230         //Empty Implementation
2231 }
2232
2233 void
2234 SubBaseFolderEntryForm::OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2235 {
2236         //Show Context Menu
2237         if (_currentIndex != INVALID_LIST_INDEX)
2238         {
2239                 ShowIconListViewContextMenu();
2240         }
2241 }
2242
2243 void
2244 SubBaseFolderEntryForm::OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2245 {
2246         //Empty Implementation.
2247 }
2248
2249 result
2250 SubBaseFolderEntryForm::CreateIconListViewContextMenu(void)
2251 {
2252         if (_pIconListViewContextMenu != null)
2253         {
2254                 return E_FAILURE;
2255         }
2256
2257         result r = E_SUCCESS;
2258
2259         String Details;
2260         String Rename;
2261         String Delete;
2262
2263         String buttonCreateFolder;
2264
2265         AppResource* pAppResource = null;
2266         //AppRegistry* pAppRegistry = null;
2267         pAppResource = Application::GetInstance()->GetAppResource();
2268
2269         //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2270
2271         if (pAppResource != null)
2272         {
2273                 pAppResource->GetString(L"IDS_MF_SK_DETAILS", Details);
2274                 pAppResource->GetString(L"IDS_MF_SK3_DELETE", Delete);
2275                 pAppResource->GetString(L"IDS_MF_BODY_RENAME_ABB", Rename);
2276         }
2277
2278         //Create the ContextMenu
2279         _pIconListViewContextMenu = new (std::nothrow) ContextMenu();
2280
2281         _pIconListViewContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_AUTO);
2282         _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2283         _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2284
2285
2286         _pIconListViewContextMenu->AddItem(Details, IDA_ICONLISTVIEW_DETAILS);
2287         if (_bIsTopLevelDirectory == false)
2288         {
2289                 _pIconListViewContextMenu->AddItem(Rename, IDA_ICONLISTVIEW_RENAME);
2290                 _pIconListViewContextMenu->AddItem(Delete, IDA_ICONLISTVIEW_DELETE);
2291         }
2292
2293         //Set the ContextMenu's ActionEventListener
2294         _pIconListViewContextMenu->AddActionEventListener(*this);
2295         _pIconListViewContextMenu->SetFocusable(true);
2296         _pIconListViewContextMenu->SetShowState(true);
2297
2298         return r;
2299 }
2300
2301 void
2302 SubBaseFolderEntryForm::ShowIconListViewContextMenu(void)
2303 {
2304
2305         CreateIconListViewContextMenu();
2306         int headerHeight = 0;
2307
2308         int y_Anchor_Position = 0;
2309
2310         Header* pHeader = GetHeader();
2311         headerHeight = pHeader->GetHeight();
2312
2313
2314         y_Anchor_Position = _currentPosition.y + headerHeight + H_DISPLAY_PATH_LABEL + 60;
2315
2316         if (_bIsTopLevelDirectory)
2317         {
2318                 y_Anchor_Position = y_Anchor_Position + H_CATEGORY_PANEL;
2319         }
2320
2321         if (_pIconListViewContextMenu != null)
2322         {
2323                 _pIconListViewContextMenu->SetAnchorPosition(Point(_currentPosition.x, y_Anchor_Position));
2324                 _pIconListViewContextMenu->SetShowState(true);
2325                 _pIconListViewContextMenu->Show();
2326         }
2327 }
2328
2329 void
2330 SubBaseFolderEntryForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
2331 {
2332         _currentPosition.x = currentPosition.x;
2333         _currentPosition.y = currentPosition.y;
2334
2335         if (_pIconListView != null)
2336         {
2337                 _currentIndex = _pIconListView->GetItemIndexFromPosition(_currentPosition);
2338         }
2339
2340
2341 }
2342
2343 void
2344 SubBaseFolderEntryForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2345 {
2346         //Empty Implementation
2347 }
2348
2349 void
2350 SubBaseFolderEntryForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2351 {
2352         //Empty Implementation
2353 }
2354
2355 void
2356 SubBaseFolderEntryForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2357 {
2358         //Empty Implementation
2359 }
2360 void
2361 SubBaseFolderEntryForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2362 {
2363         //Empty Implementation
2364 }
2365
2366 void
2367 SubBaseFolderEntryForm::SetCurrentDirectoryFlag(bool isTopDirectory)
2368 {
2369         _bIsTopLevelDirectory = isTopDirectory;
2370 }
2371 void
2372 SubBaseFolderEntryForm::OnAppControlCompleted(void)
2373 {
2374         AppLogDebug("Enter");
2375         if (_pFolderEntryPM!=null)
2376         {
2377                 if (_pFolderEntryPM->GetSourceForm() != CREATE_ITEM_SOURCE_CATEGORY_SEARCH_FORM)
2378                 {
2379                         SetFooterVisibility();
2380                 }
2381         }
2382
2383         GetHeader()->Invalidate(true);
2384
2385         if( !_bBackFromAppControl )
2386                 return;
2387
2388         if (_pListView != null && _pListView->IsVisible())
2389         {
2390                 _pListView->UpdateList();
2391         }
2392         else if (_pIconListView != null && _pIconListView->GetShowState())
2393         {
2394                 _pIconListView->UpdateList();
2395         }
2396
2397         if (_pFolderEntryPM!=null)
2398         {
2399                 _pFolderEntryPM->InitThumbnailManager();
2400         }
2401         _pFileEventManager->RemovePath(_fileEventPath);
2402         _bBackFromAppControl = false;
2403         AppLogDebug("Exit");
2404 }
2405
2406 void
2407 SubBaseFolderEntryForm::OnSceneIdChanged(const Tizen::Ui::Scenes::SceneId&      currentSceneId, const Tizen::Ui::Scenes::SceneId&       previousSceneId)
2408 {
2409         if ( _pFolderEntryPM !=null)
2410         {
2411                 if( currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM))
2412                 {
2413                         _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST_TWO);
2414                 }
2415                 else if (currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM1))
2416                 {
2417                         _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
2418                 }
2419         }
2420 }
2421
2422 void
2423 SubBaseFolderEntryForm::OnSettingValueChanged(SettingKey settingKey)
2424 {
2425         AppLogDebug("Entry");
2426
2427         if (settingKey == SETTING_KEY_FONT_SIZE)
2428         {
2429                 if (_pBaseItemProvider != null)
2430                 {
2431                         _pBaseItemProvider->GetFontSizeAndItemHeight();
2432                 }
2433         }
2434
2435         if (_pListView != null && _pListView->IsVisible())
2436         {
2437                 _pListView->UpdateList();
2438         }
2439         else if (_pIconListView != null && _pIconListView->GetShowState())
2440         {
2441                 _pIconListView->UpdateList();
2442         }
2443 }
2444
2445 void
2446 SubBaseFolderEntryForm::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
2447 {
2448         AppLogDebug("Enter");
2449         if (_pFilenames->GetCount() >0 || SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2450         {
2451                 CreateOptionMenu();
2452                 if (_pOptionMenu != null)
2453                 {
2454                         _pOptionMenu->SetShowState(true);
2455                         _pOptionMenu->Show();
2456
2457                 }
2458         }
2459
2460 }
2461
2462
2463 result
2464 SubBaseFolderEntryForm::CreateOptionMenu(void)
2465 {
2466         if (_pOptionMenu != null)
2467         {
2468                 _pOptionMenu->RemoveAllItems();
2469                 delete _pOptionMenu;
2470                 _pOptionMenu = null;
2471         }
2472
2473         _pOptionMenu = new (std::nothrow) OptionMenu();
2474         _pOptionMenu->Construct();
2475
2476         /*
2477         _pOptionMenu->AddItem("Item1",ID_OPTIONMENU_ITEM1);
2478         _pOptionMenu->AddItem("Item2",ID_OPTIONMENU_ITEM2);
2479          */
2480
2481         AppResource* pAppResource = null;
2482         AppRegistry* pAppRegistry = null;
2483
2484         String viewAs;
2485         String extensionVisibility;
2486         String sortBy;
2487         String search;
2488         String buttonCreateFolder;
2489
2490         Bitmap* pBitmapSortbyContextItem = null;
2491         Bitmap* pBitmapSearchContextItem = null;
2492         Bitmap* pBitmapCreateFolderContextItem = null;
2493
2494         pAppResource = Application::GetInstance()->GetAppResource();
2495
2496         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2497
2498         if (pAppResource != null)
2499         {
2500                 pAppResource->GetString(L"IDS_MF_OPT_VIEW_AS", viewAs);
2501                 pAppResource->GetString(L"IDS_MF_SK3_SORT_BY", sortBy);
2502                 pAppResource->GetString(L"IDS_MF_SK3_SEARCH", search);
2503                 pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", buttonCreateFolder);
2504                 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
2505                 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
2506                 pBitmapSortbyContextItem = pAppResource->GetBitmapN(IDB_POPUP_SORTBY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2507                 pBitmapSearchContextItem = pAppResource->GetBitmapN(IDB_POPUP_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2508                 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2509         }
2510
2511         pAppRegistry->Get(_extensionKeyName, extensionVisibility);
2512
2513         if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_TOP_LEVEL_DIRECTORY_FORM)
2514         {
2515                 _pOptionMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2516         }
2517         else
2518         {
2519                 if (_bIsDirectoryEmpty == false)
2520                 {
2521                         if (CheckSearchHistory() == false)
2522                         {
2523                                 _pOptionMenu->AddItem(search, IDA_CONTEXT_MENU_BTN_SEARCH, *pBitmapSearchContextItem, null, null);
2524                         }
2525
2526                         _pOptionMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2527                         _pOptionMenu->AddItem(sortBy, IDA_CONTEXT_MENU_BTN_SORT_BY, *pBitmapSortbyContextItem, null, null);
2528
2529                         if (extensionVisibility == hideExtensionKeyValue)
2530                         {
2531                                 _pOptionMenu->AddItem(_showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
2532                         }
2533                         else
2534                         {
2535                                 _pOptionMenu->AddItem(_hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
2536                         }
2537                 }
2538
2539                 if (SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2540                 {
2541                         _pOptionMenu->AddItem(buttonCreateFolder, IDA_CONTEXT_MENU_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
2542                 }
2543         }
2544
2545         _pOptionMenu->AddActionEventListener(*this);
2546
2547         delete pBitmapSortbyContextItem;
2548         delete pBitmapSearchContextItem;
2549         delete pBitmapCreateFolderContextItem;
2550
2551         return E_SUCCESS;
2552 }