2b7a2f0082639e6d9a2ebd606595535025b726cb
[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 //      if (itemIndex < __pPresentationModel->GetAlbumIndex())
514         else//artist item
515         {
516                 pContentInfo = __pPresentationModel->GetContentInfoN(itemIndex);
517
518                 ArrayList* pData = new (std::nothrow) ArrayList();
519                 pData->Construct();
520                 pData->Add(*(new (std::nothrow) String(IDSCN_ARTIST_LIST)));
521                 pData->Add(*(new (std::nothrow) String(pContentInfo->ArtistName)));
522
523                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ARTIST_CONTENT_LIST), pData);
524         }
525
526         delete pContentInfo;
527         pContentInfo = null;
528         AppLogDebug("EXIT");
529 }
530
531 void
532 SearchForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView,
533                                                                         int itemIndex,
534                                                                         Tizen::Ui::Controls::TableViewContextItem* pContextItem,
535                                                                         bool activated)
536 {
537         AppLogDebug("ENTER");
538         AppLogDebug("EXIT");
539 }
540
541 void
542 SearchForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView,
543                                                 int itemIndexFrom,
544                                                 int itemIndexTo)
545 {
546         AppLogDebug("ENTER");
547         AppLogDebug("EXIT");
548 }
549
550 void
551 SearchForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
552                                                                 const Tizen::Ui::Scenes::SceneId& currentSceneId,
553                                                                 Tizen::Base::Collection::IList* pArgs)
554 {
555         AppLogDebug("ENTER");
556         if (__pSceneId == null)
557         {
558                 __pSceneId = new (std::nothrow) String(previousSceneId);
559         }
560
561         if (__pPresentationModel->GetTotalContentCount() == 0)
562         {
563                 if (__pNoContentTextLabel == null)
564                 {
565                         Rectangle clientBounds = GetClientAreaBounds();
566                         __pNoContentTextLabel = new (std::nothrow) Label();
567                         __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"));
568                         __pNoContentTextLabel->SetTextConfig(SEARCH_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
569                         AddControl(__pNoContentTextLabel);
570                 }
571                 else
572                 {
573                         __pNoContentTextLabel->SetBounds(Rectangle(X_GAP,(GetClientAreaBounds().height - H_NO_CONTENT)/2,GetWidth() - (X_GAP * 2),H_NO_CONTENT));
574                         __pNoContentTextLabel->SetShowState(true);
575                 }
576
577                 if (pArgs != null)
578                 {
579                         pArgs->RemoveAll(true);
580                         delete pArgs;
581                 }
582
583                 if (__pSearchBar->GetMode() != SEARCH_BAR_MODE_INPUT)
584                 {
585                         __pSearchBar->SetMode(SEARCH_BAR_MODE_INPUT);
586                 }
587
588                 Invalidate(true);
589                 return;
590         }
591
592         if (__pNoContentTextLabel->GetShowState() == false)
593         {
594                 Invalidate(true);
595                 __pNoContentTextLabel->SetShowState(false);
596         }
597
598         if (pArgs != null)
599         {
600                 pArgs->RemoveAll(true);
601                 delete pArgs;
602         }
603         AppLogDebug("EXIT");
604 }
605
606 void
607 SearchForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
608                                                                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
609 {
610         AppLogDebug("ENTER");
611
612         if (__pSearchBar != null)
613         {
614                 __pSearchBar->HideKeypad();
615                 Invalidate(true);
616         }
617 //      __pPresentationModel->RemoveSearchResult();
618 //      __pSearchTableView->UpdateTableView();
619
620 //      if (__pSearchBar->GetKeypadAction() == true)
621 //      {
622 //              __pSearchBar->HideKeypad();
623 //      }
624 //
625 //      __pSearchBar->RemoveSearchBarEventListener(*this);
626 //      __pSearchBar->RemoveKeypadEventListener(*this);
627 //
628 //      __pSearchTableView->RemoveTableViewItemEventListener(*this);
629 //      __pSearchTableView->RemoveTouchEventListener(*this);
630 //      __pSearchTableView->RemoveScrollEventListener(*this);
631         AppLogDebug("EXIT");
632 }
633
634 void
635 SearchForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
636 {
637         AppLogDebug("ENTER");
638         SceneManager* pSceneManager = SceneManager::GetInstance();
639         AppAssert(pSceneManager);
640         AppLogDebug("OnActionPerformed : %d", actionId);
641         AppLogDebug("EXIT");
642 }
643
644 result
645 SearchForm::CreateGroupNameTableViewItem(Tizen::Ui::Container& parent, const Tizen::Base::String& GroupName)
646 {
647         AppLogDebug("ENTER");
648         result r = E_SUCCESS;
649
650         Label* pGroupNameLabel = new (std::nothrow) Label();
651         pGroupNameLabel->Construct(Rectangle(0, 0, W_CLIENT_AREA, H_GROUP_NAME), L"");
652         pGroupNameLabel->SetBackgroundColor(COLOR_GROUP_NAME_BG);
653         pGroupNameLabel->SetTextColor(COLOR_GROUP_TEXT);
654         pGroupNameLabel->SetTextConfig(MAIN_TEXT_SIZE, LABEL_TEXT_STYLE_NORMAL);
655         pGroupNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
656         pGroupNameLabel->SetText(GroupName);
657
658         parent.AddControl(pGroupNameLabel);
659
660         AppLogDebug("EXIT");
661         return r;
662 }
663
664 Tizen::Base::String
665 SearchForm::MakeQuery(const Tizen::Base::String& WhereExpr, const Tizen::Base::String& SearchName)
666 {
667         AppLogDebug("ENTER");
668         if (WhereExpr == null || SearchName == null)
669         {
670                 return null;
671         }
672
673         String StrMakeQuery = WhereExpr;
674
675         StrMakeQuery.Append(L" like '%");
676         StrMakeQuery.Append(SearchName);
677         StrMakeQuery.Append(L"%'");
678
679         AppLogDebug("MakeQuery : %ls", StrMakeQuery.GetPointer());
680         AppLogDebug("EXIT");
681         return StrMakeQuery;
682 }
683
684 void
685 SearchForm::OnTouchDoublePressed (const Tizen::Ui::Control& source,
686                                         const Tizen::Graphics::Point& currentPosition,
687                                         const Tizen::Ui::TouchEventInfo& touchInfo)
688 {
689         AppLogDebug("ENTER");
690         AppLogDebug("EXIT");
691 }
692
693 void
694 SearchForm::OnTouchFocusIn (const Tizen::Ui::Control& source,
695                                         const Tizen::Graphics::Point& currentPosition,
696                                         const Tizen::Ui::TouchEventInfo& touchInfo)
697 {
698         AppLogDebug("ENTER");
699         AppLogDebug("EXIT");
700 }
701
702 void
703 SearchForm::OnTouchFocusOut (const Tizen::Ui::Control& source,
704                                         const Tizen::Graphics::Point& currentPosition,
705                                         const Tizen::Ui::TouchEventInfo& touchInfo)
706 {
707         AppLogDebug("ENTER");
708         AppLogDebug("EXIT");
709 }
710
711 void
712 SearchForm::OnTouchLongPressed (const Tizen::Ui::Control& source,
713                                         const Tizen::Graphics::Point& currentPosition,
714                                         const Tizen::Ui::TouchEventInfo& touchInfo)
715 {
716         AppLogDebug("ENTER");
717         AppLogDebug("EXIT");
718 }
719
720 void
721 SearchForm::OnTouchMoved (const Tizen::Ui::Control& source,
722                                         const Tizen::Graphics::Point& currentPosition,
723                                         const Tizen::Ui::TouchEventInfo& touchInfo)
724 {
725         AppLogDebug("ENTER");
726         AppLogDebug("EXIT");
727 }
728
729 void
730 SearchForm::OnTouchPressed (const Tizen::Ui::Control& source,
731                                         const Tizen::Graphics::Point& currentPosition,
732                                         const Tizen::Ui::TouchEventInfo& touchInfo)
733 {
734         AppLogDebug("ENTER");
735         AppLogDebug("EXIT");
736 }
737
738 void
739 SearchForm::OnTouchReleased (const Tizen::Ui::Control& source,
740                                         const Tizen::Graphics::Point& currentPosition,
741                                         const Tizen::Ui::TouchEventInfo& touchInfo)
742 {
743         AppLogDebug("ENTER");
744         AppLogDebug("EXIT");
745 }
746
747 void
748 SearchForm::OnScrollEndReached (Tizen::Ui::Control& source, Tizen::Ui::Controls::ScrollEndEvent type)
749 {
750         AppLogDebug( "ENTER");
751         AppLogDebug( "EXIT");
752 }
753
754 void
755 SearchForm::OnScrollPositionChanged (Tizen::Ui::Control& source, int scrollPos)
756 {
757         AppLogDebug( "ENTER");
758         AppLogDebug( "EXIT");
759 }
760
761 void
762 SearchForm::OnScrollStopped (Tizen::Ui::Control& source)
763 {
764         AppLogDebug( "ENTER");
765         AppLogDebug( "EXIT");
766 }
767
768 void
769 SearchForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
770 {
771         AppLogDebug("ENTER");
772         __pPresentationModel->RemoveSearchResult();
773         SceneManager* pSceneManager = SceneManager::GetInstance();
774         AppAssert(pSceneManager);
775
776         __pSearchTableView->SetItemProvider(static_cast<ITableViewItemProvider*>(null));
777         pSceneManager->GoForward(ForwardSceneTransition(__pSceneId->GetPointer(), SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY));
778         AppLogDebug("EXIT");
779 }
780
781 void
782 SearchForm::OnMusicContentUpdateCompleted(void)
783 {
784         AppLogDebug("ENTER");
785         if (__pSearchBar->GetText().GetLength() != INIT_VALUE)
786         {
787                 __pPresentationModel->InitializeContentList(__pSearchBar->GetText());
788         }
789         else
790         {
791                 __pPresentationModel->RemoveSearchResult();
792         }
793
794         if (__pSearchTableView != null)
795         {
796                 __pSearchTableView->UpdateTableView();
797                 __pSearchTableView->ScrollToItem(INIT_VALUE);
798         }
799         AppLogDebug("EXIT");
800 }
801
802 void
803 SearchForm::OnFontSizeChanged(void)
804 {
805         __fontSizeValue = CommonUtil::GetFontSizeValue();
806         __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
807         __fontSize = CommonUtil::GetFontSize(__fontSizeValue);
808         __pSearchTableView->UpdateTableView();
809 }