Initialize Tizen 2.3
[apps/osp/Contacts.git] / src / CtContactValueListItemProvider.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        CtContactValueListItemProvider.cpp
19  * @brief       This is the implementation file for the ContactValueListItemProvider class.
20  */
21
22 #include "CtContactValueListItemProvider.h"
23
24 using namespace Tizen::Base;
25 using namespace Tizen::Base::Collection;
26 using namespace Tizen::Graphics;
27 using namespace Tizen::Ui::Controls;
28
29 static const int H_ITEM = 112;
30
31 ContactValueListItemProvider::ContactValueListItemProvider(Tizen::Base::Collection::IList* pContactValueList)
32 : __pContactValueList(pContactValueList)
33 {
34 }
35
36 ContactValueListItemProvider::~ContactValueListItemProvider(void)
37 {
38         if (__pContactValueList != null)
39         {
40                 __pContactValueList->RemoveAll(true);
41                 delete __pContactValueList;
42         }
43 }
44
45 Tizen::Ui::Controls::ListItemBase*
46 ContactValueListItemProvider::CreateItem(int index, int itemWidth)
47 {
48         SimpleItem* pItem = new (std::nothrow) SimpleItem();
49         pItem->Construct(Dimension(itemWidth, H_ITEM), LIST_ANNEX_STYLE_NORMAL);
50         pItem->SetElement(*static_cast<String *>(__pContactValueList->GetAt(index)));
51
52         return pItem;
53 }
54
55 bool
56 ContactValueListItemProvider::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
57 {
58         delete pItem;
59
60         return true;
61 }
62
63 int
64 ContactValueListItemProvider::GetItemCount(void)
65 {
66         return __pContactValueList->GetCount();
67 }