2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
\r
4 // Licensed under the Flora License, Version 1.0 (the License);
\r
5 // you may not use this file except in compliance with the License.
\r
6 // You may obtain a copy of the License at
\r
8 // http://floralicense.org/license/
\r
10 // Unless required by applicable law or agreed to in writing, software
\r
11 // distributed under the License is distributed on an AS IS BASIS,
\r
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 // See the License for the specific language governing permissions and
\r
14 // limitations under the License.
\r
18 * @file: SearchForm.cpp
\r
19 * @brief: This file contains implementation of SearchForm.
\r
22 #include "MfSearchForm.h"
\r
24 using namespace Tizen::App;
\r
25 using namespace Tizen::App::Package;
\r
26 using namespace Tizen::Base;
\r
27 using namespace Tizen::Base::Collection;
\r
28 using namespace Tizen::Base::Utility;
\r
29 using namespace Tizen::Content;
\r
30 using namespace Tizen::Graphics;
\r
31 using namespace Tizen::Io;
\r
32 using namespace Tizen::System;
\r
33 using namespace Tizen::Ui;
\r
34 using namespace Tizen::Ui::Controls;
\r
35 using namespace Tizen::Ui::Scenes;
\r
37 int SearchForm::searchBackSelected = 0;
\r
38 SearchForm::SearchForm(void)
\r
40 __pContentListFromLastView = null;
\r
41 __pSearchedContentList = null;
\r
44 __pSearchBar = null;
\r
45 __pPopUpPanel = null;
\r
46 __pPopUpLabel = null;
\r
47 __pCancelSearch = null;
\r
48 __pDividerLabel = null;
\r
50 __pThumbnailManager = null;
\r
51 __pSearchModel = null;
\r
54 __currentSearchDirectoryPath = L"";
\r
55 __bIsResultList = false;
\r
57 __searchedAllFolders = false;
\r
58 __isSearchCompleted = false;
\r
59 __isCancelClicked = false;
\r
60 __isSearchStarted = false;
\r
61 __bCheckArgsNull = false;
\r
62 __isCurrentDirectoryRenamed = false;
\r
65 __searchItemIndex = INVALID_LIST_INDEX;
\r
67 __pFolderBitmap = null;
\r
68 __pDummyImage = null;
\r
70 __pDeleteConfirmationPopUp = null;
\r
72 __selectedItemIndexForRename = 0;
\r
73 __selectedItemIndexForDelete = 0;
\r
74 __SelectedTab = MEMORY_TYPE_NONE;
\r
75 __previouFormTab = MEMORY_TYPE_NONE;
\r
77 __pCancelDeletion = null;
\r
79 __pFileProgressingCancelButton = null;
\r
80 __pFileProgressingHeaderLabel = null;
\r
81 __pItemContext = null;
\r
82 __pFileProgressingPopup = null;
\r
83 __pFileProgressingProgress = null;
\r
84 __pFileEventManager = null;
\r
87 SearchForm::~SearchForm(void)
\r
89 AppLogDebug("Entry");
\r
91 if (__pSearchedContentList != null)
\r
93 __pSearchedContentList->RemoveAll(true);
\r
94 delete __pSearchedContentList;
\r
97 if (__pSearchModel != null)
\r
99 delete __pSearchModel;
\r
102 if (__pItemContext != null)
\r
104 delete __pItemContext;
\r
107 if (__pDeleteConfirmationPopUp != null)
\r
109 delete __pDeleteConfirmationPopUp;
\r
111 if(__pFolderEntryPM != null)
\r
113 delete __pFolderEntryPM;
\r
115 if (__pFileEventManager != null)
\r
117 delete __pFileEventManager;
\r
123 SearchForm::operator =(const SearchForm& pSearchForm)
\r
128 SearchForm::SearchForm(const SearchForm& pSearchForm)
\r
130 __pContentListFromLastView = pSearchForm.__pContentListFromLastView;
\r
131 __selectedItemIndexForRename = pSearchForm.__selectedItemIndexForRename;
\r
136 SearchForm::Initialize(void)
\r
138 result r = Form::Construct(L"IDL_SEARCH");
\r
139 if (r != E_SUCCESS)
\r
141 AppLogDebug("Form construct failed with %s", GetErrorMessage(r));
\r
148 SearchForm::OnInitializing(void)
\r
150 AppLogDebug("ENTER::SearchForm::OnInitializing");
\r
151 result r = E_SUCCESS;
\r
152 String cancelButton(L"");
\r
154 Bitmap* pMainLabelBg = null;
\r
155 Bitmap* pDeleteNormalBmp = null;
\r
156 Bitmap* pDeletePressBmp = null;
\r
157 Label* pSearchPopUpMainlabel = null;
\r
158 Label* pSearchPopUpBottomlabel = null;
\r
159 String renameButtonText;
\r
160 String detailButtonText;
\r
161 String deleteButtonText;
\r
162 String strSearching ;
\r
163 IListT< SceneId >* pSceneList = null;
\r
165 __SelectedTab = MEMORY_TYPE_NONE;
\r
167 __pFolderBitmap = AppResource::GetInstance()->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);
\r
168 __pDummyImage = AppResource::GetInstance()->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);
\r
169 AppResource::GetInstance()->GetString(L"IDS_MF_BODY_RENAME_ABB", renameButtonText);
\r
170 AppResource::GetInstance()->GetString(L"IDS_MF_SK3_DELETE", deleteButtonText);
\r
171 AppResource::GetInstance()->GetString(L"IDS_MF_SK_DETAILS", detailButtonText);
\r
173 pDeleteNormalBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_NORMAL, 150, 72);
\r
174 pDeletePressBmp = MfUtility::GetNinepatchedBitmapN(IDB_CONTEXT_DELETE_PRESS, 150, 72);
\r
176 Footer* pFooter = GetFooter();
\r
177 pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT);
\r
178 pFooter->SetBackButton();
\r
180 SetFormBackEventListener(this);
\r
181 __pThumbnailManager = ThumbnailManager::GetInstance();
\r
182 TryCatch(__pThumbnailManager != null, , "ThumbnailManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
\r
184 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
\r
186 __searchBarMode = SEARCH_BAR_MODE_INPUT;
\r
188 __pSearchBar = static_cast< SearchBar* >(GetControl("IDC_SEARCHFORM_SEARCHBAR"));
\r
189 TryCatch(__pSearchBar != null, , "__pSearchBar is Null");
\r
191 __pSearchBar->AddSearchBarEventListener(*this);
\r
192 __pSearchBar->AddTextEventListener(*this);
\r
193 __pSearchBar->AddKeypadEventListener(*this);
\r
194 __pSearchBar->SetShowState(true);
\r
196 __pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
\r
197 TryCatch(__pFolderEntryPM != null, , "Content Manager not found!");
\r
198 __pFolderEntryPM->Construct();
\r
199 __pPopUpPanel = new (std::nothrow) Panel();
\r
200 TryCatch(__pPopUpPanel != null, , "Failed to allocate memory to __pPopUpPanel");
\r
202 r = __pPopUpPanel->Construct(Rectangle(X_POPUP_SEARCH, Y_POPUP_SEARCH, W_MAX_POPUP, H_POPUP_SEARCH));
\r
203 TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpPanel");
\r
206 pSearchPopUpMainlabel = new (std::nothrow) Label();
\r
207 TryCatch(pSearchPopUpMainlabel != null, , "Failed to allocate memory to _pSearchPopUpMainlabel");
\r
209 r = pSearchPopUpMainlabel->Construct(Rectangle(X_DEFAULT, Y_DEFAULT, __pPopUpPanel->GetWidth(), __pPopUpPanel->GetHeight() - H_BOTTOM_PANEL), L"");
\r
210 TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");
\r
212 pMainLabelBg = MfUtility::GetNinepatchedBitmapN(IDB_BACKGROUND_POPUP_CENTER, pSearchPopUpMainlabel->GetWidth(), pSearchPopUpMainlabel->GetHeight());
\r
214 if (pMainLabelBg != null)
\r
216 pSearchPopUpMainlabel->SetBackgroundBitmap(*pMainLabelBg);
\r
218 __pPopUpPanel->AddControl(*pSearchPopUpMainlabel);
\r
219 __pPopUpPanel->SetControlAlwaysAtBottom(*pSearchPopUpMainlabel, true);
\r
221 pSearchPopUpBottomlabel = new (std::nothrow) Label();
\r
222 TryCatch(pSearchPopUpBottomlabel != null, , "Failed to allocate memory to _pSearchPopUpBottomlabel");
\r
224 r = pSearchPopUpBottomlabel->Construct(Rectangle(X_DEFAULT, __pPopUpPanel->GetHeight() - H_BOTTOM_PANEL, __pPopUpPanel->GetWidth(), H_BOTTOM_PANEL), L"");
\r
225 TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");
\r
227 __pPopUpPanel->AddControl(*pSearchPopUpBottomlabel);
\r
228 __pPopUpPanel->SetControlAlwaysAtBottom(*pSearchPopUpBottomlabel, true);
\r
230 __pPopUpLabel = new (std::nothrow) Label();
\r
231 TryCatch(__pPopUpLabel != null, , "Failed to allocate memory to __pPopUpLabel");
\r
233 AppResource::GetInstance()->GetString(L"IDS_COM_POP_SEARCHING", strSearching);
\r
234 r = __pPopUpLabel->Construct(Rectangle(20, 30, __pPopUpPanel->GetWidth() - 40, 60), strSearching);
\r
235 TryCatch(r == E_SUCCESS, , "failed to construct __pPopUpLabel");
\r
237 __pPopUpLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL);
\r
238 __pPopUpPanel->AddControl(*__pPopUpLabel);
\r
240 __pDividerLabel = new (std::nothrow) Label();
\r
241 TryCatch(__pDividerLabel != null, r = GetLastResult(), "Failed to allocate memory to __pDividerLabel");
\r
243 r = __pDividerLabel->Construct(Rectangle(20, 30 + 40, __pPopUpPanel->GetWidth() - 40, 60), L"");
\r
244 TryCatch(r == E_SUCCESS, , "failed to construct __pDividerLabel");
\r
246 __pDividerLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL);
\r
248 __pPopUpPanel->AddControl(*__pDividerLabel);
\r
250 //The cancel button inside the popup, hides the popup and stops search thread, when clicked.
\r
251 AppResource::GetInstance()->GetString(L"IDS_COM_POP_CANCEL", cancelButton);
\r
252 __pCancelSearch = new (std::nothrow) Button();
\r
253 TryCatch(__pCancelSearch != null, , "MfMyFilesApp::Button For Popup not created!");
\r
255 r = __pCancelSearch->Construct(Rectangle(110, __pPopUpPanel->GetHeight() - 84, __pPopUpPanel->GetBounds().width - 220, H_DEFAULT_BUTTON), cancelButton);
\r
256 TryCatch(r == E_SUCCESS, , "failed to construct __pButtonPopPUP");
\r
258 AddControl(*__pPopUpPanel);
\r
259 __pPopUpPanel->AddControl(*__pCancelSearch);
\r
261 __pCancelSearch->SetActionId(IDA_BTN_POPUP_SEARCH_CANCEL);
\r
262 __pCancelSearch->AddActionEventListener(*this);
\r
264 SetControlAlwaysOnTop(*__pPopUpPanel, true);
\r
265 __pPopUpPanel->SetControlAlwaysOnTop(*__pCancelSearch, true);
\r
267 __pPopUpPanel->SetShowState(false);
\r
270 __listViewRectangle.SetBounds(X_DEFAULT, H_SEARCH_BAR, GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR);
\r
272 __pListView = static_cast< ListView* >(GetControl("IDC_SEARCHFORM_LISTVIEW"));
\r
273 TryCatch(__pListView != null, r = GetLastResult(), "__pListView is Null");
\r
275 __pListView->SetItemProvider(*this);
\r
276 __pListView->AddListViewItemEventListener(*this);
\r
278 __pSearchModel = new (std::nothrow) SearchPresentationModel();
\r
279 TryCatch(__pSearchModel != null, r = GetLastResult(), "SearchForm::OnInitializing::Failed to allocate memory to __PSearchModel");
\r
281 r = __pSearchModel->Initialize();
\r
282 TryCatch(r == E_SUCCESS, , "SearchPresentationModel:Init()failed with %s", GetErrorMessage(GetLastResult()));
\r
284 __pSearchedContentList = new (std::nothrow) ArrayList();
\r
285 TryCatch(__pSearchedContentList != null, , "SearchForm::GetCurrentFileControl::Failed to allocate Memory to __pSearchedContentList");
\r
287 r = __pSearchedContentList->Construct();
\r
288 TryCatch(r == E_SUCCESS, , "SearchForm::GetCurrentFileControl::Failed to construct __pSearchedContentList");
\r
290 __pItemContext = new (std::nothrow) ListContextItem();
\r
292 r = __pItemContext->Construct();
\r
293 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to construct pitemcontext");
\r
295 __pItemContext->AddElement(IDA_CONTEXT_RENAME, renameButtonText);
\r
296 __pItemContext->AddElement(IDA_CONTEXT_DETAIL, detailButtonText);
\r
298 __pItemContext->AddElement(IDA_CONTEXT_DELETE,
\r
305 __previousFormPath = FolderNavigationPresentationModel::GetCurrentPath();
\r
306 __previouFormTab = FolderNavigationPresentationModel::GetStorageType();
\r
307 pSceneList = SceneManager::GetInstance()->GetSceneHistoryN();
\r
308 if (pSceneList != null)
\r
310 __previousSceneId = SceneManager::GetInstance()->GetCurrentSceneId();
\r
315 AppLogDebug("Exit");
\r
317 if (pDeleteNormalBmp != null)
\r
319 delete pDeleteNormalBmp;
\r
320 pDeleteNormalBmp = null;
\r
322 if (pDeletePressBmp != null)
\r
324 delete pDeletePressBmp;
\r
325 pDeletePressBmp = null;
\r
328 if (pMainLabelBg != null)
\r
330 delete pMainLabelBg;
\r
331 pMainLabelBg = null;
\r
337 if (__pDividerLabel != null)
\r
339 delete __pDividerLabel;
\r
341 if (__pPopUpPanel != null)
\r
343 delete __pPopUpPanel;
\r
345 if (__pSearchBar != null)
\r
347 delete __pSearchBar;
\r
349 if (__pListView != null)
\r
351 delete __pListView;
\r
353 if (__pSearchModel != null)
\r
355 delete __pSearchModel;
\r
358 delete pDeleteNormalBmp;
\r
360 delete pDeletePressBmp;
\r
362 delete pMainLabelBg;
\r
364 AppLogDebug("EXIT::SearchForm::OnInitializing");
\r
369 SearchForm::OnTerminating(void)
\r
371 result r = E_SUCCESS;
\r
372 //((MfMyFilesApp*)Application::GetInstance())->SetCurrentView(null);
\r
374 if (__pFolderBitmap)
\r
375 delete __pFolderBitmap;
\r
378 delete __pDummyImage;
\r
383 ////////////////////////////////////////////////////////////////////////
\r
384 // Call-back functions
\r
385 ////////////////////////////////////////////////////////////////////////
\r
388 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
\r
389 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
\r
391 AppLogDebug("ENTER:SearchForm::OnSceneActivatedN:%s", GetErrorMessage(GetLastResult()));
\r
393 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
\r
395 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
\r
397 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_USB_CLIENT, *this);
\r
400 SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
\r
404 __bCheckArgsNull = true;
\r
406 __currentSearchDirectoryPath = FolderNavigationPresentationModel::GetCurrentPath();
\r
407 __SelectedTab = FolderNavigationPresentationModel::GetStorageType();
\r
409 if (__pFolderEntryPM != null)
\r
411 __pFolderEntryPM->SetSourceForm(CREATE_ITEM_SOURCE_SEARCH_FORM);
\r
412 if (__currentSearchDirectoryPath.IsEmpty() == false)
\r
414 __pFolderEntryPM->SetFolderEntryPath(__currentSearchDirectoryPath);
\r
415 __pContentListFromLastView = __pFolderEntryPM->GetFolderEntryList();
\r
416 TryCatch(__pContentListFromLastView != null, , "Failed to allocate Memory to __pContentListFromLastView");
\r
419 __isSearchCompleted = false;
\r
420 __isSearchStarted = false;
\r
422 String topLevelPath = L"";
\r
425 if (__SelectedTab == MEMORY_TYPE_PHONE)
\r
427 topLevelPath = __pFolderEntryPM->GetMediaPath();
\r
429 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
\r
431 topLevelPath = __pFolderEntryPM->GetSdCardPath();
\r
434 if (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath != topLevelPath)
\r
436 AppLogDebug("SearchForm::OnSceneActivatedN:%S:%S", __currentSearchDirectoryPath.GetPointer(), topLevelPath.GetPointer());
\r
437 __pDividerLabel->SetText(__currentSearchDirectoryPath);
\r
440 pArgs->RemoveAll(false);
\r
447 __bCheckArgsNull = false;
\r
450 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
\r
454 AppLogDebug("EXIT:SearchForm::OnSceneActivatedN");
\r
460 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
\r
461 const Tizen::Ui::Scenes::SceneId& nextSceneId)
\r
463 DeviceManager::RemoveAllDeviceEventListeners();
\r
467 SearchForm::OnFormBackRequested(Form& source)
\r
473 SearchForm::TransitionScene(void)
\r
475 //String rootMediaPath = BasePresentationModel::GetHomePath();
\r
476 String rootMediaPath = BasePresentationModel::GetMediaPath();
\r
477 SceneManager* pSceneManager = null;
\r
478 pSceneManager = SceneManager::GetInstance();
\r
480 if (__isSearchStarted == true && __isSearchCompleted == false)
\r
482 __pSearchModel->StopSearch();
\r
485 if (__previousFormPath.CompareTo("") != 0)
\r
487 if (__isCurrentDirectoryRenamed == false)
\r
488 FolderNavigationPresentationModel::SetCurrentFilePath(__previousFormPath);
\r
489 FolderNavigationPresentationModel::SetStorageType(__previouFormTab);
\r
490 AppLogDebug("__previouspath is %S", __previousFormPath.GetPointer());
\r
493 if(__pFileEventManager != null)
\r
494 __pFileEventManager->RemovePath(__currentSearchDirectoryPath);
\r
496 // pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
\r
498 if (__previousSceneId == IDSCN_SPLIT_PANEL_FORM && GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
\r
500 if (__previousFormPath == BasePresentationModel::GetMediaPath() || __previousFormPath == BasePresentationModel::GetSdCardPath())
\r
502 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
\r
506 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
\r
509 else if ((__previousSceneId == IDSCN_ROOT_DIRECTORY_FORM || __previousSceneId == IDSCN_SUB_DIRECTORY_FORM) && GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
\r
511 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SPLIT_PANEL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
\r
515 pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
\r
520 SearchForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
\r
522 int modalResult = 0;
\r
523 CustomAppControl* pCustomAppControl = null;
\r
524 String topLevelPath;
\r
525 String emptySearchString;
\r
527 DirectoryEntry* pFileDetails = null;
\r
528 MessageBox messageEmptyString;
\r
530 AppResource* pAppResource = null;
\r
533 pAppResource = UiApp::GetInstance()->GetAppResource();
\r
534 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
\r
536 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
\r
538 __pathOfSelectedFile = L"";
\r
540 if (__isCancelClicked == true)
\r
544 if (index == __itemCount && __searchedAllFolders == false)
\r
546 AppLogDebug("SearchPresentationModel::Search:%d", index);
\r
547 messageEmptyString.Construct(L"", emptySearchString , MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
\r
549 if (__pSearchBar->GetText().IsEmpty())
\r
551 messageEmptyString.ShowAndWait(modalResult);
\r
555 __searchedAllFolders = true;
\r
557 __searchItemIndex = INVALID_LIST_INDEX;
\r
558 //Free the content of __pSearchedContentList and Delete the same before searching again
\r
559 if (__pSearchedContentList != null)
\r
561 __pSearchedContentList->RemoveAll(true);
\r
564 __pListView->UpdateList();
\r
565 __pDividerLabel->SetText(L"");
\r
566 __pPopUpPanel->SetShowState(true);
\r
567 __pPopUpPanel->Draw();
\r
568 __pSearchBar->SetEnabled(false);
\r
570 if (__SelectedTab == MEMORY_TYPE_PHONE)
\r
572 topLevelPath = __pFolderEntryPM->GetMediaPath();
\r
574 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
\r
576 topLevelPath = __pFolderEntryPM->GetSdCardPath();
\r
579 __pSearchModel->SetFolderToSearch(topLevelPath);
\r
580 __pSearchModel->SetStringToSearch(__searchText);
\r
581 __pSearchModel->Start();
\r
586 if (__isSearchCompleted == false && __isSearchStarted == false)
\r
588 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
\r
592 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
\r
594 TryCatch(pFileDetails != null, , "pFileDetails is Null")
\r
597 __pathOfSelectedFile = pFileDetails->GetFullFilePath();
\r
599 if (pFileDetails->IsDirectory() == true)
\r
601 String fileName = pFileDetails->GetFileName();
\r
602 String filePath = pFileDetails->GetFullFilePath();
\r
603 LoadSubDirectoryForm(filePath, fileName);
\r
607 //Else launch the corresponding AppControl.
\r
608 if (__pathOfSelectedFile.EndsWith(L".tpk"))
\r
610 String* pFileUriScheme = new (std::nothrow) String(L"file://");
\r
611 pFileUriScheme->Append(__pathOfSelectedFile);
\r
612 AppControl* pAc = null;
\r
613 pAc = AppManager::FindAppControlN(L"D7eOJquGtL.Installer", L"http://tizen.org/appcontrol/operation/install");
\r
616 pAc->Start(pFileUriScheme, null, null, null);
\r
618 delete pFileUriScheme;
\r
622 String FileName = pFileDetails->GetFileName() + "." + pFileDetails->GetFileExtension();
\r
623 String parentDirectoryOfSelectedFile = L"";
\r
624 __pathOfSelectedFile.SubString(0, __pathOfSelectedFile.GetLength() - FileName.GetLength() , parentDirectoryOfSelectedFile);
\r
626 pCustomAppControl = CustomAppControl::GetInstance();
\r
627 if (pCustomAppControl != null)
\r
629 pCustomAppControl->SetAppControlListener(this);
\r
630 __pFileEventManager->AddPath(parentDirectoryOfSelectedFile, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_FROM | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
\r
631 AppControl* pAppControlInUse = pCustomAppControl->LaunchAppControl(__pathOfSelectedFile);
\r
632 if (pAppControlInUse != null)
\r
633 CustomAppControl::SetAppControlInUse(pAppControlInUse);
\r
645 SearchForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
\r
647 //Empty Implementation.
\r
651 SearchForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus state)
\r
653 AppLogDebug("Enter");
\r
654 AppLogDebug("ENTER: SearchForm::OnListViewContextItemStateChanged:%d, %d, %d, %d", index, elementId, __isSearchCompleted, __isSearchStarted);
\r
656 String filePath = L"";
\r
657 DirectoryEntry* pFileDetails = null;
\r
659 if (__isSearchCompleted == false)
\r
661 if (__isSearchStarted == true)
\r
663 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
\r
667 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
\r
672 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
\r
674 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
\r
676 filePath.Append(pFileDetails->GetFullFilePath());
\r
680 case IDA_CONTEXT_DETAIL:
\r
682 LoadDetailForm(filePath);
\r
686 case IDA_CONTEXT_RENAME:
\r
688 LoadRenameForm(index, pFileDetails);
\r
692 case IDA_CONTEXT_DELETE:
\r
694 __selectedItemIndexForDelete = index;
\r
695 __fileToDelete = pFileDetails->GetFullFilePath();
\r
697 ShowDeleteConfirmationPopup();
\r
711 AppLogDebug("EXIT: SearchForm::OnListViewContextItemStateChanged");
\r
715 SearchForm::GetItemCount(void)
\r
717 AppLogDebug("ENTER::SearchForm::GetItemCount:%d", __isSearchCompleted);
\r
720 TryCatch(__pSearchedContentList != null, , "__pContentListFromLastView is null!")
\r
722 if (__isSearchCompleted == false)
\r
724 if (__isSearchStarted == true)
\r
725 count = __pSearchedContentList->GetCount();
\r
728 if (__pContentListFromLastView != null)
\r
729 count = __pContentListFromLastView->GetCount();
\r
734 count = __pSearchedContentList->GetCount();
\r
735 String topLevelPath = L"";
\r
737 if (__SelectedTab == MEMORY_TYPE_PHONE)
\r
739 topLevelPath = defaultPhoneBody;
\r
740 topLevelPath.Append("/");
\r
742 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
\r
744 topLevelPath = defaultSdCardBody;
\r
745 topLevelPath.Append("/");
\r
748 if (__currentSearchDirectoryPath != topLevelPath && __searchedAllFolders == false)
\r
750 __itemCount = count++;
\r
753 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
\r
757 AppLogDebug("EXIT::SearchForm::GetItemCount:%d", count);
\r
762 SearchForm::CreateItem(int index, int itemWidth)
\r
764 AppLogDebug("ENTER::SearchForm::CreateItem");
\r
765 result r = E_SUCCESS;
\r
767 String imageIconPath;
\r
768 String strHightlightedText;
\r
770 String cacheImagePath;
\r
772 Bitmap* pFetchedCacheImage = null;
\r
773 Bitmap* pThumbnailImage = null;
\r
774 HashMap* pCacheList = null;
\r
775 ContentType contentType = CONTENT_TYPE_UNKNOWN;
\r
777 Dimension thumbnailDimension(H_LISTVIEW_ITEM_BITMAP, W_LISTVIEW_ITEM_BITMAP);
\r
778 Dimension textDimension(itemWidth - H_LISTVIEW_ITEM_BITMAP, H_ITEM_LISTVIEW);
\r
780 AppResource* pAppResource = null;
\r
781 DirectoryEntry* pFileDetails = null;
\r
782 ContentListItem* pCustomItem = null;
\r
783 ThumbRequest* pThumbReq = null;
\r
785 ArrayList* pList = null;
\r
787 if (index == __itemCount && __searchedAllFolders == false)
\r
789 CustomItem* pItem = null;
\r
790 String searchAllFolder = L"";
\r
791 AppResource::GetInstance()->GetString(L"IDS_MF_BUTTON_SEARCH_ALL_FOLDERS", searchAllFolder);
\r
792 pItem = new (std::nothrow) SearchAllFoldersItem(itemWidth, H_ITEM_LISTVIEW, searchAllFolder);
\r
796 pAppResource = Application::GetInstance()->GetAppResource();
\r
797 TryCatch(pAppResource != null, , "Resource manager not found!");
\r
799 if (__isSearchCompleted == false)
\r
801 if (__isSearchStarted == true)
\r
803 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
\r
807 if (__pContentListFromLastView != null && __pContentListFromLastView->GetCount() != 0)
\r
808 pFileDetails = static_cast< DirectoryEntry* >(__pContentListFromLastView->GetAt(index));
\r
813 pFileDetails = static_cast< DirectoryEntry* >(__pSearchedContentList->GetAt(index));
\r
815 TryCatch(pFileDetails != null, , "SearchForm::Failed to get pFileDetails");
\r
817 pCustomItem = new (std::nothrow) ContentListItem(itemWidth, H_ITEM_LISTVIEW, true);
\r
818 TryCatch(pCustomItem != null, , "SearchForm::Failed to create pCustomItem");
\r
821 filename.Append(pFileDetails->GetFileName());
\r
824 filepath.Append(pFileDetails->GetFullFilePath());
\r
826 if (pFileDetails->IsDirectory() == false)
\r
828 filename.Append(".");
\r
829 filename.Append(pFileDetails->GetFileExtension());
\r
832 if (__searchText.GetLength() > 0)
\r
833 strHightlightedText.Append(__searchText);
\r
835 pCustomItem->SetTitle(filename, strHightlightedText);
\r
838 if (__pThumbnailManager != null)
\r
840 if (pFileDetails->IsDirectory() == true)
\r
842 pListBitmap = pAppResource->GetBitmapN(L"U01_icon_folder_Cropped.png", BITMAP_PIXEL_FORMAT_ARGB8888); //pFolderImage->DecodeN(folderIconPath, BITMAP_PIXEL_FORMAT_ARGB8888);
\r
843 AppLogDebug("MfMyFilesApp::Decode Folder Result: %s", GetErrorMessage(GetLastResult()));
\r
847 imageIconPath = pFileDetails->GetFullFilePath();
\r
848 pListBitmap = __pThumbnailManager->InitThumbnailManagerN(imageIconPath, thumbnailDimension);
\r
850 TryCatch(pListBitmap != null, , "SearchForm::CreateItem::pListBitmap is null");
\r
854 contentType = ContentManagerUtil::CheckContentType(pFileDetails->GetFullFilePath());
\r
855 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
\r
857 if (pFileDetails->IsDirectory() == true)
\r
859 pCustomItem->SetThumbnail(__pFolderBitmap);
\r
863 if (pFileDetails->GetBitmap() == null)
\r
865 if (pCacheList != null && (contentType == CONTENT_TYPE_IMAGE || contentType == CONTENT_TYPE_VIDEO))
\r
867 if (pFileDetails != null)
\r
869 cacheImagePath = pFileDetails->GetFullFilePath();
\r
870 AppLogDebug("cache path is %S",cacheImagePath.GetPointer());
\r
873 if ((pCacheList->GetValue(cacheImagePath)) != null)
\r
875 pFetchedCacheImage = static_cast< Bitmap* >(pCacheList->GetValue(cacheImagePath));
\r
879 if (pFetchedCacheImage != null)
\r
881 AppLogDebug("image taken from cachemanager");
\r
882 pThumbnailImage = CacheManager::GetInstance()->GetCacheBitmapN(cacheImagePath);
\r
883 pCustomItem->SetThumbnail(pThumbnailImage);
\r
887 pCustomItem->SetThumbnail(__pDummyImage);
\r
889 pThumbReq = new (std::nothrow) ThumbRequest(CREATE_ITEM_SOURCE_SEARCH_FORM);
\r
890 TryCatch(pThumbReq != null, , "ThumbRequest is null!");
\r
892 pThumbReq->iRquestId = index;
\r
893 pThumbReq->FilePath = pFileDetails->GetFullFilePath();
\r
895 pList = new (std::nothrow) ArrayList();
\r
896 TryCatch(pList != null, , "Failed to create pList");
\r
898 r = pList->Construct();
\r
899 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
\r
901 r = pList->Add(pThumbReq);
\r
902 TryCatch(r == E_SUCCESS, , "Failed to add object to pList");
\r
904 __pThumbnailManager->SendUserEvent(ThumbnailManager::THUMB_MGR_GET_THUMBNAIL, pList);
\r
909 pCustomItem->SetThumbnail(pFileDetails->GetBitmap());
\r
913 if (__bIsResultList)
\r
915 GetParentFolderPath(&filepath);
\r
916 pCustomItem->SetFilepath(filepath);
\r
917 pCustomItem->MakeSearchFormListItem();
\r
921 pCustomItem->Make();
\r
922 } pCustomItem->SetContextItem(__pItemContext);
\r
924 AppLogDebug("EXIT::SearchForm::CreateItem");
\r
925 return pCustomItem;
\r
928 if (pCustomItem != null)
\r
930 delete pCustomItem;
\r
940 AppLogDebug("EXIT::SearchForm::CreateItem");
\r
945 SearchForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
\r
947 AppLogDebug("ENTER::SearchForm::DeleteItem");
\r
953 AppLogDebug("EXIT::SearchForm::DeleteItem");
\r
958 SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
\r
960 AppLogDebug("Enter:SearchForm::OnKeypadActionPerformed");
\r
961 int modalResult = 0;
\r
962 String emptySearchString;
\r
964 MessageBox messageEmptyString;
\r
965 AppResource* pAppResource = null;
\r
967 pAppResource = UiApp::GetInstance()->GetAppResource();
\r
968 TryReturn(pAppResource != null, , "Failed to fetch AppResource");
\r
970 pAppResource->GetString(L"IDS_SEARCH_STRING_CANNOT_BE_EMPTY", emptySearchString);
\r
972 messageEmptyString.Construct(L"", emptySearchString, MSGBOX_STYLE_NONE, ID_MESSAGE_BOX_TIMEOUT_ONE_SECOND);
\r
975 if (__pSearchBar->GetText().IsEmpty())
\r
977 messageEmptyString.ShowAndWait(modalResult);
\r
978 __pSearchBar->ShowKeypad();
\r
982 __isCancelClicked = false;
\r
984 //Get the text entered in SearchBar
\r
985 __searchText.Clear();
\r
986 __searchText = __pSearchBar->GetText();
\r
989 if (__searchText.IsEmpty() == false)
\r
992 AppLogDebug("Exit::SearchForm::OnKeypadActionPerformed");
\r
995 SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)
\r
997 AppLogDebug("ENTER::SearchForm::OnKeypadClosed");
\r
999 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
\r
1000 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
\r
1002 AppLogDebug("EXIT::SearchForm::OnKeypadClosed");
\r
1005 SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)
\r
1007 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
\r
1009 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
\r
1010 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
\r
1014 SearchForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
\r
1016 //Empty Implementation
\r
1019 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
\r
1021 AppLogDebug("ENTER::SearchForm::OnActionPerformed");
\r
1024 case IDA_BTN_POPUP_SEARCH_CANCEL:
\r
1026 AppLogDebug("SearchForm::OnSearchBarModeChanged:Search Cancelled");
\r
1027 __isSearchCompleted = true;
\r
1029 __pSearchModel->StopSearch();
\r
1031 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
\r
1032 __pSearchBar->SetMode(__searchBarMode);
\r
1033 __pSearchBar->HideKeypad();
\r
1035 __pPopUpPanel->SetShowState(false);
\r
1036 __pSearchBar->SetEnabled(true);
\r
1038 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
\r
1039 __searchText.Clear();
\r
1044 case IDA_DELETE_FILE:
\r
1046 HideDeleteConfirmationPopup();
\r
1047 //Call the DeleteFile Function.
\r
1048 DeleteFile(__fileToDelete);
\r
1052 case IDA_CANCEL_DELETION:
\r
1054 HideDeleteConfirmationPopup();
\r
1064 AppLogDebug("EXIT::SearchForm::OnActionPerformed");
\r
1067 SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
\r
1069 AppLogDebug("ENTER::SearchForm::OnTextValueChangeCanceled");
\r
1070 if (__pPopUpPanel->GetShowState() == true)
\r
1072 __pPopUpPanel->SetShowState(false);
\r
1073 __pPopUpPanel->Invalidate(true);
\r
1074 __pSearchBar->SetEnabled(true);
\r
1079 SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)
\r
1081 //Empty Implementation.
\r
1084 //SearchBar Control
\r
1086 SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode)
\r
1088 AppLogDebug("SearchForm::OnSearchBarModeChanged");
\r
1090 if (mode == SEARCH_BAR_MODE_INPUT)
\r
1092 __searchBarMode = SEARCH_BAR_MODE_INPUT;
\r
1093 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
\r
1097 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
\r
1098 SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
\r
1099 if (__isSearchStarted == true)
\r
1101 if (__isSearchCompleted == false)
\r
1103 //Stop Search Thread
\r
1104 __pSearchModel->StopSearch();
\r
1106 //Hide keypad of SearchBar
\r
1107 __pSearchBar->HideKeypad();
\r
1110 if (__pPopUpPanel != null)
\r
1112 __pPopUpPanel->SetShowState(false);
\r
1113 __pPopUpPanel->Invalidate(true);
\r
1117 __pListView->UpdateList();
\r
1120 __pSearchBar->SetContentAreaSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
\r
1121 __pListView->SetSize(Dimension(GetClientAreaBounds().width, GetClientAreaBounds().height - H_SEARCH_BAR));
\r
1123 __pSearchBar->Invalidate(true);
\r
1127 SearchForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
\r
1129 CustomAppControl::GetInstance()->SetAppControlInUse(null);
\r
1130 ContentType contentType = ContentManagerUtil::CheckContentType(__pathOfSelectedFile);
\r
1132 __pSearchBar->SetMode(__searchBarMode);
\r
1134 if (GetLastResult() == E_FILE_NOT_FOUND)
\r
1136 __isSearchCompleted = false;
\r
1137 if (__searchText.IsEmpty() == false)
\r
1142 AppLogDebug("OnAppControlResponseReceived:ContentType:%s:%d", GetErrorMessage(GetLastResult()), contentType);
\r
1145 if (__pListView != null)
\r
1146 __pListView->UpdateList();
\r
1150 SearchForm::OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs)
\r
1152 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl");
\r
1153 result r = E_FAILURE;
\r
1154 Integer* pEventType = null;
\r
1155 DirectoryEntry* pResultDirEntry = null;
\r
1156 HashMap* pCacheList = null;
\r
1157 DirectoryEntry* pCurrentEntry = null;
\r
1158 bool cacheKeyStatus = false;
\r
1161 TryCatch(pArgs != null, , "SearchForm::GetCurrentFileControl::pArg is null");
\r
1163 pEventType = static_cast< Integer* >(pArgs->GetAt(0));
\r
1164 TryCatch(pEventType != null, , "SearchForm::GetCurrentFileControl::pArg is null");
\r
1166 switch (pEventType->ToInt())
\r
1168 case ID_FOLDER_SEARCH_STARTED:
\r
1170 String* pFolderSearchResult = (String*) pArgs->GetAt(1);
\r
1171 TryCatch(pFolderSearchResult != null, , "SearchForm::GetCurrentFileControl::folderSearchResult is null");
\r
1173 String defMediaPath(L"/opt/usr/media");
\r
1174 String defSdCardPath(L"/opt/storage/sdcard");
\r
1176 String displayPhone = defaultPhoneBody;
\r
1177 String displaySdCard = defaultSdCardBody;
\r
1180 if (pFolderSearchResult->IsEmpty() == false)
\r
1182 if (pFolderSearchResult->StartsWith(defMediaPath, 0))
\r
1184 pFolderSearchResult->Replace(defMediaPath, displayPhone);
\r
1186 else if (pFolderSearchResult->StartsWith(defSdCardPath, 0))
\r
1188 pFolderSearchResult->Replace(defSdCardPath, displaySdCard);
\r
1191 __pDividerLabel->SetText(*pFolderSearchResult);
\r
1192 __pDividerLabel->Invalidate(true);
\r
1197 case ID_SEARCH_COMPLETED:
\r
1199 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:Search Completed");
\r
1200 __isSearchCompleted = true;
\r
1202 __pPopUpPanel->SetShowState(false);
\r
1203 __pPopUpPanel->Invalidate(true);
\r
1204 __pSearchBar->SetEnabled(true);
\r
1206 __pSearchModel->StopSearch();
\r
1208 if (__pSearchBar->GetMode() == SEARCH_BAR_MODE_INPUT)
\r
1210 __searchBarMode = SEARCH_BAR_MODE_NORMAL;
\r
1211 __pSearchBar->SetMode(__searchBarMode);
\r
1212 __pSearchBar->SetText(__searchText);
\r
1215 //Scroll the List to top
\r
1216 __pListView->ScrollToItem(0);
\r
1220 case ID_SEARCH_RESULT_FOUND:
\r
1222 AppLogDebug("ENTER::SearchForm::GetCurrentFileControl:ID_SEARCH_RESULT_FOUND");
\r
1223 __isSearchCompleted = false;
\r
1224 __searchItemIndex++;
\r
1225 AppLogDebug("ItemCount::%d", __searchItemIndex);
\r
1227 __pSearchBar->SetText(__searchText);
\r
1229 DirectoryEntry* pSearchResult = static_cast< DirectoryEntry* >(pArgs->GetAt(1));
\r
1230 TryCatch(pSearchResult != null, , "GetCurrentFileControl::pSearchResult is null");
\r
1232 AppLogDebug("ItemCount::%S", pSearchResult->GetFileName().GetPointer());
\r
1234 pResultDirEntry = new (std::nothrow) DirectoryEntry(*pSearchResult);
\r
1235 r = __pSearchedContentList->InsertAt(pResultDirEntry, __searchItemIndex);
\r
1237 AppLogDebug("Check Insert to SearchedContentList Result: %s", GetErrorMessage(r));
\r
1239 TryCatch(r == E_SUCCESS, , "GetCurrentFileControl::Failed to add items to __pSearchedContentList");
\r
1241 AppLogDebug("Check SearchItemIndex: %d", __searchItemIndex);
\r
1243 __bIsResultList = true;
\r
1245 result res = __pListView->RefreshList(__searchItemIndex, LIST_REFRESH_TYPE_ITEM_ADD);
\r
1246 AppLogDebug("Check Refresh List Result: %s", GetErrorMessage(res));
\r
1250 case FILE_MANAGING_RESULT_DELETING_SUCCESS:
\r
1252 AppLogDebug("FILE_MANAGING_RESULT_DELETING_SUCCESS");
\r
1253 HideFileProgressingPopup();
\r
1254 pCacheList = CacheManager::GetInstance()->GetCacheHashMap();
\r
1256 if (__isSearchCompleted == true || __isSearchStarted == true)
\r
1258 pCurrentEntry = static_cast<DirectoryEntry*>(__pSearchedContentList->GetAt(__selectedItemIndexForDelete));
\r
1260 if (pCurrentEntry != null)
\r
1262 cachePath = pCurrentEntry->GetFullFilePath();
\r
1265 if (pCacheList != null)
\r
1267 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
\r
1268 if (cacheKeyStatus)
\r
1270 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
\r
1273 __pSearchedContentList->RemoveAt(__selectedItemIndexForDelete, true);
\r
1277 pCurrentEntry = static_cast<DirectoryEntry*>(__pContentListFromLastView->GetAt(__selectedItemIndexForDelete));
\r
1279 if (pCurrentEntry != null)
\r
1281 cachePath = pCurrentEntry->GetFullFilePath();
\r
1284 if (pCacheList != null)
\r
1286 cacheKeyStatus = pCacheList->ContainsKey(cachePath);
\r
1287 if (cacheKeyStatus)
\r
1289 CacheManager::GetInstance()->RemoveCacheEntry(cachePath);
\r
1292 __pContentListFromLastView->RemoveAt(__selectedItemIndexForDelete, false);
\r
1294 __pListView->UpdateList();
\r
1303 pArgs->RemoveAll(true);
\r
1307 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
\r
1312 AppLogDebug("EXIT::SearchForm::GetCurrentFileControl");
\r
1317 SearchForm::OnFolderSearchStarted(Tizen::Base::String& folderName)
\r
1319 //Empty Implementation
\r
1323 SearchForm::OnAllFoldersSearchCompleted(void)
\r
1325 //Empty Implementation
\r
1329 SearchForm::LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName)
\r
1331 result r = E_SUCCESS;
\r
1332 ArrayList* pArg = null;
\r
1333 SceneManager* pSceneManager = null;
\r
1334 //int storageType = -1;
\r
1336 if (__SelectedTab == MEMORY_TYPE_PHONE)
\r
1338 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_PHONE);
\r
1340 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
\r
1342 FolderNavigationPresentationModel::SetStorageType(MEMORY_TYPE_SD_CARD);
\r
1346 FolderNavigationPresentationModel::SetCurrentFilePath(fullPath);
\r
1348 pArg = new (std::nothrow) ArrayList();
\r
1349 TryCatch(pArg != null, , "SearchForm::LoadSubDirectoryForm::Failed to allocate Memory to pArg");
\r
1351 r = pArg->Construct();
\r
1352 TryCatch(r == E_SUCCESS, , "SearchForm::LoadSubDirectoryForm::Failed to construct pArg");
\r
1354 pArg->Add(&fileName);
\r
1356 pSceneManager = SceneManager::GetInstance();
\r
1357 TryCatch(pSceneManager != null, , "SceneManager::GetInstance() failed:%s", GetErrorMessage(GetLastResult()));
\r
1359 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SUB_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP), pArg);
\r
1365 pArg->RemoveAll(true);
\r
1373 SearchForm::OnListViewItemStateChangedNotify(ViewType viewType)
\r
1375 //Empty Implementation.
\r
1378 SearchForm::OnThumbnailReceived(ThumbRequest* pThumbReq)
\r
1380 AppLogDebug("Enter:SearchForm::OnThumbnailReceived");
\r
1381 ArrayList* pResultList = null;
\r
1382 result res = E_SUCCESS;
\r
1383 DirectoryEntry* pFileDetails = null;
\r
1385 TryCatch(pThumbReq != null, , "SearchForm::Thumbrequest is null");
\r
1387 if (pThumbReq != null)
\r
1389 if (pThumbReq->GetCurrentSourceForm() != __pFolderEntryPM->GetSourceForm())
\r
1391 if (pThumbReq->pBitmap != null)
\r
1393 AppLogDebug("This Bitmap is not requested from same form");
\r
1394 delete pThumbReq->pBitmap;
\r
1400 if (__isSearchCompleted == false)
\r
1402 if (__isSearchStarted == true)
\r
1403 pResultList = __pSearchedContentList;
\r
1405 pResultList = __pContentListFromLastView;
\r
1408 pResultList = __pSearchedContentList;
\r
1410 TryCatch(pResultList != null, , "SearchForm::CreateItem::pResultList is null");
\r
1412 if (pThumbReq->iRquestId < pResultList->GetCount())
\r
1414 pFileDetails = static_cast< DirectoryEntry* >(pResultList->GetAt(pThumbReq->iRquestId));
\r
1415 TryCatch(pFileDetails != null, , "SearchForm::CreateItem::pFileDetails is null");
\r
1417 pFileDetails->SetBitmap(pThumbReq->pBitmap);
\r
1418 if (__pListView && __pListView->IsVisible())
\r
1420 res = __pListView->RefreshList(pThumbReq->iRquestId, LIST_REFRESH_TYPE_ITEM_MODIFY);
\r
1424 AppLogDebug("Thumbnail Request is not valid");
\r
1426 AppLogDebug("Exit");
\r
1429 if (pThumbReq != null)
\r
1431 if (pThumbReq->pBitmap != null)
\r
1432 delete pThumbReq->pBitmap;
\r
1434 AppLogDebug("Exit");
\r
1440 SearchForm::LoadDetailForm(String& fullFilePath)
\r
1442 AppLogDebug("ENTER:SearchForm::LoadDetailForm:%S", fullFilePath.GetPointer());
\r
1443 result r = E_FAILURE;
\r
1445 SceneManager* pSceneManager = null;
\r
1446 ArrayList* pList = null;
\r
1447 String* pFullFilePath = null;
\r
1449 pList = new (std::nothrow) ArrayList();
\r
1450 TryCatch(pList != null, , "Failed to create pList");
\r
1452 r = pList->Construct();
\r
1453 TryCatch(r == E_SUCCESS, , "Failed to construct pList");
\r
1455 pFullFilePath = new (std::nothrow) String(fullFilePath);
\r
1457 r = pList->Add(pFullFilePath);
\r
1458 TryCatch(r == E_SUCCESS, , "Failed to add pFullFilePath to ArrayList");
\r
1460 pSceneManager = SceneManager::GetInstance();
\r
1461 TryCatch(pSceneManager != null, , "Failed to allocate Memory to pSceneManager");
\r
1463 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FILE_DETAIL_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
\r
1464 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
\r
1469 if (pFullFilePath != null)
\r
1471 delete pFullFilePath;
\r
1472 pFullFilePath = null;
\r
1474 if (pList != null)
\r
1483 SearchForm::LoadRenameForm(int index, DirectoryEntry* pDirectory)
\r
1485 AppLogDebug("ENTER");
\r
1486 result r = E_SUCCESS;
\r
1488 ArrayList* pArg = null;
\r
1489 Integer* pSourceSelected = null;
\r
1490 SceneManager* pSceneManager = null;
\r
1492 __selectedItemIndexForRename = index;
\r
1494 if (pDirectory->IsDirectory() == true && (__currentSearchDirectoryPath == pDirectory->GetFullFilePath()))
\r
1495 __isCurrentDirectoryRenamed = true;
\r
1497 pSceneManager = SceneManager::GetInstance();
\r
1498 TryCatch(pSceneManager != null, r = GetLastResult(), "Failed to Get SceneManager instance");
\r
1500 pArg = new (std::nothrow) ArrayList;
\r
1501 r = pArg->Construct();
\r
1503 pSourceSelected = new (std::nothrow) Integer(SELECT_RENAME);
\r
1504 r = pArg->Add(pSourceSelected);
\r
1505 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add sourceSelected");
\r
1507 r = pArg->Add(pDirectory);
\r
1508 TryCatch(r == E_SUCCESS, r = GetLastResult(), "Failed to add pDirectory");
\r
1510 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_FOLDER_FORM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArg);
\r
1515 if (pSourceSelected != null)
\r
1517 delete pSourceSelected;
\r
1521 delete pDirectory;
\r
1533 SearchForm::DeleteFile(String& filePath)
\r
1535 AppLogDebug("ENTER");
\r
1537 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
\r
1538 ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
\r
1540 FolderEntryEditorPresentationModel* __pFileManager = FolderEntryEditorPresentationModel::GetInstance();
\r
1541 if (__pFileManager != null)
\r
1543 __pFileManager->SetFileManagingListener(this);
\r
1544 __pFileManager->DeleteFolderEntries(&filePath);
\r
1547 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
\r
1552 SearchForm::OnFileManagingStart(void)
\r
1554 AppLogDebug("Entry");
\r
1555 ShowFileProgressingPopup();
\r
1559 SearchForm::OnFileManagingStop(FileManagingResult fileManagingResult)
\r
1561 //Empty Implementation
\r
1565 SearchForm::ShowFileProgressingPopup(void)
\r
1567 CreateFileProgressingPopup();
\r
1569 if (__pFileProgressingPopup != null)
\r
1571 __pFileProgressingPopup->SetShowState(true);
\r
1572 __pFileProgressingPopup->Show();
\r
1577 SearchForm::HideFileProgressingPopup(void)
\r
1579 AppLogDebug("HideFileProgressingPopup:ENTER");
\r
1580 if (__pFileProgressingPopup != null && __pFileProgressingPopup->IsVisible())
\r
1582 __pFileProgressingPopup->SetShowState(false);
\r
1584 delete __pFileProgressingPopup;
\r
1585 __pFileProgressingPopup = null;
\r
1590 SearchForm::CreateFileProgressingPopup(void)
\r
1592 AppLogDebug("ENTER");
\r
1593 result r = E_SUCCESS;
\r
1596 AppResource* pAppResource = null;
\r
1597 pAppResource = UiApp::GetInstance()->GetAppResource();
\r
1598 TryReturn(pAppResource != null, r, "Failed to fetch AppResource");
\r
1600 pAppResource->GetString(L"IDS_COM_POP_DELETING", deleting);
\r
1602 __pFileProgressingPopup = new (std::nothrow) Popup();
\r
1603 __pFileProgressingPopup->Construct(L"IDL_FILE_PROGRESSING_POPUP");
\r
1605 __pFileProgressingCancelButton = static_cast< Button* >(__pFileProgressingPopup->GetControl(L"IDC_CANCEL_BUTTON", true));
\r
1606 if (__pFileProgressingCancelButton != null)
\r
1608 __pFileProgressingCancelButton->SetActionId(IDA_BTN_ANIMATION_POPUP_CANCEL);
\r
1609 __pFileProgressingCancelButton->AddActionEventListener(*this);
\r
1611 __pFileProgressingProgress = static_cast< Progress* >(__pFileProgressingPopup->GetControl(L"IDC_PROGRESS_BAR", true));
\r
1612 if (__pFileProgressingProgress != null)
\r
1614 __pFileProgressingProgress->SetName(L"IDC_ANIMATION_PROGRESS");
\r
1615 __pFileProgressingProgress->SetValue(0);
\r
1617 __pFileProgressingHeaderLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_HEADER", true));
\r
1618 if (__pFileProgressingHeaderLabel != null)
\r
1620 __pFileProgressingHeaderLabel->SetName(L"IDC_ANIMATION_HEADER");
\r
1621 __pFileProgressingHeaderLabel->SetText(deleting);
\r
1623 __pFileProgressingLabel = static_cast< Label* >(__pFileProgressingPopup->GetControl(L"IDC_ANIMATION_LABEL", true));
\r
1624 if (__pFileProgressingLabel != null)
\r
1626 __pFileProgressingLabel->SetName(L"IDC_FILE_COUNT_LABEL");
\r
1634 SearchForm::CreateDeleteConfirmationPopup(void)
\r
1636 result r = E_SUCCESS;
\r
1637 Rectangle popupBounds;
\r
1639 //Create a Delete popup control
\r
1640 __pDeleteConfirmationPopUp = new (std::nothrow) Popup();
\r
1641 __pDeleteConfirmationPopUp->Construct(L"IDL_DELETE_POPUP");
\r
1643 popupBounds = __pDeleteConfirmationPopUp->GetClientAreaBounds();
\r
1646 __pDelete = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_DELETE", true));
\r
1647 TryCatch(__pDelete != null, , "MfMyFilesApp::Button For Popup not created!");
\r
1649 __pDelete->SetActionId(IDA_DELETE_FILE);
\r
1650 __pDelete->AddActionEventListener(*this);
\r
1651 __pDelete->SetShowState(true);
\r
1653 __pCancelDeletion = static_cast< Button* >(__pDeleteConfirmationPopUp->GetControl(L"IDC_BUTTON_CANCEL", true));
\r
1654 TryCatch(__pCancelDeletion != null, , "MfMyFilesApp::Button For Popup not created!");
\r
1656 __pCancelDeletion->SetActionId(IDA_CANCEL_DELETION);
\r
1657 __pCancelDeletion->AddActionEventListener(*this);
\r
1658 __pCancelDeletion->SetShowState(true);
\r
1664 if (__pDeleteConfirmationPopUp != null)
\r
1666 delete __pDeleteConfirmationPopUp;
\r
1667 __pDeleteConfirmationPopUp = null;
\r
1675 SearchForm::HideDeleteConfirmationPopup(void)
\r
1677 if (__pDeleteConfirmationPopUp != null && __pDeleteConfirmationPopUp->IsVisible())
\r
1679 __pDeleteConfirmationPopUp->SetShowState(false);
\r
1681 delete __pDeleteConfirmationPopUp;
\r
1682 __pDeleteConfirmationPopUp = null;
\r
1688 SearchForm::ShowDeleteConfirmationPopup(void)
\r
1690 CreateDeleteConfirmationPopup();
\r
1692 if (__pDeleteConfirmationPopUp != null)
\r
1694 __pDeleteConfirmationPopUp->SetShowState(true);
\r
1695 __pDeleteConfirmationPopUp->Show();
\r
1700 SearchForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
\r
1702 bool setMediaPath = false;
\r
1703 MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
\r
1704 String unmounted = sdCardStatusUnmounted;
\r
1705 String removed = usbDeviceStatusRemoved;
\r
1706 String currentPath;
\r
1707 SceneManager* pSceneManager = null;
\r
1709 if (state == unmounted || state == removed)
\r
1711 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
\r
1712 if (state == unmounted)
\r
1714 if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
\r
1716 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
\r
1717 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
\r
1718 setMediaPath = true;
\r
1722 if (state == removed)
\r
1724 if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
\r
1726 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
\r
1727 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
\r
1728 setMediaPath = true;
\r
1734 pSceneManager = SceneManager::GetInstance();
\r
1735 if (pSceneManager != null)
\r
1737 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ROOT_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null); }
\r
1743 SearchForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
\r
1745 ComponentType currentDeviceType;
\r
1746 switch (deviceType)
\r
1750 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
\r
1756 currentDeviceType = COMPONENT_TYPE_USB;
\r
1766 OnDeviceChange(currentDeviceType, state);
\r
1770 SearchForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,
\r
1771 const Tizen::Ui::Scenes::SceneId ¤tSceneId)
\r
1773 SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
\r
1774 // __pSearchBar->SetText(L"");
\r
1775 __pSearchBar->SetMode(__searchBarMode);
\r
1778 if (__pFileEventManager != null)
\r
1780 delete __pFileEventManager;
\r
1781 __pFileEventManager = null;
\r
1784 __pFileEventManager = new (std::nothrow) FileEventManager();
\r
1785 __pFileEventManager->Construct(*this);
\r
1787 //__pFileEventManager->AddPath(__currentSearchDirectoryPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_DELETE );
\r
1789 if (__bCheckArgsNull)
\r
1791 if (__pListView != null)
\r
1793 __pListView->UpdateList();
\r
1798 if (previousSceneId == IDSCN_CREATE_FOLDER_FORM)
\r
1800 __pListView->RefreshList(__selectedItemIndexForRename, LIST_REFRESH_TYPE_ITEM_MODIFY);
\r
1806 SearchForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId ¤tSceneId,
\r
1807 const Tizen::Ui::Scenes::SceneId &nextSceneId)
\r
1809 //Empty Implementation.
\r
1813 SearchForm::StartSearch(void)
\r
1815 String searchtext;
\r
1816 String folderToSearch;
\r
1817 String topLevelPath;
\r
1819 //Hide keypad of Search bar
\r
1820 __pSearchBar->HideKeypad();
\r
1821 __pSearchBar->SetContentAreaVisible(true);
\r
1822 __pSearchBar->SetEnabled(false);
\r
1825 __pDividerLabel->SetText(folderToSearch);
\r
1826 __pPopUpPanel->SetShowState(true);
\r
1827 __pPopUpPanel->Invalidate(true);
\r
1829 ///Set Application Notification Listener to current form
\r
1830 ((MyFilesApp*) Application::GetInstance())->SetNotifyListener(this);
\r
1832 if (__SelectedTab == MEMORY_TYPE_PHONE)
\r
1834 //topLevelPath = folderEntryPM.GetMediaPath();
\r
1835 topLevelPath = __pFolderEntryPM->GetMediaPath();
\r
1837 else if (__SelectedTab == MEMORY_TYPE_SD_CARD)
\r
1839 //topLevelPath = folderEntryPM.GetSdCardPath();
\r
1840 topLevelPath = __pFolderEntryPM->GetSdCardPath();
\r
1843 if ( (__currentSearchDirectoryPath.GetLength() > 0 && __currentSearchDirectoryPath == topLevelPath ) || (FolderNavigationPresentationModel::GetCurrentPath().IsEmpty() == true))
\r
1845 __searchedAllFolders = true;
\r
1848 if (__pSearchedContentList != null)
\r
1850 __pSearchedContentList->RemoveAll(true);
\r
1852 __searchItemIndex = INVALID_LIST_INDEX;
\r
1853 __isSearchCompleted = false;
\r
1854 __isSearchStarted = true;
\r
1856 __pListView->UpdateList();
\r
1858 __pSearchModel->SetFolderToSearch(__currentSearchDirectoryPath);
\r
1859 __pSearchModel->SetStringToSearch(__searchText);
\r
1860 __pSearchModel->Start();
\r
1864 SearchForm::OnFileEventOccured(const unsigned long events,const Tizen::Base::String & path, const unsigned int eventId)
\r
1866 if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_FROM) || (events & FILE_EVENT_TYPE_MOVED_TO ))
\r
1868 __pSearchBar->SetMode(__searchBarMode);
\r
1870 if (__searchText.IsEmpty() == false)
\r
1873 if (__pListView != null)
\r
1874 __pListView->UpdateList();
\r
1879 SearchForm::GetFolderName(void)
\r
1881 String delim(L"/");
\r
1884 String folderName(L"Search ");
\r
1886 fullPath = FolderNavigationPresentationModel::GetCurrentPath();
\r
1888 StringTokenizer tokenizer(fullPath, delim);
\r
1891 DataBindingContext* pContext = null;
\r
1892 pContext = GetDataBindingContextN();
\r
1897 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
\r
1898 //it is the last token
\r
1899 while (tokenizer.HasMoreTokens())
\r
1904 tokenizer.GetNextToken(token);
\r
1908 tokenizer.GetNextToken(token);
\r
1909 folderName.Append(token);
\r
1913 if (__pSearchBar != null)
\r
1915 __pSearchBar->SetGuideText(folderName);
\r
1920 SearchForm::GetParentFolderPath(Tizen::Base::String* filePath)
\r
1922 String displayPath;
\r
1923 String delim(L"/");
\r
1926 StringTokenizer tokenizer(*filePath, delim);
\r
1928 filePath->Clear();
\r
1930 //Use a string tokenizer to get the filepath until it's the last token, break the loop when
\r
1931 //it is the last token
\r
1932 while (tokenizer.HasMoreTokens())
\r
1934 if (tokenizer.GetTokenCount() != 1)
\r
1936 filePath->Append(L"/");
\r
1937 tokenizer.GetNextToken(token);
\r
1938 filePath->Append(token);
\r
1946 filePath->Append(L"/");
\r
1948 if (filePath->StartsWith(BasePresentationModel::GetMediaPath(),0))
\r
1950 filePath->Replace(BasePresentationModel::GetMediaPath(),"Phone/",0);
\r
1952 else if(filePath->StartsWith(BasePresentationModel::GetSdCardPath(),0))
\r
1954 filePath->Replace(BasePresentationModel::GetSdCardPath(),"Memory Card/",0);
\r