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