2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
18 * @file: SearchForm.cpp
19 * @brief: This file contains implementation of SearchForm.
22 #include "MfSearchForm.h"
24 using namespace Tizen::App;
25 using namespace Tizen::App::Package;
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Base::Utility;
29 using namespace Tizen::Content;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::System;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
37 int SearchForm::searchBackSelected = 0;
38 SearchForm::SearchForm(void)
40 __pContentListFromLastView = null;
41 __pSearchedContentList = null;
45 __pSearchPopup = null;
46 __pLabelSearching = null;
47 __pCancelSearch = null;
48 __pFolderLabel = null;
50 __pThumbnailManager = null;
51 __pSearchModel = null;
54 __currentSearchDirectoryPath = L"";
55 __bIsResultList = false;
57 __searchedAllFolders = false;
58 __isSearchCompleted = false;
59 __isCancelClicked = false;
60 __isSearchStarted = false;
61 __bCheckArgsNull = false;
62 __isCurrentDirectoryRenamed = false;
63 __backFromAppControl = false;
66 __searchItemIndex = INVALID_LIST_INDEX;
68 __pFolderBitmap = null;
71 __pDeleteConfirmationPopUp = null;
73 __selectedItemIndexForRename = 0;
74 __selectedItemIndexForDelete = 0;
76 __previouFormTab = MEMORY_TYPE_NONE;
78 __pCancelDeletion = null;
80 __pFileProgressingCancelButton = null;
81 __pFileProgressingHeaderLabel = null;
82 __pItemContext = null;
83 __pFileProgressingPopup = null;
84 __pFileProgressingProgress = null;
85 __pFileEventManager = null;
88 SearchForm::~SearchForm(void)
92 if (__pSearchedContentList != null)
94 __pSearchedContentList->RemoveAll(true);
95 delete __pSearchedContentList;
98 if (__pSearchModel != null)
100 delete __pSearchModel;
103 if (__pItemContext != null)
105 delete __pItemContext;
108 if (__pDeleteConfirmationPopUp != null)
110 delete __pDeleteConfirmationPopUp;
112 if(__pFolderEntryPM != null)
114 delete __pFolderEntryPM;
116 if (__pFileEventManager != null)
118 delete __pFileEventManager;
124 SearchForm::operator =(const SearchForm& pSearchForm)
129 SearchForm::SearchForm(const SearchForm& pSearchForm)
131 __pContentListFromLastView = pSearchForm.__pContentListFromLastView;
132 __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;
137 SearchForm::Initialize(void)
139 result r = Form::Construct(L"IDL_SEARCH");
142 AppLogDebug("Form construct failed with %s", GetErrorMessage(r));
149 SearchForm::OnInitializing(void)
151 AppLogDebug("ENTER::SearchForm::OnInitializing");
152 result r = E_SUCCESS;
153 String cancelButton(L"");
155 Bitmap* pDeleteNormalBmp = null;
156 Bitmap* pDeletePressBmp = null;
157 String renameButtonText;
158 String detailButtonText;
159 String deleteButtonText;
160 String strSearching ;
161 IListT< SceneId >* pSceneList = null;
163 __SelectedTab = MEMORY_TYPE_NONE;
165 __pFolderBitmap = AppResource::GetInstance()->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);
166 __pDummyImage = AppResource::GetInstance()->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);
167 AppResource::GetInstance()->GetString(L"IDS_MF_BODY_RENAME_ABB", renameButtonText);
168 AppResource::GetInstance()->GetString(L"IDS_MF_SK3_DELETE", deleteButtonText);
169 AppResource::GetInstance()->GetString(L"IDS_MF_SK_DETAILS", detailButtonText);
171 pDeleteNormalBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_NORMAL, 150, 72);
172 pDeletePressBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_PRESS, 150, 72);
174 Footer* pFooter = GetFooter();
175 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
176 pFooter->SetBackButton();
178 SetFormBackEventListener(this);
179 __pThumbnailManager = ThumbnailManager::GetInstance();
180 TryCatch(__pThumbnailManager != null, , "ThumbnailManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
182 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
184 __searchBarMode = SEARCH_BAR_MODE_INPUT;
186 __pSearchBar = static_cast< SearchBar* >(GetControl("IDC_SEARCHFORM_SEARCHBAR"));
187 TryCatch(__pSearchBar != null, , "__pSearchBar is Null");
189 __pSearchBar->AddSearchBarEventListener(*this);
190 __pSearchBar->AddTextEventListener(*this);
191 __pSearchBar->AddKeypadEventListener(*this);
192 __pSearchBar->SetShowState(true);
194 __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
195 TryCatch(__pFolderEntryPM != null, , "Content Manager not found!");
196 __pFolderEntryPM->Construct();
198 __pSearchPopup = new (std::nothrow) Popup();
199 TryCatch(__pSearchPopup != null, , "Failed to allocate memory to __pSearchPopup");
201 r = __pSearchPopup->Construct(L"IDL_SEARCH_POPUP");
202 TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpPanel");
204 __pLabelSearching = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_SEARCHING"));
205 TryCatch(__pLabelSearching != null, , "Failed to get __pLabelSearching");
207 __pFolderLabel = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_FOLDER"));
208 TryCatch(__pFolderLabel != null, r = GetLastResult(), "Failed to get __pFolderLabel");
210 __pCancelSearch = static_cast<Button*> (__pSearchPopup->GetControl(L"IDC_BUTTON_CANCEL"));
211 TryCatch(__pCancelSearch != null, , "Failed to get __pCancelSearch");
213 __pCancelSearch->SetActionId(IDA_BTN_POPUP_SEARCH_CANCEL);
214 __pCancelSearch->AddActionEventListener(*this);
216 __pSearchPopup->SetShowState(false);
219 __listViewRectangle.SetBounds(X_DEFAULT, H_SEARCH_BAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR);
221 __pListView = static_cast< ListView* >(GetControl("IDC_SEARCHFORM_LISTVIEW"));
222 TryCatch(__pListView != null, r = GetLastResult(), "__pListView is Null");
224 __pListView->SetItemProvider(*this);
225 __pListView->AddListViewItemEventListener(*this);
227 __pSearchModel = new (std::nothrow) SearchPresentationModel();
228 TryCatch(__pSearchModel != null, r = GetLastResult(), "SearchForm::OnInitializing::Failed to allocate memory to __PSearchModel");
230 r = __pSearchModel->Initialize();
231 TryCatch(r == E_SUCCESS, , "SearchPresentationModel:Init()failed with %s", GetErrorMessage(GetLastResult()));
233 __pSearchedContentList = new (std::nothrow) ArrayList();
234 TryCatch(__pSearchedContentList != null, , "SearchForm::GetCurrentFileControl::Failed to allocate Memory to __pSearchedContentList");
236 r = __pSearchedContentList->Construct();
237 TryCatch(r == E_SUCCESS, , "SearchForm::GetCurrentFileControl::Failed to construct __pSearchedContentList");
239 __pItemContext = new (std::nothrow) ListContextItem();
241 r = __pItemContext->Construct();
242 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to construct pitemcontext");
244 __pItemContext->AddElement(IDA_CONTEXT_RENAME, renameButtonText);
245 __pItemContext->AddElement(IDA_CONTEXT_DETAIL, detailButtonText);
247 __pItemContext->AddElement(IDA_CONTEXT_DELETE,
254 __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();
255 __previouFormTab = FolderNavigationPresentationModel::GetStorageType();
256 pSceneList = SceneManager::GetInstance()->GetSceneHistoryN();
257 if (pSceneList != null)
259 __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
264 if (pDeleteNormalBmp != null)
266 delete pDeleteNormalBmp;
267 pDeleteNormalBmp = null;
269 if (pDeletePressBmp != null)
271 delete pDeletePressBmp;
272 pDeletePressBmp = null;
279 if (__pSearchBar != null)
283 if (__pListView != null)
287 if (__pSearchModel != null)
289 delete __pSearchModel;
292 delete pDeleteNormalBmp;
294 delete pDeletePressBmp;
296 AppLogDebug("EXIT::SearchForm::OnInitializing");
301 SearchForm::OnTerminating(void)
303 result r = E_SUCCESS;
304 //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
307 delete __pFolderBitmap;
310 delete __pDummyImage;
315 ////////////////////////////////////////////////////////////////////////
316 // Call-back functions
317 ////////////////////////////////////////////////////////////////////////
320 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
321 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
323 AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));
325 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
327 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
328 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
331 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
334 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
338 __bCheckArgsNull = true;
340 __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
341 __SelectedTab = FolderNavigationPresentationModel::GetStorageType();
343 if (__pFolderEntryPM != null)
345 __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);
346 if (__currentSearchDirectoryPath.IsEmpty() == false)
348 __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);
349 __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();
350 TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");
353 __isSearchCompleted = false;
354 __isSearchStarted = false;
356 String topLevelPath = L"";
359 if (__SelectedTab == MEMORY_TYPE_PHONE)
361 topLevelPath = __pFolderEntryPM->GetMediaPath();
363 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
365 topLevelPath = __pFolderEntryPM->GetSdCardPath();
368 if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)
370 AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());
371 __pFolderLabel->SetText(__currentSearchDirectoryPath);
374 pArgs->RemoveAll(false);
381 __bCheckArgsNull = false;
384 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
388 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
394 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
395 const Tizen::Ui::Scenes::SceneId& nextSceneId)
397 DeviceManager::RemoveAllDeviceEventListeners();
398 __pSearchBar->RemoveKeypadEventListener(*this);
402 SearchForm::OnFormBackRequested(Form& source)
408 SearchForm::TransitionScene(void)
410 //String rootMediaPath = BasePresentationModel::GetHomePath();
411 String rootMediaPath = BasePresentationModel::GetMediaPath();
412 SceneManager* pSceneManager = null;
413 pSceneManager = SceneManager::GetInstance();
415 if (__isSearchStarted == true && __isSearchCompleted == false)
417 __pSearchModel->StopSearch();
420 if (__previousFormPath.CompareTo("") != 0)
422 if (__isCurrentDirectoryRenamed == false)
423 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
424 FolderNavigationPresentationModel::SetStorageType(__previouFormTab);
425 AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());
428 if(__pFileEventManager != null)
429 __pFileEventManager->RemovePath(__currentSearchDirectoryPath);
431 // pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
433 if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
435 if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())
437 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
441 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
444 else if ((__previousSceneId == IDSCN_ROOT_DIRECTORY_FORM || __previousSceneId == IDSCN_SUB_DIRECTORY_FORM) && GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
446 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
450 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
455 SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
458 CustomAppControl* pCustomAppControl = null;
460 String emptySearchString;
462 DirectoryEntry* pFileDetails = null;
463 MessageBox messageEmptyString;
465 AppResource* pAppResource = null;
468 pAppResource = UiApp::GetInstance()->GetAppResource();
469 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
471 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
473 __pathOfSelectedFile = L"";
475 if (__isCancelClicked == true)
479 if (index == __itemCount && __searchedAllFolders == false)
481 AppLogDebug("SearchPresentationModel::Search:%d", index);
482 messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
484 if (__pSearchBar->GetText().IsEmpty())
486 messageEmptyString.ShowAndWait(modalResult);
490 //Set CurrentSearchDirectory to topLevelPath and StartSearch
491 if (__SelectedTab == MEMORY_TYPE_PHONE)
493 topLevelPath = __pFolderEntryPM->GetMediaPath();
495 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
497 topLevelPath = __pFolderEntryPM->GetSdCardPath();
499 __currentSearchDirectoryPath = topLevelPath;
505 if (__isSearchCompleted == false && __isSearchStarted == false)
507 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
511 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
513 TryCatch(pFileDetails != null, , "pFileDetails is Null")
516 __pathOfSelectedFile = pFileDetails->GetFullFilePath();
518 if (pFileDetails->IsDirectory() == true)
520 String fileName = pFileDetails->GetFileName();
521 String filePath = pFileDetails->GetFullFilePath();
522 LoadSubDirectoryForm(filePath, fileName);
526 //Else launch the corresponding AppControl.
527 if (__pathOfSelectedFile.EndsWith(L".tpk") || __pathOfSelectedFile.EndsWith(L".wgt"))
529 String* pFileUriScheme = new (std::nothrow) String(L"file://");
530 pFileUriScheme->Append(__pathOfSelectedFile);
532 AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
533 delete pFileUriScheme;
537 String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();
538 String parentDirectoryOfSelectedFile = L"";
539 __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);
541 pCustomAppControl = CustomAppControl::GetInstance();
542 if (pCustomAppControl != null)
544 pCustomAppControl->SetAppControlListener(this);
545 __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
546 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);
547 if (pAppControlInUse != null)
548 CustomAppControl::SetAppControlInUse(pAppControlInUse);
554 __selectedItemIndex = index;
562 SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
564 //Empty Implementation.
568 SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
570 AppLogDebug("Enter");
571 AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);
573 String filePath = L"";
574 DirectoryEntry* pFileDetails = null;
576 if (__isSearchCompleted == false)
578 if (__isSearchStarted == true)
580 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
584 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
589 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
591 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
593 filePath.Append(pFileDetails->GetFullFilePath());
597 case IDA_CONTEXT_DETAIL:
599 LoadDetailForm(filePath);
603 case IDA_CONTEXT_RENAME:
605 LoadRenameForm(index, pFileDetails);
609 case IDA_CONTEXT_DELETE:
611 __selectedItemIndexForDelete = index;
612 __fileToDelete = pFileDetails->GetFullFilePath();
614 ShowDeleteConfirmationPopup();
628 AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");
632 SearchForm::GetItemCount(void)
634 AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);
637 TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")
639 if (__isSearchCompleted == false)
641 if (__isSearchStarted == true)
642 count = __pSearchedContentList->GetCount();
645 if (__pContentListFromLastView != null)
646 count = __pContentListFromLastView->GetCount();
651 count = __pSearchedContentList->GetCount();
652 String topLevelPath = L"";
654 if (__SelectedTab == MEMORY_TYPE_PHONE)
656 topLevelPath = defaultPhoneBody;
657 topLevelPath.Append("/");
659 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
661 topLevelPath = defaultSdCardBody;
662 topLevelPath.Append("/");
665 if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)
667 __itemCount = count++;
670 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
674 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
679 SearchForm::CreateItem(int index, int itemWidth)
681 AppLogDebug("ENTER::SearchForm::CreateItem");
682 result r = E_SUCCESS;
684 String imageIconPath;
685 String strHightlightedText;
687 String cacheImagePath;
689 Bitmap* pFetchedCacheImage = null;
690 Bitmap* pThumbnailImage = null;
691 HashMap* pCacheList = null;
692 ContentType contentType = CONTENT_TYPE_UNKNOWN;
694 Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
695 Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
697 AppResource* pAppResource = null;
698 DirectoryEntry* pFileDetails = null;
699 ContentListItem* pCustomItem = null;
700 ThumbRequest* pThumbReq = null;
702 ArrayList* pList = null;
704 if (index == __itemCount && __searchedAllFolders == false)
706 CustomItem* pItem = null;
707 String searchAllFolder = L"";
708 AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);
709 pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);
713 pAppResource = Application::GetInstance()->GetAppResource();
714 TryCatch(pAppResource != null, , "Resource manager not found!");
716 if (__isSearchCompleted == false)
718 if (__isSearchStarted == true)
720 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
724 if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)
725 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
730 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
732 TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");
734 pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW, true);
735 TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");
738 filename.Append(pFileDetails->GetFileName());
741 filepath.Append(pFileDetails->GetFullFilePath());
743 if (pFileDetails->IsDirectory() == false)
745 filename.Append(".");
746 filename.Append(pFileDetails->GetFileExtension());
749 if (__searchText.GetLength() > 0)
750 strHightlightedText.Append(__searchText);
752 pCustomItem->SetTitle(filename, strHightlightedText);
755 if (__pThumbnailManager != null)
757 if (pFileDetails->IsDirectory() == true)
759 pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);
760 AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));
764 imageIconPath = pFileDetails->GetFullFilePath();
765 pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);
767 TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");
771 contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());
772 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
774 if (pFileDetails->IsDirectory() == true)
776 pCustomItem->SetThumbnail(__pFolderBitmap);
780 if (pFileDetails->GetBitmap() == null)
782 if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
784 if (pFileDetails != null)
786 cacheImagePath = pFileDetails->GetFullFilePath();
787 AppLogDebug("cache path is %S",cacheImagePath.GetPointer());
790 if ((pCacheList->GetValue(cacheImagePath)) != null)
792 pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
796 if (pFetchedCacheImage != null)
798 AppLogDebug("image taken from cachemanager");
799 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
800 pCustomItem->SetThumbnail(pThumbnailImage);
804 pCustomItem->SetThumbnail(__pDummyImage);
806 pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);
807 TryCatch(pThumbReq != null, , "ThumbRequest is null!");
809 pThumbReq->iRquestId = index;
810 pThumbReq->FilePath = pFileDetails->GetFullFilePath();
812 pList = new (std::nothrow) ArrayList();
813 TryCatch(pList != null, , "Failed to create pList");
815 r = pList->Construct();
816 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
818 r = pList->Add(pThumbReq);
819 TryCatch(r == E_SUCCESS, , "Failed to add object to pList");
821 __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);
826 pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
831 pCustomItem->SetListAnnexStyle(ANNEX_STYLE_NORMAL);
835 GetParentFolderPath(&filepath);
836 pCustomItem->SetFilepath(filepath);
837 pCustomItem->MakeSearchFormListItem();
842 } pCustomItem->SetContextItem(__pItemContext);
844 AppLogDebug("EXIT::SearchForm::CreateItem");
848 if (pCustomItem != null)
860 AppLogDebug("EXIT::SearchForm::CreateItem");
865 SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
867 AppLogDebug("ENTER::SearchForm::DeleteItem");
873 AppLogDebug("EXIT::SearchForm::DeleteItem");
878 SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
880 AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");
882 String emptySearchString;
884 MessageBox messageEmptyString;
885 AppResource* pAppResource = null;
887 pAppResource = UiApp::GetInstance()->GetAppResource();
888 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
890 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
892 messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
895 if (__pSearchBar->GetText().IsEmpty())
897 messageEmptyString.ShowAndWait(modalResult);
898 __pSearchBar->ShowKeypad();
902 __isCancelClicked = false;
904 //Get the text entered in SearchBar
905 __searchText.Clear();
906 __searchText = __pSearchBar->GetText();
909 if (__searchText.IsEmpty() == false)
912 AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");
915 SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)
917 AppLogDebug("ENTER::SearchForm::OnKeypadClosed");
919 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
920 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
922 AppLogDebug("EXIT::SearchForm::OnKeypadClosed");
925 SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)
927 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
929 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
930 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
934 SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
936 //Empty Implementation
939 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
941 AppLogDebug("ENTER::SearchForm::OnActionPerformed");
944 case IDA_BTN_POPUP_SEARCH_CANCEL:
946 AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");
947 __isSearchCompleted = true;
949 __pSearchModel->StopSearch();
951 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
952 __pSearchBar->SetMode(__searchBarMode);
953 __pSearchBar->HideKeypad();
955 __pSearchPopup->SetShowState(false);
956 __pSearchBar->SetEnabled(true);
957 __pSearchBar->SetText(__searchText);
959 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
960 __searchText.Clear();
965 case IDA_DELETE_FILE:
967 HideDeleteConfirmationPopup();
968 //Call the DeleteFile Function.
969 DeleteFile(__fileToDelete);
973 case IDA_CANCEL_DELETION:
975 HideDeleteConfirmationPopup();
985 AppLogDebug("EXIT::SearchForm::OnActionPerformed");
988 SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
990 AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");
991 if (__pSearchPopup->GetShowState() == true)
993 __pSearchPopup->SetShowState(false);
994 __pSearchBar->SetEnabled(true);
999 SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1001 //Empty Implementation.
1006 SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1008 AppLogDebug("SearchForm::OnSearchBarModeChanged");
1010 if (mode == SEARCH_BAR_MODE_INPUT)
1012 __searchBarMode = SEARCH_BAR_MODE_INPUT;
1013 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1017 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1018 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1019 if (__isSearchStarted == true)
1021 if (__isSearchCompleted == false)
1023 //Stop Search Thread
1024 __pSearchModel->StopSearch();
1026 //Hide keypad of SearchBar
1027 __pSearchBar->HideKeypad();
1030 if (__pSearchPopup != null)
1032 __pSearchPopup->SetShowState(false);
1036 __pListView->UpdateList();
1039 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1040 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1042 __pSearchBar->Invalidate(true);
1046 SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1048 CustomAppControl::GetInstance()->SetAppControlInUse(null);
1049 ContentType contentType = ContentManagerUtil::CheckContentType(__pathOfSelectedFile);
1051 __pSearchBar->SetMode(__searchBarMode);
1053 if (GetLastResult() == E_FILE_NOT_FOUND)
1055 __isSearchCompleted = false;
1056 if (__searchText.IsEmpty() == false)
1061 AppLogDebug("OnAppControlResponseReceived:ContentType:%s:%d", GetErrorMessage(GetLastResult()), contentType);
1064 if (__pListView != null)
1065 __pListView->UpdateList();
1069 SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1071 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");
1072 result r = E_FAILURE;
1073 Integer* pEventType = null;
1074 DirectoryEntry* pResultDirEntry = null;
1075 HashMap* pCacheList = null;
1076 DirectoryEntry* pCurrentEntry = null;
1077 bool cacheKeyStatus = false;
1080 TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1082 pEventType = static_cast< Integer* >(pArgs->GetAt(0));
1083 TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1085 switch (pEventType->ToInt())
1087 case ID_FOLDER_SEARCH_STARTED:
1089 String* pFolderSearchResult = (String*) pArgs->GetAt(1);
1090 TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");
1092 String defMediaPath(L"/opt/usr/media");
1093 String defSdCardPath(L"/opt/storage/sdcard");
1095 String displayPhone = defaultPhoneBody;
1096 String displaySdCard = defaultSdCardBody;
1099 if (pFolderSearchResult->IsEmpty() == false)
1101 if (pFolderSearchResult->StartsWith(defMediaPath, 0))
1103 pFolderSearchResult->Replace(defMediaPath, displayPhone);
1105 else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))
1107 pFolderSearchResult->Replace(defSdCardPath, displaySdCard);
1110 __pFolderLabel->SetText(*pFolderSearchResult);
1111 __pFolderLabel->Invalidate(true);
1116 case ID_SEARCH_COMPLETED:
1118 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");
1119 __isSearchCompleted = true;
1121 __pSearchPopup->SetShowState(false);
1122 __pSearchBar->SetEnabled(true);
1124 __pSearchModel->StopSearch();
1126 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
1128 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1129 __pSearchBar->SetMode(__searchBarMode);
1130 __pSearchBar->SetText(__searchText);
1133 //Scroll the List to top
1134 __pListView->ScrollToItem(0);
1138 case ID_SEARCH_RESULT_FOUND:
1140 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");
1141 __isSearchCompleted = false;
1142 __searchItemIndex++;
1143 AppLogDebug("ItemCount::%d", __searchItemIndex);
1145 __pSearchBar->SetText(__searchText);
1147 DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));
1148 TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");
1150 AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());
1152 pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);
1153 r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);
1155 AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));
1157 TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to __pSearchedContentList");
1159 AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);
1161 __bIsResultList = true;
1163 result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);
1164 AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));
1168 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1170 AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");
1171 HideFileProgressingPopup();
1172 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1174 if (__isSearchCompleted == true || __isSearchStarted == true)
1176 pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));
1178 if (pCurrentEntry != null)
1180 cachePath = pCurrentEntry->GetFullFilePath();
1183 if (pCacheList != null)
1185 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1188 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1191 __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);
1195 pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));
1197 if (pCurrentEntry != null)
1199 cachePath = pCurrentEntry->GetFullFilePath();
1202 if (pCacheList != null)
1204 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1207 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1210 __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);
1212 __pListView->UpdateList();
1221 pArgs->RemoveAll(true);
1225 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1230 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1235 SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)
1237 //Empty Implementation
1241 SearchForm::OnAllFoldersSearchCompleted(void)
1243 //Empty Implementation
1247 SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)
1249 result r = E_SUCCESS;
1250 ArrayList* pArg = null;
1251 SceneManager* pSceneManager = null;
1254 if (fullPath.Contains(BasePresentationModel::GetMediaPath()) == true)
1256 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1258 else if (fullPath.Contains(BasePresentationModel::GetSdCardPath()) == true)
1260 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1262 //SetCurrentFilePath
1263 FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);
1265 pArg = new (std::nothrow) ArrayList();
1266 TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");
1268 r = pArg->Construct();
1269 TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");
1271 pArg->Add(&fileName);
1273 pSceneManager = SceneManager::GetInstance();
1274 TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
1276 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);
1282 pArg->RemoveAll(true);
1290 SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)
1292 //Empty Implementation.
1295 SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1297 AppLogDebug("Enter:SearchForm::OnThumbnailReceived");
1298 ArrayList* pResultList = null;
1299 result res = E_SUCCESS;
1300 DirectoryEntry* pFileDetails = null;
1302 TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");
1304 if (pThumbReq != null)
1306 if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())
1308 if (pThumbReq->pBitmap != null)
1310 AppLogDebug("This Bitmap is not requested from same form");
1311 delete pThumbReq->pBitmap;
1317 if (__isSearchCompleted == false)
1319 if (__isSearchStarted == true)
1320 pResultList = __pSearchedContentList;
1322 pResultList = __pContentListFromLastView;
1325 pResultList = __pSearchedContentList;
1327 TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");
1329 if (pThumbReq->iRquestId < pResultList->GetCount())
1331 pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));
1332 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
1334 pFileDetails->SetBitmap(pThumbReq->pBitmap);
1335 if (__pListView && __pListView->IsVisible())
1337 res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1341 AppLogDebug("Thumbnail Request is not valid");
1343 AppLogDebug("Exit");
1346 if (pThumbReq != null)
1348 if (pThumbReq->pBitmap != null)
1349 delete pThumbReq->pBitmap;
1351 AppLogDebug("Exit");
1357 SearchForm::LoadDetailForm(String& fullFilePath)
1359 AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());
1360 result r = E_FAILURE;
1362 SceneManager* pSceneManager = null;
1363 ArrayList* pList = null;
1364 String* pFullFilePath = null;
1366 FolderNavigationPresentationModel::SetCurrentFilePath(fullFilePath);
1368 pList = new (std::nothrow) ArrayList();
1369 TryCatch(pList != null, , "Failed to create pList");
1371 r = pList->Construct();
1372 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
1374 pFullFilePath = new (std::nothrow) String(fullFilePath);
1376 r = pList->Add(pFullFilePath);
1377 TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");
1379 pSceneManager = SceneManager::GetInstance();
1380 TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
1382 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
1383 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1388 if (pFullFilePath != null)
1390 delete pFullFilePath;
1391 pFullFilePath = null;
1402 SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)
1404 AppLogDebug("ENTER");
1405 result r = E_SUCCESS;
1407 ArrayList* pArg = null;
1408 Integer* pSourceSelected = null;
1409 SceneManager* pSceneManager = null;
1411 __selectedItemIndexForRename = index;
1413 FolderNavigationPresentationModel::SetCurrentFilePath(pDirectory->GetFullFilePath());
1415 if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))
1416 __isCurrentDirectoryRenamed = true;
1418 pSceneManager = SceneManager::GetInstance();
1419 TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");
1421 pArg = new (std::nothrow) ArrayList;
1422 r = pArg->Construct();
1424 pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
1425 r = pArg->Add(pSourceSelected);
1426 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");
1428 r = pArg->Add(pDirectory);
1429 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");
1431 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
1436 if (pSourceSelected != null)
1438 delete pSourceSelected;
1454 SearchForm::DeleteFile(String& filePath)
1456 AppLogDebug("ENTER");
1458 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1459 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
1461 FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();
1462 if (__pFileManager != null)
1464 __pFileManager->SetFileManagingListener(this);
1465 __pFileManager->DeleteFolderEntries(&filePath);
1468 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1473 SearchForm::OnFileManagingStart(void)
1475 AppLogDebug("Entry");
1476 ShowFileProgressingPopup();
1480 SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)
1482 //Empty Implementation
1486 SearchForm::ShowFileProgressingPopup(void)
1488 CreateFileProgressingPopup();
1490 if (__pFileProgressingPopup != null)
1492 __pFileProgressingPopup->SetShowState(true);
1493 __pFileProgressingPopup->Show();
1498 SearchForm::HideFileProgressingPopup(void)
1500 AppLogDebug("HideFileProgressingPopup:ENTER");
1501 if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())
1503 __pFileProgressingPopup->SetShowState(false);
1505 delete __pFileProgressingPopup;
1506 __pFileProgressingPopup = null;
1511 SearchForm::CreateFileProgressingPopup(void)
1513 AppLogDebug("ENTER");
1514 result r = E_SUCCESS;
1517 AppResource* pAppResource = null;
1518 pAppResource = UiApp::GetInstance()->GetAppResource();
1519 TryReturn(pAppResource != null, r, "Failed to fetch AppResource");
1521 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
1523 __pFileProgressingPopup = new (std::nothrow) Popup();
1524 __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1526 __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1527 if (__pFileProgressingCancelButton != null)
1529 __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1530 __pFileProgressingCancelButton->AddActionEventListener(*this);
1532 __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1533 if (__pFileProgressingProgress != null)
1535 __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
1536 __pFileProgressingProgress->SetValue(0);
1538 __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1539 if (__pFileProgressingHeaderLabel != null)
1541 __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
1542 __pFileProgressingHeaderLabel->SetText(deleting);
1544 __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1545 if (__pFileProgressingLabel != null)
1547 __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
1555 SearchForm::CreateDeleteConfirmationPopup(void)
1557 result r = E_SUCCESS;
1558 Rectangle popupBounds;
1560 //Create a Delete popup control
1561 __pDeleteConfirmationPopUp = new (std::nothrow) Popup();
1562 __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
1564 popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();
1567 __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
1568 TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");
1570 __pDelete->SetActionId(IDA_DELETE_FILE);
1571 __pDelete->AddActionEventListener(*this);
1572 __pDelete->SetShowState(true);
1574 __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
1575 TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
1577 __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
1578 __pCancelDeletion->AddActionEventListener(*this);
1579 __pCancelDeletion->SetShowState(true);
1585 if (__pDeleteConfirmationPopUp != null)
1587 delete __pDeleteConfirmationPopUp;
1588 __pDeleteConfirmationPopUp = null;
1596 SearchForm::HideDeleteConfirmationPopup(void)
1598 if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())
1600 __pDeleteConfirmationPopUp->SetShowState(false);
1602 delete __pDeleteConfirmationPopUp;
1603 __pDeleteConfirmationPopUp = null;
1609 SearchForm::ShowDeleteConfirmationPopup(void)
1611 CreateDeleteConfirmationPopup();
1613 if (__pDeleteConfirmationPopUp != null)
1615 __pDeleteConfirmationPopUp->SetShowState(true);
1616 __pDeleteConfirmationPopUp->Show();
1621 SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1623 AppLogDebug("SearchForm::OnDeviceStateChanged");
1625 HideDeleteConfirmationPopup();
1626 HideFileProgressingPopup();
1628 if (__SelectedTab == MEMORY_TYPE_NONE )
1630 __pSearchBar->SetMode(__searchBarMode);
1632 if (__searchText.IsEmpty() == false)
1635 if (__pListView != null)
1636 __pListView->UpdateList();
1638 else if (__SelectedTab == MEMORY_TYPE_SD_CARD )
1640 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
1646 SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
1647 const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1649 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1650 __pSearchBar->SetMode(__searchBarMode);
1652 if (__pFileEventManager != null)
1654 delete __pFileEventManager;
1655 __pFileEventManager = null;
1658 __pFileEventManager = new (std::nothrow) FileEventManager();
1659 __pFileEventManager->Construct(*this);
1661 if (__bCheckArgsNull)
1663 if (__pListView != null)
1665 __pListView->UpdateList();
1670 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1672 __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);
1678 SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
1679 const Tizen::Ui::Scenes::SceneId &nextSceneId)
1681 //Empty Implementation.
1685 SearchForm::StartSearch(void)
1688 String folderToSearch;
1689 String topLevelPath;
1691 //Hide keypad of Search bar
1692 __pSearchBar->HideKeypad();
1693 __pSearchBar->SetContentAreaVisible(true);
1694 __pSearchBar->SetEnabled(false);
1695 __pSearchBar->SetMode(__searchBarMode);
1697 //Show Popup if Application is in FOREGROUND
1698 if ( Application::GetInstance()->GetAppUiState() == APP_UI_STATE_FOREGROUND)
1700 __pFolderLabel->SetText(folderToSearch);
1701 __pSearchPopup->SetShowState(true);
1702 __pSearchPopup->Show();
1705 ///Set Application Notification Listener to current form
1706 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1708 if (__SelectedTab == MEMORY_TYPE_PHONE)
1710 topLevelPath = __pFolderEntryPM->GetMediaPath();
1712 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
1714 topLevelPath = __pFolderEntryPM->GetSdCardPath();
1717 if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))
1719 __searchedAllFolders = true;
1722 if (__pSearchedContentList != null)
1724 __pSearchedContentList->RemoveAll(true);
1726 __searchItemIndex = INVALID_LIST_INDEX;
1727 __isSearchCompleted = false;
1728 __isSearchStarted = true;
1730 __pListView->UpdateList();
1732 __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);
1733 __pSearchModel->SetStringToSearch(__searchText);
1734 __pSearchModel->Start();
1738 SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1740 bool cacheKeyStatus = false;
1741 HashMap* pCacheList = null;
1742 DirectoryEntry* pCurrentEntry = null;
1746 ArrayList* pCurrentList = null;
1748 if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1750 __backFromAppControl = true;
1752 //changes added for Nabi issue # N_SE-38472
1753 if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM))
1755 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1756 if (pCacheList != null)
1758 if (__isSearchCompleted == false)
1760 if (__isSearchStarted == true)
1761 pCurrentList = __pSearchedContentList;
1763 pCurrentList = __pContentListFromLastView;
1766 pCurrentList = __pSearchedContentList;
1770 pCurrentEntry = static_cast<DirectoryEntry*>(pCurrentList->GetAt(__selectedItemIndex));
1771 if (pCurrentEntry != null)
1773 cachePath = pCurrentEntry->GetFullFilePath();
1775 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1778 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1784 __selectedItemIndex =-1;
1788 SearchForm::GetFolderName(void)
1795 AppResource::GetInstance()->GetString(L"IDS_MF_SK3_SEARCH", folderName);
1797 folderName.Append(L" ");
1799 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
1801 StringTokenizer tokenizer(fullPath, delim);
1804 DataBindingContext* pContext = null;
1805 pContext = GetDataBindingContextN();
1810 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1811 //it is the last token
1812 while (tokenizer.HasMoreTokens())
1817 tokenizer.GetNextToken(token);
1821 tokenizer.GetNextToken(token);
1822 folderName.Append(token);
1826 if (__pSearchBar != null)
1828 __pSearchBar->SetGuideText(folderName);
1833 SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)
1839 StringTokenizer tokenizer(*filePath, delim);
1843 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1844 //it is the last token
1845 while (tokenizer.HasMoreTokens())
1847 if (tokenizer.GetTokenCount() != 1)
1849 filePath->Append(L"/");
1850 tokenizer.GetNextToken(token);
1851 filePath->Append(token);
1859 filePath->Append(L"/");
1861 if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))
1863 filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);
1865 else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))
1867 filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);
1873 SearchForm::OnAppControlCompleted(void)
1875 AppLogDebug("OnAppControlCompleted++");
1876 if ( __backFromAppControl==true )
1878 __pSearchBar->SetMode(__searchBarMode);
1880 if (__searchText.IsEmpty() == false)
1883 if (__pListView != null)
1884 __pListView->UpdateList();
1885 __backFromAppControl = false;
1887 AppLogDebug("OnAppControlCompleted--");
1891 SearchForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1893 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1894 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));