Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_ExpandableListData.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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 /**
19 * @file                 FUiCtrl_ExpandableListData.cpp
20 * @brief                This is the implementation file for _MainItem, _SubItem & _ExpandableListItemDataProvider class.
21 *
22 */
23
24 // Includes
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_ExpandableListData.h"
27 #include "FUiCtrl_ExpandableListImpl.h"
28 #include "FUiCtrl_CustomListImpl.h"
29
30 using namespace Tizen::Base::Collection;
31
32 namespace Tizen { namespace Ui { namespace Controls
33 {
34
35 _MainItem::_MainItem(void)
36         : isExpanded(false)
37         , isEnabled(true)
38         , checkCount(0)
39         , pCustomItemData(null)
40 {
41 }
42
43 _MainItem::~_MainItem(void)
44 {
45         subItemList.RemoveAll(!isExpanded);
46         actualSubItemList.RemoveAll(true);
47 }
48
49
50 _SubItem::_SubItem(bool removeItemData)
51         : isEnabled(true)
52         , pCustomItemData(null)
53         , isDeleteNeeded(removeItemData)
54 {
55 }
56
57 _SubItem::~_SubItem(void)
58 {
59         if (isDeleteNeeded)
60         {
61                 delete pCustomItemData;
62                 pCustomItemData = null;
63         }
64 }
65
66
67 _ExpandableListItemDataProvider::_ExpandableListItemDataProvider(_ExpandableListImpl* pList)
68         : __pList(pList)
69 {
70 }
71
72 _ExpandableListItemDataProvider::~_ExpandableListItemDataProvider(void)
73 {
74
75 }
76
77 int
78 _ExpandableListItemDataProvider::GetItemCount(void)
79 {
80
81         if (__pList)
82         {
83                 return __pList->__mainList.GetCount();
84         }
85
86         return 0;
87 }
88
89 ListItemBase*
90 _ExpandableListItemDataProvider::CreateItem(int index, int itemWidth)
91 {
92         _MainItem* pMainItem = null;
93         _SubItem* pSubItem = null;
94         _CustomItemData* pCustomItemData = null;
95
96         pMainItem = dynamic_cast<_MainItem*>(__pList->__mainList.GetAt(index));
97
98         if (pMainItem!= null)
99         {
100                 return pCustomItemData = dynamic_cast<_CustomItemData*>(pMainItem->pCustomItemData);
101         }
102
103         pSubItem = dynamic_cast<_SubItem*>(__pList->__mainList.GetAt(index));
104
105         if (pSubItem != null)
106         {
107                 return pCustomItemData = dynamic_cast<_CustomItemData*>(pSubItem->pCustomItemData);
108         }
109
110         return null;
111 }
112
113 bool
114 _ExpandableListItemDataProvider::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
115 {
116         return false;
117 }
118
119 }}} // Tizen::Ui::Controls