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)
92 if (__pSearchedContentList != null)
94 __pSearchedContentList->RemoveAll(true);
95 delete __pSearchedContentList;
98 if (__pSearchModel != null)
100 delete __pSearchModel;
103 if (__pItemContext != null)
105 delete __pItemContext;
108 if (__pDeleteConfirmationPopUp != null)
110 delete __pDeleteConfirmationPopUp;
112 if(__pFolderEntryPM != null)
114 delete __pFolderEntryPM;
116 if (__pFileEventManager != null)
118 delete __pFileEventManager;
124 SearchForm::operator =(const SearchForm& pSearchForm)
129 SearchForm::SearchForm(const SearchForm& pSearchForm)
131 __pContentListFromLastView = pSearchForm.__pContentListFromLastView;
132 __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;
137 SearchForm::Initialize(void)
139 result r = Form::Construct(L"IDL_SEARCH");
142 AppLogDebug("Form construct failed with %s", GetErrorMessage(r));
149 SearchForm::OnInitializing(void)
151 AppLogDebug("ENTER::SearchForm::OnInitializing");
152 result r = E_SUCCESS;
153 String cancelButton(L"");
154 unsigned int CONTEXT_ITEM_DELETE_COLOR = Color32<208, 82, 82>::Value;
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);
175 SetFormBackEventListener(this);
176 __pThumbnailManager = ThumbnailManager::GetInstance();
177 TryCatch(__pThumbnailManager != null, , "ThumbnailManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
179 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
181 __currentFont = MfUtility::GetFontSize();
183 __fontSize = MfUtility::GetFontSizeInInt();
185 if (__currentFont == FONT_GIANT || __currentFont == FONT_HUGE)
187 __listItemHeight = H_ITEM_GIANT_FONT_LISTVIEW;
191 __listItemHeight = H_ITEM_LISTVIEW;
194 __searchBarMode = SEARCH_BAR_MODE_INPUT;
196 __pSearchBar = static_cast< SearchBar* >(GetControl("IDC_SEARCHFORM_SEARCHBAR"));
197 TryCatch(__pSearchBar != null, , "__pSearchBar is Null");
199 __pSearchBar->AddSearchBarEventListener(*this);
200 __pSearchBar->AddTextEventListener(*this);
201 __pSearchBar->AddKeypadEventListener(*this);
202 __pSearchBar->SetShowState(true);
204 __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
205 TryCatch(__pFolderEntryPM != null, , "Content Manager not found!");
206 __pFolderEntryPM->Construct();
208 __pSearchPopup = new (std::nothrow) Popup();
209 TryCatch(__pSearchPopup != null, , "Failed to allocate memory to __pSearchPopup");
211 r = __pSearchPopup->Construct(L"IDL_SEARCH_POPUP");
212 TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpPanel");
214 __pLabelSearching = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_SEARCHING"));
215 TryCatch(__pLabelSearching != null, , "Failed to get __pLabelSearching");
217 __pFolderLabel = static_cast<Label*> (__pSearchPopup->GetControl(L"IDC_LABEL_FOLDER"));
218 TryCatch(__pFolderLabel != null, r = GetLastResult(), "Failed to get __pFolderLabel");
220 __pCancelSearch = static_cast<Button*> (__pSearchPopup->GetControl(L"IDC_BUTTON_CANCEL"));
221 TryCatch(__pCancelSearch != null, , "Failed to get __pCancelSearch");
223 __pCancelSearch->SetActionId(IDA_BTN_POPUP_SEARCH_CANCEL);
224 __pCancelSearch->AddActionEventListener(*this);
226 __pSearchPopup->SetShowState(false);
229 __listViewRectangle.SetBounds(X_DEFAULT, H_SEARCH_BAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR);
231 __pListView = static_cast< ListView* >(GetControl("IDC_SEARCHFORM_LISTVIEW"));
232 TryCatch(__pListView != null, r = GetLastResult(), "__pListView is Null");
234 __pListView->SetItemProvider(*this);
235 __pListView->AddListViewItemEventListener(*this);
237 __pSearchModel = new (std::nothrow) SearchPresentationModel();
238 TryCatch(__pSearchModel != null, r = GetLastResult(), "SearchForm::OnInitializing::Failed to allocate memory to __PSearchModel");
240 r = __pSearchModel->Initialize();
241 TryCatch(r == E_SUCCESS, , "SearchPresentationModel:Init()failed with %s", GetErrorMessage(GetLastResult()));
243 __pSearchedContentList = new (std::nothrow) ArrayList();
244 TryCatch(__pSearchedContentList != null, , "SearchForm::GetCurrentFileControl::Failed to allocate Memory to __pSearchedContentList");
246 r = __pSearchedContentList->Construct();
247 TryCatch(r == E_SUCCESS, , "SearchForm::GetCurrentFileControl::Failed to construct __pSearchedContentList");
249 __pItemContext = new (std::nothrow) ListContextItem();
251 r = __pItemContext->Construct();
252 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to construct pitemcontext");
254 __pItemContext->AddElement(IDA_CONTEXT_RENAME, renameButtonText);
255 __pItemContext->AddElement(IDA_CONTEXT_DETAIL, detailButtonText);
256 __pItemContext->AddElement(IDA_CONTEXT_DELETE, deleteButtonText);
257 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL, CONTEXT_ITEM_DELETE_COLOR);
258 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED, CONTEXT_ITEM_DELETE_COLOR);
259 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_DELETE, LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED, CONTEXT_ITEM_DELETE_COLOR);
261 /*if (pDeleteNormalBmp != null && pDeletePressBmp != null)
263 __pItemContext->AddElement(IDA_CONTEXT_DELETE,
270 delete pDeleteNormalBmp;
271 pDeleteNormalBmp = null;
273 delete pDeletePressBmp;
274 pDeletePressBmp = null;
279 __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();
280 __previouFormTab = FolderNavigationPresentationModel::GetStorageType();
281 pSceneList = SceneManager::GetInstance()->GetSceneHistoryN();
282 if (pSceneList != null)
284 __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
289 if (pDeleteNormalBmp != null)
291 delete pDeleteNormalBmp;
292 pDeleteNormalBmp = null;
294 if (pDeletePressBmp != null)
296 delete pDeletePressBmp;
297 pDeletePressBmp = null;
304 if (__pSearchBar != null)
308 if (__pListView != null)
312 if (__pSearchModel != null)
314 delete __pSearchModel;
317 delete pDeleteNormalBmp;
319 delete pDeletePressBmp;
321 AppLogDebug("EXIT::SearchForm::OnInitializing");
326 SearchForm::OnTerminating(void)
328 result r = E_SUCCESS;
329 //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
332 delete __pFolderBitmap;
335 delete __pDummyImage;
340 ////////////////////////////////////////////////////////////////////////
341 // Call-back functions
342 ////////////////////////////////////////////////////////////////////////
345 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
346 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
348 AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));
350 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
351 //((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
353 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
354 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
357 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
360 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
364 __bCheckArgsNull = true;
366 __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
367 __SelectedTab = FolderNavigationPresentationModel::GetStorageType();
369 if (__pFolderEntryPM != null)
371 __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);
372 if (__currentSearchDirectoryPath.IsEmpty() == false)
374 __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);
375 __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();
376 TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");
379 __isSearchCompleted = false;
380 __isSearchStarted = false;
382 String topLevelPath = L"";
385 if (__SelectedTab == MEMORY_TYPE_PHONE)
387 topLevelPath = __pFolderEntryPM->GetMediaPath();
389 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
391 topLevelPath = __pFolderEntryPM->GetSdCardPath();
394 if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)
396 AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());
397 __pFolderLabel->SetText(__currentSearchDirectoryPath);
400 pArgs->RemoveAll(false);
407 __bCheckArgsNull = false;
412 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
416 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
422 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
423 const Tizen::Ui::Scenes::SceneId& nextSceneId)
425 DeviceManager::RemoveAllDeviceEventListeners();
426 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(null);
427 if(__pFileEventManager != null)
429 __pFileEventManager->RemovePath(__directoryForFileEvent);
430 delete __pFileEventManager;
431 __pFileEventManager = null;
437 SearchForm::OnFormBackRequested(Form& source)
439 AppLogDebug("Enter");
444 SearchForm::TransitionScene(void)
446 //String rootMediaPath = BasePresentationModel::GetHomePath();
447 String rootMediaPath = BasePresentationModel::GetMediaPath();
448 SceneManager* pSceneManager = null;
449 pSceneManager = SceneManager::GetInstance();
451 if (__isSearchStarted == true && __isSearchCompleted == false)
453 __pSearchModel->StopSearch();
456 if (__previousFormPath.CompareTo("") != 0)
458 if (__isCurrentDirectoryRenamed == false)
459 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
460 FolderNavigationPresentationModel::SetStorageType(__previouFormTab);
461 AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());
464 if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
466 if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())
468 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
472 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
477 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
482 SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
485 result r = E_SUCCESS;
486 CustomAppControl* pCustomAppControl = null;
488 String emptySearchString;
490 DirectoryEntry* pFileDetails = null;
491 MessageBox messageEmptyString;
493 AppResource* pAppResource = null;
496 pAppResource = UiApp::GetInstance()->GetAppResource();
497 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
499 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
501 __pathOfSelectedFile = L"";
503 if (__isCancelClicked == true)
507 if (index == __itemCount && __searchedAllFolders == false)
509 AppLogDebug("SearchPresentationModel::Search:%d", index);
510 messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
512 if (__pSearchBar->GetText().IsEmpty())
514 messageEmptyString.ShowAndWait(modalResult);
518 //Set CurrentSearchDirectory to topLevelPath and StartSearch
519 if (__SelectedTab == MEMORY_TYPE_PHONE)
521 topLevelPath = __pFolderEntryPM->GetMediaPath();
523 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
525 topLevelPath = __pFolderEntryPM->GetSdCardPath();
527 __currentSearchDirectoryPath = topLevelPath;
533 if (__isSearchCompleted == false && __isSearchStarted == false)
535 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
539 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
541 TryCatch(pFileDetails != null, , "pFileDetails is Null")
544 __pathOfSelectedFile = pFileDetails->GetFullFilePath();
546 if (pFileDetails->IsDirectory() == true)
548 String fileName = pFileDetails->GetFileName();
549 String filePath = pFileDetails->GetFullFilePath();
550 LoadSubDirectoryForm(filePath, fileName);
554 //Else launch the corresponding AppControl.
555 if (__pathOfSelectedFile.EndsWith(L".tpk") || __pathOfSelectedFile.EndsWith(L".wgt"))
557 String* pFileUriScheme = new (std::nothrow) String(L"file://");
558 pFileUriScheme->Append(__pathOfSelectedFile);
560 AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/view", pFileUriScheme, null, null, null, null);
561 delete pFileUriScheme;
565 String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();
566 String parentDirectoryOfSelectedFile = L"";
567 __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);
569 pCustomAppControl = CustomAppControl::GetInstance();
570 if (pCustomAppControl != null)
572 pCustomAppControl->SetAppControlListener(this);
574 r= CreateFileEventManager(parentDirectoryOfSelectedFile);
576 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);
577 if (pAppControlInUse != null)
578 CustomAppControl::SetAppControlInUse(pAppControlInUse);
584 __selectedItemIndex = index;
592 SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
594 //Empty Implementation.
598 SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
600 AppLogDebug("Enter");
601 AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);
603 String filePath = L"";
604 DirectoryEntry* pFileDetails = null;
606 if (__isSearchCompleted == false)
608 if (__isSearchStarted == true)
610 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
614 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
619 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
621 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
623 filePath.Append(pFileDetails->GetFullFilePath());
627 case IDA_CONTEXT_DETAIL:
629 LoadDetailForm(filePath);
633 case IDA_CONTEXT_RENAME:
635 __pathToRename = pFileDetails->GetFullFilePath();
636 __nameToRename = pFileDetails->GetFileName();
638 LoadRenameForm(index, pFileDetails);
642 case IDA_CONTEXT_DELETE:
644 __selectedItemIndexForDelete = index;
645 __fileToDelete = pFileDetails->GetFullFilePath();
647 ShowDeleteConfirmationPopup();
661 AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");
665 SearchForm::GetItemCount(void)
667 AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);
670 TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")
672 if (__isSearchCompleted == false)
674 if (__isSearchStarted == true)
675 count = __pSearchedContentList->GetCount();
678 if (__pContentListFromLastView != null)
679 count = __pContentListFromLastView->GetCount();
684 count = __pSearchedContentList->GetCount();
685 String topLevelPath = L"";
687 if (__SelectedTab == MEMORY_TYPE_PHONE)
689 topLevelPath = defaultPhoneBody;
690 topLevelPath.Append("/");
692 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
694 topLevelPath = defaultSdCardBody;
695 topLevelPath.Append("/");
698 if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)
701 __itemCount = count++;
704 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
708 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
713 SearchForm::CreateItem(int index, int itemWidth)
715 AppLogDebug("ENTER::SearchForm::CreateItem");
716 result r = E_SUCCESS;
718 String imageIconPath;
719 String strHightlightedText;
721 String cacheImagePath;
723 Bitmap* pFetchedCacheImage = null;
724 Bitmap* pThumbnailImage = null;
725 HashMap* pCacheList = null;
726 ContentType contentType = CONTENT_TYPE_UNKNOWN;
728 Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
729 Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
731 AppResource* pAppResource = null;
732 DirectoryEntry* pFileDetails = null;
733 ContentListItem* pCustomItem = null;
735 if (index == __itemCount && __isSearchCompleted == true && __searchedAllFolders == false)
737 CustomItem* pItem = null;
738 String searchAllFolder = L"";
739 AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);
740 pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);
744 pAppResource = Application::GetInstance()->GetAppResource();
745 TryCatch(pAppResource != null, , "Resource manager not found!");
747 if (__isSearchCompleted == false)
749 if (__isSearchStarted == true)
751 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
755 if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)
756 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
761 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
763 TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");
765 pCustomItem = new (std::nothrow) ContentListItem(itemWidth, __listItemHeight, true);
766 TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");
769 filename.Append(pFileDetails->GetFileName());
772 filepath.Append(pFileDetails->GetFullFilePath());
774 if (pFileDetails->IsDirectory() == false)
776 filename.Append(".");
777 filename.Append(pFileDetails->GetFileExtension());
780 if (__searchText.GetLength() > 0)
781 strHightlightedText.Append(__searchText);
783 pCustomItem->SetTitle(filename, strHightlightedText);
786 if (__pThumbnailManager != null)
788 if (pFileDetails->IsDirectory() == true)
790 pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);
791 AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));
795 imageIconPath = pFileDetails->GetFullFilePath();
796 pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);
798 TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");
802 contentType = MfUtility::GetContentType(pFileDetails->GetFullFilePath());
803 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
805 if (pFileDetails->IsDirectory() == true)
807 pCustomItem->SetThumbnail(__pFolderBitmap);
811 if (pFileDetails->GetBitmap() == null)
813 if (pCacheList != null && ((contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)))
815 if (pFileDetails != null)
817 cacheImagePath = pFileDetails->GetFullFilePath();
820 //GetThumbnail from Cache,if already added. If not ask ThumbnailManager to generate it.
821 pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
822 if (pFetchedCacheImage)
824 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
825 pCustomItem->SetThumbnail(pThumbnailImage);
827 else //set parameters to help ThumbnailManager generate thumbnail for this file.
829 pFileDetails->SetDummy(true);
830 pFileDetails->SetLoadBitmap(true);
831 pCustomItem->SetThumbnail(__pDummyImage);
833 r = RequestThumbnail(pFileDetails, index);
834 AppLogDebug("Request Send-result : %s", GetErrorMessage(r));
837 else if (contentType == CONTENT_TYPE_OTHER || contentType == CONTENT_TYPE_UNKNOWN || contentType == CONTENT_TYPE_AUDIO )
839 AppLogDebug("Content Type [%d]", contentType);
841 if ( contentType == CONTENT_TYPE_AUDIO )
842 pThumbnailImage = CacheManager::GetInstance()->GetCachedImageOfOtherFileType(cacheImagePath, true);
844 pThumbnailImage = CacheManager::GetInstance()->GetCachedImageOfOtherFileType(cacheImagePath);
846 if ( pThumbnailImage !=null )
848 pCustomItem->SetThumbnail(pThumbnailImage);
852 pFileDetails->SetDummy(true);
853 pFileDetails->SetLoadBitmap(true);
854 pCustomItem->SetThumbnail(__pDummyImage);
856 r = RequestThumbnail(pFileDetails, index);
857 AppLogDebug("Request Send-result : %s", GetErrorMessage(r));
863 pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
868 pCustomItem->SetListAnnexStyle(ANNEX_STYLE_NORMAL);
872 pCustomItem->SetItemHeightAndFontSize(__listItemHeight, __fontSize, __currentFont);
874 GetParentFolderPath(&filepath);
875 pCustomItem->SetFilepath(filepath);
876 pCustomItem->MakeSearchFormListItem();
880 pCustomItem->SetItemHeightAndFontSize(__listItemHeight, __fontSize,__currentFont);
883 } pCustomItem->SetContextItem(__pItemContext);
885 AppLogDebug("EXIT : %s", GetErrorMessage(GetLastResult()));
890 AppLogDebug("EXIT with Error %s", GetErrorMessage(GetLastResult()));
891 if (pCustomItem != null)
895 AppLogDebug("EXIT::SearchForm::CreateItem");
900 SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
902 AppLogDebug("ENTER::SearchForm::DeleteItem");
908 AppLogDebug("EXIT::SearchForm::DeleteItem");
913 SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
915 AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");
917 String emptySearchString;
919 MessageBox messageEmptyString;
920 AppResource* pAppResource = null;
922 pAppResource = UiApp::GetInstance()->GetAppResource();
923 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
925 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
927 messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
929 if (__pSearchBar->GetText().IsEmpty())
931 messageEmptyString.ShowAndWait(modalResult);
932 __pSearchBar->ShowKeypad();
936 __isCancelClicked = false;
938 //Get the text entered in SearchBar
939 __searchText.Clear();
940 __searchText = __pSearchBar->GetText();
943 if (__searchText.IsEmpty() == false)
946 AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");
949 SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)
951 AppLogDebug("ENTER::SearchForm::OnKeypadClosed");
953 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
954 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
956 AppLogDebug("EXIT::SearchForm::OnKeypadClosed");
959 SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)
961 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
962 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
966 SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
968 //Empty Implementation
971 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
973 AppLogDebug("ENTER::SearchForm::OnActionPerformed");
976 case IDA_BTN_POPUP_SEARCH_CANCEL:
978 AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");
979 __isSearchCompleted = true;
981 __pSearchModel->StopSearch();
983 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
984 __pSearchBar->SetMode(__searchBarMode);
985 __pSearchBar->HideKeypad();
987 __pSearchPopup->SetShowState(false);
988 __pSearchBar->SetEnabled(true);
989 __pSearchBar->SetText(__searchText);
991 __searchText.Clear();
996 case IDA_DELETE_FILE:
998 HideDeleteConfirmationPopup();
999 //Call the DeleteFile Function.
1000 DeleteFile(__fileToDelete);
1004 case IDA_CANCEL_DELETION:
1006 HideDeleteConfirmationPopup();
1016 AppLogDebug("EXIT::SearchForm::OnActionPerformed");
1019 SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
1021 AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");
1022 if (__pSearchPopup->GetShowState() == true)
1024 __pSearchPopup->SetShowState(false);
1025 __pSearchBar->SetEnabled(true);
1030 SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)
1032 if (__pSearchBar->GetText().IsEmpty() == true)
1034 __pSearchBar->SetContentAreaVisible(true);
1038 __pSearchBar->SetContentAreaVisible(false);
1040 __pSearchBar->Invalidate(true);
1045 SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
1047 AppLogDebug("SearchForm::OnSearchBarModeChanged");
1049 if (mode == SEARCH_BAR_MODE_INPUT)
1051 if (__pSearchBar->GetText().IsEmpty() == false)
1053 __pSearchBar->SetContentAreaVisible(false);
1055 __searchBarMode = SEARCH_BAR_MODE_INPUT;
1059 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1060 if (__isSearchStarted == true)
1062 if (__isSearchCompleted == false)
1064 //Stop Search Thread
1065 __pSearchModel->StopSearch();
1067 //Hide keypad of SearchBar
1068 __pSearchBar->HideKeypad();
1071 if (__pSearchPopup != null)
1073 __pSearchPopup->SetShowState(false);
1079 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1080 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1082 __pSearchBar->Invalidate(true);
1086 SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
1092 SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
1094 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");
1095 result r = E_FAILURE;
1096 Integer* pEventType = null;
1097 DirectoryEntry* pResultDirEntry = null;
1098 HashMap* pCacheList = null;
1099 DirectoryEntry* pCurrentEntry = null;
1100 bool cacheKeyStatus = false;
1103 TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1105 pEventType = static_cast< Integer* >(pArgs->GetAt(0));
1106 TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");
1108 switch (pEventType->ToInt())
1110 case ID_FOLDER_SEARCH_STARTED:
1112 String* pFolderSearchResult = (String*) pArgs->GetAt(1);
1113 TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");
1115 String defMediaPath(L"/opt/usr/media");
1116 String defSdCardPath(L"/opt/storage/sdcard");
1118 String displayPhone = defaultPhoneBody;
1119 String displaySdCard = defaultSdCardBody;
1122 if (pFolderSearchResult->IsEmpty() == false)
1124 if (pFolderSearchResult->StartsWith(defMediaPath, 0))
1126 pFolderSearchResult->Replace(defMediaPath, displayPhone);
1128 else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))
1130 pFolderSearchResult->Replace(defSdCardPath, displaySdCard);
1133 __pFolderLabel->SetText(*pFolderSearchResult);
1134 __pFolderLabel->Invalidate(true);
1139 case ID_SEARCH_COMPLETED:
1141 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");
1142 __isSearchCompleted = true;
1144 __pSearchPopup->SetShowState(false);
1145 __pSearchBar->SetEnabled(true);
1147 __pSearchModel->StopSearch();
1149 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
1151 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
1152 __pSearchBar->SetMode(__searchBarMode);
1154 __pSearchBar->SetText(__searchText);
1156 if (__searchedAllFolders == false)
1158 __searchItemIndex++;
1160 result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);
1161 AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));
1163 //Scroll the List to top
1164 __pListView->ScrollToItem(0);
1168 case ID_SEARCH_RESULT_FOUND:
1170 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");
1171 __isSearchCompleted = false;
1172 __searchItemIndex++;
1174 AppLogDebug("ItemCount::%d", __searchItemIndex);
1176 __pSearchBar->SetText(__searchText);
1178 DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));
1179 TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");
1181 AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());
1183 pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);
1184 r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);
1186 AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));
1188 TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to __pSearchedContentList");
1190 AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);
1192 __bIsResultList = true;
1193 __listItemHeight = MfUtility::GetItemHeight();
1195 result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);
1196 AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));
1200 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
1202 AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");
1203 HideFileProgressingPopup();
1204 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1206 if (__isSearchCompleted == true || __isSearchStarted == true)
1208 pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));
1210 if (pCurrentEntry != null)
1212 cachePath = pCurrentEntry->GetFullFilePath();
1215 if (pCacheList != null)
1217 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1220 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1223 __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);
1227 pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));
1229 if (pCurrentEntry != null)
1231 cachePath = pCurrentEntry->GetFullFilePath();
1234 if (pCacheList != null)
1236 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
1239 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
1242 __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);
1251 pArgs->RemoveAll(true);
1255 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1260 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
1265 SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)
1267 //Empty Implementation
1271 SearchForm::OnAllFoldersSearchCompleted(void)
1273 //Empty Implementation
1277 SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)
1279 result r = E_SUCCESS;
1280 ArrayList* pArg = null;
1281 SceneManager* pSceneManager = null;
1284 if (fullPath.Contains(BasePresentationModel::GetMediaPath()) == true)
1286 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
1288 else if (fullPath.Contains(BasePresentationModel::GetSdCardPath()) == true)
1290 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
1292 //SetCurrentFilePath
1293 FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);
1295 pArg = new (std::nothrow) ArrayList();
1296 TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");
1298 r = pArg->Construct();
1299 TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");
1301 pArg->Add(&fileName);
1303 pSceneManager = SceneManager::GetInstance();
1304 TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
1306 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);
1312 pArg->RemoveAll(true);
1320 SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)
1322 //Empty Implementation.
1325 SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
1327 AppLogDebug("Enter:SearchForm::OnThumbnailReceived");
1328 ArrayList* pResultList = null;
1329 result res = E_SUCCESS;
1330 DirectoryEntry* pFileDetails = null;
1332 ContentType contentType = CONTENT_TYPE_UNKNOWN;
1333 HashMap* pCacheList = null;
1335 TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");
1337 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
1338 TryCatch(pCacheList != null, , "Cache Hashmap is null");
1340 if (pThumbReq != null)
1342 if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())
1344 if (pThumbReq->pBitmap != null)
1346 AppLogDebug("This Bitmap is not requested from same form");
1347 delete pThumbReq->pBitmap;
1353 if (__isSearchCompleted == false)
1355 if (__isSearchStarted == true)
1356 pResultList = __pSearchedContentList;
1358 pResultList = __pContentListFromLastView;
1361 pResultList = __pSearchedContentList;
1363 TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");
1365 contentType = MfUtility::GetContentType(pThumbReq->FilePath);
1367 if (pThumbReq->iRquestId < pResultList->GetCount())
1369 pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));
1370 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
1372 AppLogDebug("Content Type [%d]", contentType);
1373 if (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO)
1375 if ((pCacheList->GetValue(pThumbReq->FilePath)) == null)
1377 AppLogDebug("Adding Image to Cache : %S", pThumbReq->FilePath.GetPointer());
1378 pCachePath = new (std::nothrow) String(pThumbReq->FilePath);
1379 if (pCachePath != null)
1381 AppLogDebug("Adding to Cache");
1382 CacheManager::GetInstance()->AddCacheEntry(*pCachePath,pThumbReq->pBitmap);
1386 else if (contentType == CONTENT_TYPE_OTHER || contentType == CONTENT_TYPE_UNKNOWN )
1388 AppLogDebug("Other type images are added to cahce");
1389 CacheManager::GetInstance()->AddOtherTypeImagesToCache(pThumbReq->FilePath, pThumbReq->pBitmap);
1391 else if ( contentType == CONTENT_TYPE_AUDIO)
1393 AppLogDebug("Audio type images are added to cahce");
1394 CacheManager::GetInstance()->AddOtherTypeImagesToCache(pThumbReq->FilePath, pThumbReq->pBitmap, true);
1397 pFileDetails->SetBitmap(pThumbReq->pBitmap);
1398 if (__pListView && __pListView->IsVisible())
1400 res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
1403 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
1407 AppLogDebug("Exit-Error %s", GetErrorMessage(GetLastResult()));
1408 if (pThumbReq != null)
1410 if (pThumbReq->pBitmap != null)
1411 delete pThumbReq->pBitmap;
1413 AppLogDebug("Exit");
1419 SearchForm::LoadDetailForm(String& fullFilePath)
1421 AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());
1422 result r = E_FAILURE;
1424 SceneManager* pSceneManager = null;
1425 ArrayList* pList = null;
1426 String* pFullFilePath = null;
1428 FolderNavigationPresentationModel::SetCurrentFilePath(fullFilePath);
1430 pList = new (std::nothrow) ArrayList();
1431 TryCatch(pList != null, , "Failed to create pList");
1433 r = pList->Construct();
1434 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
1436 pFullFilePath = new (std::nothrow) String(fullFilePath);
1438 r = pList->Add(pFullFilePath);
1439 TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");
1441 pSceneManager = SceneManager::GetInstance();
1442 TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
1444 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
1445 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1450 if (pFullFilePath != null)
1452 delete pFullFilePath;
1453 pFullFilePath = null;
1464 SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)
1466 AppLogDebug("ENTER");
1467 result r = E_SUCCESS;
1469 ArrayList* pArg = null;
1470 Integer* pSourceSelected = null;
1471 SceneManager* pSceneManager = null;
1473 __selectedItemIndexForRename = index;
1475 FolderNavigationPresentationModel::SetCurrentFilePath(pDirectory->GetFullFilePath());
1477 if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))
1478 __isCurrentDirectoryRenamed = true;
1480 pSceneManager = SceneManager::GetInstance();
1481 TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");
1483 pArg = new (std::nothrow) ArrayList;
1484 r = pArg->Construct();
1486 pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
1487 r = pArg->Add(pSourceSelected);
1488 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");
1490 r = pArg->Add(pDirectory);
1491 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");
1493 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
1498 if (pSourceSelected != null)
1500 delete pSourceSelected;
1516 SearchForm::DeleteFile(String& filePath)
1518 AppLogDebug("ENTER");
1520 //((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
1521 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
1523 FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();
1524 if (__pFileManager != null)
1526 __pFileManager->SetFileManagingListener(this);
1527 __pFileManager->DeleteFolderEntries(&filePath);
1530 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1535 SearchForm::OnFileManagingStart(void)
1537 AppLogDebug("Entry");
1538 ShowFileProgressingPopup();
1542 SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)
1544 //Empty Implementation
1548 SearchForm::ShowFileProgressingPopup(void)
1550 CreateFileProgressingPopup();
1552 if (__pFileProgressingPopup != null)
1554 __pFileProgressingPopup->SetShowState(true);
1555 __pFileProgressingPopup->Show();
1560 SearchForm::HideFileProgressingPopup(void)
1562 AppLogDebug("HideFileProgressingPopup:ENTER");
1563 if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())
1565 __pFileProgressingPopup->SetShowState(false);
1567 delete __pFileProgressingPopup;
1568 __pFileProgressingPopup = null;
1573 SearchForm::CreateFileProgressingPopup(void)
1575 AppLogDebug("ENTER");
1576 result r = E_SUCCESS;
1579 AppResource* pAppResource = null;
1580 pAppResource = UiApp::GetInstance()->GetAppResource();
1581 TryReturn(pAppResource != null, r, "Failed to fetch AppResource");
1583 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
1585 __pFileProgressingPopup = new (std::nothrow) Popup();
1586 __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
1588 __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
1589 if (__pFileProgressingCancelButton != null)
1591 __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
1592 __pFileProgressingCancelButton->AddActionEventListener(*this);
1594 __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
1595 if (__pFileProgressingProgress != null)
1597 __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
1598 __pFileProgressingProgress->SetValue(0);
1600 __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
1601 if (__pFileProgressingHeaderLabel != null)
1603 __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
1604 __pFileProgressingHeaderLabel->SetText(deleting);
1606 __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
1607 if (__pFileProgressingLabel != null)
1609 __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
1617 SearchForm::CreateDeleteConfirmationPopup(void)
1619 result r = E_SUCCESS;
1620 Rectangle popupBounds;
1622 //Create a Delete popup control
1623 __pDeleteConfirmationPopUp = new (std::nothrow) Popup();
1624 __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
1626 popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();
1629 __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
1630 TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");
1632 __pDelete->SetActionId(IDA_DELETE_FILE);
1633 __pDelete->AddActionEventListener(*this);
1634 __pDelete->SetShowState(true);
1636 __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
1637 TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
1639 __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
1640 __pCancelDeletion->AddActionEventListener(*this);
1641 __pCancelDeletion->SetShowState(true);
1647 if (__pDeleteConfirmationPopUp != null)
1649 delete __pDeleteConfirmationPopUp;
1650 __pDeleteConfirmationPopUp = null;
1658 SearchForm::HideDeleteConfirmationPopup(void)
1660 if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())
1662 __pDeleteConfirmationPopUp->SetShowState(false);
1664 delete __pDeleteConfirmationPopUp;
1665 __pDeleteConfirmationPopUp = null;
1671 SearchForm::ShowDeleteConfirmationPopup(void)
1673 CreateDeleteConfirmationPopup();
1675 if (__pDeleteConfirmationPopUp != null)
1677 __pDeleteConfirmationPopUp->SetShowState(true);
1678 __pDeleteConfirmationPopUp->Show();
1683 SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1685 AppLogDebug("SearchForm::OnDeviceStateChanged:%d, %S", deviceType, state.GetPointer());
1687 HideDeleteConfirmationPopup();
1688 HideFileProgressingPopup();
1690 if (__SelectedTab == MEMORY_TYPE_NONE )
1692 __pSearchBar->SetMode(__searchBarMode);
1694 if (__searchText.IsEmpty() == false)
1698 else if (__SelectedTab == MEMORY_TYPE_SD_CARD )
1700 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);
1706 SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
1707 const Tizen::Ui::Scenes::SceneId ¤tSceneId)
1709 result r = E_SUCCESS;
1710 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1711 __pSearchBar->SetMode(__searchBarMode);
1713 r = CreateFileEventManager(__currentSearchDirectoryPath);
1715 AppLogDebug("SearchForm::OnSceneTransitionCompleted:%S:%s", __directoryForFileEvent.GetPointer(), GetErrorMessage(GetLastResult()));
1717 if (__bCheckArgsNull == false)
1719 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
1721 if (!File::IsFileExist(__pathToRename))
1724 if (__searchText.IsEmpty() == false)
1730 __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);
1737 SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
1738 const Tizen::Ui::Scenes::SceneId &nextSceneId)
1740 //Empty Implementation.
1744 SearchForm::StartSearch(void)
1747 String folderToSearch;
1748 String topLevelPath;
1750 //Hide keypad of Search bar
1751 __pSearchBar->HideKeypad();
1752 __pSearchBar->SetContentAreaVisible(true);
1753 __pSearchBar->SetEnabled(false);
1754 __pSearchBar->SetMode(__searchBarMode);
1756 //Show Popup if Application is in FOREGROUND
1757 if ( Application::GetInstance()->GetAppUiState() == APP_UI_STATE_FOREGROUND)
1759 __pFolderLabel->SetText(folderToSearch);
1760 __pSearchPopup->SetShowState(true);
1761 __pSearchPopup->Show();
1764 if (__SelectedTab == MEMORY_TYPE_PHONE)
1766 topLevelPath = __pFolderEntryPM->GetMediaPath();
1768 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
1770 topLevelPath = __pFolderEntryPM->GetSdCardPath();
1773 if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))
1775 __searchedAllFolders = true;
1778 if (__pSearchedContentList != null)
1780 __pSearchedContentList->RemoveAll(true);
1782 __searchItemIndex = INVALID_LIST_INDEX;
1783 __isSearchCompleted = false;
1784 __isSearchStarted = true;
1785 __pListView->UpdateList();
1788 __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);
1789 __pSearchModel->SetStringToSearch(__searchText);
1790 __pSearchModel->Start();
1794 SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
1796 AppLogDebug("SearchForm::OnFileEventOccured");
1797 if ((events & FILE_EVENT_TYPE_CREATE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1799 __backFromAppControl = true;
1801 SceneManager::GetInstance()->GoBackward(BackwardSceneTransition());
1804 __selectedItemIndex =-1;
1808 SearchForm::GetFolderName(void)
1811 DataBindingContext* pContext = null;
1812 pContext = GetDataBindingContextN();
1824 AppResource::GetInstance()->GetString(L"IDS_MF_SK3_SEARCH", folderName);
1826 folderName.Append(L" ");
1828 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
1830 StringTokenizer tokenizer(fullPath, delim);
1832 if (fullPath.CompareTo(BasePresentationModel::GetMediaPath()) == 0)
1834 AppResource::GetInstance()->GetString(L"IDS_MF_TAB_PHONE", token);
1836 else if (fullPath.CompareTo(BasePresentationModel::GetSdCardPath()) == 0)
1838 AppResource::GetInstance()->GetString(L"IDS_MF_TAB_MEMORY_CARD", token);
1842 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1843 //it is the last token
1844 while (tokenizer.HasMoreTokens())
1849 tokenizer.GetNextToken(token);
1853 tokenizer.GetNextToken(token);
1858 folderName.Append(token);
1860 if (__pSearchBar != null)
1862 __pSearchBar->SetGuideText(folderName);
1867 SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)
1873 StringTokenizer tokenizer(*filePath, delim);
1877 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
1878 //it is the last token
1879 while (tokenizer.HasMoreTokens())
1881 if (tokenizer.GetTokenCount() != 1)
1883 filePath->Append(L"/");
1884 tokenizer.GetNextToken(token);
1885 filePath->Append(token);
1893 filePath->Append(L"/");
1895 if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))
1897 filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);
1899 else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))
1901 filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);
1907 SearchForm::OnAppControlCompleted(void)
1909 result r = E_SUCCESS;
1910 AppLogDebug("OnAppControlCompleted++");
1911 if ( __backFromAppControl==true )
1913 r = CreateFileEventManager(__currentSearchDirectoryPath);
1915 __pSearchBar->SetMode(__searchBarMode);
1917 if (__searchText.IsEmpty() == false)
1919 __backFromAppControl = false;
1921 AppLogDebug("OnAppControlCompleted--");
1925 SearchForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
1927 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1928 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
1933 SearchForm::RequestThumbnail(DirectoryEntry* pDirEntry, int index)
1935 result r = E_SUCCESS;
1936 ThumbRequest* pThumbReq = null;
1937 ArrayList* pList = null;
1939 TryCatch(__pThumbnailManager != null, r = E_FAILURE, "Thumbnail manager not found!");
1941 pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);
1942 TryCatch(pThumbReq != null, r = E_FAILURE, "ThumbRequest is null!");
1944 pThumbReq->iRquestId = index;
1945 pThumbReq->FilePath = pDirEntry->GetFullFilePath();
1947 pList = new (std::nothrow) ArrayList();
1948 TryCatch(pList != null, r = E_FAILURE, "Failed to create pList");
1950 r = pList->Construct();
1951 TryCatch(r == E_SUCCESS, r = E_FAILURE , "Failed to construct pList");
1953 r = pList->Add(pThumbReq);
1954 TryCatch(r == E_SUCCESS, r = E_FAILURE, "Failed to add object to pList");
1956 __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);
1963 SearchForm::CreateFileEventManager(String& path)
1965 result r = E_SUCCESS;
1966 if(__pFileEventManager != null)
1968 __pFileEventManager->RemovePath(__directoryForFileEvent);
1969 delete __pFileEventManager;
1970 __pFileEventManager = null;
1972 __pFileEventManager = new (std::nothrow) FileEventManager();
1973 __pFileEventManager->Construct(*this);
1975 __directoryForFileEvent = path;
1976 r = __pFileEventManager->AddPath(__directoryForFileEvent, FILE_EVENT_TYPE_CREATE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );