NABI issues
[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                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
268                 labelString.Append(L"(0)");
269
270                 if (__pInfoPanel != null)
271                 {
272                         __pInfoLabel->SetText(labelString);
273                         __pInfoPanel->Draw();
274                         __pInfoPanel->Show();
275                 }
276
277                 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
278                 String notification = CommonUtil::GetString(L"IDS_BR_POP_DELETED");
279                 pNotification->SetText(notification);
280                 pNotification->ShowNotification();
281
282
283                 if( __pListview->GetItemCount() == 0)
284                 {
285                         __pTimer->Start(1000);
286                 }
287         }
288         break;
289         case IDA_CANCELITEM_CLICKED:
290         {
291                 if ( __pTimer != NULL)
292                 {
293                         __pTimer->Cancel();
294                 }
295                 if(pSceneManager != NULL)
296                 {
297                         r = pSceneManager->GoBackward(BackwardSceneTransition());
298                 }
299                 if (IsFailed(r))
300                 {
301                         AppLogDebug("EditBookmarkListForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
302                         return;
303                 }
304         }
305         break;
306         case IDA_BUTTON_CHECKED:
307         {
308                 String labelString;
309                 bool flag = false;
310
311                 for (int count = 0;count < __pListview->GetItemCount();count++)
312                 {
313                         __pListview->SetItemChecked(count,true);
314                 }
315
316                 GetFooter()->SetItemEnabled(0,true);
317                 GetFooter()->Invalidate(true);
318
319                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
320                 labelString.Append(L"(");
321                 labelString.Append(__pListview->GetItemCount());
322                 labelString.Append(L")");
323
324                 __pInfoLabel->SetText(labelString);
325                 __pInfoPanel->Draw();
326                 __pInfoPanel->Show();
327
328                 int totalCount = __pData->GetCount();
329                 for(int index = 0; index <  totalCount; index++)
330                 {
331                         BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
332                         if (pBookMark == null)
333                         {
334
335                         }
336                         String *pBookmarkId = new(std::nothrow) String();
337                         if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
338                         {
339                                 pBookmarkId->Append("F");
340                         }
341                         else
342                         {
343                                 pBookmarkId->Append("U");
344                         }
345                         pBookmarkId->Append(pBookMark->GetBookmarkId());
346
347                         __pListview->SetItemChecked(index, true);
348                         __pSelectedList->Add(pBookmarkId);
349                 }
350         __pListview->Invalidate(true);
351         }
352         break;
353         case IDA_BUTTON_UNCHECKED:
354         {
355                 String labelString = L"";
356
357                 for (int count = 0;count < __pListview->GetItemCount();count++)
358                 {
359                         __pListview->SetItemChecked(count,false);
360                 }
361
362                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
363                 labelString.Append(L"(0)");
364                 __pInfoLabel->SetText(labelString);
365                 __pInfoPanel->Draw();
366                 __pInfoPanel->Show();
367                 __pSelectedList->RemoveAll(true);
368                 __pListview->Invalidate(true);
369
370                 GetFooter()->SetItemEnabled(0,false);
371                 GetFooter()->Invalidate(true);
372         }
373         break;
374         default:
375                 break;
376         }
377
378         CATCH: return ;
379 }
380
381 ListItemBase*
382 EditBookmarkListForm::CreateItem(int index, int itemWidth)
383 {
384         result r = E_SUCCESS;
385         ListAnnexStyle style = LIST_ANNEX_STYLE_MARK;
386         CustomItem* pItem = null;
387         BookmarkData* pBookMark = null;
388         Bitmap* pBitmap = null;
389         String bitmapId;
390         const int x_Margin_Url = 104;
391         const int y_Margin_Url = 70;
392         const int height_Url = 40;
393         const int width_Url = GetClientAreaBounds().width - 104 - 120 - 16;
394         const int itemHeight = 112;
395         const int textSize = 32;
396         const int width_Title = GetClientAreaBounds().width - 104 - 120 - 16;
397
398         pItem = new(std::nothrow) CustomItem();
399         if (pItem == null)
400         {
401                 return null;
402         }
403         pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
404         if (pBookMark == null)
405         {
406                 delete pItem;
407                 pItem = null;
408                 return null;
409         }
410         if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
411         {
412                 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 112), style);
413                 TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
414
415                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_FOLDER_OPEN);
416
417                 if (pBitmap != null)
418                 {
419                         pItem->AddElement(Rectangle(16, 26, 60, 60), IDA_FORMAT_ICON, *pBitmap, null);
420                         delete pBitmap;
421                 }
422
423                 pItem->AddElement(Rectangle(92, 8, width_Title/*__pListview->GetWidth() - 92 - 80*/, 112), IDA_FORMAT_FOLDER, pBookMark->GetBookmarkTitle(), true);
424
425
426                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ITEM);
427
428                 if (pBitmap != null)
429                 {
430                         pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 80, 20, 60, 60), IDA_FORMAT_BITMAP, *pBitmap, null, null);
431                         pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
432                         delete pBitmap;
433                 }
434         }
435         else
436         {
437                 r = pItem->Construct(Tizen::Graphics::Dimension(itemWidth, 128), style);
438                 TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::CreateItem contruct item failed  %s",GetErrorMessage(r));
439
440                 pBitmap = pBookMark->GetFavIconBitmap();
441
442                 if (pBitmap == null)
443                 {
444                         pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
445                 }
446
447                 pItem->AddElement(Rectangle(16, 28, 72, 72), IDA_FORMAT_ICON, *pBitmap, null);
448                 delete pBitmap;
449
450                 pItem->AddElement(Rectangle(104, 10, width_Title, itemHeight - height_Url), IDA_FORMAT_SITE, pBookMark->GetBookmarkTitle(), true);
451                 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);
452
453                 //pBitmap = AppResource::GetInstance()->GetBitmapN("I01_picker_arrow_right.png");
454                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_RIGHT_ARROW);
455                 if (pBitmap != null)
456                 {
457                         pItem->AddElement(Rectangle(GetClientAreaBounds().width - 92 - 84, 32, 64, 64), IDA_FORMAT_BITMAP, *pBitmap, null, null);
458                         pItem->SetElementSelectionEnabled(IDA_FORMAT_BITMAP, true);
459                         delete pBitmap;
460                 }
461         }
462         return pItem;
463
464         CATCH:
465         delete pItem;
466         pItem = null;
467         return NULL;
468 }
469
470 bool
471 EditBookmarkListForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
472 {
473         delete pItem;
474         pItem = null;
475         return true;
476 }
477
478 int
479 EditBookmarkListForm::GetItemCount(void)
480 {
481         int count = 0;
482         result r = E_SUCCESS;
483
484         BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID, count);
485
486         if (__pData != NULL)
487         {
488                 __pData->RemoveAll(true);
489                 delete __pData;
490                 __pData = NULL ;
491
492         }
493         __pData = new(std::nothrow) ArrayList();
494
495         if (__pData == null)
496         {
497                 return 0;
498         }
499
500         r = __pData->Construct();
501
502         TryCatch( r == E_SUCCESS,,"EditBookmarkListForm::GetItemCount __pData->Construct() failed  %s",GetErrorMessage(r));
503
504         BookmarkPresentationModel::GetInstance()->GetFoldersBookmarks(__parentID, 0, count, *__pData);
505
506
507         if ( count == 0)
508         {
509                 if(__pCheckButton != null)
510                 {
511                         __pCheckButton->SetShowState(false);
512                 }
513                 if(__pInfoPanel != null)
514                 {
515                         __pInfoPanel->SetShowState(false);
516                 }
517                 __pListview->SetBounds(__pListview->GetX(), 0, __pListview->GetWidth(), GetClientAreaBounds().height);
518
519         }
520         else
521         {
522                 if(__pCheckButton != null)
523                 {
524                         __pCheckButton->SetShowState(true);
525                 }
526                 if(__pInfoPanel != null)
527                 {
528                         __pInfoPanel->SetShowState(true);
529                 }
530                 if(__pCheckButton != null && __pInfoPanel != null)
531                 __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), __pListview->GetWidth(), GetClientAreaBounds().height - __pCheckButton->GetHeight() - __pInfoPanel->GetHeight());
532
533         }
534         if(__pCheckButton != null)
535         {
536                 __pCheckButton->Invalidate(true);
537         }
538         if(__pInfoPanel != null)
539         {
540                 __pInfoPanel->Invalidate(false);
541         }
542
543         return count;
544
545         CATCH:
546         __pData->RemoveAll(true);
547         delete __pData;
548         __pData = null;
549         return 0;
550 }
551
552 void
553 EditBookmarkListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
554 {
555
556 }
557
558 void
559 EditBookmarkListForm::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
560 {
561
562 }
563
564 void
565 EditBookmarkListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
566 {
567         String labelString;
568         __selectedItemCount = 0;
569         result r = E_SUCCESS;
570
571         switch (elementId)
572         {
573         case IDA_FORMAT_BITMAP:
574         {
575                 ArrayList* pArgList = null;
576                 SceneManager* pSceneManager = SceneManager::GetInstance();
577                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
578
579
580                 if(pBookMark == NULL)
581                 {
582                         return;
583                 }
584                 String *pBookmarkId = new(std::nothrow) String();
585                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
586                 {
587                         pBookmarkId->Append("F");
588                 }
589                 else
590                 {
591                         pBookmarkId->Append("U");
592                 }
593                 pBookmarkId->Append(pBookMark->GetBookmarkId());
594
595 //              if (__pListview->IsItemChecked(index) == true)
596 //              {
597 //                      __pListview->SetItemChecked(index, false);
598 //                      __pSelectedList->Remove(*pBookmarkId);
599 //              }
600 //              else
601 //              {
602 //                      __pListview->SetItemChecked(index, true);
603 //                      __pSelectedList->Add(pBookmarkId);
604 //              }
605
606                 if (pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
607                 {
608                         pArgList = new(std::nothrow) ArrayList();
609
610                         if (pArgList != null)
611                         {
612                                 pArgList->Construct();
613                                 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
614                                 if ( pSceneManager != null)
615                                 {
616                                         result r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CREATE_BOOKMARK_FOLDER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
617                                 }
618
619                                 if (pArgList != null)
620                                 {
621                                         pArgList->RemoveAll(false);
622                                         delete pArgList;
623                                         pArgList = null;
624                                 }
625                                 if(IsFailed(r))
626                                 {
627                                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
628                                         return;
629                                 }
630                         }
631                 }
632                 else
633                 {
634                         pArgList = new(std::nothrow) ArrayList();
635
636                         if (pArgList != null)
637                         {
638                                 pArgList->Construct();
639                                 pArgList->Add(*new(std::nothrow) String(L"1"));
640                                 pArgList->Add(*new(std::nothrow) BookmarkData(*pBookMark));
641                                 if ( pSceneManager != null)
642                                 {
643                                         result r = pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ADD_BOOKMARK, SCENE_TRANSITION_ANIMATION_TYPE_NONE), pArgList);
644                                 }
645                                 if (pArgList != null)
646                                 {
647                                         pArgList->RemoveAll(false);
648                                         delete pArgList;
649                                         pArgList = null;
650                                 }
651                                 if(IsFailed(r))
652                                 {
653                                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
654                                         return;
655                                 }
656                         }
657                 }
658         }
659         break;
660
661         default:
662         {
663                 int count = 0;
664                 bool flag = false;
665                 BookmarkData* pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
666
667
668                 if(pBookMark == NULL)
669                 {
670                         return;
671                 }
672                 String *pBookmarkId = new(std::nothrow) String();
673                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
674                 {
675                         pBookmarkId->Append("F");
676                 }
677                 else
678                 {
679                         pBookmarkId->Append("U");
680                 }
681                 pBookmarkId->Append(pBookMark->GetBookmarkId());
682
683                 if (__pListview->IsItemChecked(index) == false)
684                 {
685                         __pSelectedList->Remove(*pBookmarkId);
686                 }
687                 else
688                 {
689                         __pSelectedList->Add(pBookmarkId);
690                 }
691
692
693                 int itemCount = __pListview->GetItemCount();
694                 for (int count = 0;count < itemCount ; count++)
695                 {
696                         if (__pListview->IsItemChecked(count))
697                         {
698                                 __selectedItemCount++;
699                         }
700                 }
701
702                 //labelString.Append(__selectedItemCount);
703                 labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
704                 labelString.Append(L"(");
705                 labelString.Append(__selectedItemCount);
706                 labelString.Append(L")");
707                 __pInfoLabel->SetText(labelString);
708                 __pInfoPanel->Draw();
709                 __pInfoPanel->Show();
710                 BookmarkPresentationModel::GetInstance()->GetFolderBookmarkCount(__parentID,count);
711                 if (__selectedItemCount == count)
712                 {
713                         __pCheckButton->SetSelected(true);
714                 }
715                 else
716                 {
717                         __pCheckButton->SetSelected(false);
718                 }
719
720                 itemCount = __pListview->GetItemCount();
721                 for (int count = 0;count < itemCount ;count++)
722                 {
723                         if (__pListview->IsItemChecked(count))
724                         {
725                                 flag = true;
726                                 break;
727                         }
728                 }
729
730                 if (flag == true)
731                 {
732                         GetFooter()->SetItemEnabled(0,true);
733                 }
734                 else
735                 {
736                         GetFooter()->SetItemEnabled(0,false);
737                 }
738
739                 GetFooter()->Invalidate(true);
740
741         }
742         break;
743         }
744 }
745
746 void
747 EditBookmarkListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
748 {
749
750 }
751
752 void
753 EditBookmarkListForm::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index)
754 {
755
756 }
757 void
758 EditBookmarkListForm::OnListViewItemReordered(Tizen::Ui::Controls::ListView& listView, int indexFrom, int indexTo)
759 {
760
761 }
762
763 void
764 EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
765 {
766         result r = E_FAILURE;
767         String labelString ;
768         int count = 0;
769         BookmarkData* pBookMark = null;
770
771         if (pArgs != null)
772         {
773                 __parentID.Clear();
774                 String* pStr = dynamic_cast<String*>(pArgs->GetAt(0));
775                 if(pStr == null)
776                 {
777                         return;
778                 }
779                 __parentID.Append(pStr->GetPointer());
780         }
781
782         __selectedItemCount = 0;
783
784         labelString.Append(CommonUtil::GetString(L"IDS_COM_OPT_SELECTED"));
785         labelString.Append(L"(");
786         labelString.Append(__pSelectedList->GetCount());
787         labelString.Append(L")");
788         __pInfoLabel->SetText(labelString);
789         __pListview->UpdateList();
790
791         count = __pListview->GetItemCount();
792
793         for(int index = 0 ; index < count ; index++)
794         {
795                 pBookMark = dynamic_cast< BookmarkData* >(__pData->GetAt(index));
796
797                 if(pBookMark == NULL)
798                 {
799                         return;
800                 }
801                 String *pBookmarkId = new(std::nothrow) String();
802                 if(pBookMark->GetBookmarkType() == BOOKMARK_TYPE_FOLDER)
803                 {
804                         pBookmarkId->Append("F");
805                 }
806                 else
807                 {
808                         pBookmarkId->Append("U");
809                 }
810                 pBookmarkId->Append(pBookMark->GetBookmarkId());
811
812                 AppLog("BookmarkId: %ls", pBookmarkId->GetPointer());
813
814                 if(__pSelectedList->Contains(*pBookmarkId))
815                 {
816                         __pListview->SetItemChecked(index,true);
817                         __selectedItemCount++;
818                 }
819                 else
820                 {
821                         __pListview->SetItemChecked(index,false);
822                 }
823         }
824         if(__selectedItemCount < __pListview->GetItemCount())
825         {
826                 __pCheckButton->SetSelected(false);
827                 GetFooter()->SetItemEnabled(0, false);
828                 GetFooter()->Invalidate(true);
829         }
830         else
831         {
832                 __pCheckButton->SetSelected(true);
833                 GetFooter()->SetItemEnabled(0, true);
834                 GetFooter()->Invalidate(true);
835         }
836
837
838         __pInfoPanel->Draw();
839         __pInfoPanel->Show();
840
841         Invalidate(true);
842
843 }
844
845 void
846 EditBookmarkListForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
847 {
848
849 }
850
851 void
852 EditBookmarkListForm::OnFormBackRequested(Form& source)
853 {
854         SceneManager* pSceneManager = SceneManager::GetInstance();
855
856         if ( __pTimer != NULL)
857         {
858                 __pTimer->Cancel();
859         }
860
861         if (pSceneManager != null)
862         {
863                 //pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
864                 result r = pSceneManager->GoBackward(BackwardSceneTransition());
865                 if(IsFailed(r))
866                 {
867                         AppLogDebug("BookmarkListForm::CreateItem Construct failed %s",GetErrorMessage(r));
868                         return;
869                 }
870
871         }
872         GetFooter()->Invalidate(true);
873 }
874
875
876 void EditBookmarkListForm::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
877 {
878         int itemCount = 0;
879         ArrayList* pCheckedItems  = NULL ;
880
881         if (__pListview != null)
882         {
883                 AppLog("the list Y axis is %d", __pListview->GetY());
884                 pCheckedItems  = new(std::nothrow) ArrayList();
885                 pCheckedItems->Construct();
886                 if ( __pListview->GetItemCount() == 0)
887                 {
888                         __pCheckButton->SetShowState(false);
889                         __pInfoPanel->SetShowState(false);
890                         __pListview->SetBounds(0, __pListview->GetY(), GetClientAreaBounds().width, GetClientAreaBounds().height -__pListview->GetY());
891
892                 }
893                 else
894                 {
895                         __pCheckButton->SetShowState(true);
896                         __pInfoPanel->SetShowState(true);
897                         __pListview->SetBounds(__pListview->GetX(), __pListview->GetY(), __pListview->GetWidth(), GetClientAreaBounds().height - __pCheckButton->GetHeight() - __pInfoPanel->GetHeight());
898
899                 }
900                 __pCheckButton->Invalidate(true);
901
902                 itemCount = __pListview->GetItemCount();
903
904                 for (int count = 0;count < itemCount ; count++)
905                 {
906
907                         if (__pListview->IsItemChecked(count))
908                         {
909                                 pCheckedItems->Add(* new Integer(count));
910                         }
911                 }
912
913                 __pListview->UpdateList();
914
915                 for (int count = 0;count < itemCount ;count++)
916                 {
917                         if (pCheckedItems->Contains(* new Integer(count)) == true)
918                         {
919                                 __pListview->SetItemChecked(count, true);
920                         }
921                 }
922                 if ( pCheckedItems != NULL )
923                 {
924                         pCheckedItems->RemoveAll(true);
925                         delete pCheckedItems;
926                 }
927                 Invalidate(true);
928         }
929 }
930
931 void
932 EditBookmarkListForm::OnTimerExpired(Timer&  timer)
933 {
934         SceneManager* pSceneManager = SceneManager::GetInstance();
935
936         if ( pSceneManager != NULL)
937         {
938                 result r = pSceneManager->GoBackward(BackwardSceneTransition());
939                 if(IsFailed(r))
940                 {
941                         AppLogDebug("EditBookmarkListForm::OnTimerExpired GoBackward failed %s",GetErrorMessage(r));
942                 }
943         }
944 }