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                         //displayPath.Append(L"\x200E");
1452                         displayPath.Append(token);
1453                         displayPath.Append(L"/");
1454
1455                 }
1456         }
1457
1458         if (_pLabelDisplayPath != null)
1459         {
1460
1461                 //_displayPath.Append(L"\x200E");
1462                 _displayPath.Append(displayPath);
1463                 _displayPath.Append(L"\x200E");
1464
1465                 AppLogDebug("SubBaseFolderEntryForm::SetNextDisplayPath:%S", _displayPath.GetPointer());
1466
1467                 _pLabelDisplayPath->SetText(_displayPath);
1468                 _pLabelDisplayPath->Invalidate(true);
1469         }
1470
1471 #if 0
1472         if (pContext != null)
1473         {
1474                 //UpdateBinding on the target label control.
1475                 pContext->UpdateBinding(L"ID_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
1476         }
1477
1478         if (pContext != null)
1479         {
1480                 delete pContext;
1481         }
1482 #endif
1483
1484 }
1485
1486 FolderEntryPresentationModel*
1487 SubBaseFolderEntryForm::GetFolderEntryPresentationModel(void)
1488 {
1489         return _pFolderEntryPM;
1490 }
1491
1492 result
1493 SubBaseFolderEntryForm::DeleteFile(String& filePath)
1494 {
1495         AppLogDebug("ENTER");
1496         result r = E_SUCCESS;
1497
1498         //_pFolderEntryPM->SetFileEventListener(null);
1499         ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1500         _pFileManager->DeleteFolderEntries(&filePath);
1501
1502         AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1503         return r;
1504 }
1505
1506 void
1507 SubBaseFolderEntryForm::SubBaseOnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1508 {
1509         AppLogDebug("ENTER");
1510         DirectoryEntry* pDirStr = null;
1511         String fullPath;
1512
1513         switch (actionId)
1514         {
1515         case IDA_BTN_EDIT:
1516         {
1517                 _editOrShare = FILE_MANAGE_EDIT;
1518                 //If filenames is not empty then Load the edit form.
1519                 if (_pFilenames->GetCount() != 0)
1520                 {
1521                         //_pFolderEntryPM->SetFileEventListener(null);
1522
1523                         LoadEditForm();
1524                 }
1525         }
1526         break;
1527
1528         case IDA_BTN_SHARE:
1529         {
1530                 AppLogDebug("Share Button Clicked!");
1531
1532                 _editOrShare = FILE_MANAGE_SHARE;
1533                 if (_pFilenames->GetCount() != 0)
1534                 {
1535                         //_pFolderEntryPM->SetFileEventListener(null);
1536
1537                         LoadEditForm();
1538                 }
1539         }
1540         break;
1541
1542         case IDA_BTN_MORE:
1543         {
1544                 CreateMoreContextMenu();
1545
1546                 ShowMoreContextMenu();
1547         }
1548         break;
1549
1550         case IDA_CONTEXT_MENU_BTN_SORT_BY:
1551         {
1552                 //Show the SortBy PopUp.
1553                 if (_pCustomListViewForPopup != null)
1554                 {
1555                         _pCustomListViewForPopup->SetSelectionPopup(POP_UP_SORT_BY);
1556                 }
1557                 ShowSortByPopup();
1558         }
1559         break;
1560
1561         case IDA_CONTEXT_MENU_CREATE_FOLDER:
1562         {
1563                 //Load the CreateFolder Form.
1564                 //_pFolderEntryPM->SetFileEventListener(null);
1565                 _renameOrCreate = SELECT_CREATE_FOLDER;
1566
1567                 if (_pMoreContextMenu != null)
1568                 {
1569                         delete _pMoreContextMenu;
1570                         _pMoreContextMenu = null;
1571                 }
1572
1573                 LoadCreateFolderForm();
1574         }
1575         break;
1576
1577         case IDA_CONTEXT_MENU_VIEW_AS:
1578         {
1579                 //Show the ViewAs Popup
1580                 if (_pCustomListViewForPopup != null)
1581                 {
1582                         _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
1583                 }
1584
1585                 ShowViewAsPopup();
1586         }
1587         break;
1588
1589         case IDA_BTN_POPUP_CANCEL:
1590         {
1591                 //Hide the ViewAs PopUp and redraw the form.
1592                 HideViewAsPopup();
1593         }
1594         break;
1595
1596         case IDA_BTN_SORT_POPUP_CANCEL:
1597         {
1598                 //Hide the SortBy PopUp and redraw the form.
1599                 HideSortByPopup();
1600         }
1601         break;
1602
1603         case IDA_CONTEXT_MENU_BTN_SEARCH:
1604         {
1605                 //Load the SearchForm
1606                 LoadSearchForm();
1607         }
1608         break;
1609
1610         case IDA_DELETE_FILE:
1611         {
1612                 HideDeleteConfirmationPopup();
1613
1614                 if (_pDeleteConfirmationPopUp != null)
1615                 {
1616                         delete _pDeleteConfirmationPopUp;
1617                         _pDeleteConfirmationPopUp = null;
1618                 }
1619                 _filePath.Clear();
1620
1621                 if (_pFilenames != null)
1622                 {
1623                         pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(_indexToDelete));
1624                 }
1625                 if (pDirStr != null)
1626                 {
1627                         _filePath = pDirStr->GetFullFilePath();
1628                 }
1629                 _indexTracker = _indexToDelete;
1630                 //Call the DeleteFile Function.
1631                 DeleteFile(_filePath);
1632         }
1633         break;
1634
1635         case IDA_CANCEL_DELETION:
1636         {
1637                 HideDeleteConfirmationPopup();
1638
1639                 if (_pDeleteConfirmationPopUp != null)
1640                 {
1641                         delete _pDeleteConfirmationPopUp;
1642                         _pDeleteConfirmationPopUp = null;
1643                 }
1644         }
1645         break;
1646
1647         case IDA_BTN_ANIMATION_POPUP_CANCEL:
1648         {
1649                 AppLogDebug("IDA_BTN_ANIMATION_POPUP_CANCEL");
1650                 HideFileProgressingPopup();
1651                 _pFileManager->ForceStopWorkerThread();
1652         }
1653         break;
1654
1655         case IDA_ICONLISTVIEW_DETAILS:
1656         {
1657                 if (_pIconListViewContextMenu != null)
1658                 {
1659                         delete _pIconListViewContextMenu;
1660                         _pIconListViewContextMenu = null;
1661                 }
1662
1663                 if (_bIsTopLevelDirectory == false)
1664                 {
1665                         if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1666                         {
1667                                 pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1668
1669                                 if (pDirStr != null)
1670                                 {
1671                                         fullPath = pDirStr->GetFullFilePath();
1672                                 }
1673                         }
1674                 }
1675                 else
1676                 {
1677                         switch (_currentIndex)
1678                         {
1679                         case 0:
1680                                 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetMediaPath());
1681                                 fullPath = FolderNavigationPresentationModel::GetMediaPath();
1682                                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1683                                 break;
1684                         case 1:
1685                                 FolderNavigationPresentationModel::SetCurrentFilePath(FolderNavigationPresentationModel::GetSdCardPath());
1686                                 fullPath = FolderNavigationPresentationModel::GetSdCardPath();
1687                                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1688
1689                                 break;
1690                         case 2:
1691                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetUsbPath());
1692                                 fullPath = FolderNavigationPresentationModel::GetUsbPath();
1693                                 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_EXTERNAL);
1694                                 break;
1695                         }
1696                 }
1697
1698                 LoadDetailForm(fullPath);
1699         }
1700         break;
1701
1702         case IDA_ICONLISTVIEW_DELETE:
1703         {
1704                 if (_pIconListViewContextMenu != null)
1705                 {
1706                         delete _pIconListViewContextMenu;
1707                         _pIconListViewContextMenu = null;
1708                 }
1709
1710                 ShowDeleteConfirmationPopup();
1711
1712                 _indexToDelete = _currentIndex;
1713
1714         }
1715         break;
1716
1717         case IDA_ICONLISTVIEW_RENAME:
1718         {
1719                 if (_pIconListViewContextMenu != null)
1720                 {
1721                         delete _pIconListViewContextMenu;
1722                         _pIconListViewContextMenu = null;
1723                 }
1724
1725                 if (_currentIndex != INVALID_LIST_INDEX && _pFilenames != null)
1726                 {
1727                         pDirStr = static_cast <DirectoryEntry*>(_pFilenames->GetAt(_currentIndex));
1728
1729                         if (pDirStr != null)
1730                         {
1731                                 _currentFileName.Clear();
1732                                 _currentFileName = pDirStr->GetFileName();
1733                         }
1734                 }
1735
1736                 _renameIndex = _currentIndex;
1737                 _renameOrCreate = SELECT_RENAME;
1738
1739                 //Load the Rename View of the item selected.
1740                 LoadRenameForm(_currentIndex);
1741         }
1742         break;
1743
1744         default:
1745         {
1746                 //Do Nothing.
1747         }
1748         break;
1749         }
1750 }
1751
1752 void
1753 SubBaseFolderEntryForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
1754 {
1755         DirectoryEntry* pDirStr = null;
1756         _selectedItemIndex = index;
1757         if (_pFilenames != null)
1758         {
1759                 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
1760
1761                 if (pDirStr != null)
1762                 {
1763                         switch (elementId)
1764                         {
1765                         case IDA_CONTEXT_DETAIL:
1766                         {
1767                                 _filePath.Clear();
1768                                 _filePath = pDirStr->GetFullFilePath();
1769                                 LoadDetailForm(_filePath);
1770                         }
1771                         break;
1772
1773                         case IDA_CONTEXT_RENAME:
1774                         {
1775                                 _currentFileName.Clear();
1776                                 _currentFileName = pDirStr->GetFileName();
1777                                 _renameIndex = index;
1778                                 _renameOrCreate = SELECT_RENAME;
1779                                 //Load the Rename View of the item selected.
1780                                 LoadRenameForm(index);
1781                         }
1782                         break;
1783
1784                         case IDA_CONTEXT_DELETE:
1785                         {
1786                                 _indexToDelete = index;
1787
1788                                 ShowDeleteConfirmationPopup();
1789                         }
1790                         break;
1791
1792                         default:
1793                         {
1794                                 //Empty Implementation.
1795                         }
1796                         break;
1797                         }
1798                 }
1799         }
1800 }
1801
1802 void
1803 SubBaseFolderEntryForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1804 {
1805         result res = E_SUCCESS;
1806         AppLogDebug("Enter");
1807
1808         if (_pFolderEntryPM)
1809         {
1810                 if (pThumbReq != null)
1811                 {
1812                         if (pThumbReq->GetCurrentSourceForm() != _pFolderEntryPM->GetSourceForm())
1813                         {
1814                                 if (pThumbReq->pBitmap != null)
1815                                 {
1816                                         delete pThumbReq->pBitmap;
1817                                 }
1818                                 return;
1819                         }
1820                 }
1821
1822                 if (pThumbReq != null)
1823                 {
1824                         if (pThumbReq->GetCurrentRequestId() != _pFolderEntryPM->GetCurrentReqId())
1825                         {
1826                                 if (pThumbReq->pBitmap != null)
1827                                 {
1828                                         delete pThumbReq->pBitmap;
1829                                 }
1830                                 AppLogDebug("mismatch in id so returning");
1831                                 return;
1832                         }
1833                 }
1834                 if (pThumbReq)
1835                 {
1836                         if (pThumbReq->iRquestId < _pFilenames->GetCount())
1837                         {
1838                                 _pFolderEntryPM->OnThumbnailResponseReceived(pThumbReq->pBitmap, pThumbReq->iRquestId);
1839                                 if (_pListView && _pListView->IsVisible())
1840                                 {
1841                                         res = _pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1842                                 }
1843                                 else if (_pIconListView && _pIconListView->IsVisible())
1844                                 {
1845                                         res = _pIconListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1846                                 }
1847                         }
1848                         else
1849                                 AppLogDebug("Thumbnail Request is not valid");
1850                 }
1851                 else
1852                 {
1853                         _pFolderEntryPM->OnThumbnailResponseFailed();
1854                 }
1855         }
1856         AppLogDebug("Exit %s", GetErrorMessage(res));
1857         return;
1858 }
1859
1860 result
1861 SubBaseFolderEntryForm::CreateSortByPopup(void)
1862 {
1863         result r = E_SUCCESS;
1864
1865         if (_pSortByPopup != null)
1866         {
1867                 AppLogDebug("_pSortByPopup is not null");
1868                 return r;
1869         }
1870
1871         String cancelButton;
1872         String sortByPopupTitle;
1873
1874 //      Label* pSortByPanelLabel = null;
1875 //      Label* pSortByPopupLabel = null;
1876
1877 //      Bitmap* pPanelBackground = null;
1878 //      Bitmap* pPopUpBackground = null;
1879
1880         //      pPanelBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888);
1881         //pPopUpBackground = UiApp::App::GetInstance()->GetAppResource()->GetBitmapN(IDB_BACKGROUND_POPUP_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888);
1882 //      pPopUpBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, 512, 632);
1883 //      pPanelBackground = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_BOTTOM, 612, 96);
1884
1885         _pSortByPopup = new (std::nothrow) Popup();
1886         _pSortByPopup->Construct(L"IDL_SORT_BY_POPUP");
1887
1888         _pCancelSortBy = static_cast< Button* >(_pSortByPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1889         TryCatch(_pCancelSortBy != null, , "MfMyFilesApp::Button For Popup not created!");
1890
1891         _pCancelSortBy->SetActionId(IDA_BTN_SORT_POPUP_CANCEL);
1892         _pCancelSortBy->AddActionEventListener(*this);
1893         _pCancelSortBy->SetShowState(true);
1894
1895 //      pSortByPanelLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_PANEL_BACKGROUND", true));
1896 //      TryCatch(pSortByPanelLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1897 //
1898 //      pSortByPopupLabel = static_cast< Label* >(_pSortByPopup->GetControl(L"IDC_LABEL_POPUP_BACKGROUND", true));
1899 //      TryCatch(pSortByPopupLabel != null, , "MfMyFilesApp::pLabel For Popup not created!");
1900 //
1901 //      if (pPanelBackground != null)
1902 //      {
1903 //              pSortByPanelLabel->SetBackgroundBitmap(*pPanelBackground);
1904 //      }
1905 //
1906 //      if (pPopUpBackground != null)
1907 //      {
1908 //              pSortByPopupLabel->SetBackgroundBitmap(*pPopUpBackground);
1909 //
1910 //      }
1911
1912         _pSortByListView = static_cast< ListView* >(_pSortByPopup->GetControl(L"IDC_LISTVIEW_SORT_BY", true));
1913         TryCatch(_pSortByListView != null, , "MfMyFilesApp::ListView Control For Popup not created!");
1914
1915         _pSortByListView->SetShowState(true);
1916         _pSortByListView->AddListViewItemEventListener(*_pCustomListViewForPopup);
1917         _pSortByListView->SetItemProvider(*_pCustomListViewForPopup);
1918         _pSortByListView->SetName(L"SORT_BY_LISTVIEW");
1919         _pSortByListView->SetItemDividerColor(Color::GetColor(COLOR_ID_GREY));
1920
1921         AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
1922
1923 //      _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPanelLabel, true);
1924 //      _pSortByPopup->SetControlAlwaysAtBottom(*pSortByPopupLabel, true);
1925         _pSortByPopup->SetControlAlwaysOnTop(*_pSortByListView, true);
1926         _pSortByPopup->SetControlAlwaysOnTop(*_pCancelSortBy, true);
1927
1928 //      if (pPanelBackground != null)
1929 //      {
1930 //              delete pPanelBackground;
1931 //              pPanelBackground = null;
1932 //      }
1933 //      if (pPopUpBackground != null)
1934 //      {
1935 //              delete pPopUpBackground;
1936 //              pPopUpBackground = null;
1937 //      }
1938         return r;
1939
1940         CATCH:
1941         if (_pCustomListViewForPopup != null)
1942         {
1943                 delete _pCustomListViewForPopup;
1944                 _pCustomListViewForPopup = null;
1945         }
1946
1947         if (_pSortByPopup != null)
1948         {
1949                 delete _pSortByPopup;
1950                 _pSortByPopup = null;
1951         }
1952
1953 //      if (pPanelBackground != null)
1954 //      {
1955 //              delete pPanelBackground;
1956 //              pPanelBackground = null;
1957 //      }
1958 //
1959 //      if (pPopUpBackground != null)
1960 //      {
1961 //              delete pPopUpBackground;
1962 //              pPopUpBackground = null;
1963 //      }
1964
1965         return r;
1966 }
1967
1968 result
1969 SubBaseFolderEntryForm::CreateMoreContextMenu(void)
1970 {
1971         result r = E_SUCCESS;
1972
1973         int xPosition = 0;
1974         int yPosition = 0;
1975
1976         AppResource* pAppResource = null;
1977         AppRegistry* pAppRegistry = null;
1978
1979         String viewAs;
1980         String extensionVisibility;
1981         String sortBy;
1982         String search;
1983         String buttonCreateFolder;
1984
1985         Bitmap* pBitmapSortbyContextItem = null;
1986         Bitmap* pBitmapSearchContextItem = null;
1987         Bitmap* pBitmapCreateFolderContextItem = null;
1988
1989         pAppResource = Application::GetInstance()->GetAppResource();
1990
1991         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
1992
1993         if (pAppResource != null)
1994         {
1995                 pAppResource->GetString(L"IDS_MF_OPT_VIEW_AS", viewAs);
1996                 pAppResource->GetString(L"IDS_MF_SK3_SORT_BY", sortBy);
1997                 pAppResource->GetString(L"IDS_MF_SK3_SEARCH", search);
1998                 pAppResource->GetString(L"IDS_MF_OPT_CREATE_FOLDER", buttonCreateFolder);
1999                 pAppResource->GetString(L"IDS_MF_OPT_HIDE_FILE_EXTENSION_ABB", _hideExtension);
2000                 pAppResource->GetString(L"IDS_MF_OPT_SHOW_FILE_EXTENSION", _showExtension);
2001                 pBitmapSortbyContextItem = pAppResource->GetBitmapN(IDB_POPUP_SORTBY_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2002                 pBitmapSearchContextItem = pAppResource->GetBitmapN(IDB_POPUP_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2003                 pBitmapCreateFolderContextItem = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
2004         }
2005
2006         pAppRegistry->Get(_extensionKeyName, extensionVisibility);
2007
2008         _pFooter = GetFooter();
2009         if (_pFooter != null)
2010         {
2011                 _pFooter->GetPosition(xPosition, yPosition);
2012         }
2013
2014         xPosition += 3 * (GetClientAreaBounds().width / 4);
2015
2016         //Create the ContextMenu
2017         _pMoreContextMenu = new (std::nothrow) ContextMenu();
2018         _pMoreContextMenu->Construct(Point(0, yPosition), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
2019         _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2020         _pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2021
2022         if (SceneManager::GetInstance()->GetCurrentSceneId() == IDSCN_TOP_LEVEL_DIRECTORY_FORM)
2023         {
2024                 _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2025         }
2026         else
2027         {
2028                 if (_bIsDirectoryEmpty == false)
2029                 {
2030                         if (CheckSearchHistory() == false)
2031                         {
2032                                 _pMoreContextMenu->AddItem(search, IDA_CONTEXT_MENU_BTN_SEARCH, *pBitmapSearchContextItem, null, null);
2033                         }
2034
2035                         _pMoreContextMenu->AddItem(viewAs, IDA_CONTEXT_MENU_VIEW_AS);
2036                         _pMoreContextMenu->AddItem(sortBy, IDA_CONTEXT_MENU_BTN_SORT_BY, *pBitmapSortbyContextItem, null, null);
2037
2038                         if (extensionVisibility == _hideExtension)
2039                         {
2040                                 _pMoreContextMenu->AddItem(_showExtension, IDA_CONTEXT_MENU_SHOW_EXTENSION);
2041                         }
2042                         else
2043                         {
2044                                 _pMoreContextMenu->AddItem(_hideExtension, IDA_CONTEXT_MENU_HIDE_EXTENSION);
2045                         }
2046                 }
2047
2048                 if (SceneManager::GetInstance()->GetCurrentSceneId() != IDSCN_CATEGORY_SEARCH_FORM)
2049                 {
2050                         _pMoreContextMenu->AddItem(buttonCreateFolder, IDA_CONTEXT_MENU_CREATE_FOLDER, *pBitmapCreateFolderContextItem, null, null);
2051                 }
2052         }
2053
2054         //Set the ContextMenu's ActionEventListener
2055         _pMoreContextMenu->AddActionEventListener(*this);
2056         //_pMoreContextMenu->SetAnchorPosition(Point(xPosition, yPosition));
2057         _pMoreContextMenu->SetShowState(true);
2058
2059         delete pBitmapSortbyContextItem;
2060         delete pBitmapSearchContextItem;
2061         delete pBitmapCreateFolderContextItem;
2062         return r;
2063 }
2064
2065 result
2066 SubBaseFolderEntryForm::SetDefaultSelectionForViewAsPopUp(void)
2067 {
2068         result r = E_SUCCESS;
2069
2070         int defaultViewAsPopUpSelect = 0;
2071         int uncheckItem1 = 0;
2072         int uncheckItem2 = 0;
2073
2074         int viewType = VIEW_TYPE_AS_NONE;
2075         String viewStyleKeyName(L"ListDisplayType");
2076
2077         AppRegistry* pAppRegistry = null;
2078
2079         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2080
2081         r = pAppRegistry->Get(viewStyleKeyName, viewType);
2082
2083         switch (viewType)
2084         {
2085
2086         case VIEW_TYPE_AS_DETAILED_LIST:
2087         {
2088                 defaultViewAsPopUpSelect = 1;
2089                 uncheckItem1 = 0;
2090                 uncheckItem2 = 2;
2091         }
2092         break;
2093
2094         case VIEW_TYPE_AS_NORMAL_LIST:
2095         {
2096                 defaultViewAsPopUpSelect = 0;
2097                 uncheckItem1 = 1;
2098                 uncheckItem2 = 2;
2099         }
2100         break;
2101
2102         case VIEW_TYPE_AS_THUMBNAILS:
2103         {
2104                 defaultViewAsPopUpSelect = 2;
2105                 uncheckItem1 = 0;
2106                 uncheckItem2 = 1;
2107         }
2108         break;
2109
2110         default:
2111         {
2112                 //Empty Implementation.
2113         }
2114         break;
2115         }
2116
2117
2118         if (_pCustomListViewForPopup != null)
2119         {
2120                 _pCustomListViewForPopup->SetSelectionPopup(POP_UP_VIEW_AS);
2121         }
2122
2123         if (_pViewAsPopup != null && _pViewAsListView != null)
2124         {
2125                 _pViewAsListView->UpdateList();
2126                 _pViewAsListView->SetItemChecked(defaultViewAsPopUpSelect, true);
2127                 _pViewAsListView->SetItemChecked(uncheckItem1, false);
2128                 _pViewAsListView->SetItemChecked(uncheckItem2, false);
2129                 _pViewAsListView->Invalidate(true);
2130         }
2131         return r;
2132 }
2133
2134
2135 void
2136 SubBaseFolderEntryForm::SetFooterVisibility(void)
2137 {
2138         AppLogDebug("Entry");
2139         int folderCount=0, fileCount=0;
2140
2141         _pFooter = GetFooter();
2142
2143         if( _pFolderEntryPM )
2144                 _pFolderEntryPM->GetFolderEntryCount(FolderNavigationPresentationModel::GetCurrentPath(), folderCount, fileCount);
2145
2146         if (folderCount ==0 && fileCount == 0)
2147         {
2148                 _pFooter->SetItemEnabled(0, false);
2149                 _pFooter->SetItemEnabled(1, false);
2150         }
2151         else
2152         {
2153                 _pFooter->SetItemEnabled(0, true);
2154
2155                 if (fileCount != 0)
2156                 {
2157                         _pFooter->SetItemEnabled(1, true);
2158                 }
2159                 else
2160                 {
2161                         _pFooter->SetItemEnabled(1, false);
2162                 }
2163
2164         }
2165
2166         _pFooter->Invalidate(true);
2167 }
2168
2169 bool
2170 SubBaseFolderEntryForm::CheckSearchHistory(void)
2171 {
2172         bool searchHistoryStatus = false;
2173         int itemCount = 0;
2174         String searchScene;
2175         SceneManager* pSceneManager = SceneManager::GetInstance();
2176         IListT< SceneId >* pSceneList = pSceneManager->GetSceneHistoryN();
2177
2178         if (pSceneList != null)
2179         {
2180                 itemCount = pSceneList->GetCount() - 1;
2181                 pSceneList->GetAt(itemCount, searchScene);
2182                 while (searchScene != IDSCN_SEARCH_FORM && itemCount >= 0)
2183                 {
2184                         itemCount--;
2185                         pSceneList->GetAt(itemCount, searchScene);
2186                 }
2187         }
2188
2189         if (searchScene == IDSCN_SEARCH_FORM)
2190         {
2191                 AppLogDebug("Search scene present");
2192                 searchHistoryStatus = true;
2193         }
2194         else
2195         {
2196                 AppLogDebug("Search scene not present");
2197                 searchHistoryStatus = false;
2198         }
2199
2200         if(pSceneList)
2201         {
2202                 pSceneList->RemoveAll();
2203                 delete pSceneList;
2204                 pSceneList = null;
2205         }
2206         return searchHistoryStatus;
2207 }
2208
2209
2210 void
2211 SubBaseFolderEntryForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int     eventId)
2212 {
2213         //Empty Implementation
2214 }
2215
2216 void
2217 SubBaseFolderEntryForm::OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2218 {
2219         //Show Context Menu
2220         if (_currentIndex != INVALID_LIST_INDEX)
2221         {
2222                 ShowIconListViewContextMenu();
2223         }
2224 }
2225
2226 void
2227 SubBaseFolderEntryForm::OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector)
2228 {
2229         //Empty Implementation.
2230 }
2231
2232 result
2233 SubBaseFolderEntryForm::CreateIconListViewContextMenu(void)
2234 {
2235         if (_pIconListViewContextMenu != null)
2236         {
2237                 return E_FAILURE;
2238         }
2239
2240         result r = E_SUCCESS;
2241
2242         String Details;
2243         String Rename;
2244         String Delete;
2245
2246         String buttonCreateFolder;
2247
2248         AppResource* pAppResource = null;
2249         //AppRegistry* pAppRegistry = null;
2250         pAppResource = Application::GetInstance()->GetAppResource();
2251
2252         //pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
2253
2254         if (pAppResource != null)
2255         {
2256                 pAppResource->GetString(L"IDS_MF_SK_DETAILS", Details);
2257                 pAppResource->GetString(L"IDS_MF_SK3_DELETE", Delete);
2258                 pAppResource->GetString(L"IDS_MF_BODY_RENAME_ABB", Rename);
2259         }
2260
2261         //Create the ContextMenu
2262         _pIconListViewContextMenu = new (std::nothrow) ContextMenu();
2263
2264         _pIconListViewContextMenu->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_AUTO);
2265         _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
2266         _pIconListViewContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
2267
2268
2269         _pIconListViewContextMenu->AddItem(Details, IDA_ICONLISTVIEW_DETAILS);
2270         if (_bIsTopLevelDirectory == false)
2271         {
2272                 _pIconListViewContextMenu->AddItem(Rename, IDA_ICONLISTVIEW_RENAME);
2273                 _pIconListViewContextMenu->AddItem(Delete, IDA_ICONLISTVIEW_DELETE);
2274         }
2275
2276         //Set the ContextMenu's ActionEventListener
2277         _pIconListViewContextMenu->AddActionEventListener(*this);
2278         _pIconListViewContextMenu->SetShowState(true);
2279
2280         return r;
2281 }
2282
2283 void
2284 SubBaseFolderEntryForm::ShowIconListViewContextMenu(void)
2285 {
2286
2287         CreateIconListViewContextMenu();
2288         int headerHeight = 0;
2289
2290         int y_Anchor_Position = 0;
2291
2292         Header* pHeader = GetHeader();
2293         headerHeight = pHeader->GetHeight();
2294
2295
2296         y_Anchor_Position = _currentPosition.y + headerHeight + H_DISPLAY_PATH_LABEL + 60;
2297
2298         if (_bIsTopLevelDirectory)
2299         {
2300                 y_Anchor_Position = y_Anchor_Position + H_CATEGORY_PANEL;
2301         }
2302
2303         if (_pIconListViewContextMenu != null)
2304         {
2305                 _pIconListViewContextMenu->SetAnchorPosition(Point(_currentPosition.x, y_Anchor_Position));
2306                 _pIconListViewContextMenu->SetShowState(true);
2307                 _pIconListViewContextMenu->Show();
2308         }
2309 }
2310
2311 void
2312 SubBaseFolderEntryForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo)
2313 {
2314         _currentPosition.x = currentPosition.x;
2315         _currentPosition.y = currentPosition.y;
2316
2317         if (_pIconListView != null)
2318         {
2319                 _currentIndex = _pIconListView->GetItemIndexFromPosition(_currentPosition);
2320         }
2321
2322
2323 }
2324
2325 void
2326 SubBaseFolderEntryForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2327 {
2328         //Empty Implementation
2329 }
2330
2331 void
2332 SubBaseFolderEntryForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2333 {
2334         //Empty Implementation
2335 }
2336
2337 void
2338 SubBaseFolderEntryForm::OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2339 {
2340         //Empty Implementation
2341 }
2342 void
2343 SubBaseFolderEntryForm::OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2344 {
2345         //Empty Implementation
2346 }
2347
2348 void
2349 SubBaseFolderEntryForm::SetCurrentDirectoryFlag(bool isTopDirectory)
2350 {
2351         _bIsTopLevelDirectory = isTopDirectory;
2352 }
2353 void
2354 SubBaseFolderEntryForm::OnAppControlCompleted(void)
2355 {
2356         AppLogDebug("Enter");
2357         if (_pFolderEntryPM!=null)
2358         {
2359                 if (_pFolderEntryPM->GetSourceForm() != CREATE_ITEM_SOURCE_CATEGORY_SEARCH_FORM)
2360                 {
2361                         SetFooterVisibility();
2362                 }
2363         }
2364
2365         if( !_bBackFromAppControl )
2366                 return;
2367
2368         if (_pListView != null && _pListView->IsVisible())
2369         {
2370                 _pListView->UpdateList();
2371         }
2372
2373         if (_pIconListView != null && _pIconListView->IsVisible())
2374         {
2375                 _pIconListView->UpdateList();
2376         }
2377
2378         if (_pFolderEntryPM!=null)
2379         {
2380                 _pFolderEntryPM->InitThumbnailManager();
2381         }
2382         _pFileEventManager->RemovePath(_fileEventPath);
2383         _bBackFromAppControl = false;
2384         AppLogDebug("Exit");
2385 }
2386
2387 void
2388 SubBaseFolderEntryForm::OnSceneIdChanged(const Tizen::Ui::Scenes::SceneId&      currentSceneId, const Tizen::Ui::Scenes::SceneId&       previousSceneId)
2389 {
2390         if ( _pFolderEntryPM !=null)
2391         {
2392                 if( currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM))
2393                 {
2394                         _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST_TWO);
2395                 }
2396                 else if (currentSceneId.CompareTo(IDSCN_SUB_DIRECTORY_FORM1))
2397                 {
2398                         _pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SUB_FOLDER_FILE_LIST);
2399                 }
2400         }
2401 }
2402
2403 void
2404 SubBaseFolderEntryForm::OnSettingValueChanged(void)
2405 {
2406         AppLogDebug("Entry");
2407         if (_pListView != null && _pListView->IsVisible())
2408         {
2409                 _pListView->UpdateList();
2410         }
2411
2412         if (_pIconListView != null && _pIconListView->IsVisible())
2413         {
2414                 _pIconListView->UpdateList();
2415         }
2416 }