Fixed Nabi Issues N_SE-56966,56735
[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.1 (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 "IntSceneRegister.h"
33 #include "IntTypes.h"
34
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Base::Runtime;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43
44 static const wchar_t* IDB_ICON_FOLDER_OPEN = L"I01_icon_folder_open.png";
45 static const wchar_t* IDB_ITEM = L"edit_item.png";
46 static const wchar_t* IDB_RIGHT_ARROW = L"00_circle_bg_ef.png";
47 static const wchar_t* IDB_RIGHT_ARROW_PRESS = L"00_circle_bg_ef_press.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"0";
70         __pInfoPanel = null;
71         __pInfoLabel = null;
72         __selectedItemCount = 0;
73         __pCheckButton = null;
74         __pConfirmationPopup = null;
75         __pSelectedList = null;
76         __fontSize = 44;
77         __pNotification = null;
78 }
79
80 EditBookmarkListForm::~EditBookmarkListForm(void)
81 {
82         if (__pData != null)
83         {
84                 __pData->RemoveAll(false);
85                 delete __pData;
86         }
87         if(__pSelectedList != null)
88         {
89                 __pSelectedList->RemoveAll(false);
90                 delete __pSelectedList;
91         }
92 //      if(__pNotification)
93 //              delete __pNotification;
94 }
95
96 bool
97 EditBookmarkListForm::Initialize(void)
98 {
99         Construct(L"IDL_EDIT_BOOKMARK_LIST");
100
101         return true;
102 }
103 result
104 EditBookmarkListForm::OnInitializing(void)
105 {
106         result r = E_SUCCESS;
107
108         Rectangle rc = GetClientAreaBounds();
109         String selected = CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED");
110
111         // Setup back event listener
112         SetFormBackEventListener(this);
113         AddOrientationEventListener(*this);
114
115         SceneManager* pSceneManager = SceneManager::GetInstance();
116
117         if (pSceneManager != null)
118         {
119                 pSceneManager->AddSceneEventListener(IDSCN_EDIT_BOOKMARK_LIST, *this);
120         }
121
122         __fontSize = CommonUtil::GetFontSize();
123         Header* pHeader = GetHeader();
124
125         if (pHeader == NULL)
126         {
127                 return E_FAILURE;
128         }
129         pHeader->SetTitleText(CommonUtil::GetString(L"IDS_BR_HEADER_EDIT_BOOKMARK"));
130
131         __pCheckButton = static_cast< CheckButton* >(GetControl(
132                         L"IDC_SELECT_CHECKBUTTON", true));
133
134         if (__pCheckButton == null)
135         {
136                 return E_FAILURE;
137         }
138
139         __pCheckButton->SetActionId(IDA_BUTTON_CHECKED, IDA_BUTTON_UNCHECKED);
140         __pCheckButton->AddActionEventListener(*this);
141
142         __pListview = static_cast< ListView* >(GetControl("IDC_LISTVIEW1"));
143
144         if (__pListview == null)
145         {
146                 return E_FAILURE;
147         }
148
149         __pListview->AddFastScrollListener(*this);
150         __pListview->AddListViewItemEventListener(*this);
151         __pListview->SetItemProvider(*this);
152
153         __pInfoPanel = static_cast< Panel* >(GetControl(
154                         L"IDC_INFO_PANEL", true));
155
156         if (__pInfoPanel == null)
157         {
158                 return E_FAILURE;
159         }
160
161         __pInfoLabel = static_cast< Label* >(GetControl(
162                         L"IDC_INFO_LABEL", true));
163
164         if (__pInfoLabel == null)
165         {
166                 return E_FAILURE;
167         }
168
169 //      __pInfoLabel->SetBounds(Rectangle(0,0,rc.width, 48));
170         //selected.Append(L"(0)");
171         selected.Format(25, selected.GetPointer() , 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                 if(__pConfirmationPopup)
199                 {
200                         delete __pConfirmationPopup;
201                         __pConfirmationPopup = null;
202                 }
203                 if (!__pConfirmationPopup)
204                 {
205                         String closeWarning = CommonUtil::GetString(L"IDS_BR_SK3_DELETE");
206                         __pConfirmationPopup = new(std::nothrow) ConfirmationPopup();
207                         __pConfirmationPopup->Initialize();
208
209                         __pConfirmationPopup->RemoveActionListener(*this);
210                         __pConfirmationPopup->AddActionListener(*this);
211                         __pConfirmationPopup->setMessage(closeWarning);
212                         __pConfirmationPopup->Show();
213                 }
214                 break;
215         case IDA_BUTTON_NO:
216                 if(__pConfirmationPopup)
217                 {
218                         __pConfirmationPopup->SetShowState(false);
219                         __pConfirmationPopup->Show();
220                         delete __pConfirmationPopup;
221                         __pConfirmationPopup = null;
222                 }
223                 break;
224         case IDA_BUTTON_YES:
225         {
226                 String labelString;
227                 int count = 0;
228                 if(__pListview == null)
229                 {
230                         return;
231                 }
232                 int totalCount = __pListview->GetItemCount();
233                 for (int count = 0;count < totalCount;count++)
234                 {
235                         if (__pListview->IsItemChecked(count))
236                         {
237                                 int id = 0;
238                                 String bookmarkId;
239                                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(count));
240                                 if (pBookMark == null)
241                                 {
242                                         return;
243                                 }
244                                 bookmarkId = pBookMark->GetBookmarkId();
245                                 Integer::Parse(bookmarkId,id);
246
247                                 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_URL)
248                                 {
249                                         r = BookmarkPresentationModel::GetInstance()->DeleteBookmark(id);
250                                         TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::OnActionPerformed BookmarkPresentationModel::GetInstance()->DeleteBookmark failed %s",GetErrorMessage(r));
251                                 }
252                                 else
253                                 {
254                                         r = BookmarkPresentationModel::GetInstance()->DeleteFolder(id);
255                                         TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::OnActionPerformed BookmarkPresentationModel::GetInstance()->DeleteBookmark failed %s",GetErrorMessage(r));
256                                 }
257                         }
258                 }
259
260                 if (__pListview != null)
261                 {
262                         count = __pListview->GetItemCount();
263
264                         for(int index = 0; index < count ; index ++)
265                         {
266                                 if(__pListview->IsItemChecked(index) == true )
267                                 {
268                                         __pListview->SetItemChecked(index,false);
269                                 }
270                         }
271
272                         __pCheckButton->SetSelected(false);
273                         __pListview->UpdateList();
274
275                         if ( __pListview->GetItemCount() == 0)
276                         {
277                                 __pCheckButton->SetShowState(false);
278                                 __pCheckButton->Invalidate(true);
279                                 if (__pInfoPanel != null)
280                                 {
281                                         __pInfoPanel->SetShowState(false);
282                                 }
283                                 r = __pListview->SetBounds(__pListview->GetX(), 0, __pListview->GetWidth(), GetClientAreaBounds().height);
284                                 if (IsFailed(r))
285                                 {
286                                         return;
287                                 }
288
289
290                         }
291                 }
292                 GetFooter()->SetItemEnabled(0,false);
293                 GetFooter()->Invalidate(true);
294                 // removing all the element from selected list
295                 __pSelectedList->RemoveAll(false);
296
297                 labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , 0);
298
299                 /*labelString.Append(CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED"));
300                 labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
301                 labelString.Append(L"(0)");*/
302
303                 if (__pInfoPanel != null)
304                 {
305                         __pInfoLabel->SetText(labelString);
306                         __pInfoPanel->Draw();
307                         __pInfoPanel->Show();
308                 }
309
310 //              if(__pNotification)
311 //              {
312 ////                    delete __pNotification;
313 //                      __pNotification = null;
314 //              }
315                 __pNotification = new (std::nothrow) NotificationPanel(*this);
316                 String notification = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
317                 __pNotification->SetText(notification);
318                 __pNotification->ShowNotification();
319
320                 if(__pConfirmationPopup)
321                 {
322                         delete __pConfirmationPopup;
323                         __pConfirmationPopup = null;
324                 }
325                 if( __pListview->GetItemCount() == 0)
326                 {
327                         __pTimer->Start(1000);
328                 }
329         }
330         break;
331         case IDA_CANCELITEM_CLICKED:
332         {
333                 if ( __pTimer != NULL)
334                 {
335                         __pTimer->Cancel();
336                 }
337                 if(pSceneManager != NULL)
338                 {
339                         r = pSceneManager->GoBackward(BackwardSceneTransition());
340                 }
341                 if (IsFailed(r))
342                 {
343                         AppLogDebug("EditBookmarkListForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
344                         return;
345                 }
346         }
347         break;
348         case IDA_BUTTON_CHECKED:
349         {
350                 String labelString;
351                 bool flag = false;
352
353                 for (int count = 0;count < __pListview->GetItemCount();count++)
354                 {
355                         __pListview->SetItemChecked(count,true);
356                 }
357
358                 GetFooter()->SetItemEnabled(0,true);
359                 GetFooter()->Invalidate(true);
360
361                 if(__pListview->GetItemCount() >1)
362                 {
363                         labelString.Format(25, CommonUtil::GetString(L"IDS_BR_POP_PD_ITEMS_SELECTED").GetPointer() , __pListview->GetItemCount());
364                 }
365                 else
366                 {
367                         labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __pListview->GetItemCount());
368                 }
369
370                 __selectedItemCount = 0;
371
372                 __pInfoLabel->SetText(labelString);
373                 __pInfoPanel->Draw();
374                 __pInfoPanel->Show();
375
376                 __pSelectedList->RemoveAll();
377                 int totalCount = __pData->GetCount();
378                 for(int index = 0; index <  totalCount; index++)
379                 {
380                         BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
381                         if (pBookMark == null)
382                         {
383                                 continue;
384                         }
385                         String *pBookmarkId = new(std::nothrow) String();
386                         if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
387                         {
388                                 pBookmarkId->Append("F");
389                         }
390                         else
391                         {
392                                 pBookmarkId->Append("U");
393                         }
394                         pBookmarkId->Append(pBookMark->GetBookmarkId());
395
396                         __pListview->SetItemChecked(index, true);
397                         __pSelectedList->Add(pBookmarkId);
398                 }
399         __pListview->Invalidate(true);
400         }
401         break;
402         case IDA_BUTTON_UNCHECKED:
403         {
404                 String labelString = L"";
405
406                 for (int count = 0;count < __pListview->GetItemCount();count++)
407                 {
408                         __pListview->SetItemChecked(count,false);
409                 }
410
411                 /*labelString.Append(CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED"));
412                 labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
413                 labelString.Append(L"(0)");*/
414
415                 labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , 0);
416
417                 __pInfoLabel->SetText(labelString);
418                 __pInfoPanel->Draw();
419                 __pInfoPanel->Show();
420                 __pSelectedList->RemoveAll(true);
421                 __pListview->Invalidate(true);
422
423                 GetFooter()->SetItemEnabled(0,false);
424                 GetFooter()->Invalidate(true);
425         }
426         break;
427         default:
428                 break;
429         }
430
431         CATCH: return ;
432 }
433
434 ListItemBase*
435 EditBookmarkListForm::CreateItem(int index, int itemWidth)
436 {
437         result r = E_SUCCESS;
438         ListAnnexStyle style = LIST_ANNEX_STYLE_MARK;
439         CustomItem* pItem = null;
440         BookmarkData* pBookMark = null;
441         Bitmap* pBitmap = null;
442         String bitmapId;
443         const int x_Margin_Url = 104;
444         const int y_Margin_Url = 70;
445         const int height_Url = 40;
446         const int width_Url = GetClientAreaBounds().width - 104 - 120 - 16 - 48;
447         const int itemHeight = 112;
448         const int textSize = 32;
449         const int width_Title = GetClientAreaBounds().width - 104 - 120 - 16 - 48;
450
451         pItem = new(std::nothrow) CustomItem();
452         if (pItem == null)
453         {
454                 return null;
455         }
456         pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
457         if (pBookMark == null)
458         {
459                 delete pItem;
460                 pItem = null;
461                 return null;
462         }
463         if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
464         {
465                 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 112 - 44 + __fontSize), style);
466                 TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
467
468                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
469
470                 if (pBitmap != null)
471                 {
472                         pItem->AddElement(Rectangle(16, 26+(__fontSize - 44)/2, 60, 60), IDA_FORMAT_ICON, *pBitmap, null);
473                         delete pBitmap;
474                 }
475
476                 pItem->AddElement(Rectangle(92, 8, width_Title/*__pListview->GetWidth() - 92 - 80*/, 112 + (__fontSize - 44)), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(),__fontSize, CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
477
478                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ITEM);
479
480                 if (pBitmap != null)
481                 {
482                         pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 80, 20 + (__fontSize - 44)/2, 60, 60), IDA_FORMAT_BITMAP, *pBitmap, null, null);
483                         pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
484                         delete pBitmap;
485                 }
486         }
487         else
488         {
489                 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 128 + (__fontSize - 44)), style);
490                 TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
491
492                 pBitmap = pBookMark->GetFavIconBitmap();
493
494                 if (pBitmap == null)
495                 {
496                         pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
497                 }
498
499                 pItem->AddElement(Rectangle(16, 28 + (__fontSize - 44)/2, 72, 72), IDA_FORMAT_ICON, *pBitmap, null);
500                 delete pBitmap;
501
502                 pItem->AddElement(Rectangle(104, 10, width_Title, itemHeight - height_Url + (__fontSize - 44)), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(),__fontSize,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,CUSTOM_COLOR_TRANSPARENT,true);
503                 pItem->AddElement(Rectangle(x_Margin_Url, y_Margin_Url + (__fontSize - 44), width_Url, height_Url), IDA_FORMAT_URL, pBookMark->GetUrl(),textSize,CUSTOM_COLOR_GREY,CUSTOM_COLOR_LISTVIEW_TEXT,CUSTOM_COLOR_LISTVIEW_TEXT,true);
504
505                 //pBitmap = AppResource::GetInstance()->GetBitmapN("I01_picker_arrow_right.png");
506                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_RIGHT_ARROW);
507                 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_RIGHT_ARROW_PRESS);
508                 if (pBitmap != null && pPressedBitmap != null)
509                 {
510                         pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 84-4, 32 + (__fontSize - 44)/2-4, 72, 72), IDA_FORMAT_BITMAP, *pBitmap, pPressedBitmap, null);
511                         pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
512                         delete pBitmap;
513                         delete pPressedBitmap;
514                 }
515         }
516         return pItem;
517
518         CATCH:
519         delete pItem;
520         pItem = null;
521         return NULL;
522 }
523
524 bool
525 EditBookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
526 {
527         delete pItem;
528         pItem = null;
529         return true;
530 }
531
532 int
533 EditBookmarkListForm::GetItemCount(void)
534 {
535         int count = 0;
536         result r = E_SUCCESS;
537
538         BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
539
540         if (__pData != NULL)
541         {
542                 __pData->RemoveAll(true);
543                 delete __pData;
544                 __pData = NULL ;
545
546         }
547         __pData = new(std::nothrow) ArrayList();
548
549         if (__pData == null)
550         {
551                 return 0;
552         }
553
554         r = __pData->Construct();
555
556         TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::GetItemCount __pData->Construct() failed  %s",GetErrorMessage(r));
557
558         BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
559
560
561         if ( count == 0)
562         {
563                 if(__pCheckButton != null)
564                 {
565                         __pCheckButton->SetShowState(false);
566                 }
567                 if(__pInfoPanel != null)
568                 {
569                         __pInfoPanel->SetShowState(false);
570                 }
571                 __pListview->SetBounds(__pListview->GetX(), 0, __pListview->GetWidth(), GetClientAreaBounds().height);
572
573         }
574         else
575         {
576                 if(__pCheckButton != null)
577                 {
578                         __pCheckButton->SetShowState(true);
579                 }
580                 if(__pInfoPanel != null)
581                 {
582                         __pInfoPanel->SetShowState(true);
583                 }
584                 if(__pCheckButton != null && __pInfoPanel != null)
585                 __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), __pListview->GetWidth(), GetClientAreaBounds().height - __pCheckButton->GetHeight() - __pInfoPanel->GetHeight());
586
587         }
588         if(__pCheckButton != null)
589         {
590                 __pCheckButton->Invalidate(true);
591         }
592         if(__pInfoPanel != null)
593         {
594                 __pInfoPanel->Invalidate(false);
595         }
596
597         return count;
598
599         CATCH:
600         __pData->RemoveAll(true);
601         delete __pData;
602         __pData = null;
603         return 0;
604 }
605
606 void
607 EditBookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
608 {
609
610 }
611
612 void
613 EditBookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
614 {
615
616 }
617
618 void
619 EditBookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
620 {
621         String labelString;
622         __selectedItemCount = 0;
623         result r = E_SUCCESS;
624
625         switch (elementId)
626         {
627         case IDA_FORMAT_BITMAP:
628         {
629                 ArrayList* pArgList = null;
630                 SceneManager* pSceneManager = SceneManager::GetInstance();
631                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
632
633                 if(pBookMark == NULL)
634                 {
635                         return;
636                 }
637
638                 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
639                 {
640                         pArgList = new(std::nothrow) ArrayList();
641
642                         if (pArgList != null)
643                         {
644                                 pArgList->Construct();
645                                 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
646                                 if ( pSceneManager != null)
647                                 {
648                                         result r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
649                                 }
650
651                                 if (pArgList != null)
652                                 {
653                                         pArgList->RemoveAll(false);
654                                         delete pArgList;
655                                         pArgList = null;
656                                 }
657                                 if(IsFailed(r))
658                                 {
659                                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
660                                         return;
661                                 }
662                         }
663                 }
664                 else
665                 {
666                         pArgList = new(std::nothrow) ArrayList();
667
668                         if (pArgList != null)
669                         {
670                                 pArgList->Construct();
671                                 pArgList->Add(*new(std::nothrow) String(L"1"));
672                                 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
673                                 if ( pSceneManager != null)
674                                 {
675                                         result r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK, SCENE_TRANSITION_ANIMATION_TYPE_NONE), pArgList);
676                                 }
677                                 if (pArgList != null)
678                                 {
679                                         pArgList->RemoveAll(false);
680                                         delete pArgList;
681                                         pArgList = null;
682                                 }
683                                 if(IsFailed(r))
684                                 {
685                                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
686                                         return;
687                                 }
688                         }
689                 }
690         }
691         break;
692
693         default:
694         {
695                 int count = 0;
696                 bool flag = false;
697                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
698
699
700                 if(pBookMark == NULL)
701                 {
702                         return;
703                 }
704                 String *pBookmarkId = new(std::nothrow) String();
705                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
706                 {
707                         pBookmarkId->Append("F");
708                 }
709                 else
710                 {
711                         pBookmarkId->Append("U");
712                 }
713                 pBookmarkId->Append(pBookMark->GetBookmarkId());
714
715                 if (__pListview->IsItemChecked(index) == false)
716                 {
717                         __pSelectedList->Remove(*pBookmarkId);
718                 }
719                 else
720                 {
721                         __pSelectedList->Add(pBookmarkId);
722                 }
723
724
725                 int itemCount = __pListview->GetItemCount();
726                 for (int count = 0;count < itemCount ; count++)
727                 {
728                         if (__pListview->IsItemChecked(count))
729                         {
730                                 __selectedItemCount++;
731                         }
732                 }
733
734                 //labelString.Append(__selectedItemCount);
735                 /*labelString.Append(CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED"));
736                 labelString.Append(L"\x200E"); // LEFT-TO-RIGHT MARK
737                 labelString.Append(L"(");
738                 labelString.Append(__selectedItemCount);
739                 labelString.Append(L")");*/
740
741                 if(__selectedItemCount >1)
742                 {
743                         labelString.Format(25, CommonUtil::GetString(L"IDS_BR_POP_PD_ITEMS_SELECTED").GetPointer() , __selectedItemCount);
744                 }
745                 else
746                 {
747                         labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __selectedItemCount);
748                 }
749
750                 __pInfoLabel->SetText(labelString);
751                 __pInfoPanel->Draw();
752                 __pInfoPanel->Show();
753                 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID,count);
754                 if (__selectedItemCount == count)
755                 {
756                         __pCheckButton->SetSelected(true);
757                 }
758                 else
759                 {
760                         __pCheckButton->SetSelected(false);
761                 }
762
763                 itemCount = __pListview->GetItemCount();
764                 for (int count = 0;count < itemCount ;count++)
765                 {
766                         if (__pListview->IsItemChecked(count))
767                         {
768                                 flag = true;
769                                 break;
770                         }
771                 }
772
773                 if (flag == true)
774                 {
775                         GetFooter()->SetItemEnabled(0,true);
776                 }
777                 else
778                 {
779                         GetFooter()->SetItemEnabled(0,false);
780                 }
781
782                 GetFooter()->Invalidate(true);
783
784         }
785         break;
786         }
787 }
788
789 void
790 EditBookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
791 {
792
793 }
794
795 void
796 EditBookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
797 {
798
799 }
800 void
801 EditBookmarkListForm::OnListViewItemReordered(Tizen::Ui::Controls::ListView& listView, int indexFrom, int indexTo)
802 {
803
804 }
805
806 void
807 EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
808 {
809         result r = E_FAILURE;
810         String labelString ;
811         int count = 0;
812         BookmarkData* pBookMark = null;
813
814         if (pArgs != null)
815         {
816                 __parentID.Clear();
817                 String* pStr = dynamic_cast<String*>(pArgs->GetAt(0));
818                 if(pStr == null)
819                 {
820                         return;
821                 }
822                 __parentID.Append(pStr->GetPointer());
823         }
824
825         __selectedItemCount = 0;
826
827
828         __pListview->UpdateList();
829
830         count = __pListview->GetItemCount();
831         if(count == 0)
832         {
833                 __pTimer->Start(1000);
834         }
835
836         for(int index = 0 ; index < count ; index++)
837         {
838                 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
839
840                 if(pBookMark == NULL)
841                 {
842                         return;
843                 }
844                 String *pBookmarkId = new(std::nothrow) String();
845                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
846                 {
847                         pBookmarkId->Append("F");
848                 }
849                 else
850                 {
851                         pBookmarkId->Append("U");
852                 }
853                 pBookmarkId->Append(pBookMark->GetBookmarkId());
854
855                 if(__pSelectedList->Contains(*pBookmarkId))
856                 {
857                         __pListview->SetItemChecked(index,true);
858                         __selectedItemCount++;
859                 }
860                 else
861                 {
862                         __pListview->SetItemChecked(index,false);
863                 }
864                 if (pBookmarkId)
865                 {
866                         delete pBookmarkId;
867                         pBookmarkId = null;
868                 }
869         }
870
871         //if(previousSceneId == IDSCN_ADD_BOOKMARK)
872         //      return;
873
874         if(__selectedItemCount >1)
875         {
876                 labelString.Format(25, CommonUtil::GetString(L"IDS_BR_POP_PD_ITEMS_SELECTED").GetPointer() , __selectedItemCount);
877         }
878         else
879         {
880                 labelString.Format(25, CommonUtil::GetString(L"IDS_BR_BODY_PD_ITEM_SELECTED").GetPointer() , __selectedItemCount);
881         }
882
883         __pInfoLabel->SetText(labelString);
884
885
886         if(__selectedItemCount == 0)
887         {
888                 GetFooter()->SetItemEnabled(0, false);
889                 GetFooter()->Invalidate(true);
890         }
891         else
892         {
893                 GetFooter()->SetItemEnabled(0, true);
894                 GetFooter()->Invalidate(true);
895         }
896         if(__selectedItemCount < __pListview->GetItemCount())
897         {
898                 __pCheckButton->SetSelected(false);
899         }
900         else
901         {
902                 __pCheckButton->SetSelected(true);
903         }
904         
905         Invalidate(true);
906 }
907
908 void
909 EditBookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
910 {
911
912 }
913
914 void
915 EditBookmarkListForm::OnFormBackRequested(Form& source)
916 {
917         SceneManager* pSceneManager = SceneManager::GetInstance();
918
919         if ( __pTimer != NULL)
920         {
921                 __pTimer->Cancel();
922                 delete __pTimer;
923         }
924
925         if (pSceneManager != null)
926         {
927                 //pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
928                 result r = pSceneManager->GoBackward(BackwardSceneTransition());
929                 if(IsFailed(r))
930                 {
931                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
932                         return;
933                 }
934
935         }
936         GetFooter()->Invalidate(true);
937 }
938
939
940 void EditBookmarkListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
941 {
942         int itemCount = 0;
943         ArrayList* pCheckedItems  = NULL ;
944
945         if(__pNotification)
946                 __pNotification->SetShowState(false);
947
948         if (__pListview != null)
949         {
950                 AppLog("the list Y axis is %d", __pListview->GetY());
951                 pCheckedItems  = new(std::nothrow) ArrayList();
952                 pCheckedItems->Construct();
953                 if ( __pListview->GetItemCount() == 0)
954                 {
955                         __pCheckButton->SetShowState(false);
956                         __pInfoPanel->SetShowState(false);
957                         __pListview->SetBounds(0, __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height -__pListview->GetY());
958
959                 }
960                 else
961                 {
962                         AppLog("EditBookmarkListForm::OnOrientationChanged 1");
963                         __pCheckButton->SetShowState(true);
964                         __pInfoPanel->SetShowState(true);
965                         __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), __pListview->GetWidth(), GetClientAreaBounds().height - __pCheckButton->GetHeight() - __pInfoPanel->GetHeight());
966                         __pInfoLabel->SetBounds(__pInfoLabel->GetX(),__pInfoLabel->GetY(), GetClientAreaBounds().width,__pInfoLabel->GetHeight());
967                         __pInfoLabel->Invalidate(true);
968                 }
969                 __pCheckButton->Invalidate(true);
970
971                 itemCount = __pListview->GetItemCount();
972
973                 for (int count = 0;count < itemCount ; count++)
974                 {
975
976                         if (__pListview->IsItemChecked(count))
977                         {
978                                 pCheckedItems->Add(* new Integer(count));
979                         }
980                 }
981
982 //              __pListview->UpdateList();
983
984                 for (int count = 0;count < itemCount ;count++)
985                 {
986                         if (pCheckedItems->Contains(* new Integer(count)) == true)
987                         {
988                                 __pListview->SetItemChecked(count, true);
989                         }
990                 }
991                 if ( pCheckedItems != NULL )
992                 {
993                         pCheckedItems->RemoveAll(true);
994                         delete pCheckedItems;
995                 }
996                 Invalidate(true);
997         }
998 }
999
1000 void
1001 EditBookmarkListForm::OnTimerExpired(Timer&  timer)
1002 {
1003         SceneManager* pSceneManager = SceneManager::GetInstance();
1004
1005         if ( pSceneManager != NULL)
1006         {
1007                 result r = pSceneManager->GoBackward(BackwardSceneTransition());
1008                 if(IsFailed(r))
1009                 {
1010                         AppLogDebug("EditBookmarkListForm::OnTimerExpired GoBackward failed %s",GetErrorMessage(r));
1011                 }
1012         }
1013 }
1014
1015 void
1016 EditBookmarkListForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
1017 {
1018         AppLog("receiving userevent for appcontrol %d",requestId);
1019         if (requestId == APPCONTROL_LAUNCH_MAX_LIMIT_REACHED)
1020         {
1021                 AppLog("receiving userevent for appcontrol %d ",requestId);
1022                 if(__pConfirmationPopup)
1023                 {
1024                         __pConfirmationPopup->SetShowState(false);
1025                         delete __pConfirmationPopup;
1026                         __pConfirmationPopup = null;
1027                 }
1028         }
1029 }