Fix for TDIS - 4347, 4703,4820 in SGL
authorkatpaga.a <katpaga.a@samsung.com>
Wed, 27 Mar 2013 09:28:20 +0000 (14:58 +0530)
committerkatpaga.a <katpaga.a@samsung.com>
Wed, 27 Mar 2013 09:28:20 +0000 (14:58 +0530)
Change-Id: I209d5e2d0bfa9afc3128335280d0992c590938fe
Signed-off-by: katpaga.a <katpaga.a@samsung.com>
src/ui/controls/FUiCtrl_SlidableGroupedListImpl.cpp
src/ui/inc/FUiCtrl_SlidableGroupedListImpl.h

index 1cd814a..51ed6c1 100644 (file)
@@ -123,6 +123,16 @@ _SlidableGroupedListItemProvider::CreateGroupItem(int groupIndex, int itemWidth)
        r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
        SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       if (GetItemCount(groupIndex) == 0 && groupIndex > __pListImpl->__topGroup)
+       {
+               __pListImpl->__bottomGroup++;
+       }
+
+       if (groupIndex < __pListImpl->__topGroup)
+       {
+               __pListImpl->__topGroup = groupIndex;
+       }
+
        return __pListImpl->GetTableViewGroupItemAt(groupIndex);
 }
 
@@ -135,6 +145,25 @@ _SlidableGroupedListItemProvider::DeleteGroupItem(int groupIndex, TableViewGroup
                pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData = null;
        }
 
+       if (__pListImpl->GetItemCountAt(groupIndex) == 0)
+       {
+               if (groupIndex == __pListImpl->__topGroup)
+               {
+                       if (__pListImpl->__topGroup < __pListImpl->__bottomGroup)
+                       {
+                               __pListImpl->__topGroup++;
+                       }
+               }
+               else if (groupIndex < __pListImpl->__topGroup)
+               {
+                       __pListImpl->__topGroup--;
+               }
+               if (__pListImpl->__bottomGroup != 0)
+               {
+                       __pListImpl->__bottomGroup--;
+               }
+       }
+
        delete pItem;
 
        return true;
@@ -492,6 +521,10 @@ _SlidableGroupedListItemProvider::DeleteItem(int groupIndex, int itemIndex, Tabl
                        }
                }
        }
+       else if (__pListImpl->__isFullUpdate == true)
+       {
+               __pListImpl->RemoveFromItemsList(groupIndex, (__pListImpl->GetSubItemCountAt(groupIndex) - 1), false);
+       }
 
        delete pItem;
        pItem = null;
@@ -535,6 +568,7 @@ _SlidableGroupedListImpl::_SlidableGroupedListImpl(Control* pList, _TableView* p
        , __bottomGroup(0)
        , __topGroup(0)
        , __loadedCount(0)
+       , __isFullUpdate(false)
        , __pItemProvider(null)
        , __directDelete(false)
        , __forceScroll(false)
@@ -872,12 +906,21 @@ _SlidableGroupedListImpl::InsertGroupAt(int groupIndex, const String& text, cons
                return E_SUCCESS;
        }
 
-       if (groupIndex <= __topGroup)
+       if (groupIndex <= __bottomGroup)
        {
-               __topGroup++;
                __bottomGroup++;
        }
 
+       if (groupIndex < __topGroup)
+       {
+               __topGroup++;
+               _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
+               SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM,
+                               "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
+
+               pGroupObject->__topIndex = itemCount - 1;
+       }
+
        if (__pItemProvider == null)
        {
                r = CreateItemProvider();
@@ -1087,9 +1130,6 @@ _SlidableGroupedListImpl::InsertItemAt(int groupIndex, int index, const CustomLi
        SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
                                E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
 
-       SysTryReturn(NID_UI_CTRL, (index >= GetTopItemIndex(groupIndex) && index <= (GetSubItemCountAt(groupIndex) + GetTopItemIndex(groupIndex))), E_INVALID_ARG, E_INVALID_ARG,
-                       "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
-
 
        _TableViewItemParams tableViewItemParams;
        tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
@@ -1106,8 +1146,12 @@ _SlidableGroupedListImpl::InsertItemAt(int groupIndex, int index, const CustomLi
        SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
                        "[%s] A system error has occurred. Failed to create an item.", GetErrorMessage(r));
 
-       r = InsertIntoItemsList(item, groupIndex, (index - GetTopItemIndex(groupIndex)));
-       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
+       int subItemCount = GetSubItemCountAt(groupIndex);
+       if (index < (subItemCount + GetTopItemIndex(groupIndex)) && (index >= GetTopItemIndex(groupIndex)))
+       {
+               r = InsertIntoItemsList(item, groupIndex, (index - GetTopItemIndex(groupIndex)));
+               SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
+       }
 
        _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
        SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
@@ -1372,40 +1416,16 @@ _SlidableGroupedListImpl::RemoveAllCheckedItemsAt(int groupIndex, int itemHeight
        SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
                        "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
 
-       result r = E_SUCCESS;
        Boolean* pChecked = null;
        int itemIndex = 0;
-       int subItemCount = GetSubItemCountAt(groupIndex);
 
-       for (itemIndex = pGroupObject->__itemCount; itemIndex >= 0; itemIndex--)
+       for (itemIndex = (GetItemCountAt(groupIndex) - 1); itemIndex >= 0; itemIndex--)
        {
            pChecked = dynamic_cast<Boolean*>(pGroupObject->__pCheckedList->GetAt(itemIndex));
 
            if (pChecked && pChecked->ToBool() == true)
            {
-
-               if (pGroupObject->__pCheckedList != null)
-               {
-                   pGroupObject->__pCheckedList->RemoveAt(itemIndex, true);
-               }
-
-               __directDelete = true;
-
-               if (itemIndex < (subItemCount + pGroupObject->__topIndex) && (itemIndex >= pGroupObject->__topIndex))
-               {
-                   RemoveFromItemsList(groupIndex, (itemIndex - pGroupObject->__topIndex));
-               }
-
-               r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
-               if (r != E_SUCCESS)
-               {
-                   SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupIndex);
-               }
-
-               __directDelete = false;
-
-               CallUnloadItemCb(groupIndex, itemIndex);
-               pGroupObject->__itemCount--;
+                       RemoveItemAt(groupIndex, itemIndex, 0);
            }
        }
 
@@ -1436,35 +1456,17 @@ _SlidableGroupedListImpl::RemoveAllCheckedItems(int itemHeight)
 result
 _SlidableGroupedListImpl::RemoveAllItemsAt(int groupIndex)
 {
-       result r = E_SUCCESS;
 
        SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
                                E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
 
-       _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
-       SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
-                       "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
-
-       __directDelete = true;
-
-       for (int itemCount = 0; itemCount < GetSubItemCountAt(groupIndex);)
-       {
-               r = RemoveItemAt(groupIndex, 0, 0);
-               if (r != E_SUCCESS)
-               {
-                       SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupIndex);
-               }
-       }
-
-       __directDelete = false;
+       int itemIndex = 0;
 
-       if (pGroupObject->__pCheckedList != null)
+       for (itemIndex = (GetItemCountAt(groupIndex) - 1); itemIndex >= 0; itemIndex--)
        {
-               pGroupObject->__pCheckedList->RemoveAll(true);
+               RemoveItemAt(groupIndex, itemIndex, 0);
        }
 
-       pGroupObject->__itemCount = 0;
-
        return E_SUCCESS;
 }
 
@@ -1478,11 +1480,21 @@ _SlidableGroupedListImpl::RemoveAllItems(void)
 
        for (groupCount = 0; groupCount < __groupsList.GetCount(); groupCount++)
        {
-               RemoveAllItemsAt(groupCount);
+               _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupCount));
+               SysTryReturn(NID_UI_CTRL, pGroupObject, 0, E_SYSTEM,
+                           "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupCount);
+
+               pGroupObject->__itemCount = 0;
+               pGroupObject->__topIndex = 0;
+
        }
 
-       __pItemProvider->firstTime = true;
+       __isFullUpdate = true;
+       GetCore().UpdateTableView();
+       __isFullUpdate = false;
 
+       __pItemProvider->firstTime = true;
+       __topGroup = 0;
        return E_SUCCESS;
 }
 
@@ -1521,18 +1533,20 @@ _SlidableGroupedListImpl::RemoveItemAt(int groupIndex, int index, int itemHeight
 
        int subItemCount = GetSubItemCountAt(groupIndex);
 
-       SysTryReturn(NID_UI_CTRL, (index >= 0 && index < subItemCount),
+       SysTryReturn(NID_UI_CTRL, (index >= 0 && index < pGroupObject->__itemCount),
                                E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
 
-       if (!(index < pGroupObject->__topIndex + subItemCount))
+       __directDelete = true;
+
+       if (pGroupObject->__pCheckedList != null)
        {
-               pGroupObject->__itemCount--;
-               return E_SUCCESS;
+               pGroupObject->__pCheckedList->RemoveAt(index, true);
        }
 
-       __directDelete = true;
-
-       RemoveFromItemsList(groupIndex, index);
+       if (index < (subItemCount + pGroupObject->__topIndex) && (index >= pGroupObject->__topIndex))
+       {
+               RemoveFromItemsList(groupIndex, (index - pGroupObject->__topIndex));
+       }
 
        result r = GetCore().RefreshTableView(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
        if (r != E_SUCCESS)
@@ -1540,11 +1554,6 @@ _SlidableGroupedListImpl::RemoveItemAt(int groupIndex, int index, int itemHeight
                SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupIndex);
        }
 
-       if (pGroupObject->__pCheckedList != null)
-       {
-               pGroupObject->__pCheckedList->RemoveAt(index, true);
-       }
-
        __directDelete = false;
 
        CallUnloadItemCb(groupIndex, index);
index 0064a6f..76f4261 100644 (file)
@@ -277,6 +277,7 @@ private:
        int __bottomGroup;
        int __topGroup;
        int __loadedCount;
+       bool __isFullUpdate;
        _SlidableGroupedListItemProvider* __pItemProvider;
        Tizen::Base::Collection::LinkedList __slidableListenersList;
        Tizen::Base::Collection::LinkedList __itemListenersList;