Applied latest source code
[apps/native/preloaded/MusicPlayer.git] / src / MpSearchForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                MpSearchForm.cpp
19  * @brief               This is the implementation file for SearchForm class.
20  */
21
22 #include "MpSearchForm.h"
23 #include "MpSearchListItem.h"
24 #include "MpMusicPlayerApp.h"
25
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Content;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Media;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
35
36 static const int H_SEARCH_BAR = 86;
37 static const int H_GROUP_NAME = 80;
38 static const int X_GAP = 16;
39 static const int SEARCH_FONT_SIZE = 50;
40 static const int IDA_GROUP_ITEM_ELEMENT = 100;
41 static const int IDA_SEARCH_ITEM_MAIN_ELEMENT = 101;
42 static const int IDA_SEARCH_ITEM_SUB_ELEMENT = 102;
43 static const Tizen::Graphics::Color COLOR_GROUP_NAME_BG (127, 127, 127);
44 static const Tizen::Graphics::Color COLOR_GROUP_TEXT (255, 255, 255);
45
46 SearchForm::SearchForm(void)
47         : __pSearchListView(null)
48         , __pSearchBar(null)
49         , __pNoContentTextLabel(null)
50         , __pSceneId(null)
51         , __itemHeight(ITEM_HEIGHT_MAIN_TEXT_NORMAL)
52         , __fontSize(FONT_MAIN_TEXT_SIZE_NORMAL)
53 {
54         AppLogDebug("ENTER");
55         AppLogDebug("EXIT");
56 }
57
58 SearchForm::~SearchForm(void)
59 {
60         AppLogDebug("ENTER");
61         AppLogDebug("EXIT");
62 }
63
64 bool
65 SearchForm::Initialize(void)
66 {
67         AppLogDebug("ENTER");
68
69         Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_PORTRAIT_INDICATOR | FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE);
70
71         AppLogDebug("EXIT");
72         return true;
73 }
74
75 result
76 SearchForm::OnInitializing(void)
77 {
78         AppLogDebug("ENTER");
79         AddOrientationEventListener(*this);
80         SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
81
82         GetHeader()->SetTitleText(ResourceManager::GetString("IDS_COM_BODY_SEARCH"));
83
84         __pPresentationModel = SearchPresentationModel::GetInstance();
85         __pSearchBar = new (std::nothrow) SearchBar();
86         __pSearchBar->Construct(Rectangle(0, 0, GetClientAreaBounds().width, H_SEARCH_BAR));
87         __pSearchBar->SetGuideText(ResourceManager::GetString("IDS_COM_BODY_SEARCH"));
88         __pSearchBar->AddSearchBarEventListener(*this);
89         __pSearchBar->AddTextEventListener(*this);
90         __pSearchBar->AddKeypadEventListener(*this);
91 //      __pSearchBar->SetLowerCaseModeEnabled(true);
92         AddControl(__pSearchBar);
93         __pSearchListView = new (std::nothrow) ListView();
94         __pSearchListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pSearchBar->GetHeight()),
95                                         true,
96                                         SCROLL_STYLE_FADE_OUT);
97
98         __pSearchListView->SetItemProvider(*this);
99         __pSearchListView->AddListViewItemEventListener(*this);
100         __pSearchListView->AddTouchEventListener(*this);
101         __pSearchListView->AddScrollEventListener(*this);
102         __pSearchBar->SetContent(__pSearchListView);
103
104         __fontSizeValue = CommonUtil::GetFontSizeValue();
105         __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
106         __fontSize = CommonUtil::GetFontSize(__fontSizeValue);
107
108         if (GetFooter() != null)
109         {
110                 GetFooter()->SetBackButton();
111         }
112
113         SetFormBackEventListener(this);
114         AppLogDebug("EXIT");
115         return E_SUCCESS;
116 }
117
118 result
119 SearchForm::OnTerminating(void)
120 {
121         AppLogDebug("ENTER");
122         __pSearchListView->Destroy();
123         AppLogDebug("EXIT");
124         return E_SUCCESS;
125 }
126
127 void
128 SearchForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source,
129                                                                         Tizen::Ui::Controls::SearchBarMode mode)
130 {
131         AppLogDebug("ENTER");
132         __pPresentationModel->RemoveSearchResult();
133
134         if (__pSearchListView != null)
135         {
136                 __pSearchListView->UpdateList();
137                 __pSearchListView->ScrollToItem(INIT_VALUE);
138                 __pSearchListView->Invalidate(true);
139         }
140         AppLogDebug("EXIT");
141 }
142
143 void
144 SearchForm::OnSearchBarContentAreaResized(Tizen::Ui::Controls::SearchBar& source,
145                                                                                         Dimension& size)
146 {
147         AppLogDebug("ENTER");
148         AppLogDebug("EXIT");
149 }
150
151 void
152 SearchForm::OnTextValueChanged(const Tizen::Ui::Control& source)
153 {
154         AppLogDebug("ENTER");
155         if (__pSearchBar->GetText().GetLength() != INIT_VALUE)
156         {
157                 __pPresentationModel->InitializeContentList(__pSearchBar->GetText());
158         }
159         else
160         {
161                 __pPresentationModel->RemoveSearchResult();
162         }
163
164         if (__pSearchListView != null)
165         {
166                 __pSearchListView->UpdateList();
167                 __pSearchListView->ScrollToItem(INIT_VALUE);
168                 __pSearchListView->Invalidate(true);
169         }
170         AppLogDebug("EXIT");
171 }
172
173 void
174 SearchForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
175 {
176         AppLogDebug("ENTER");
177         AppLogDebug("EXIT");
178 }
179
180 void
181 SearchForm::OnKeypadActionPerformed(Tizen::Ui::Control& source,
182                                                                         Tizen::Ui::KeypadAction keypadAction)
183 {
184         AppLogDebug("ENTER");
185         if (keypadAction == KEYPAD_ACTION_SEARCH)
186         {
187                 __pSearchBar->HideKeypad();
188
189                 if (__pSearchBar->GetTextLength() != INIT_VALUE)
190                 {
191                         __pPresentationModel->InitializeContentList(__pSearchBar->GetText());
192                 }
193                 else
194                 {
195                         __pPresentationModel->RemoveSearchResult();
196                 }
197                 if (__pSearchListView != null)
198                 {
199                         __pSearchListView->UpdateList();
200                         __pSearchListView->ScrollToItem(INIT_VALUE);
201                         __pSearchListView->Invalidate(true);
202                 }
203         }
204         AppLogDebug("EXIT");
205 }
206
207 void
208 SearchForm::OnKeypadClosed(Tizen::Ui::Control& source)
209 {
210         AppLogDebug("ENTER");
211         if (GetFooter() != null)
212         {
213                 GetFooter()->SetShowState(true);
214         }
215
216         FloatRectangle clientRect = GetClientAreaBoundsF();
217         FloatRectangle searchBarBounds = CoordinateSystem::AlignToDevice(FloatRectangle(__pSearchBar->GetBoundsF()));
218         __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - searchBarBounds.height));
219         __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - searchBarBounds.height));
220         if (__pNoContentTextLabel != null)
221         {
222                 __pNoContentTextLabel->SetBounds(FloatRectangle(X_GAP,(searchBarBounds.y+searchBarBounds.height),GetWidth() - (X_GAP * 2),clientRect.height - (searchBarBounds.y+searchBarBounds.height)));
223         }
224         AppLogDebug("EXIT");
225 }
226
227 void
228 SearchForm::OnKeypadOpened(Tizen::Ui::Control& source)
229 {
230         AppLogDebug("ENTER");
231         FloatRectangle clientRect = CoordinateSystem::AlignToDevice(GetClientAreaBoundsF());
232         FloatRectangle searchBarBounds = CoordinateSystem::AlignToDevice(FloatRectangle(__pSearchBar->GetBoundsF()));
233         __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - searchBarBounds.height));
234         __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - searchBarBounds.height));
235
236         if (__pNoContentTextLabel != null)
237         {
238                 __pNoContentTextLabel->SetBounds(Rectangle(X_GAP,(searchBarBounds.y+searchBarBounds.height),GetWidth() - (X_GAP * 2),clientRect.height - (searchBarBounds.y+searchBarBounds.height)));
239         }
240         AppLogDebug("EXIT");
241 }
242
243 void
244 SearchForm::OnKeypadWillOpen(Tizen::Ui::Control &source)
245 {
246         AppLogDebug("ENTER");
247 //      GetFooter()->SetShowState(false);
248         AppLogDebug("EXIT");
249 }
250
251 void
252 SearchForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
253 {
254         FloatRectangle clientRect = GetClientAreaBoundsF();
255         FloatRectangle searchBarBounds = CoordinateSystem::AlignToDevice(FloatRectangle(__pSearchBar->GetBoundsF()));
256         __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - searchBarBounds.height));
257         __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - searchBarBounds.height));
258
259         if (__pNoContentTextLabel != null && __pNoContentTextLabel->GetShowState())
260         {
261                 __pNoContentTextLabel->SetBounds(Rectangle(X_GAP,(searchBarBounds.y+searchBarBounds.height),GetWidth() - (X_GAP * 2),clientRect.height - (searchBarBounds.y+searchBarBounds.height)));
262         }
263 }
264
265 int
266 SearchForm::GetItemCount(void)
267 {
268         AppLogDebug("ENTER");
269         int contentCount = __pPresentationModel->GetTotalContentCount();
270
271         if ( __pNoContentTextLabel != null)
272         {
273                 if (contentCount == 0)
274                 {
275                         __pNoContentTextLabel->SetShowState(true);
276                 }
277                 else
278                 {
279                         __pNoContentTextLabel->SetShowState(false);
280                 }
281         }
282
283         Invalidate(true);
284         AppLogDebug("EXIT");
285         return contentCount;
286 }
287
288 Tizen::Ui::Controls::ListItemBase*
289 SearchForm::CreateItem(const int itemIndex, int itemWidth)
290 {
291         AppLogDebug("ENTER");
292         int artistIndex = __pPresentationModel->GetArtistIndex();
293         int albumIndex = __pPresentationModel->GetAlbumIndex();
294         int songIndex = __pPresentationModel->GetSongIndex();
295
296         ContentInformation* pContentInfo = null;
297         CustomItem* pItem = new (std::nothrow) CustomItem();
298
299         result r = pItem->Construct(Dimension(itemWidth, H_GROUP_NAME), LIST_ANNEX_STYLE_NORMAL);
300         TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
301
302         if (artistIndex == itemIndex)
303         {
304                 r = CreateGroupNameTableViewItem(pItem, ResourceManager::GetString(L"IDS_MUSIC_TAB4_ARTISTS"));
305                 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
306
307                 AppLogDebug("EXIT");
308                 return pItem;
309         }
310         else if (albumIndex == itemIndex)
311         {
312                 r = CreateGroupNameTableViewItem(pItem, ResourceManager::GetString(L"IDS_MUSIC_BODY_ALBUMS"));
313                 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
314
315                 AppLogDebug("EXIT");
316                 return pItem;
317         }
318         else if (songIndex == itemIndex)
319         {
320                 r = CreateGroupNameTableViewItem(pItem, ResourceManager::GetString(L"IDS_MUSIC_HEADER_SONGS"));
321                 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
322
323                 AppLogDebug("EXIT");
324                 return pItem;
325         }
326         else
327         {
328                 delete pItem;
329         }
330
331         pItem = new (std::nothrow) CustomItem();
332         r = pItem->Construct(Dimension(itemWidth, __itemHeight), LIST_ANNEX_STYLE_NORMAL);
333         TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
334
335         pContentInfo = __pPresentationModel->GetContentInfoN(itemIndex);
336         TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
337
338         if (artistIndex != -1 && itemIndex > artistIndex)
339         {
340                 bool addArtist = true;
341
342                 if(albumIndex != -1 && itemIndex > albumIndex)
343                 {
344                         addArtist = false;
345                 }
346
347                 if(songIndex != -1 && albumIndex == -1 && itemIndex > songIndex)
348                 {
349                         addArtist = false;
350                 }
351
352                 if(addArtist)
353                 {
354                         CreateSearchResultText(pItem,  pContentInfo->ArtistName, SEARCH_NAME_ARTIST);
355                 }
356         }
357
358         if(albumIndex != -1 && itemIndex > albumIndex)
359         {
360                 bool addAlbum = true;
361                 if(songIndex != -1 && itemIndex > songIndex)
362                 {
363                         addAlbum = false;
364                 }
365
366                 if(addAlbum)
367                 {
368                         CreateSearchResultText(pItem, pContentInfo->AlbumName, SEARCH_NAME_ALBUM);
369                         CreateSubArtistNameText(pItem, pContentInfo->ArtistName);
370                 }
371         }
372         if(songIndex != -1 && itemIndex > songIndex)
373         {
374                 CreateSearchResultText(pItem, pContentInfo->TitleName, SEARCH_NAME_SONG);
375         }
376         delete pContentInfo;
377
378         AppLogDebug("EXIT");
379         return pItem;
380
381 CATCH:
382         AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
383         return null;
384 }
385
386 void
387 SearchForm::CreateSearchResultText(Tizen::Ui::Controls::CustomItem* pItem, const Tizen::Base::String& searchName, const SearchName name)
388 {
389         SearchListItem* pSearchItem = null;
390         String keyword = __pSearchBar->GetText();
391         keyword.ToLowerCase();
392         pSearchItem = new (std::nothrow) SearchListItem(keyword, searchName, __fontSize, __itemHeight, name);
393
394         if (name == SEARCH_NAME_ALBUM)
395         {
396                 pItem->AddElement(Rectangle(X_GAP_THUMBNAIL, 0, GetClientAreaBounds().width - X_GAP_THUMBNAIL,  __itemHeight - 50), IDA_SEARCH_ITEM_MAIN_ELEMENT, *pSearchItem);
397         }
398         else
399         {
400                 pItem->AddElement(Rectangle(X_GAP_THUMBNAIL, 0, GetClientAreaBounds().width - X_GAP_THUMBNAIL,  __itemHeight - 20), IDA_SEARCH_ITEM_MAIN_ELEMENT, *pSearchItem);
401                 pItem->SetElementTextVerticalAlignment(IDA_SEARCH_ITEM_MAIN_ELEMENT, ALIGNMENT_MIDDLE);
402         }
403
404         return;
405 }
406
407 void
408 SearchForm::CreateSubArtistNameText(Tizen::Ui::Controls::CustomItem* pItem, const Tizen::Base::String& ArtistName)
409 {
410         Font font;
411         TextElement* pArtist = null;
412         EnrichedText* pArtistName = new (std::nothrow) EnrichedText();
413         pArtistName->Construct(Dimension(GetClientAreaBounds().width - X_GAP_THUMBNAIL, 50));
414         pArtistName->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
415         pArtistName->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
416         font.Construct(FONT_STYLE_BOLD, SUB_TEXT_SIZE);
417         pArtist = new (std::nothrow) TextElement();
418         pArtist->Construct(ArtistName);
419         pArtist->SetFont(font);
420         pArtist->SetTextColor(COLOR_SUB_TEXT);
421         pArtistName->Add(*pArtist);
422         pItem->AddElement(Rectangle(X_GAP_THUMBNAIL, __itemHeight - 50, GetClientAreaBounds().width - X_GAP_THUMBNAIL,  50), IDA_SEARCH_ITEM_SUB_ELEMENT, *pArtistName);
423         pItem->SetElementTextVerticalAlignment(IDA_SEARCH_ITEM_SUB_ELEMENT, ALIGNMENT_TOP);
424         pArtistName->RemoveAllTextElements(true);
425         delete pArtistName;
426         return;
427 }
428 bool
429 SearchForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
430 {
431         AppLogDebug("ENTER");
432
433         AppLogDebug("EXIT");
434         return false;
435 }
436
437 void
438 SearchForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
439 {
440         AppLogDebug("ENTER");
441         AppLogDebug("EXIT");
442 }
443
444 int
445 SearchForm::GetDefaultItemHeight(void)
446 {
447         AppLogDebug("ENTER");
448         AppLogDebug("EXIT");
449         return ITEM_HEIGHT;
450 }
451
452 void
453 SearchForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView,
454                         int index,
455                         int elementId, Tizen::Ui::Controls::ListItemStatus status)
456 {
457         AppLogDebug("ENTER");
458         if (status != LIST_ITEM_STATUS_SELECTED)
459         {
460                 return;
461         }
462
463         if (index == __pPresentationModel->GetArtistIndex()
464                 || index == __pPresentationModel->GetAlbumIndex()
465                 || index == __pPresentationModel->GetSongIndex())
466         {
467                 __pSearchBar->HideKeypad();
468                 Invalidate(true);
469                 return;
470         }
471
472         int albumIndex = __pPresentationModel->GetAlbumIndex();
473         int songIndex = __pPresentationModel->GetSongIndex();
474
475         ContentInformation* pContentInfo;
476         SceneManager* pSceneManager = SceneManager::GetInstance();
477         AppAssert(pSceneManager);
478
479         if (songIndex != -1 && index > songIndex) //song result
480         {
481                 __pSearchBar->HideKeypad();
482                 pContentInfo = __pPresentationModel->GetContentInfoN(index);
483                 ArrayList* pPath = new (std::nothrow) ArrayList();
484                 pPath->Construct();
485                 pPath->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
486
487                 ArrayList* pData = new (std::nothrow) ArrayList();
488                 pData->Construct();
489                 pData->Add(*(new (std::nothrow) String(MUSIC)));
490                 pData->Add(*(new (std::nothrow) Integer(0)));
491                 pData->Add(*(pPath));
492
493                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PLAYER), pData);
494         }
495         else if (albumIndex != -1 && index > albumIndex)//album item
496         {
497                 pContentInfo = __pPresentationModel->GetContentInfoN(index);
498
499                 ArrayList* pData = new (std::nothrow) ArrayList();
500                 pData->Construct();
501                 pData->Add(*(new (std::nothrow) String(IDSCN_SEARCH)));
502                 pData->Add(*(new (std::nothrow) String(pContentInfo->AlbumName)));
503                 pData->Add(*(new (std::nothrow) Integer(index)));
504
505                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_CONTENT_LIST), pData);
506         }
507         else//artist item
508         {
509                 pContentInfo = __pPresentationModel->GetContentInfoN(index);
510
511                 ArrayList* pData = new (std::nothrow) ArrayList();
512                 pData->Construct();
513                 pData->Add(*(new (std::nothrow) String(IDSCN_ARTIST_LIST)));
514                 pData->Add(*(new (std::nothrow) String(pContentInfo->ArtistName)));
515
516                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ARTIST_CONTENT_LIST), pData);
517         }
518
519         delete pContentInfo;
520         pContentInfo = null;
521         AppLogDebug("EXIT");
522 }
523
524
525 void
526 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
527                                                                 const Tizen::Ui::Scenes::SceneId& currentSceneId,
528                                                                 Tizen::Base::Collection::IList* pArgs)
529 {
530         AppLogDebug("ENTER");
531         if (__pSceneId == null)
532         {
533                 __pSceneId = new (std::nothrow) String(previousSceneId);
534         }
535
536         if (__pPresentationModel->GetTotalContentCount() == 0)
537         {
538                 FloatRectangle clientBounds = GetClientAreaBoundsF();
539                 FloatRectangle searchBarBounds = __pSearchBar->GetBoundsF();
540                 if (__pNoContentTextLabel == null)
541                 {
542                         __pNoContentTextLabel = new (std::nothrow) Label();
543                         __pNoContentTextLabel->Construct(FloatRectangle(X_GAP,searchBarBounds.y+searchBarBounds.height,
544                                         GetWidth() - (X_GAP * 2),clientBounds.height - (searchBarBounds.height+searchBarBounds.y)),ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
545                         __pNoContentTextLabel->SetTextConfig(SEARCH_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
546                         AddControl(__pNoContentTextLabel);
547                 }
548                 else
549                 {
550                         __pNoContentTextLabel->SetBounds(FloatRectangle(X_GAP, (searchBarBounds.y+searchBarBounds.height),GetWidth() - (X_GAP * 2),clientBounds.height - (searchBarBounds.y+searchBarBounds.height)));
551                         __pNoContentTextLabel->SetShowState(true);
552                 }
553
554                 if (pArgs != null)
555                 {
556                         pArgs->RemoveAll(true);
557                         delete pArgs;
558                 }
559
560                 if (__pSearchBar->GetMode() != SEARCH_BAR_MODE_INPUT)
561                 {
562                         __pSearchBar->SetMode(SEARCH_BAR_MODE_INPUT);
563                 }
564
565                 Invalidate(true);
566                 return;
567         }
568
569         if (__pNoContentTextLabel->GetShowState() == false)
570         {
571                 Invalidate(true);
572                 __pNoContentTextLabel->SetShowState(false);
573         }
574
575         if (pArgs != null)
576         {
577                 pArgs->RemoveAll(true);
578                 delete pArgs;
579         }
580         AppLogDebug("EXIT");
581 }
582
583 void
584 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
585                                                                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
586 {
587         AppLogDebug("ENTER");
588
589         if (__pSearchBar != null)
590         {
591                 __pSearchBar->HideKeypad();
592                 Invalidate(true);
593         }
594 //      __pPresentationModel->RemoveSearchResult();
595 //      __pSearchTableView->UpdateTableView();
596
597 //      if (__pSearchBar->GetKeypadAction() == true)
598 //      {
599 //              __pSearchBar->HideKeypad();
600 //      }
601 //
602 //      __pSearchBar->RemoveSearchBarEventListener(*this);
603 //      __pSearchBar->RemoveKeypadEventListener(*this);
604 //
605 //      __pSearchTableView->RemoveTableViewItemEventListener(*this);
606 //      __pSearchTableView->RemoveTouchEventListener(*this);
607 //      __pSearchTableView->RemoveScrollEventListener(*this);
608         AppLogDebug("EXIT");
609 }
610
611 void
612 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
613 {
614         AppLogDebug("ENTER");
615         SceneManager* pSceneManager = SceneManager::GetInstance();
616         AppAssert(pSceneManager);
617         AppLogDebug("OnActionPerformed : %d", actionId);
618         AppLogDebug("EXIT");
619 }
620
621 result
622 SearchForm::CreateGroupNameTableViewItem(Tizen::Ui::Controls::CustomItem* pItem, const Tizen::Base::String& GroupName)
623 {
624         AppLogDebug("ENTER");
625         result r = E_SUCCESS;
626         pItem->AddElement(Rectangle(10, 0, W_CLIENT_AREA, H_GROUP_NAME), IDA_GROUP_ITEM_ELEMENT, GroupName, MAIN_TEXT_SIZE, COLOR_GROUP_TEXT, COLOR_GROUP_TEXT, COLOR_GROUP_TEXT, true);
627         pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, COLOR_GROUP_NAME_BG);
628         pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED, COLOR_GROUP_NAME_BG);
629         pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, COLOR_GROUP_NAME_BG);
630         pItem->SetElementTextHorizontalAlignment(IDA_GROUP_ITEM_ELEMENT, ALIGNMENT_LEFT);
631         pItem->SetElementSelectionEnabled(IDA_GROUP_ITEM_ELEMENT, false);
632         AppLogDebug("EXIT");
633         return r;
634 }
635
636 Tizen::Base::String
637 SearchForm::MakeQuery(const Tizen::Base::String& WhereExpr, const Tizen::Base::String& SearchName)
638 {
639         AppLogDebug("ENTER");
640         if (WhereExpr == null || SearchName == null)
641         {
642                 return String();
643         }
644
645         String strMakeQuery = WhereExpr;
646
647         strMakeQuery.Append(L" like '%");
648         strMakeQuery.Append(SearchName);
649         strMakeQuery.Append(L"%'");
650
651         AppLogDebug("MakeQuery : %ls", strMakeQuery.GetPointer());
652         AppLogDebug("EXIT");
653         return strMakeQuery;
654 }
655
656 void
657 SearchForm::OnTouchDoublePressed (const Tizen::Ui::Control& source,
658                                         const Tizen::Graphics::Point& currentPosition,
659                                         const Tizen::Ui::TouchEventInfo& touchInfo)
660 {
661         AppLogDebug("ENTER");
662         AppLogDebug("EXIT");
663 }
664
665 void
666 SearchForm::OnTouchFocusIn (const Tizen::Ui::Control& source,
667                                         const Tizen::Graphics::Point& currentPosition,
668                                         const Tizen::Ui::TouchEventInfo& touchInfo)
669 {
670         AppLogDebug("ENTER");
671         AppLogDebug("EXIT");
672 }
673
674 void
675 SearchForm::OnTouchFocusOut (const Tizen::Ui::Control& source,
676                                         const Tizen::Graphics::Point& currentPosition,
677                                         const Tizen::Ui::TouchEventInfo& touchInfo)
678 {
679         AppLogDebug("ENTER");
680         AppLogDebug("EXIT");
681 }
682
683 void
684 SearchForm::OnTouchLongPressed (const Tizen::Ui::Control& source,
685                                         const Tizen::Graphics::Point& currentPosition,
686                                         const Tizen::Ui::TouchEventInfo& touchInfo)
687 {
688         AppLogDebug("ENTER");
689         AppLogDebug("EXIT");
690 }
691
692 void
693 SearchForm::OnTouchMoved (const Tizen::Ui::Control& source,
694                                         const Tizen::Graphics::Point& currentPosition,
695                                         const Tizen::Ui::TouchEventInfo& touchInfo)
696 {
697         AppLogDebug("ENTER");
698         AppLogDebug("EXIT");
699 }
700
701 void
702 SearchForm::OnTouchPressed (const Tizen::Ui::Control& source,
703                                         const Tizen::Graphics::Point& currentPosition,
704                                         const Tizen::Ui::TouchEventInfo& touchInfo)
705 {
706         AppLogDebug("ENTER");
707         AppLogDebug("EXIT");
708 }
709
710 void
711 SearchForm::OnTouchReleased (const Tizen::Ui::Control& source,
712                                         const Tizen::Graphics::Point& currentPosition,
713                                         const Tizen::Ui::TouchEventInfo& touchInfo)
714 {
715         AppLogDebug("ENTER");
716         AppLogDebug("EXIT");
717 }
718
719 void
720 SearchForm::OnScrollEndReached (Tizen::Ui::Control& source, Tizen::Ui::Controls::ScrollEndEvent type)
721 {
722         AppLogDebug( "ENTER");
723         AppLogDebug( "EXIT");
724 }
725
726 void
727 SearchForm::OnScrollPositionChanged (Tizen::Ui::Control& source, int scrollPos)
728 {
729         AppLogDebug( "ENTER");
730         AppLogDebug( "EXIT");
731 }
732
733 void
734 SearchForm::OnScrollStopped (Tizen::Ui::Control& source)
735 {
736         AppLogDebug( "ENTER");
737         AppLogDebug( "EXIT");
738 }
739
740 void
741 SearchForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
742 {
743         AppLogDebug("ENTER");
744         __pPresentationModel->RemoveSearchResult();
745         SceneManager* pSceneManager = SceneManager::GetInstance();
746         AppAssert(pSceneManager);
747         pSceneManager->GoForward(ForwardSceneTransition(__pSceneId->GetPointer(), SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
748         AppLogDebug("EXIT");
749 }
750
751 void
752 SearchForm::OnMusicContentUpdateCompleted(void)
753 {
754         AppLogDebug("ENTER");
755         if (__pSearchBar->GetText().GetLength() != INIT_VALUE)
756         {
757                 __pPresentationModel->InitializeContentList(__pSearchBar->GetText());
758         }
759         else
760         {
761                 __pPresentationModel->RemoveSearchResult();
762         }
763
764         if (__pSearchListView != null)
765         {
766                 __pSearchListView->UpdateList();
767                 __pSearchListView->ScrollToItem(INIT_VALUE);
768         }
769         AppLogDebug("EXIT");
770 }
771
772 void
773 SearchForm::OnFontSizeChanged(void)
774 {
775         __fontSizeValue = CommonUtil::GetFontSizeValue();
776         __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
777         __fontSize = CommonUtil::GetFontSize(__fontSizeValue);
778         __pSearchListView->UpdateList();
779 }
780
781 void
782 SearchForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
783 {
784         // Empty Implementation
785 }
786
787 void
788 SearchForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
789 {
790         // Empty Implementation
791 }
792
793 void
794 SearchForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
795 {
796         FloatRectangle clientRect = GetClientAreaBoundsF();
797         __pSearchBar->SetBounds(Rectangle(0, 0, clientRect.width, H_SEARCH_BAR));
798         FloatRectangle searchBarBounds = CoordinateSystem::AlignToDevice(FloatRectangle(__pSearchBar->GetBoundsF()));
799         __pSearchBar->SetContentAreaSize(FloatDimension(clientRect.width, clientRect.height - searchBarBounds.height));
800         __pSearchListView->SetSize(FloatDimension(clientRect.width, clientRect.height - __pSearchBar->GetHeightF()));
801         if (__pNoContentTextLabel != null)
802         {
803                 __pNoContentTextLabel->SetBounds(Rectangle(X_GAP,(searchBarBounds.y+searchBarBounds.height),GetWidth() - (X_GAP * 2),clientRect.height-(searchBarBounds.y+searchBarBounds.height)));
804         }
805         Invalidate(true);
806 }