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