d40de10bb63b945085a9e0b11c252e7ee239ec72
[apps/osp/Internet.git] / src / IntEditBookmarkListForm.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 //!Internet
19 /*@file:    EditBookmarkListForm
20  *@brief:       This class defines EditBookmarkListForm used to edit the bookmark
21  *
22  */
23
24 #include <FAppUiApp.h>
25 #include <FUi.h>
26
27 #include "IntBookmarkData.h"
28 #include "IntBookmarkPresentationModel.h"
29 #include "IntCommonLib.h"
30 #include "IntEditBookmarkListForm.h"
31 #include "IntFaviconManager.h"
32 #include "IntNotificationPanel.h"
33 #include "IntSceneRegister.h"
34 #include "IntTypes.h"
35
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Base::Runtime;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Ui;
42 using namespace Tizen::Ui::Controls;
43 using namespace Tizen::Ui::Scenes;
44
45 static const wchar_t* IDB_ICON_FOLDER_OPEN = L"I01_icon_folder_open.png";
46 static const wchar_t* IDB_ITEM = L"edit_item.png";
47 static const wchar_t* IDB_RIGHT_ARROW = L"I01_right_arrow.png";
48
49
50 const int EditBookmarkListForm::IDA_BUTTON_CHECKED = 101;
51 const int EditBookmarkListForm::IDA_TABBAR_ITEM_1 = 102;
52 const int EditBookmarkListForm::IDA_TABBAR_ITEM_2 = 103;
53 const int EditBookmarkListForm::IDA_DELETEITEM_CLICKED = 104;
54 const int EditBookmarkListForm::IDA_SHAREITEM_CLICKED = 105;
55 const int EditBookmarkListForm::IDA_CANCELITEM_CLICKED = 106;
56 const int EditBookmarkListForm::IDA_FORMAT_FOLDER = 107;
57 const int EditBookmarkListForm::IDA_FORMAT_SITE = 108;
58 const int EditBookmarkListForm::IDA_FORMAT_ICON = 109;
59 const int EditBookmarkListForm::IDA_FORMAT_BITMAP = 110;
60 const int EditBookmarkListForm::IDA_BUTTON_UNCHECKED = 111;
61 const int EditBookmarkListForm::IDA_FORMAT_URL = 112;
62
63
64 EditBookmarkListForm::EditBookmarkListForm(void)
65 {
66         __pListview = null;
67         __pData = null;
68         __pTimer = null;
69         __parentID = L"-1";
70         __pInfoPanel = null;
71         __pInfoLabel = null;
72         __selectedItemCount = 0;
73         __pCheckButton = null;
74         __pConfirmationPopup = null;
75         __pSelectedList = null;
76 }
77
78 EditBookmarkListForm::~EditBookmarkListForm(void)
79 {
80         if (__pData != null)
81         {
82                 __pData->RemoveAll(false);
83                 delete __pData;
84         }
85         if(__pSelectedList != null)
86         {
87                 __pSelectedList->RemoveAll(false);
88                 delete __pSelectedList;
89         }
90 }
91
92 bool
93 EditBookmarkListForm::Initialize(void)
94 {
95         Construct(L"IDL_EDIT_BOOKMARK_LIST");
96
97         return true;
98 }
99 result
100 EditBookmarkListForm::OnInitializing(void)
101 {
102         result r = E_SUCCESS;
103
104         Rectangle rc = GetClientAreaBounds();
105         String selected = CommonUtil::GetString(L"IDS_COM_OPT_SELECTED");
106
107         // Setup back event listener
108         SetFormBackEventListener(this);
109         AddOrientationEventListener(*this);
110
111         SceneManager* pSceneManager = SceneManager::GetInstance();
112
113         if (pSceneManager != null)
114         {
115                 pSceneManager->AddSceneEventListener(IDSCN_EDIT_BOOKMARK_LIST, *this);
116         }
117
118         Header* pHeader = GetHeader();
119
120         if (pHeader == NULL)
121         {
122                 return E_FAILURE;
123         }
124         pHeader->SetTitleText(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_BOOKMARK"));
125
126         __pCheckButton = static_cast< CheckButton* >(GetControl(
127                         L"IDC_SELECT_CHECKBUTTON", true));
128
129         if (__pCheckButton == null)
130         {
131                 return E_FAILURE;
132         }
133
134         __pCheckButton->SetActionId(IDA_BUTTON_CHECKED, IDA_BUTTON_UNCHECKED);
135         __pCheckButton->AddActionEventListener(*this);
136
137         __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
138
139         if (__pListview == null)
140         {
141                 return E_FAILURE;
142         }
143
144 //      __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), __pListview->GetWidth(), rc.height - 112 - 48);
145         __pListview->AddFastScrollListener(*this);
146         __pListview->AddListViewItemEventListener(*this);
147         __pListview->SetItemProvider(*this);
148
149
150         __pInfoPanel = static_cast< Panel* >(GetControl(
151                         L"IDC_INFO_PANEL", true));
152
153         if (__pInfoPanel == null)
154         {
155                 return E_FAILURE;
156         }
157
158 //      __pInfoPanel->SetBounds(Rectangle(0,rc.height - 48, rc.width, 48));
159
160         //SetControlAlwaysOnTop(*__pInfoPanel, true);
161
162         __pInfoLabel = static_cast< Label* >(GetControl(
163                         L"IDC_INFO_LABEL", true));
164
165         if (__pInfoLabel == null)
166         {
167                 return E_FAILURE;
168         }
169
170 //      __pInfoLabel->SetBounds(Rectangle(0,0,rc.width, 48));
171         selected.Append(L"(0)");
172         __pInfoLabel->SetText(selected);
173
174         __pInfoLabel->SetTextConfig(32,LABEL_TEXT_STYLE_BOLD);
175         //__pInfoLabel->SetBackgroundColor(CUSTOM_COLOR_INFO_LABEL);
176         __pInfoLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
177         __pInfoLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
178         GetFooter()->SetItemEnabled(0,false);
179         GetFooter()->AddActionEventListener(*this);
180         __pTimer = new (std::nothrow) Timer();
181         __pTimer->Construct(*this);
182
183         __pSelectedList = new(std::nothrow) ArrayList();
184                 __pSelectedList->Construct();
185         return r;
186 }
187
188 void
189 EditBookmarkListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
190 {
191         result r = E_SUCCESS;
192
193         SceneManager* pSceneManager = SceneManager::GetInstance();
194
195         switch (actionId)
196         {
197         case IDA_DELETEITEM_CLICKED:
198         {
199                 String labelString;
200                 int count = 0;
201                 if(__pListview == null)
202                 {
203                         return;
204                 }
205                 int totalCount = __pListview->GetItemCount();
206                 for (int count = 0;count < totalCount;count++)
207                 {
208                         if (__pListview->IsItemChecked(count))
209                         {
210                                 int id = 0;
211                                 String bookmarkId;
212                                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(count));
213                                 if (pBookMark == null)
214                                 {
215                                         return;
216                                 }
217                                 bookmarkId = pBookMark->GetBookmarkId();
218                                 Integer::Parse(bookmarkId,id);
219
220                                 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
221                                 {
222                                         r = BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
223                                         TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::OnActionPerformed BookmarkPresentationModel::GetInstance()->DeleteBookmark failed %s",GetErrorMessage(r));
224                                 }
225                                 else
226                                 {
227                                         r = BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
228                                         TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::OnActionPerformed BookmarkPresentationModel::GetInstance()->DeleteBookmark failed %s",GetErrorMessage(r));
229                                 }
230                         }
231                 }
232
233                 if (__pListview != null)
234                 {
235                         count = __pListview->GetItemCount();
236
237                         for(int index = 0; index < count ; index ++)
238                         {
239                                 if(__pListview->IsItemChecked(index) == true )
240                                 {
241                                         __pListview->SetItemChecked(index,false);
242                                 }
243                         }
244
245                         __pCheckButton->SetSelected(false);
246                         __pListview->UpdateList();
247
248                         if ( __pListview->GetItemCount() == 0)
249                         {
250                                 __pCheckButton->SetShowState(false);
251                                 __pCheckButton->Invalidate(true);
252                                 if (__pInfoPanel != null)
253                                 {
254                                         __pInfoPanel->SetShowState(false);
255                                 }
256                                 r = __pListview->SetBounds(__pListview->GetX(), 0, __pListview->GetWidth(), GetClientAreaBounds().height);
257                                 if (IsFailed(r))
258                                 {
259                                         return;
260                                 }
261
262
263                         }
264                 }
265                 GetFooter()->SetItemEnabled(0,false);
266                 GetFooter()->Invalidate(true);
267                 // removing all the element from selected list
268                 __pSelectedList->RemoveAll(false);
269                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
270                 labelString.Append(L"(0)");
271
272                 if (__pInfoPanel != null)
273                 {
274                         __pInfoLabel->SetText(labelString);
275                         __pInfoPanel->Draw();
276                         __pInfoPanel->Show();
277                 }
278
279                 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
280                 String notification = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
281                 pNotification->SetText(notification);
282                 pNotification->ShowNotification();
283
284
285                 if( __pListview->GetItemCount() == 0)
286                 {
287                         __pTimer->Start(1000);
288                 }
289         }
290         break;
291         case IDA_CANCELITEM_CLICKED:
292         {
293                 if ( __pTimer != NULL)
294                 {
295                         __pTimer->Cancel();
296                 }
297                 if(pSceneManager != NULL)
298                 {
299                         r = pSceneManager->GoBackward(BackwardSceneTransition());
300                 }
301                 if (IsFailed(r))
302                 {
303                         AppLogDebug("EditBookmarkListForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
304                         return;
305                 }
306         }
307         break;
308         case IDA_BUTTON_CHECKED:
309         {
310                 String labelString;
311                 bool flag = false;
312
313                 for (int count = 0;count < __pListview->GetItemCount();count++)
314                 {
315                         __pListview->SetItemChecked(count,true);
316                 }
317
318                 GetFooter()->SetItemEnabled(0,true);
319                 GetFooter()->Invalidate(true);
320
321                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
322                 labelString.Append(L"(");
323                 labelString.Append(__pListview->GetItemCount());
324                 labelString.Append(L")");
325
326                 __pInfoLabel->SetText(labelString);
327                 __pInfoPanel->Draw();
328                 __pInfoPanel->Show();
329
330                 int totalCount = __pData->GetCount();
331                 for(int index = 0; index <  totalCount; index++)
332                 {
333                         BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
334                         if (pBookMark == null)
335                         {
336
337                         }
338                         String *pBookmarkId = new(std::nothrow) String();
339                         if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
340                         {
341                                 pBookmarkId->Append("F");
342                         }
343                         else
344                         {
345                                 pBookmarkId->Append("U");
346                         }
347                         pBookmarkId->Append(pBookMark->GetBookmarkId());
348
349                         __pListview->SetItemChecked(index, true);
350                         __pSelectedList->Add(pBookmarkId);
351                 }
352         __pListview->Invalidate(true);
353         }
354         break;
355         case IDA_BUTTON_UNCHECKED:
356         {
357                 String labelString = L"";
358
359                 for (int count = 0;count < __pListview->GetItemCount();count++)
360                 {
361                         __pListview->SetItemChecked(count,false);
362                 }
363
364                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
365                 labelString.Append(L"(0)");
366                 __pInfoLabel->SetText(labelString);
367                 __pInfoPanel->Draw();
368                 __pInfoPanel->Show();
369                 __pSelectedList->RemoveAll(true);
370                 __pListview->Invalidate(true);
371
372                 GetFooter()->SetItemEnabled(0,false);
373                 GetFooter()->Invalidate(true);
374         }
375         break;
376         default:
377                 break;
378         }
379
380         CATCH: return ;
381 }
382
383 ListItemBase*
384 EditBookmarkListForm::CreateItem(int index, int itemWidth)
385 {
386         result r = E_SUCCESS;
387         ListAnnexStyle style = LIST_ANNEX_STYLE_MARK;
388         CustomItem* pItem = null;
389         BookmarkData* pBookMark = null;
390         Bitmap* pBitmap = null;
391         String bitmapId;
392         const int x_Margin_Url = 104;
393         const int y_Margin_Url = 70;
394         const int height_Url = 40;
395         const int width_Url = GetClientAreaBounds().width - 104 - 120 - 16 - 48;
396         const int itemHeight = 112;
397         const int textSize = 32;
398         const int width_Title = GetClientAreaBounds().width - 104 - 120 - 16 - 48;
399
400         pItem = new(std::nothrow) CustomItem();
401         if (pItem == null)
402         {
403                 return null;
404         }
405         pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
406         if (pBookMark == null)
407         {
408                 delete pItem;
409                 pItem = null;
410                 return null;
411         }
412         if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
413         {
414                 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 112), style);
415                 TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
416
417                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
418
419                 if (pBitmap != null)
420                 {
421                         pItem->AddElement(Rectangle(16, 26, 60, 60), IDA_FORMAT_ICON, *pBitmap, null);
422                         delete pBitmap;
423                 }
424
425                 pItem->AddElement(Rectangle(92, 8, width_Title/*__pListview->GetWidth() - 92 - 80*/, 112), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
426
427
428                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ITEM);
429
430                 if (pBitmap != null)
431                 {
432                         pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 80, 20, 60, 60), IDA_FORMAT_BITMAP, *pBitmap, null, null);
433                         pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
434                         delete pBitmap;
435                 }
436         }
437         else
438         {
439                 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 128), style);
440                 TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
441
442                 pBitmap = pBookMark->GetFavIconBitmap();
443
444                 if (pBitmap == null)
445                 {
446                         pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
447                 }
448
449                 pItem->AddElement(Rectangle(16, 28, 72, 72), IDA_FORMAT_ICON, *pBitmap, null);
450                 delete pBitmap;
451
452                 pItem->AddElement(Rectangle(104, 10, width_Title, itemHeight - height_Url), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(), true);
453                 pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url, width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,CUSTOM_COLOR_GREY,true);
454
455                 //pBitmap = AppResource::GetInstance()->GetBitmapN("I01_picker_arrow_right.png");
456                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_RIGHT_ARROW);
457                 if (pBitmap != null)
458                 {
459                         pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 84, 32, 64, 64), IDA_FORMAT_BITMAP, *pBitmap, null, null);
460                         pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
461                         delete pBitmap;
462                 }
463         }
464         return pItem;
465
466         CATCH:
467         delete pItem;
468         pItem = null;
469         return NULL;
470 }
471
472 bool
473 EditBookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
474 {
475         delete pItem;
476         pItem = null;
477         return true;
478 }
479
480 int
481 EditBookmarkListForm::GetItemCount(void)
482 {
483         int count = 0;
484         result r = E_SUCCESS;
485
486         BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
487
488         if (__pData != NULL)
489         {
490                 __pData->RemoveAll(true);
491                 delete __pData;
492                 __pData = NULL ;
493
494         }
495         __pData = new(std::nothrow) ArrayList();
496
497         if (__pData == null)
498         {
499                 return 0;
500         }
501
502         r = __pData->Construct();
503
504         TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::GetItemCount __pData->Construct() failed  %s",GetErrorMessage(r));
505
506         BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
507
508
509         if ( count == 0)
510         {
511                 if(__pCheckButton != null)
512                 {
513                         __pCheckButton->SetShowState(false);
514                 }
515                 if(__pInfoPanel != null)
516                 {
517                         __pInfoPanel->SetShowState(false);
518                 }
519                 __pListview->SetBounds(__pListview->GetX(), 0, __pListview->GetWidth(), GetClientAreaBounds().height);
520
521         }
522         else
523         {
524                 if(__pCheckButton != null)
525                 {
526                         __pCheckButton->SetShowState(true);
527                 }
528                 if(__pInfoPanel != null)
529                 {
530                         __pInfoPanel->SetShowState(true);
531                 }
532                 if(__pCheckButton != null && __pInfoPanel != null)
533                 __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), __pListview->GetWidth(), GetClientAreaBounds().height - __pCheckButton->GetHeight() - __pInfoPanel->GetHeight());
534
535         }
536         if(__pCheckButton != null)
537         {
538                 __pCheckButton->Invalidate(true);
539         }
540         if(__pInfoPanel != null)
541         {
542                 __pInfoPanel->Invalidate(false);
543         }
544
545         return count;
546
547         CATCH:
548         __pData->RemoveAll(true);
549         delete __pData;
550         __pData = null;
551         return 0;
552 }
553
554 void
555 EditBookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
556 {
557
558 }
559
560 void
561 EditBookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
562 {
563
564 }
565
566 void
567 EditBookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
568 {
569         String labelString;
570         __selectedItemCount = 0;
571         result r = E_SUCCESS;
572
573         switch (elementId)
574         {
575         case IDA_FORMAT_BITMAP:
576         {
577                 ArrayList* pArgList = null;
578                 SceneManager* pSceneManager = SceneManager::GetInstance();
579                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
580
581
582                 if(pBookMark == NULL)
583                 {
584                         return;
585                 }
586                 String *pBookmarkId = new(std::nothrow) String();
587                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
588                 {
589                         pBookmarkId->Append("F");
590                 }
591                 else
592                 {
593                         pBookmarkId->Append("U");
594                 }
595                 pBookmarkId->Append(pBookMark->GetBookmarkId());
596
597 //              if (__pListview->IsItemChecked(index) == true)
598 //              {
599 //                      __pListview->SetItemChecked(index, false);
600 //                      __pSelectedList->Remove(*pBookmarkId);
601 //              }
602 //              else
603 //              {
604 //                      __pListview->SetItemChecked(index, true);
605 //                      __pSelectedList->Add(pBookmarkId);
606 //              }
607
608                 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
609                 {
610                         pArgList = new(std::nothrow) ArrayList();
611
612                         if (pArgList != null)
613                         {
614                                 pArgList->Construct();
615                                 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
616                                 if ( pSceneManager != null)
617                                 {
618                                         result r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
619                                 }
620
621                                 if (pArgList != null)
622                                 {
623                                         pArgList->RemoveAll(false);
624                                         delete pArgList;
625                                         pArgList = null;
626                                 }
627                                 if(IsFailed(r))
628                                 {
629                                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
630                                         return;
631                                 }
632                         }
633                 }
634                 else
635                 {
636                         pArgList = new(std::nothrow) ArrayList();
637
638                         if (pArgList != null)
639                         {
640                                 pArgList->Construct();
641                                 pArgList->Add(*new(std::nothrow) String(L"1"));
642                                 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
643                                 if ( pSceneManager != null)
644                                 {
645                                         result r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK, SCENE_TRANSITION_ANIMATION_TYPE_NONE), pArgList);
646                                 }
647                                 if (pArgList != null)
648                                 {
649                                         pArgList->RemoveAll(false);
650                                         delete pArgList;
651                                         pArgList = null;
652                                 }
653                                 if(IsFailed(r))
654                                 {
655                                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
656                                         return;
657                                 }
658                         }
659                 }
660         }
661         break;
662
663         default:
664         {
665                 int count = 0;
666                 bool flag = false;
667                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
668
669
670                 if(pBookMark == NULL)
671                 {
672                         return;
673                 }
674                 String *pBookmarkId = new(std::nothrow) String();
675                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
676                 {
677                         pBookmarkId->Append("F");
678                 }
679                 else
680                 {
681                         pBookmarkId->Append("U");
682                 }
683                 pBookmarkId->Append(pBookMark->GetBookmarkId());
684
685                 if (__pListview->IsItemChecked(index) == false)
686                 {
687                         __pSelectedList->Remove(*pBookmarkId);
688                 }
689                 else
690                 {
691                         __pSelectedList->Add(pBookmarkId);
692                 }
693
694
695                 int itemCount = __pListview->GetItemCount();
696                 for (int count = 0;count < itemCount ; count++)
697                 {
698                         if (__pListview->IsItemChecked(count))
699                         {
700                                 __selectedItemCount++;
701                         }
702                 }
703
704                 //labelString.Append(__selectedItemCount);
705                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
706                 labelString.Append(L"(");
707                 labelString.Append(__selectedItemCount);
708                 labelString.Append(L")");
709                 __pInfoLabel->SetText(labelString);
710                 __pInfoPanel->Draw();
711                 __pInfoPanel->Show();
712                 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID,count);
713                 if (__selectedItemCount == count)
714                 {
715                         __pCheckButton->SetSelected(true);
716                 }
717                 else
718                 {
719                         __pCheckButton->SetSelected(false);
720                 }
721
722                 itemCount = __pListview->GetItemCount();
723                 for (int count = 0;count < itemCount ;count++)
724                 {
725                         if (__pListview->IsItemChecked(count))
726                         {
727                                 flag = true;
728                                 break;
729                         }
730                 }
731
732                 if (flag == true)
733                 {
734                         GetFooter()->SetItemEnabled(0,true);
735                 }
736                 else
737                 {
738                         GetFooter()->SetItemEnabled(0,false);
739                 }
740
741                 GetFooter()->Invalidate(true);
742
743         }
744         break;
745         }
746 }
747
748 void
749 EditBookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
750 {
751
752 }
753
754 void
755 EditBookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
756 {
757
758 }
759 void
760 EditBookmarkListForm::OnListViewItemReordered(Tizen::Ui::Controls::ListView& listView, int indexFrom, int indexTo)
761 {
762
763 }
764
765 void
766 EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
767 {
768         result r = E_FAILURE;
769         String labelString ;
770         int count = 0;
771         BookmarkData* pBookMark = null;
772
773         if (pArgs != null)
774         {
775                 __parentID.Clear();
776                 String* pStr = dynamic_cast<String*>(pArgs->GetAt(0));
777                 if(pStr == null)
778                 {
779                         return;
780                 }
781                 __parentID.Append(pStr->GetPointer());
782         }
783
784         __selectedItemCount = 0;
785
786         labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
787         labelString.Append(L"(");
788         labelString.Append(__pSelectedList->GetCount());
789         labelString.Append(L")");
790         __pInfoLabel->SetText(labelString);
791         __pListview->UpdateList();
792
793         count = __pListview->GetItemCount();
794
795         for(int index = 0 ; index < count ; index++)
796         {
797                 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
798
799                 if(pBookMark == NULL)
800                 {
801                         return;
802                 }
803                 String *pBookmarkId = new(std::nothrow) String();
804                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
805                 {
806                         pBookmarkId->Append("F");
807                 }
808                 else
809                 {
810                         pBookmarkId->Append("U");
811                 }
812                 pBookmarkId->Append(pBookMark->GetBookmarkId());
813
814                 AppLog("BookmarkId: %ls", pBookmarkId->GetPointer());
815
816                 if(__pSelectedList->Contains(*pBookmarkId))
817                 {
818                         __pListview->SetItemChecked(index,true);
819                         __selectedItemCount++;
820                 }
821                 else
822                 {
823                         __pListview->SetItemChecked(index,false);
824                 }
825         }
826         if(__selectedItemCount < __pListview->GetItemCount())
827         {
828                 __pCheckButton->SetSelected(false);
829                 GetFooter()->SetItemEnabled(0, false);
830                 GetFooter()->Invalidate(true);
831         }
832         else
833         {
834                 __pCheckButton->SetSelected(true);
835                 GetFooter()->SetItemEnabled(0, true);
836                 GetFooter()->Invalidate(true);
837         }
838
839
840         __pInfoPanel->Draw();
841         __pInfoPanel->Show();
842
843         Invalidate(true);
844
845 }
846
847 void
848 EditBookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
849 {
850
851 }
852
853 void
854 EditBookmarkListForm::OnFormBackRequested(Form& source)
855 {
856         SceneManager* pSceneManager = SceneManager::GetInstance();
857
858         if ( __pTimer != NULL)
859         {
860                 __pTimer->Cancel();
861         }
862
863         if (pSceneManager != null)
864         {
865                 //pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
866                 result r = pSceneManager->GoBackward(BackwardSceneTransition());
867                 if(IsFailed(r))
868                 {
869                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
870                         return;
871                 }
872
873         }
874         GetFooter()->Invalidate(true);
875 }
876
877
878 void EditBookmarkListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
879 {
880         int itemCount = 0;
881         ArrayList* pCheckedItems  = NULL ;
882
883         if (__pListview != null)
884         {
885                 AppLog("the list Y axis is %d", __pListview->GetY());
886                 pCheckedItems  = new(std::nothrow) ArrayList();
887                 pCheckedItems->Construct();
888                 if ( __pListview->GetItemCount() == 0)
889                 {
890                         __pCheckButton->SetShowState(false);
891                         __pInfoPanel->SetShowState(false);
892                         __pListview->SetBounds(0, __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height -__pListview->GetY());
893
894                 }
895                 else
896                 {
897                         AppLog("EditBookmarkListForm::OnOrientationChanged 1");
898                         __pCheckButton->SetShowState(true);
899                         __pInfoPanel->SetShowState(true);
900                         __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), __pListview->GetWidth(), GetClientAreaBounds().height - __pCheckButton->GetHeight() - __pInfoPanel->GetHeight());
901                         __pInfoLabel->SetBounds(__pInfoLabel->GetX(),__pInfoLabel->GetY(), GetClientAreaBounds().width,__pInfoLabel->GetHeight());
902                         __pInfoLabel->Invalidate(true);
903                 }
904                 __pCheckButton->Invalidate(true);
905
906                 itemCount = __pListview->GetItemCount();
907
908                 for (int count = 0;count < itemCount ; count++)
909                 {
910
911                         if (__pListview->IsItemChecked(count))
912                         {
913                                 pCheckedItems->Add(* new Integer(count));
914                         }
915                 }
916
917                 __pListview->UpdateList();
918
919                 for (int count = 0;count < itemCount ;count++)
920                 {
921                         if (pCheckedItems->Contains(* new Integer(count)) == true)
922                         {
923                                 __pListview->SetItemChecked(count, true);
924                         }
925                 }
926                 if ( pCheckedItems != NULL )
927                 {
928                         pCheckedItems->RemoveAll(true);
929                         delete pCheckedItems;
930                 }
931                 Invalidate(true);
932         }
933 }
934
935 void
936 EditBookmarkListForm::OnTimerExpired(Timer&  timer)
937 {
938         SceneManager* pSceneManager = SceneManager::GetInstance();
939
940         if ( pSceneManager != NULL)
941         {
942                 result r = pSceneManager->GoBackward(BackwardSceneTransition());
943                 if(IsFailed(r))
944                 {
945                         AppLogDebug("EditBookmarkListForm::OnTimerExpired GoBackward failed %s",GetErrorMessage(r));
946                 }
947         }
948 }