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