Initialize Tizen 2.3
[apps/osp/Contacts.git] / src / CtAccountListItemProvider.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        CtAccountListItemProvider.cpp
19  * @brief       This is the implementation file for the AccountListItemProvider class.
20  */
21
22 #include "CtAccountListItemProvider.h"
23 #include "CtContactListPresentationModel.h"
24
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Ui::Controls;
29
30 static const int H_ITEM = 112;
31
32 AccountListItemProvider::AccountListItemProvider(Tizen::Ui::Controls::ListView* pAccountListView, ContactListPresentationModel* pContactListPresentationModel)
33 : __pAccountListView(pAccountListView)
34 , __pContactListPresentationModel(pContactListPresentationModel)
35 {
36 }
37
38 AccountListItemProvider::~AccountListItemProvider(void)
39 {
40 }
41
42 Tizen::Ui::Controls::ListItemBase*
43 AccountListItemProvider::CreateItem(int index, int itemWidth)
44 {
45         SimpleItem* pItem = null;
46         String addressbookName(__pContactListPresentationModel->GetAddressbookName(index));
47
48         pItem = new (std::nothrow) SimpleItem();
49         pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_RADIO);
50         pItem->SetElement(addressbookName);
51
52         if (addressbookName.Equals(__pContactListPresentationModel->GetCurrentAddressbook()))
53         {
54                 __pAccountListView->SetItemChecked(index, true);
55         }
56
57         return pItem;
58 }
59
60 bool
61 AccountListItemProvider::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
62 {
63         delete pItem;
64         pItem = null;
65
66         return true;
67 }
68
69 int
70 AccountListItemProvider::GetItemCount(void)
71 {
72         return __pContactListPresentationModel->GetAddressbookCount();
73 }