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 __directoryForFileEvent = L"";
56 __bIsResultList = false;
58 __searchedAllFolders = false;
59 __isSearchCompleted = false;
60 __isCancelClicked = false;
61 __isSearchStarted = false;
62 __bCheckArgsNull = false;
63 __isCurrentDirectoryRenamed = false;
64 __backFromAppControl = false;
67 __searchItemIndex = INVALID_LIST_INDEX;
69 __pFolderBitmap = null;
72 __pDeleteConfirmationPopUp = null;
74 __selectedItemIndexForRename = 0;
75 __selectedItemIndexForDelete = 0;
77 __previouFormTab = MEMORY_TYPE_NONE;
79 __pCancelDeletion = null;
81 __pFileProgressingCancelButton = null;
82 __pFileProgressingHeaderLabel = null;
83 __pItemContext = null;
84 __pFileProgressingPopup = null;
85 __pFileProgressingProgress = null;
86 __pFileEventManager = null;
89 SearchForm::~SearchForm(void)
93 if (__pSearchedContentList != null)
95 __pSearchedContentList->RemoveAll(true);
96 delete __pSearchedContentList;
99 if (__pSearchModel != null)
101 delete __pSearchModel;
104 if (__pItemContext != null)
106 delete __pItemContext;
109 if (__pDeleteConfirmationPopUp != null)
111 delete __pDeleteConfirmationPopUp;
113 if(__pFolderEntryPM != null)
115 delete __pFolderEntryPM;
117 if (__pFileEventManager != null)
119 delete __pFileEventManager;
125 SearchForm::operator =(const SearchForm& pSearchForm)
130 SearchForm::SearchForm(const SearchForm& pSearchForm)
132 __pContentListFromLastView = pSearchForm.__pContentListFromLastView;
133 __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;
138 SearchForm::Initialize(void)
140 result r = Form::Construct(L"IDL_SEARCH");
143 AppLogDebug("Form construct failed with %s", GetErrorMessage(r));
150 SearchForm::OnInitializing(void)
152 AppLogDebug("ENTER::SearchForm::OnInitializing");
153 result r = E_SUCCESS;
154 String cancelButton(L"");
156 Bitmap* pDeleteNormalBmp = null;
157 Bitmap* pDeletePressBmp = null;
158 String renameButtonText;
159 String detailButtonText;
160 String deleteButtonText;
161 String strSearching ;
162 IListT< SceneId >* pSceneList = null;
164 __SelectedTab = MEMORY_TYPE_NONE;
166 __pFolderBitmap = AppResource::GetInstance()->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);
167 __pDummyImage = AppResource::GetInstance()->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);
168 AppResource::GetInstance()->GetString(L"IDS_MF_BODY_RENAME_ABB", renameButtonText);
169 AppResource::GetInstance()->GetString(L"IDS_MF_SK3_DELETE", deleteButtonText);
170 AppResource::GetInstance()->GetString(L"IDS_MF_SK_DETAILS", detailButtonText);
172 pDeleteNormalBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_NORMAL, 150, 72);
173 pDeletePressBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_PRESS, 150, 72);
175 Footer* pFooter = GetFooter();
176 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
177 pFooter->SetBackButton();
179 SetFormBackEventListener(this);
180 __pThumbnailManager = ThumbnailManager::GetInstance();
181 TryCatch(__pThumbnailManager != null, , "ThumbnailManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
183 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
185 __searchBarMode = SEARCH_BAR_MODE_INPUT;
187 __pSearchBar = static_cast< SearchBar* >(GetControl("IDC_SEARCHFORM_SEARCHBAR"));
188 TryCatch(__pSearchBar != null, , "__pSearchBar is Null");
190 __pSearchBar->AddSearchBarEventListener(*this);
191 __pSearchBar->AddTextEventListener(*this);
192 __pSearchBar->AddKeypadEventListener(*this);
193 __pSearchBar->SetShowState(true);
195 __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
196 TryCatch(__pFolderEntryPM != null, , "Content Manager not found!");
197 __pFolderEntryPM->Construct();
199 __pSearchPopup = new (std::nothrow) Popup();
200 TryCatch(__pSearchPopup != null, , "Failed to allocate memory to __pSearchPopup");
202 r = __pSearchPopup->Construct(L"IDL_SEARCH_POPUP");
203 TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpPanel");
205 __pLabelSearching = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_SEARCHING"));
206 TryCatch(__pLabelSearching != null, , "Failed to get __pLabelSearching");
208 __pFolderLabel = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_FOLDER"));
209 TryCatch(__pFolderLabel != null, r = GetLastResult(), "Failed to get __pFolderLabel");
211 __pCancelSearch = static_cast<Button*> (__pSearchPopup->GetControl(L"IDC_BUTTON_CANCEL"));
212 TryCatch(__pCancelSearch != null, , "Failed to get __pCancelSearch");
214 __pCancelSearch->SetActionId(IDA_BTN_POPUP_SEARCH_CANCEL);
215 __pCancelSearch->AddActionEventListener(*this);
217 __pSearchPopup->SetShowState(false);
220 __listViewRectangle.SetBounds(X_DEFAULT, H_SEARCH_BAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR);
222 __pListView = static_cast< ListView* >(GetControl("IDC_SEARCHFORM_LISTVIEW"));
223 TryCatch(__pListView != null, r = GetLastResult(), "__pListView is Null");
225 __pListView->SetItemProvider(*this);
226 __pListView->AddListViewItemEventListener(*this);
228 __pSearchModel = new (std::nothrow) SearchPresentationModel();
229 TryCatch(__pSearchModel != null, r = GetLastResult(), "SearchForm::OnInitializing::Failed to allocate memory to __PSearchModel");
231 r = __pSearchModel->Initialize();
232 TryCatch(r == E_SUCCESS, , "SearchPresentationModel:Init()failed with %s", GetErrorMessage(GetLastResult()));
234 __pSearchedContentList = new (std::nothrow) ArrayList();
235 TryCatch(__pSearchedContentList != null, , "SearchForm::GetCurrentFileControl::Failed to allocate Memory to __pSearchedContentList");
237 r = __pSearchedContentList->Construct();
238 TryCatch(r == E_SUCCESS, , "SearchForm::GetCurrentFileControl::Failed to construct __pSearchedContentList");
240 __pItemContext = new (std::nothrow) ListContextItem();
242 r = __pItemContext->Construct();
243 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to construct pitemcontext");
245 __pItemContext->AddElement(IDA_CONTEXT_RENAME, renameButtonText);
246 __pItemContext->AddElement(IDA_CONTEXT_DETAIL, detailButtonText);
248 __pItemContext->AddElement(IDA_CONTEXT_DELETE,
255 __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();
256 __previouFormTab = FolderNavigationPresentationModel::GetStorageType();
257 pSceneList = SceneManager::GetInstance()->GetSceneHistoryN();
258 if (pSceneList != null)
260 __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
265 if (pDeleteNormalBmp != null)
267 delete pDeleteNormalBmp;
268 pDeleteNormalBmp = null;
270 if (pDeletePressBmp != null)
272 delete pDeletePressBmp;
273 pDeletePressBmp = null;
280 if (__pSearchBar != null)
284 if (__pListView != null)
288 if (__pSearchModel != null)
290 delete __pSearchModel;
293 delete pDeleteNormalBmp;
295 delete pDeletePressBmp;
297 AppLogDebug("EXIT::SearchForm::OnInitializing");
302 SearchForm::OnTerminating(void)
304 result r = E_SUCCESS;
305 //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
308 delete __pFolderBitmap;
311 delete __pDummyImage;
316 ////////////////////////////////////////////////////////////////////////
317 // Call-back functions
318 ////////////////////////////////////////////////////////////////////////
321 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
322 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
324 AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));
326 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
328 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
329 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
332 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
335 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
339 __bCheckArgsNull = true;
341 __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
342 __SelectedTab = FolderNavigationPresentationModel::GetStorageType();
344 if (__pFolderEntryPM != null)
346 __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);
347 if (__currentSearchDirectoryPath.IsEmpty() == false)
349 __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);
350 __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();
351 TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");
354 __isSearchCompleted = false;
355 __isSearchStarted = false;
357 String topLevelPath = L"";
360 if (__SelectedTab == MEMORY_TYPE_PHONE)
362 topLevelPath = __pFolderEntryPM->GetMediaPath();
364 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
366 topLevelPath = __pFolderEntryPM->GetSdCardPath();
369 if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)
371 AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());
372 __pFolderLabel->SetText(__currentSearchDirectoryPath);
375 pArgs->RemoveAll(false);
382 __bCheckArgsNull = false;
385 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
389 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
395 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
396 const Tizen::Ui::Scenes::SceneId& nextSceneId)
398 DeviceManager::RemoveAllDeviceEventListeners();
399 __pSearchBar->RemoveKeypadEventListener(*this);
403 SearchForm::OnFormBackRequested(Form& source)
409 SearchForm::TransitionScene(void)
411 //String rootMediaPath = BasePresentationModel::GetHomePath();
412 String rootMediaPath = BasePresentationModel::GetMediaPath();
413 SceneManager* pSceneManager = null;
414 pSceneManager = SceneManager::GetInstance();
416 if (__isSearchStarted == true && __isSearchCompleted == false)
418 __pSearchModel->StopSearch();
421 if (__previousFormPath.CompareTo("") != 0)
423 if (__isCurrentDirectoryRenamed == false)
424 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
425 FolderNavigationPresentationModel::SetStorageType(__previouFormTab);
426 AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());
429 if(__pFileEventManager != null)
430 __pFileEventManager->RemovePath(__directoryForFileEvent);
432 // pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
434 if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
436 if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())
438 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
442 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
445 /*else if ((__previousSceneId == IDSCN_ROOT_DIRECTORY_FORM || __previousSceneId == IDSCN_SUB_DIRECTORY_FORM) && GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
447 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
451 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
456 SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
459 CustomAppControl* pCustomAppControl = null;
461 String emptySearchString;
463 DirectoryEntry* pFileDetails = null;
464 MessageBox messageEmptyString;
466 AppResource* pAppResource = null;
469 pAppResource = UiApp::GetInstance()->GetAppResource();
470 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
472 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
474 __pathOfSelectedFile = L"";
476 if (__isCancelClicked == true)
480 if (index == __itemCount && __searchedAllFolders == false)
482 AppLogDebug("SearchPresentationModel::Search:%d", index);
483 messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
485 if (__pSearchBar->GetText().IsEmpty())
487 messageEmptyString.ShowAndWait(modalResult);
491 //Set CurrentSearchDirectory to topLevelPath and StartSearch
492 if (__SelectedTab == MEMORY_TYPE_PHONE)
494 topLevelPath = __pFolderEntryPM->GetMediaPath();
496 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
498 topLevelPath = __pFolderEntryPM->GetSdCardPath();
500 __currentSearchDirectoryPath = topLevelPath;
506 if (__isSearchCompleted == false && __isSearchStarted == false)
508 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
512 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
514 TryCatch(pFileDetails != null, , "pFileDetails is Null")
517 __pathOfSelectedFile = pFileDetails->GetFullFilePath();
519 if (pFileDetails->IsDirectory() == true)
521 String fileName = pFileDetails->GetFileName();
522 String filePath = pFileDetails->GetFullFilePath();
523 LoadSubDirectoryForm(filePath, fileName);
527 //Else launch the corresponding AppControl.
528 if (__pathOfSelectedFile.EndsWith(L".tpk") || __pathOfSelectedFile.EndsWith(L".wgt"))
530 String* pFileUriScheme = new (std::nothrow) String(L"file://");
531 pFileUriScheme->Append(__pathOfSelectedFile);
533 AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
534 delete pFileUriScheme;
538 String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();
539 String parentDirectoryOfSelectedFile = L"";
540 __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);
542 pCustomAppControl = CustomAppControl::GetInstance();
543 if (pCustomAppControl != null)
545 pCustomAppControl->SetAppControlListener(this);
546 if(__pFileEventManager != null)
548 __pFileEventManager->RemovePath(__directoryForFileEvent);
549 delete __pFileEventManager;
550 __pFileEventManager = null;
552 __pFileEventManager = new (std::nothrow) FileEventManager();
553 __pFileEventManager->Construct(*this);
555 __directoryForFileEvent = parentDirectoryOfSelectedFile;
556 __pFileEventManager->AddPath(__directoryForFileEvent, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
557 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);
558 if (pAppControlInUse != null)
559 CustomAppControl::SetAppControlInUse(pAppControlInUse);
565 __selectedItemIndex = index;
573 SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
575 //Empty Implementation.
579 SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
581 AppLogDebug("Enter");
582 AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);
584 String filePath = L"";
585 DirectoryEntry* pFileDetails = null;
587 if (__isSearchCompleted == false)
589 if (__isSearchStarted == true)
591 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
595 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
600 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
602 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
604 filePath.Append(pFileDetails->GetFullFilePath());
608 case IDA_CONTEXT_DETAIL:
610 LoadDetailForm(filePath);
614 case IDA_CONTEXT_RENAME:
616 LoadRenameForm(index, pFileDetails);
620 case IDA_CONTEXT_DELETE:
622 __selectedItemIndexForDelete = index;
623 __fileToDelete = pFileDetails->GetFullFilePath();
625 ShowDeleteConfirmationPopup();
639 AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");
643 SearchForm::GetItemCount(void)
645 AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);
648 TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")
650 if (__isSearchCompleted == false)
652 if (__isSearchStarted == true)
653 count = __pSearchedContentList->GetCount();
656 if (__pContentListFromLastView != null)
657 count = __pContentListFromLastView->GetCount();
662 count = __pSearchedContentList->GetCount();
663 String topLevelPath = L"";
665 if (__SelectedTab == MEMORY_TYPE_PHONE)
667 topLevelPath = defaultPhoneBody;
668 topLevelPath.Append("/");
670 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
672 topLevelPath = defaultSdCardBody;
673 topLevelPath.Append("/");
676 if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)
678 __itemCount = count++;
681 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
685 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
690 SearchForm::CreateItem(int index, int itemWidth)
692 AppLogDebug("ENTER::SearchForm::CreateItem");
693 result r = E_SUCCESS;
695 String imageIconPath;
696 String strHightlightedText;
698 String cacheImagePath;
700 Bitmap* pFetchedCacheImage = null;
701 Bitmap* pThumbnailImage = null;
702 HashMap* pCacheList = null;
703 ContentType contentType = CONTENT_TYPE_UNKNOWN;
705 Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
706 Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
708 AppResource* pAppResource = null;
709 DirectoryEntry* pFileDetails = null;
710 ContentListItem* pCustomItem = null;
711 ThumbRequest* pThumbReq = null;
713 ArrayList* pList = null;
715 if (index == __itemCount && __searchedAllFolders == false)
717 CustomItem* pItem = null;
718 String searchAllFolder = L"";
719 AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);
720 pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);
724 pAppResource = Application::GetInstance()->GetAppResource();
725 TryCatch(pAppResource != null, , "Resource manager not found!");
727 if (__isSearchCompleted == false)
729 if (__isSearchStarted == true)
731 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
735 if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)
736 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
741 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
743 TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");
745 pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW, true);
746 TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");
749 filename.Append(pFileDetails->GetFileName());
752 filepath.Append(pFileDetails->GetFullFilePath());
754 if (pFileDetails->IsDirectory() == false)
756 filename.Append(".");
757 filename.Append(pFileDetails->GetFileExtension());
760 if (__searchText.GetLength() > 0)
761 strHightlightedText.Append(__searchText);
763 pCustomItem->SetTitle(filename, strHightlightedText);
766 if (__pThumbnailManager != null)
768 if (pFileDetails->IsDirectory() == true)
770 pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);
771 AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));
775 imageIconPath = pFileDetails->GetFullFilePath();
776 pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);
778 TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");
782 contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());
783 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
785 if (pFileDetails->IsDirectory() == true)
787 pCustomItem->SetThumbnail(__pFolderBitmap);
791 if (pFileDetails->GetBitmap() == null)
793 if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
795 if (pFileDetails != null)
797 cacheImagePath = pFileDetails->GetFullFilePath();
798 AppLogDebug("cache path is %S",cacheImagePath.GetPointer());
801 if ((pCacheList->GetValue(cacheImagePath)) != null)
803 pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
807 if (pFetchedCacheImage != null)
809 AppLogDebug("image taken from cachemanager");
810 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
811 pCustomItem->SetThumbnail(pThumbnailImage);
815 pCustomItem->SetThumbnail(__pDummyImage);
817 pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);
818 TryCatch(pThumbReq != null, , "ThumbRequest is null!");
820 pThumbReq->iRquestId = index;
821 pThumbReq->FilePath = pFileDetails->GetFullFilePath();
823 pList = new (std::nothrow) ArrayList();
824 TryCatch(pList != null, , "Failed to create pList");
826 r = pList->Construct();
827 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
829 r = pList->Add(pThumbReq);
830 TryCatch(r == E_SUCCESS, , "Failed to add object to pList");
832 __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);
837 pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
842 pCustomItem->SetListAnnexStyle(ANNEX_STYLE_NORMAL);
846 GetParentFolderPath(&filepath);
847 pCustomItem->SetFilepath(filepath);
848 pCustomItem->MakeSearchFormListItem();
853 } pCustomItem->SetContextItem(__pItemContext);
855 AppLogDebug("EXIT::SearchForm::CreateItem");
859 if (pCustomItem != null)
871 AppLogDebug("EXIT::SearchForm::CreateItem");
876 SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
878 AppLogDebug("ENTER::SearchForm::DeleteItem");
884 AppLogDebug("EXIT::SearchForm::DeleteItem");
889 SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
891 AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");
893 String emptySearchString;
895 MessageBox messageEmptyString;
896 AppResource* pAppResource = null;
898 pAppResource = UiApp::GetInstance()->GetAppResource();
899 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
901 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
903 messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
906 if (__pSearchBar->GetText().IsEmpty())
908 messageEmptyString.ShowAndWait(modalResult);
909 __pSearchBar->ShowKeypad();
913 __isCancelClicked = false;
915 //Get the text entered in SearchBar
916 __searchText.Clear();
917 __searchText = __pSearchBar->GetText();
920 if (__searchText.IsEmpty() == false)
923 AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");
926 SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)
928 AppLogDebug("ENTER::SearchForm::OnKeypadClosed");
930 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
931 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
933 AppLogDebug("EXIT::SearchForm::OnKeypadClosed");
936 SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)
938 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
940 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
941 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
945 SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
947 //Empty Implementation
950 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
952 AppLogDebug("ENTER::SearchForm::OnActionPerformed");
955 case IDA_BTN_POPUP_SEARCH_CANCEL:
957 AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");
958 __isSearchCompleted = true;
960 __pSearchModel->StopSearch();
962 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
963 __pSearchBar->SetMode(__searchBarMode);
964 __pSearchBar->HideKeypad();
966 __pSearchPopup->SetShowState(false);
967 __pSearchBar->SetEnabled(true);
968 __pSearchBar->SetText(__searchText);
970 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
971 __searchText.Clear();
976 case IDA_DELETE_FILE:
978 HideDeleteConfirmationPopup();
979 //Call the DeleteFile Function.
980 DeleteFile(__fileToDelete);
984 case IDA_CANCEL_DELETION:
986 HideDeleteConfirmationPopup();
996 AppLogDebug("EXIT::SearchForm::OnActionPerformed");
999 SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
1001 AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");
1002 if (__pSearchPopup->GetShowState() == true)
1004 __pSearchPopup->SetShowState(false);
1005 __pSearchBar->SetEnabled(true);
1010 SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1012 //Empty Implementation.
1017 SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1019 AppLogDebug("SearchForm::OnSearchBarModeChanged");
1021 if (mode == SEARCH_BAR_MODE_INPUT)
1023 __searchBarMode = SEARCH_BAR_MODE_INPUT;
1024 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1028 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1029 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1030 if (__isSearchStarted == true)
1032 if (__isSearchCompleted == false)
1034 //Stop Search Thread
1035 __pSearchModel->StopSearch();
1037 //Hide keypad of SearchBar
1038 __pSearchBar->HideKeypad();
1041 if (__pSearchPopup != null)
1043 __pSearchPopup->SetShowState(false);
1047 __pListView->UpdateList();
1050 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1051 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1053 __pSearchBar->Invalidate(true);
1057 SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1059 CustomAppControl::GetInstance()->SetAppControlInUse(null);
1060 ContentType contentType = ContentManagerUtil::CheckContentType(__pathOfSelectedFile);
1062 __pSearchBar->SetMode(__searchBarMode);
1064 if (GetLastResult() == E_FILE_NOT_FOUND)
1066 __isSearchCompleted = false;
1067 if (__searchText.IsEmpty() == false)
1072 AppLogDebug("OnAppControlResponseReceived:ContentType:%s:%d", GetErrorMessage(GetLastResult()), contentType);
1075 if (__pListView != null)
1076 __pListView->UpdateList();
1080 SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1082 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");
1083 result r = E_FAILURE;
1084 Integer* pEventType = null;
1085 DirectoryEntry* pResultDirEntry = null;
1086 HashMap* pCacheList = null;
1087 DirectoryEntry* pCurrentEntry = null;
1088 bool cacheKeyStatus = false;
1091 TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1093 pEventType = static_cast< Integer* >(pArgs->GetAt(0));
1094 TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1096 switch (pEventType->ToInt())
1098 case ID_FOLDER_SEARCH_STARTED:
1100 String* pFolderSearchResult = (String*) pArgs->GetAt(1);
1101 TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");
1103 String defMediaPath(L"/opt/usr/media");
1104 String defSdCardPath(L"/opt/storage/sdcard");
1106 String displayPhone = defaultPhoneBody;
1107 String displaySdCard = defaultSdCardBody;
1110 if (pFolderSearchResult->IsEmpty() == false)
1112 if (pFolderSearchResult->StartsWith(defMediaPath, 0))
1114 pFolderSearchResult->Replace(defMediaPath, displayPhone);
1116 else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))
1118 pFolderSearchResult->Replace(defSdCardPath, displaySdCard);
1121 __pFolderLabel->SetText(*pFolderSearchResult);
1122 __pFolderLabel->Invalidate(true);
1127 case ID_SEARCH_COMPLETED:
1129 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");
1130 __isSearchCompleted = true;
1132 __pSearchPopup->SetShowState(false);
1133 __pSearchBar->SetEnabled(true);
1135 __pSearchModel->StopSearch();
1137 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
1139 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1140 __pSearchBar->SetMode(__searchBarMode);
1141 __pSearchBar->SetText(__searchText);
1144 //Scroll the List to top
1145 __pListView->ScrollToItem(0);
1149 case ID_SEARCH_RESULT_FOUND:
1151 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");
1152 __isSearchCompleted = false;
1153 __searchItemIndex++;
1154 AppLogDebug("ItemCount::%d", __searchItemIndex);
1156 __pSearchBar->SetText(__searchText);
1158 DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));
1159 TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");
1161 AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());
1163 pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);
1164 r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);
1166 AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));
1168 TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to __pSearchedContentList");
1170 AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);
1172 __bIsResultList = true;
1174 result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);
1175 AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));
1179 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1181 AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");
1182 HideFileProgressingPopup();
1183 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1185 if (__isSearchCompleted == true || __isSearchStarted == true)
1187 pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));
1189 if (pCurrentEntry != null)
1191 cachePath = pCurrentEntry->GetFullFilePath();
1194 if (pCacheList != null)
1196 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1199 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1202 __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);
1206 pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));
1208 if (pCurrentEntry != null)
1210 cachePath = pCurrentEntry->GetFullFilePath();
1213 if (pCacheList != null)
1215 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1218 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1221 __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);
1223 __pListView->UpdateList();
1232 pArgs->RemoveAll(true);
1236 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1241 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1246 SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)
1248 //Empty Implementation
1252 SearchForm::OnAllFoldersSearchCompleted(void)
1254 //Empty Implementation
1258 SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)
1260 result r = E_SUCCESS;
1261 ArrayList* pArg = null;
1262 SceneManager* pSceneManager = null;
1265 if (fullPath.Contains(BasePresentationModel::GetMediaPath()) == true)
1267 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1269 else if (fullPath.Contains(BasePresentationModel::GetSdCardPath()) == true)
1271 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1273 //SetCurrentFilePath
1274 FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);
1276 pArg = new (std::nothrow) ArrayList();
1277 TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");
1279 r = pArg->Construct();
1280 TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");
1282 pArg->Add(&fileName);
1284 pSceneManager = SceneManager::GetInstance();
1285 TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
1287 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);
1293 pArg->RemoveAll(true);
1301 SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)
1303 //Empty Implementation.
1306 SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1308 AppLogDebug("Enter:SearchForm::OnThumbnailReceived");
1309 ArrayList* pResultList = null;
1310 result res = E_SUCCESS;
1311 DirectoryEntry* pFileDetails = null;
1313 TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");
1315 if (pThumbReq != null)
1317 if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())
1319 if (pThumbReq->pBitmap != null)
1321 AppLogDebug("This Bitmap is not requested from same form");
1322 delete pThumbReq->pBitmap;
1328 if (__isSearchCompleted == false)
1330 if (__isSearchStarted == true)
1331 pResultList = __pSearchedContentList;
1333 pResultList = __pContentListFromLastView;
1336 pResultList = __pSearchedContentList;
1338 TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");
1340 if (pThumbReq->iRquestId < pResultList->GetCount())
1342 pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));
1343 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
1345 pFileDetails->SetBitmap(pThumbReq->pBitmap);
1346 if (__pListView && __pListView->IsVisible())
1348 res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1352 AppLogDebug("Thumbnail Request is not valid");
1354 AppLogDebug("Exit");
1357 if (pThumbReq != null)
1359 if (pThumbReq->pBitmap != null)
1360 delete pThumbReq->pBitmap;
1362 AppLogDebug("Exit");
1368 SearchForm::LoadDetailForm(String& fullFilePath)
1370 AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());
1371 result r = E_FAILURE;
1373 SceneManager* pSceneManager = null;
1374 ArrayList* pList = null;
1375 String* pFullFilePath = null;
1377 FolderNavigationPresentationModel::SetCurrentFilePath(fullFilePath);
1379 pList = new (std::nothrow) ArrayList();
1380 TryCatch(pList != null, , "Failed to create pList");
1382 r = pList->Construct();
1383 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
1385 pFullFilePath = new (std::nothrow) String(fullFilePath);
1387 r = pList->Add(pFullFilePath);
1388 TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");
1390 pSceneManager = SceneManager::GetInstance();
1391 TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
1393 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
1394 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1399 if (pFullFilePath != null)
1401 delete pFullFilePath;
1402 pFullFilePath = null;
1413 SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)
1415 AppLogDebug("ENTER");
1416 result r = E_SUCCESS;
1418 ArrayList* pArg = null;
1419 Integer* pSourceSelected = null;
1420 SceneManager* pSceneManager = null;
1422 __selectedItemIndexForRename = index;
1424 FolderNavigationPresentationModel::SetCurrentFilePath(pDirectory->GetFullFilePath());
1426 if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))
1427 __isCurrentDirectoryRenamed = true;
1429 pSceneManager = SceneManager::GetInstance();
1430 TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");
1432 pArg = new (std::nothrow) ArrayList;
1433 r = pArg->Construct();
1435 pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
1436 r = pArg->Add(pSourceSelected);
1437 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");
1439 r = pArg->Add(pDirectory);
1440 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");
1442 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
1447 if (pSourceSelected != null)
1449 delete pSourceSelected;
1465 SearchForm::DeleteFile(String& filePath)
1467 AppLogDebug("ENTER");
1469 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1470 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
1472 FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();
1473 if (__pFileManager != null)
1475 __pFileManager->SetFileManagingListener(this);
1476 __pFileManager->DeleteFolderEntries(&filePath);
1479 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1484 SearchForm::OnFileManagingStart(void)
1486 AppLogDebug("Entry");
1487 ShowFileProgressingPopup();
1491 SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)
1493 //Empty Implementation
1497 SearchForm::ShowFileProgressingPopup(void)
1499 CreateFileProgressingPopup();
1501 if (__pFileProgressingPopup != null)
1503 __pFileProgressingPopup->SetShowState(true);
1504 __pFileProgressingPopup->Show();
1509 SearchForm::HideFileProgressingPopup(void)
1511 AppLogDebug("HideFileProgressingPopup:ENTER");
1512 if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())
1514 __pFileProgressingPopup->SetShowState(false);
1516 delete __pFileProgressingPopup;
1517 __pFileProgressingPopup = null;
1522 SearchForm::CreateFileProgressingPopup(void)
1524 AppLogDebug("ENTER");
1525 result r = E_SUCCESS;
1528 AppResource* pAppResource = null;
1529 pAppResource = UiApp::GetInstance()->GetAppResource();
1530 TryReturn(pAppResource != null, r, "Failed to fetch AppResource");
1532 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
1534 __pFileProgressingPopup = new (std::nothrow) Popup();
1535 __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1537 __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1538 if (__pFileProgressingCancelButton != null)
1540 __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1541 __pFileProgressingCancelButton->AddActionEventListener(*this);
1543 __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1544 if (__pFileProgressingProgress != null)
1546 __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
1547 __pFileProgressingProgress->SetValue(0);
1549 __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1550 if (__pFileProgressingHeaderLabel != null)
1552 __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
1553 __pFileProgressingHeaderLabel->SetText(deleting);
1555 __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1556 if (__pFileProgressingLabel != null)
1558 __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
1566 SearchForm::CreateDeleteConfirmationPopup(void)
1568 result r = E_SUCCESS;
1569 Rectangle popupBounds;
1571 //Create a Delete popup control
1572 __pDeleteConfirmationPopUp = new (std::nothrow) Popup();
1573 __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
1575 popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();
1578 __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
1579 TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");
1581 __pDelete->SetActionId(IDA_DELETE_FILE);
1582 __pDelete->AddActionEventListener(*this);
1583 __pDelete->SetShowState(true);
1585 __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
1586 TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
1588 __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
1589 __pCancelDeletion->AddActionEventListener(*this);
1590 __pCancelDeletion->SetShowState(true);
1596 if (__pDeleteConfirmationPopUp != null)
1598 delete __pDeleteConfirmationPopUp;
1599 __pDeleteConfirmationPopUp = null;
1607 SearchForm::HideDeleteConfirmationPopup(void)
1609 if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())
1611 __pDeleteConfirmationPopUp->SetShowState(false);
1613 delete __pDeleteConfirmationPopUp;
1614 __pDeleteConfirmationPopUp = null;
1620 SearchForm::ShowDeleteConfirmationPopup(void)
1622 CreateDeleteConfirmationPopup();
1624 if (__pDeleteConfirmationPopUp != null)
1626 __pDeleteConfirmationPopUp->SetShowState(true);
1627 __pDeleteConfirmationPopUp->Show();
1632 SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1634 AppLogDebug("SearchForm::OnDeviceStateChanged");
1636 HideDeleteConfirmationPopup();
1637 HideFileProgressingPopup();
1639 if (__SelectedTab == MEMORY_TYPE_NONE )
1641 __pSearchBar->SetMode(__searchBarMode);
1643 if (__searchText.IsEmpty() == false)
1646 if (__pListView != null)
1647 __pListView->UpdateList();
1649 else if (__SelectedTab == MEMORY_TYPE_SD_CARD )
1651 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
1657 SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
1658 const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1660 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1661 __pSearchBar->SetMode(__searchBarMode);
1663 if (__pFileEventManager != null)
1665 delete __pFileEventManager;
1666 __pFileEventManager = null;
1669 __pFileEventManager = new (std::nothrow) FileEventManager();
1670 __pFileEventManager->Construct(*this);
1672 __directoryForFileEvent = __currentSearchDirectoryPath;
1673 __pFileEventManager->AddPath(__directoryForFileEvent, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
1674 AppLogDebug("SearchForm::OnSceneTransitionCompleted:%S:%s", __directoryForFileEvent.GetPointer(), GetErrorMessage(GetLastResult()));
1676 if (__bCheckArgsNull)
1678 if (__pListView != null)
1680 __pListView->UpdateList();
1685 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1687 __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);
1693 SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
1694 const Tizen::Ui::Scenes::SceneId &nextSceneId)
1696 //Empty Implementation.
1700 SearchForm::StartSearch(void)
1703 String folderToSearch;
1704 String topLevelPath;
1706 //Hide keypad of Search bar
1707 __pSearchBar->HideKeypad();
1708 __pSearchBar->SetContentAreaVisible(true);
1709 __pSearchBar->SetEnabled(false);
1710 __pSearchBar->SetMode(__searchBarMode);
1712 //Show Popup if Application is in FOREGROUND
1713 if ( Application::GetInstance()->GetAppUiState() == APP_UI_STATE_FOREGROUND)
1715 __pFolderLabel->SetText(folderToSearch);
1716 __pSearchPopup->SetShowState(true);
1717 __pSearchPopup->Show();
1720 ///Set Application Notification Listener to current form
1721 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1723 if (__SelectedTab == MEMORY_TYPE_PHONE)
1725 topLevelPath = __pFolderEntryPM->GetMediaPath();
1727 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
1729 topLevelPath = __pFolderEntryPM->GetSdCardPath();
1732 if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))
1734 __searchedAllFolders = true;
1737 if (__pSearchedContentList != null)
1739 __pSearchedContentList->RemoveAll(true);
1741 __searchItemIndex = INVALID_LIST_INDEX;
1742 __isSearchCompleted = false;
1743 __isSearchStarted = true;
1745 __pListView->UpdateList();
1747 __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);
1748 __pSearchModel->SetStringToSearch(__searchText);
1749 __pSearchModel->Start();
1753 SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1755 AppLogDebug("SearchForm::OnFileEventOccured");
1756 bool cacheKeyStatus = false;
1757 HashMap* pCacheList = null;
1758 DirectoryEntry* pCurrentEntry = null;
1762 ArrayList* pCurrentList = null;
1764 if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1766 __backFromAppControl = true;
1768 //changes added for Nabi issue # N_SE-38472
1769 if ( (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM))
1771 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1772 if (pCacheList != null)
1774 if (__isSearchCompleted == false)
1776 if (__isSearchStarted == true)
1777 pCurrentList = __pSearchedContentList;
1779 pCurrentList = __pContentListFromLastView;
1782 pCurrentList = __pSearchedContentList;
1786 pCurrentEntry = static_cast<DirectoryEntry*>(pCurrentList->GetAt(__selectedItemIndex));
1787 if (pCurrentEntry != null)
1789 cachePath = pCurrentEntry->GetFullFilePath();
1791 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1794 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1799 if (((MyFilesApp*) Application::GetInstance())->IsAppControlLaunched() == false)
1801 AppLogDebug("SearchForm::OnFileEventOccured");
1802 if (__searchText.IsEmpty() == false)
1805 if (__pListView != null)
1806 __pListView->UpdateList();
1810 __selectedItemIndex =-1;
1814 SearchForm::GetFolderName(void)
1821 AppResource::GetInstance()->GetString(L"IDS_MF_SK3_SEARCH", folderName);
1823 folderName.Append(L" ");
1825 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
1827 StringTokenizer tokenizer(fullPath, delim);
1830 DataBindingContext* pContext = null;
1831 pContext = GetDataBindingContextN();
1836 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1837 //it is the last token
1838 while (tokenizer.HasMoreTokens())
1843 tokenizer.GetNextToken(token);
1847 tokenizer.GetNextToken(token);
1848 folderName.Append(token);
1852 if (__pSearchBar != null)
1854 __pSearchBar->SetGuideText(folderName);
1859 SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)
1865 StringTokenizer tokenizer(*filePath, delim);
1869 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1870 //it is the last token
1871 while (tokenizer.HasMoreTokens())
1873 if (tokenizer.GetTokenCount() != 1)
1875 filePath->Append(L"/");
1876 tokenizer.GetNextToken(token);
1877 filePath->Append(token);
1885 filePath->Append(L"/");
1887 if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))
1889 filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);
1891 else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))
1893 filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);
1899 SearchForm::OnAppControlCompleted(void)
1901 AppLogDebug("OnAppControlCompleted++");
1902 if ( __backFromAppControl==true )
1904 if (__pFileEventManager != null)
1906 __pFileEventManager->RemovePath(__directoryForFileEvent);
1907 delete __pFileEventManager;
1908 __pFileEventManager = null;
1911 __pFileEventManager = new (std::nothrow) FileEventManager();
1912 __pFileEventManager->Construct(*this);
1914 __directoryForFileEvent = __currentSearchDirectoryPath;
1915 __pFileEventManager->AddPath(__directoryForFileEvent, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
1918 __pSearchBar->SetMode(__searchBarMode);
1920 if (__searchText.IsEmpty() == false)
1923 if (__pListView != null)
1924 __pListView->UpdateList();
1925 __backFromAppControl = false;
1927 AppLogDebug("OnAppControlCompleted--");
1931 SearchForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1933 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1934 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));