2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_ListViewModel.h
20 * @brief This is the header file for the _ListViewModel class.
22 * This header file contains the declarations of the _ListViewModel class.
25 #ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_
26 #define _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_
28 #include "FUiCtrl_LinkedList.h"
29 #include "FUiCtrl_ListViewTypes.h"
31 namespace Tizen { namespace Ui { namespace Controls
34 class _IListItemProviderAdaptor;
35 class _IListItemCommon;
37 struct _ListViewGroupNode
41 _ListViewGroupNode(void)
43 __itemCountInGroup = 0;
44 __radioCheckedItemIndex = -1;
45 __usingRadioStyle = false;
46 __itemExpanded = true;
50 friend class _ListViewModel;
52 _LinkedList <_IListItemCommon*> __items;
53 _LinkedList <int> __checkedItems;
54 _LinkedList <int> __disabledItems;
55 int __itemCountInGroup; // except groupItem
56 int __radioCheckedItemIndex;
57 bool __usingRadioStyle;
59 }; // _ListViewGroupNode
66 virtual ~_ListViewModel(void);
68 // Set/Get ItemProviderAdaptor
69 _IListItemProviderAdaptor* GetItemProviderAdaptor(void) const;
71 result RegisterItemProviderAdaptor(const _IListItemProviderAdaptor* pProviderAdaptor);
73 //item handling ( Add / Insert / Delete / Get )
74 _IListItemCommon* GetGroup(int groupIndex) const;
76 _IListItemCommon* LoadItem(int groupIndex, int itemIndex);
78 _IListItemCommon* GetItemFromContainer(int groupIndex, int itemIndex) const;
80 _IListItemCommon* GetItemFromTemporaryBuffer(int groupIndex, int itemIndex);
82 bool IsValidItem(int groupIndex, int itemIndex) const;
84 bool IsLoadedItem(int groupIndex, int itemIndex) const;
86 result AddGroup(int itemCount = 0, bool usingRadioStyle = false);
88 result InsertGroup(int groupIndex, int itemCount = 0, bool usingRadioStyle = false);
90 result RemoveGroup(int groupIndex);
92 result AddItemToGroup(_IListItemCommon* pItem, int groupIndex);
94 result InsertItemToGroup(_IListItemCommon* pItem, int groupIndex, int itemIndex);
96 result SetItem(_IListItemCommon& item, int groupIndex, int itemIndex);
98 result MoveItem(_ListItemPos originPosition, _ListItemPos destinationPosition);
100 result RemoveItemAt(int groupIndex, int itemIndex, bool internalDestroy = false);
102 result RemoveAllItem(bool internalDestroy = false, bool backupItemStatus = false);
104 void RestoreItemStatus(void);
106 result DeleteAllGroupAndItem(void);
108 result SetMaxCachingSize(int cachingSize);
110 int GetMaxCachingSize(void) const;
112 result UnloadItem(int groupIndex, int itemIndex);
114 // Focused item & element
115 bool IsFocusedItem(int groupIndex, int itemIndex) const;
117 void GetFocusedItem(int& groupIndex, int& itemIndex) const;
119 void SetFocusedItem(int groupIndex, int itemIndex);
121 bool IsItemEnabled(int groupIndex, int itemIndex) const;
123 result SetItemEnabled(int groupIndex, int itemIndex, bool enable);
125 result SetItemChecked(int groupIndex, int itemIndex, bool check);
127 bool IsItemChecked(int groupIndex, int itemIndex) const;
129 int GetIndexOfRadioCheckedItem(int groupIndex) const;
131 //item handling - Group and item
132 int GetAllItemCount(void) const;
134 int GetAllGroupCount(void) const;
136 int GetItemCountInGroup(int groupIndex) const;
138 // for group Expand/Collapse
139 result SetGroupExpandState(int groupIndex, bool state);
141 bool IsGroupExpanded(int groupIndex) const;
143 void SetAllLoadedItemStateChanged(bool state);
145 void GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const;
147 void GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const;
150 void MoveCheckedAndDisabledItemIndex(_ListViewGroupNode* pListGroupNode, int originItemIndex, int destinationItemIndex, bool checked = false, bool enabled = true);
152 result LoadItemToContainer(int groupIndex, int itemIndex, _IListItemCommon& item);
154 result UnloadAllItem(void);
156 // item handling - item states
157 int GetOverflowCount(void) const;
159 result RemoveOverflowItems(bool deleteFromEnd, int removeCount);
161 _ListViewGroupNode* GetGroupNode(int groupIndex) const;
164 _ListViewModel(const _ListViewModel& rhs);
166 _ListViewModel& operator =(const _ListViewModel& rhs);
169 static const int CACHE_SIZE = 30;
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;
179 // member variables for items
180 int __indexOfFocusedGroup;
181 int __indexOfFocusedItem;
183 // member variables for model
184 int __sizeOfCachingItems;
185 bool __overflowItemsRemovingEnabled;
188 }}} // Tizen::Ui::Controls
190 #endif // _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_