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