2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 __pPopUpSearching = null;
47 __pCancelSearch = null;
48 __pDividerLabel = 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;
65 __searchItemIndex = INVALID_LIST_INDEX;
67 __pFolderBitmap = null;
70 __pDeleteConfirmationPopUp = null;
72 __selectedItemIndexForRename = 0;
73 __selectedItemIndexForDelete = 0;
74 __SelectedTab = MEMORY_TYPE_NONE;
75 __previouFormTab = MEMORY_TYPE_NONE;
77 __pCancelDeletion = null;
79 __pFileProgressingCancelButton = null;
80 __pFileProgressingHeaderLabel = null;
81 __pItemContext = null;
82 __pFileProgressingPopup = null;
83 __pFileProgressingProgress = null;
84 __pFileEventManager = null;
87 SearchForm::~SearchForm(void)
91 if (__pSearchedContentList != null)
93 __pSearchedContentList->RemoveAll(true);
94 delete __pSearchedContentList;
97 if (__pSearchModel != null)
99 delete __pSearchModel;
102 if (__pItemContext != null)
104 delete __pItemContext;
107 if (__pDeleteConfirmationPopUp != null)
109 delete __pDeleteConfirmationPopUp;
111 if(__pFolderEntryPM != null)
113 delete __pFolderEntryPM;
115 if (__pFileEventManager != null)
117 delete __pFileEventManager;
123 SearchForm::operator =(const SearchForm& pSearchForm)
128 SearchForm::SearchForm(const SearchForm& pSearchForm)
130 __pContentListFromLastView = pSearchForm.__pContentListFromLastView;
131 __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;
136 SearchForm::Initialize(void)
138 result r = Form::Construct(L"IDL_SEARCH");
141 AppLogDebug("Form construct failed with %s", GetErrorMessage(r));
148 SearchForm::OnInitializing(void)
150 AppLogDebug("ENTER::SearchForm::OnInitializing");
151 result r = E_SUCCESS;
152 String cancelButton(L"");
154 Bitmap* pMainLabelBg = null;
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 __pPopUpSearching = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_SEARCHING"));
205 TryCatch(__pPopUpSearching != null, , "Failed to get __pPopUpSearching");
207 __pDividerLabel = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_FOLDER"));
208 TryCatch(__pDividerLabel != null, r = GetLastResult(), "Failed to get __pPopUpSearching");
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;
275 if (pMainLabelBg != null)
285 if (__pSearchBar != null)
289 if (__pListView != null)
293 if (__pSearchModel != null)
295 delete __pSearchModel;
298 delete pDeleteNormalBmp;
300 delete pDeletePressBmp;
304 AppLogDebug("EXIT::SearchForm::OnInitializing");
309 SearchForm::OnTerminating(void)
311 result r = E_SUCCESS;
312 //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
315 delete __pFolderBitmap;
318 delete __pDummyImage;
323 ////////////////////////////////////////////////////////////////////////
324 // Call-back functions
325 ////////////////////////////////////////////////////////////////////////
328 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
329 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
331 AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));
333 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
335 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
337 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
340 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
344 __bCheckArgsNull = true;
346 __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
347 __SelectedTab = FolderNavigationPresentationModel::GetStorageType();
349 if (__pFolderEntryPM != null)
351 __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);
352 if (__currentSearchDirectoryPath.IsEmpty() == false)
354 __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);
355 __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();
356 TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");
359 __isSearchCompleted = false;
360 __isSearchStarted = false;
362 String topLevelPath = L"";
365 if (__SelectedTab == MEMORY_TYPE_PHONE)
367 topLevelPath = __pFolderEntryPM->GetMediaPath();
369 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
371 topLevelPath = __pFolderEntryPM->GetSdCardPath();
374 if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)
376 AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());
377 __pDividerLabel->SetText(__currentSearchDirectoryPath);
380 pArgs->RemoveAll(false);
387 __bCheckArgsNull = false;
390 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
394 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
400 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
401 const Tizen::Ui::Scenes::SceneId& nextSceneId)
403 DeviceManager::RemoveAllDeviceEventListeners();
407 SearchForm::OnFormBackRequested(Form& source)
413 SearchForm::TransitionScene(void)
415 //String rootMediaPath = BasePresentationModel::GetHomePath();
416 String rootMediaPath = BasePresentationModel::GetMediaPath();
417 SceneManager* pSceneManager = null;
418 pSceneManager = SceneManager::GetInstance();
420 if (__isSearchStarted == true && __isSearchCompleted == false)
422 __pSearchModel->StopSearch();
425 if (__previousFormPath.CompareTo("") != 0)
427 if (__isCurrentDirectoryRenamed == false)
428 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
429 FolderNavigationPresentationModel::SetStorageType(__previouFormTab);
430 AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());
433 if(__pFileEventManager != null)
434 __pFileEventManager->RemovePath(__currentSearchDirectoryPath);
436 // pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
438 if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
440 if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())
442 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
446 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
449 else if ((__previousSceneId == IDSCN_ROOT_DIRECTORY_FORM || __previousSceneId == IDSCN_SUB_DIRECTORY_FORM) && GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
451 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
455 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
460 SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
463 CustomAppControl* pCustomAppControl = null;
465 String emptySearchString;
467 DirectoryEntry* pFileDetails = null;
468 MessageBox messageEmptyString;
470 AppResource* pAppResource = null;
473 pAppResource = UiApp::GetInstance()->GetAppResource();
474 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
476 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
478 __pathOfSelectedFile = L"";
480 if (__isCancelClicked == true)
484 if (index == __itemCount && __searchedAllFolders == false)
486 AppLogDebug("SearchPresentationModel::Search:%d", index);
487 messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
489 if (__pSearchBar->GetText().IsEmpty())
491 messageEmptyString.ShowAndWait(modalResult);
495 __searchedAllFolders = true;
497 __searchItemIndex = INVALID_LIST_INDEX;
498 //Free the content of __pSearchedContentList and Delete the same before searching again
499 if (__pSearchedContentList != null)
501 __pSearchedContentList->RemoveAll(true);
504 __pListView->UpdateList();
505 __pDividerLabel->SetText(L"");
506 __pSearchPopup->SetShowState(true);
507 __pSearchPopup->Show();
508 __pSearchBar->SetEnabled(false);
510 if (__SelectedTab == MEMORY_TYPE_PHONE)
512 topLevelPath = __pFolderEntryPM->GetMediaPath();
514 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
516 topLevelPath = __pFolderEntryPM->GetSdCardPath();
519 __pSearchModel->SetFolderToSearch(topLevelPath);
520 __pSearchModel->SetStringToSearch(__searchText);
521 __pSearchModel->Start();
526 if (__isSearchCompleted == false && __isSearchStarted == false)
528 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
532 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
534 TryCatch(pFileDetails != null, , "pFileDetails is Null")
537 __pathOfSelectedFile = pFileDetails->GetFullFilePath();
539 if (pFileDetails->IsDirectory() == true)
541 String fileName = pFileDetails->GetFileName();
542 String filePath = pFileDetails->GetFullFilePath();
543 LoadSubDirectoryForm(filePath, fileName);
547 //Else launch the corresponding AppControl.
548 if (__pathOfSelectedFile.EndsWith(L".tpk") || __pathOfSelectedFile.EndsWith(L".wgt"))
550 String* pFileUriScheme = new (std::nothrow) String(L"file://");
551 pFileUriScheme->Append(__pathOfSelectedFile);
553 AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
554 delete pFileUriScheme;
558 String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();
559 String parentDirectoryOfSelectedFile = L"";
560 __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);
562 pCustomAppControl = CustomAppControl::GetInstance();
563 if (pCustomAppControl != null)
565 pCustomAppControl->SetAppControlListener(this);
566 __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
567 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);
568 if (pAppControlInUse != null)
569 CustomAppControl::SetAppControlInUse(pAppControlInUse);
581 SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
583 //Empty Implementation.
587 SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
589 AppLogDebug("Enter");
590 AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);
592 String filePath = L"";
593 DirectoryEntry* pFileDetails = null;
595 if (__isSearchCompleted == false)
597 if (__isSearchStarted == true)
599 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
603 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
608 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
610 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
612 filePath.Append(pFileDetails->GetFullFilePath());
616 case IDA_CONTEXT_DETAIL:
618 LoadDetailForm(filePath);
622 case IDA_CONTEXT_RENAME:
624 LoadRenameForm(index, pFileDetails);
628 case IDA_CONTEXT_DELETE:
630 __selectedItemIndexForDelete = index;
631 __fileToDelete = pFileDetails->GetFullFilePath();
633 ShowDeleteConfirmationPopup();
647 AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");
651 SearchForm::GetItemCount(void)
653 AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);
656 TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")
658 if (__isSearchCompleted == false)
660 if (__isSearchStarted == true)
661 count = __pSearchedContentList->GetCount();
664 if (__pContentListFromLastView != null)
665 count = __pContentListFromLastView->GetCount();
670 count = __pSearchedContentList->GetCount();
671 String topLevelPath = L"";
673 if (__SelectedTab == MEMORY_TYPE_PHONE)
675 topLevelPath = defaultPhoneBody;
676 topLevelPath.Append("/");
678 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
680 topLevelPath = defaultSdCardBody;
681 topLevelPath.Append("/");
684 if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)
686 __itemCount = count++;
689 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
693 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
698 SearchForm::CreateItem(int index, int itemWidth)
700 AppLogDebug("ENTER::SearchForm::CreateItem");
701 result r = E_SUCCESS;
703 String imageIconPath;
704 String strHightlightedText;
706 String cacheImagePath;
708 Bitmap* pFetchedCacheImage = null;
709 Bitmap* pThumbnailImage = null;
710 HashMap* pCacheList = null;
711 ContentType contentType = CONTENT_TYPE_UNKNOWN;
713 Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
714 Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
716 AppResource* pAppResource = null;
717 DirectoryEntry* pFileDetails = null;
718 ContentListItem* pCustomItem = null;
719 ThumbRequest* pThumbReq = null;
721 ArrayList* pList = null;
723 if (index == __itemCount && __searchedAllFolders == false)
725 CustomItem* pItem = null;
726 String searchAllFolder = L"";
727 AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);
728 pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);
732 pAppResource = Application::GetInstance()->GetAppResource();
733 TryCatch(pAppResource != null, , "Resource manager not found!");
735 if (__isSearchCompleted == false)
737 if (__isSearchStarted == true)
739 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
743 if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)
744 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
749 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
751 TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");
753 pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW, true);
754 TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");
757 filename.Append(pFileDetails->GetFileName());
760 filepath.Append(pFileDetails->GetFullFilePath());
762 if (pFileDetails->IsDirectory() == false)
764 filename.Append(".");
765 filename.Append(pFileDetails->GetFileExtension());
768 if (__searchText.GetLength() > 0)
769 strHightlightedText.Append(__searchText);
771 pCustomItem->SetTitle(filename, strHightlightedText);
774 if (__pThumbnailManager != null)
776 if (pFileDetails->IsDirectory() == true)
778 pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);
779 AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));
783 imageIconPath = pFileDetails->GetFullFilePath();
784 pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);
786 TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");
790 contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());
791 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
793 if (pFileDetails->IsDirectory() == true)
795 pCustomItem->SetThumbnail(__pFolderBitmap);
799 if (pFileDetails->GetBitmap() == null)
801 if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
803 if (pFileDetails != null)
805 cacheImagePath = pFileDetails->GetFullFilePath();
806 AppLogDebug("cache path is %S",cacheImagePath.GetPointer());
809 if ((pCacheList->GetValue(cacheImagePath)) != null)
811 pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
815 if (pFetchedCacheImage != null)
817 AppLogDebug("image taken from cachemanager");
818 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
819 pCustomItem->SetThumbnail(pThumbnailImage);
823 pCustomItem->SetThumbnail(__pDummyImage);
825 pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);
826 TryCatch(pThumbReq != null, , "ThumbRequest is null!");
828 pThumbReq->iRquestId = index;
829 pThumbReq->FilePath = pFileDetails->GetFullFilePath();
831 pList = new (std::nothrow) ArrayList();
832 TryCatch(pList != null, , "Failed to create pList");
834 r = pList->Construct();
835 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
837 r = pList->Add(pThumbReq);
838 TryCatch(r == E_SUCCESS, , "Failed to add object to pList");
840 __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);
845 pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
850 pCustomItem->SetListAnnexStyle(ANNEX_STYLE_NORMAL);
854 GetParentFolderPath(&filepath);
855 pCustomItem->SetFilepath(filepath);
856 pCustomItem->MakeSearchFormListItem();
861 } pCustomItem->SetContextItem(__pItemContext);
863 AppLogDebug("EXIT::SearchForm::CreateItem");
867 if (pCustomItem != null)
879 AppLogDebug("EXIT::SearchForm::CreateItem");
884 SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
886 AppLogDebug("ENTER::SearchForm::DeleteItem");
892 AppLogDebug("EXIT::SearchForm::DeleteItem");
897 SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
899 AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");
901 String emptySearchString;
903 MessageBox messageEmptyString;
904 AppResource* pAppResource = null;
906 pAppResource = UiApp::GetInstance()->GetAppResource();
907 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
909 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
911 messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
914 if (__pSearchBar->GetText().IsEmpty())
916 messageEmptyString.ShowAndWait(modalResult);
917 __pSearchBar->ShowKeypad();
921 __isCancelClicked = false;
923 //Get the text entered in SearchBar
924 __searchText.Clear();
925 __searchText = __pSearchBar->GetText();
928 if (__searchText.IsEmpty() == false)
931 AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");
934 SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)
936 AppLogDebug("ENTER::SearchForm::OnKeypadClosed");
938 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
939 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
941 AppLogDebug("EXIT::SearchForm::OnKeypadClosed");
944 SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)
946 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
948 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
949 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
953 SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
955 //Empty Implementation
958 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
960 AppLogDebug("ENTER::SearchForm::OnActionPerformed");
963 case IDA_BTN_POPUP_SEARCH_CANCEL:
965 AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");
966 __isSearchCompleted = true;
968 __pSearchModel->StopSearch();
970 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
971 __pSearchBar->SetMode(__searchBarMode);
972 __pSearchBar->HideKeypad();
974 __pSearchPopup->SetShowState(false);
975 __pSearchBar->SetEnabled(true);
977 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
978 __searchText.Clear();
983 case IDA_DELETE_FILE:
985 HideDeleteConfirmationPopup();
986 //Call the DeleteFile Function.
987 DeleteFile(__fileToDelete);
991 case IDA_CANCEL_DELETION:
993 HideDeleteConfirmationPopup();
1003 AppLogDebug("EXIT::SearchForm::OnActionPerformed");
1006 SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
1008 AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");
1009 if (__pSearchPopup->GetShowState() == true)
1011 __pSearchPopup->SetShowState(false);
1012 __pSearchBar->SetEnabled(true);
1017 SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1019 //Empty Implementation.
1024 SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1026 AppLogDebug("SearchForm::OnSearchBarModeChanged");
1028 if (mode == SEARCH_BAR_MODE_INPUT)
1030 __searchBarMode = SEARCH_BAR_MODE_INPUT;
1031 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1035 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1036 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1037 if (__isSearchStarted == true)
1039 if (__isSearchCompleted == false)
1041 //Stop Search Thread
1042 __pSearchModel->StopSearch();
1044 //Hide keypad of SearchBar
1045 __pSearchBar->HideKeypad();
1048 if (__pSearchPopup != null)
1050 __pSearchPopup->SetShowState(false);
1054 __pListView->UpdateList();
1057 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1058 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1060 __pSearchBar->Invalidate(true);
1064 SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1066 CustomAppControl::GetInstance()->SetAppControlInUse(null);
1067 ContentType contentType = ContentManagerUtil::CheckContentType(__pathOfSelectedFile);
1069 __pSearchBar->SetMode(__searchBarMode);
1071 if (GetLastResult() == E_FILE_NOT_FOUND)
1073 __isSearchCompleted = false;
1074 if (__searchText.IsEmpty() == false)
1079 AppLogDebug("OnAppControlResponseReceived:ContentType:%s:%d", GetErrorMessage(GetLastResult()), contentType);
1082 if (__pListView != null)
1083 __pListView->UpdateList();
1087 SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1089 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");
1090 result r = E_FAILURE;
1091 Integer* pEventType = null;
1092 DirectoryEntry* pResultDirEntry = null;
1093 HashMap* pCacheList = null;
1094 DirectoryEntry* pCurrentEntry = null;
1095 bool cacheKeyStatus = false;
1098 TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1100 pEventType = static_cast< Integer* >(pArgs->GetAt(0));
1101 TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1103 switch (pEventType->ToInt())
1105 case ID_FOLDER_SEARCH_STARTED:
1107 String* pFolderSearchResult = (String*) pArgs->GetAt(1);
1108 TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");
1110 String defMediaPath(L"/opt/usr/media");
1111 String defSdCardPath(L"/opt/storage/sdcard");
1113 String displayPhone = defaultPhoneBody;
1114 String displaySdCard = defaultSdCardBody;
1117 if (pFolderSearchResult->IsEmpty() == false)
1119 if (pFolderSearchResult->StartsWith(defMediaPath, 0))
1121 pFolderSearchResult->Replace(defMediaPath, displayPhone);
1123 else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))
1125 pFolderSearchResult->Replace(defSdCardPath, displaySdCard);
1128 __pDividerLabel->SetText(*pFolderSearchResult);
1129 __pDividerLabel->Invalidate(true);
1134 case ID_SEARCH_COMPLETED:
1136 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");
1137 __isSearchCompleted = true;
1139 __pSearchPopup->SetShowState(false);
1140 __pSearchBar->SetEnabled(true);
1142 __pSearchModel->StopSearch();
1144 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
1146 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1147 __pSearchBar->SetMode(__searchBarMode);
1148 __pSearchBar->SetText(__searchText);
1151 //Scroll the List to top
1152 __pListView->ScrollToItem(0);
1156 case ID_SEARCH_RESULT_FOUND:
1158 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");
1159 __isSearchCompleted = false;
1160 __searchItemIndex++;
1161 AppLogDebug("ItemCount::%d", __searchItemIndex);
1163 __pSearchBar->SetText(__searchText);
1165 DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));
1166 TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");
1168 AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());
1170 pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);
1171 r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);
1173 AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));
1175 TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to __pSearchedContentList");
1177 AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);
1179 __bIsResultList = true;
1181 result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);
1182 AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));
1186 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1188 AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");
1189 HideFileProgressingPopup();
1190 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1192 if (__isSearchCompleted == true || __isSearchStarted == true)
1194 pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));
1196 if (pCurrentEntry != null)
1198 cachePath = pCurrentEntry->GetFullFilePath();
1201 if (pCacheList != null)
1203 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1206 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1209 __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);
1213 pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));
1215 if (pCurrentEntry != null)
1217 cachePath = pCurrentEntry->GetFullFilePath();
1220 if (pCacheList != null)
1222 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1225 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1228 __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);
1230 __pListView->UpdateList();
1239 pArgs->RemoveAll(true);
1243 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1248 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1253 SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)
1255 //Empty Implementation
1259 SearchForm::OnAllFoldersSearchCompleted(void)
1261 //Empty Implementation
1265 SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)
1267 result r = E_SUCCESS;
1268 ArrayList* pArg = null;
1269 SceneManager* pSceneManager = null;
1270 //int storageType = -1;
1272 if (__SelectedTab == MEMORY_TYPE_PHONE)
1274 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1276 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
1278 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1282 FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);
1284 pArg = new (std::nothrow) ArrayList();
1285 TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");
1287 r = pArg->Construct();
1288 TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");
1290 pArg->Add(&fileName);
1292 pSceneManager = SceneManager::GetInstance();
1293 TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
1295 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);
1301 pArg->RemoveAll(true);
1309 SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)
1311 //Empty Implementation.
1314 SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1316 AppLogDebug("Enter:SearchForm::OnThumbnailReceived");
1317 ArrayList* pResultList = null;
1318 result res = E_SUCCESS;
1319 DirectoryEntry* pFileDetails = null;
1321 TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");
1323 if (pThumbReq != null)
1325 if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())
1327 if (pThumbReq->pBitmap != null)
1329 AppLogDebug("This Bitmap is not requested from same form");
1330 delete pThumbReq->pBitmap;
1336 if (__isSearchCompleted == false)
1338 if (__isSearchStarted == true)
1339 pResultList = __pSearchedContentList;
1341 pResultList = __pContentListFromLastView;
1344 pResultList = __pSearchedContentList;
1346 TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");
1348 if (pThumbReq->iRquestId < pResultList->GetCount())
1350 pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));
1351 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
1353 pFileDetails->SetBitmap(pThumbReq->pBitmap);
1354 if (__pListView && __pListView->IsVisible())
1356 res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1360 AppLogDebug("Thumbnail Request is not valid");
1362 AppLogDebug("Exit");
1365 if (pThumbReq != null)
1367 if (pThumbReq->pBitmap != null)
1368 delete pThumbReq->pBitmap;
1370 AppLogDebug("Exit");
1376 SearchForm::LoadDetailForm(String& fullFilePath)
1378 AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());
1379 result r = E_FAILURE;
1381 SceneManager* pSceneManager = null;
1382 ArrayList* pList = null;
1383 String* pFullFilePath = null;
1385 pList = new (std::nothrow) ArrayList();
1386 TryCatch(pList != null, , "Failed to create pList");
1388 r = pList->Construct();
1389 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
1391 pFullFilePath = new (std::nothrow) String(fullFilePath);
1393 r = pList->Add(pFullFilePath);
1394 TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");
1396 pSceneManager = SceneManager::GetInstance();
1397 TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
1399 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
1400 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1405 if (pFullFilePath != null)
1407 delete pFullFilePath;
1408 pFullFilePath = null;
1419 SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)
1421 AppLogDebug("ENTER");
1422 result r = E_SUCCESS;
1424 ArrayList* pArg = null;
1425 Integer* pSourceSelected = null;
1426 SceneManager* pSceneManager = null;
1428 __selectedItemIndexForRename = index;
1430 if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))
1431 __isCurrentDirectoryRenamed = true;
1433 pSceneManager = SceneManager::GetInstance();
1434 TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");
1436 pArg = new (std::nothrow) ArrayList;
1437 r = pArg->Construct();
1439 pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
1440 r = pArg->Add(pSourceSelected);
1441 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");
1443 r = pArg->Add(pDirectory);
1444 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");
1446 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
1451 if (pSourceSelected != null)
1453 delete pSourceSelected;
1469 SearchForm::DeleteFile(String& filePath)
1471 AppLogDebug("ENTER");
1473 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1474 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
1476 FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();
1477 if (__pFileManager != null)
1479 __pFileManager->SetFileManagingListener(this);
1480 __pFileManager->DeleteFolderEntries(&filePath);
1483 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1488 SearchForm::OnFileManagingStart(void)
1490 AppLogDebug("Entry");
1491 ShowFileProgressingPopup();
1495 SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)
1497 //Empty Implementation
1501 SearchForm::ShowFileProgressingPopup(void)
1503 CreateFileProgressingPopup();
1505 if (__pFileProgressingPopup != null)
1507 __pFileProgressingPopup->SetShowState(true);
1508 __pFileProgressingPopup->Show();
1513 SearchForm::HideFileProgressingPopup(void)
1515 AppLogDebug("HideFileProgressingPopup:ENTER");
1516 if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())
1518 __pFileProgressingPopup->SetShowState(false);
1520 delete __pFileProgressingPopup;
1521 __pFileProgressingPopup = null;
1526 SearchForm::CreateFileProgressingPopup(void)
1528 AppLogDebug("ENTER");
1529 result r = E_SUCCESS;
1532 AppResource* pAppResource = null;
1533 pAppResource = UiApp::GetInstance()->GetAppResource();
1534 TryReturn(pAppResource != null, r, "Failed to fetch AppResource");
1536 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
1538 __pFileProgressingPopup = new (std::nothrow) Popup();
1539 __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1541 __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1542 if (__pFileProgressingCancelButton != null)
1544 __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1545 __pFileProgressingCancelButton->AddActionEventListener(*this);
1547 __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1548 if (__pFileProgressingProgress != null)
1550 __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
1551 __pFileProgressingProgress->SetValue(0);
1553 __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1554 if (__pFileProgressingHeaderLabel != null)
1556 __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
1557 __pFileProgressingHeaderLabel->SetText(deleting);
1559 __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1560 if (__pFileProgressingLabel != null)
1562 __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
1570 SearchForm::CreateDeleteConfirmationPopup(void)
1572 result r = E_SUCCESS;
1573 Rectangle popupBounds;
1575 //Create a Delete popup control
1576 __pDeleteConfirmationPopUp = new (std::nothrow) Popup();
1577 __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
1579 popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();
1582 __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
1583 TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");
1585 __pDelete->SetActionId(IDA_DELETE_FILE);
1586 __pDelete->AddActionEventListener(*this);
1587 __pDelete->SetShowState(true);
1589 __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
1590 TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
1592 __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
1593 __pCancelDeletion->AddActionEventListener(*this);
1594 __pCancelDeletion->SetShowState(true);
1600 if (__pDeleteConfirmationPopUp != null)
1602 delete __pDeleteConfirmationPopUp;
1603 __pDeleteConfirmationPopUp = null;
1611 SearchForm::HideDeleteConfirmationPopup(void)
1613 if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())
1615 __pDeleteConfirmationPopUp->SetShowState(false);
1617 delete __pDeleteConfirmationPopUp;
1618 __pDeleteConfirmationPopUp = null;
1624 SearchForm::ShowDeleteConfirmationPopup(void)
1626 CreateDeleteConfirmationPopup();
1628 if (__pDeleteConfirmationPopUp != null)
1630 __pDeleteConfirmationPopUp->SetShowState(true);
1631 __pDeleteConfirmationPopUp->Show();
1636 SearchForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
1638 bool setMediaPath = false;
1639 MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
1640 String unmounted = sdCardStatusUnmounted;
1641 String removed = usbDeviceStatusRemoved;
1643 SceneManager* pSceneManager = null;
1645 if (state == unmounted || state == removed)
1647 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
1648 if (state == unmounted)
1650 if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
1652 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1653 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1654 setMediaPath = true;
1658 if (state == removed)
1660 if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
1662 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1663 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1664 setMediaPath = true;
1670 pSceneManager = SceneManager::GetInstance();
1671 if (pSceneManager != null)
1673 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null); }
1679 SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1681 ComponentType currentDeviceType;
1686 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1692 currentDeviceType = COMPONENT_TYPE_USB;
1702 OnDeviceChange(currentDeviceType, state);
1706 SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
1707 const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1709 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1710 // __pSearchBar->SetText(L"");
1711 __pSearchBar->SetMode(__searchBarMode);
1714 if (__pFileEventManager != null)
1716 delete __pFileEventManager;
1717 __pFileEventManager = null;
1720 __pFileEventManager = new (std::nothrow) FileEventManager();
1721 __pFileEventManager->Construct(*this);
1723 //__pFileEventManager->AddPath(__currentSearchDirectoryPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_DELETE );
1725 if (__bCheckArgsNull)
1727 if (__pListView != null)
1729 __pListView->UpdateList();
1734 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1736 __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);
1742 SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
1743 const Tizen::Ui::Scenes::SceneId &nextSceneId)
1745 //Empty Implementation.
1749 SearchForm::StartSearch(void)
1752 String folderToSearch;
1753 String topLevelPath;
1755 //Hide keypad of Search bar
1756 __pSearchBar->HideKeypad();
1757 __pSearchBar->SetContentAreaVisible(true);
1758 __pSearchBar->SetEnabled(false);
1761 __pDividerLabel->SetText(folderToSearch);
1762 __pSearchPopup->SetShowState(true);
1763 __pSearchPopup->Show();
1765 ///Set Application Notification Listener to current form
1766 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1768 if (__SelectedTab == MEMORY_TYPE_PHONE)
1770 //topLevelPath = folderEntryPM.GetMediaPath();
1771 topLevelPath = __pFolderEntryPM->GetMediaPath();
1773 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
1775 //topLevelPath = folderEntryPM.GetSdCardPath();
1776 topLevelPath = __pFolderEntryPM->GetSdCardPath();
1779 if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))
1781 __searchedAllFolders = true;
1784 if (__pSearchedContentList != null)
1786 __pSearchedContentList->RemoveAll(true);
1788 __searchItemIndex = INVALID_LIST_INDEX;
1789 __isSearchCompleted = false;
1790 __isSearchStarted = true;
1792 __pListView->UpdateList();
1794 __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);
1795 __pSearchModel->SetStringToSearch(__searchText);
1796 __pSearchModel->Start();
1800 SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1802 if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1804 __pSearchBar->SetMode(__searchBarMode);
1806 if (__searchText.IsEmpty() == false)
1809 if (__pListView != null)
1810 __pListView->UpdateList();
1815 SearchForm::GetFolderName(void)
1820 String folderName(L"Search ");
1822 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
1824 StringTokenizer tokenizer(fullPath, delim);
1827 DataBindingContext* pContext = null;
1828 pContext = GetDataBindingContextN();
1833 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1834 //it is the last token
1835 while (tokenizer.HasMoreTokens())
1840 tokenizer.GetNextToken(token);
1844 tokenizer.GetNextToken(token);
1845 folderName.Append(token);
1849 if (__pSearchBar != null)
1851 __pSearchBar->SetGuideText(folderName);
1856 SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)
1862 StringTokenizer tokenizer(*filePath, delim);
1866 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1867 //it is the last token
1868 while (tokenizer.HasMoreTokens())
1870 if (tokenizer.GetTokenCount() != 1)
1872 filePath->Append(L"/");
1873 tokenizer.GetNextToken(token);
1874 filePath->Append(token);
1882 filePath->Append(L"/");
1884 if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))
1886 filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);
1888 else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))
1890 filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);