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