Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / inc / FUiCtrl_ListViewModel.h
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_ListViewModel.h
20  * @brief       This is the header file for the _ListViewModel class.
21  *
22  * This header file contains the declarations of the _ListViewModel class.
23  */
24
25 #ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_
26 #define _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_
27
28 #include "FUiCtrl_LinkedList.h"
29 #include "FUiCtrl_ListViewTypes.h"
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 class _IListItemProviderAdaptor;
35 class _IListItemCommon;
36
37 struct _ListViewGroupNode
38 {
39
40 public:
41         _ListViewGroupNode(void)
42         {
43                 __itemCountInGroup = 0;
44                 __radioCheckedItemIndex = -1;
45                 __usingRadioStyle = false;
46                 __itemExpanded = true;
47         }
48
49 private:
50         friend class _ListViewModel;
51
52         _LinkedList <_IListItemCommon*> __items;
53         _LinkedList <int> __checkedItems;
54         _LinkedList <int> __disabledItems;
55         int __itemCountInGroup;                         // except groupItem
56         int __radioCheckedItemIndex;
57         bool __usingRadioStyle;
58     bool __itemExpanded;
59 }; // _ListViewGroupNode
60
61 class _ListViewModel
62 {
63 public:
64         _ListViewModel(void);
65
66         virtual ~_ListViewModel(void);
67
68         // Set/Get ItemProviderAdaptor
69         _IListItemProviderAdaptor* GetItemProviderAdaptor(void) const;
70
71         result RegisterItemProviderAdaptor(const _IListItemProviderAdaptor* pProviderAdaptor);
72
73         //item handling ( Add / Insert / Delete / Get )
74         _IListItemCommon* GetGroup(int groupIndex) const;
75
76         _IListItemCommon* LoadItem(int groupIndex, int itemIndex);
77
78         _IListItemCommon* GetItemFromContainer(int groupIndex, int itemIndex) const;
79
80         _IListItemCommon* GetItemFromTemporaryBuffer(int groupIndex, int itemIndex);
81
82         bool IsValidItem(int groupIndex, int itemIndex) const;
83
84         bool IsLoadedItem(int groupIndex, int itemIndex) const;
85
86         result AddGroup(int itemCount = 0, bool usingRadioStyle = false);
87
88         result InsertGroup(int groupIndex, int itemCount = 0, bool usingRadioStyle = false);
89
90         result RemoveGroup(int groupIndex);
91
92         result AddItemToGroup(_IListItemCommon* pItem, int groupIndex);
93
94         result InsertItemToGroup(_IListItemCommon* pItem, int groupIndex, int itemIndex);
95
96         result SetItem(_IListItemCommon& item, int groupIndex, int itemIndex);
97
98         result MoveItem(_ListItemPos originPosition, _ListItemPos destinationPosition);
99
100         result RemoveItemAt(int groupIndex, int itemIndex, bool internalDestroy = false);
101
102         result RemoveAllItem(bool internalDestroy = false, bool backupItemStatus = false);
103
104         void RestoreItemStatus(void);
105
106         result DeleteAllGroupAndItem(void);
107
108         result SetMaxCachingSize(int cachingSize);
109
110         int GetMaxCachingSize(void) const;
111
112         result UnloadItem(int groupIndex, int itemIndex);
113
114         // Focused item & element
115         bool IsFocusedItem(int groupIndex, int itemIndex) const;
116
117         void GetFocusedItem(int& groupIndex, int& itemIndex) const;
118
119         void SetFocusedItem(int groupIndex, int itemIndex);
120
121         bool IsItemEnabled(int groupIndex, int itemIndex) const;
122
123         result SetItemEnabled(int groupIndex, int itemIndex, bool enable);
124
125         result SetItemChecked(int groupIndex, int itemIndex, bool check);
126
127         bool IsItemChecked(int groupIndex, int itemIndex) const;
128
129         int GetIndexOfRadioCheckedItem(int groupIndex) const;
130
131         //item handling - Group and item
132         int GetAllItemCount(void) const;
133
134         int GetAllGroupCount(void) const;
135
136         int GetItemCountInGroup(int groupIndex) const;
137
138     // for group Expand/Collapse
139     result SetGroupExpandState(int groupIndex, bool state);
140
141     bool IsGroupExpanded(int groupIndex) const;
142
143         void SetAllLoadedItemStateChanged(bool state);
144
145         void GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const;
146
147         void GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const;
148
149 private:
150         void MoveCheckedAndDisabledItemIndex(_ListViewGroupNode* pListGroupNode, int originItemIndex, int destinationItemIndex, bool checked = false, bool enabled = true);
151
152         result LoadItemToContainer(int groupIndex, int itemIndex, _IListItemCommon& item);
153
154         result UnloadAllItem(void);
155
156         // item handling - item states
157         int GetOverflowCount(void) const;
158
159         result RemoveOverflowItems(bool deleteFromEnd, int removeCount);
160
161         _ListViewGroupNode* GetGroupNode(int groupIndex) const;
162
163 private:
164         _ListViewModel(const _ListViewModel& rhs);
165
166         _ListViewModel& operator =(const _ListViewModel& rhs);
167
168 private:
169         static const int CACHE_SIZE = 30;
170
171         // member variables for view
172         _LinkedList <_ListViewGroupNode*> __groupNodes;
173         _LinkedList <_ListViewGroupNode*> __backupGroupNodes;
174         _IListItemProviderAdaptor* __pListProviderAdaptor;
175         _IListItemCommon* __pTemporaryItemBuffer;
176         int __countOfAllGroups;
177         int __countOfAllItems;
178
179         // member variables for items
180         int __indexOfFocusedGroup;
181         int __indexOfFocusedItem;
182
183         // member variables for model
184         int __sizeOfCachingItems;
185         bool __overflowItemsRemovingEnabled;
186 }; // _ListViewModel
187
188 }}} // Tizen::Ui::Controls
189
190 #endif // _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_
191