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