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