Modified Section footer item layout
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_TableViewPresenter.cpp
index 51b29a3..09cd71c 100644 (file)
@@ -341,7 +341,7 @@ _TableViewPresenter::GetItemCountAt(int groupIndex) const
 bool
 _TableViewPresenter::HasSectionHeader(int groupIndex) const
 {
-       if (__pProviderAdaptor == null)
+       if (__pProviderAdaptor == null || __pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
        {
                return false;
        }
@@ -352,7 +352,7 @@ _TableViewPresenter::HasSectionHeader(int groupIndex) const
 bool
 _TableViewPresenter::HasSectionFooter(int groupIndex) const
 {
-       if (__pProviderAdaptor == null)
+       if (__pProviderAdaptor == null || __pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
        {
                return false;
        }
@@ -1233,16 +1233,6 @@ _TableViewPresenter::SetItemType(_TableViewItem* pItem, TableViewItemTag itemPos
 {
        TableViewStyle style = __pTableView->GetTableViewStyle();
 
-       int lastItem = GetItemCountAt(itemPosition.groupIndex) - 1;
-
-       if (style == TABLE_VIEW_STYLE_SECTION)
-       {
-               if (HasSectionFooter(itemPosition.groupIndex))
-               {
-                       lastItem--;
-               }
-       }
-
        if (itemPosition.itemIndex == -1)
        {
                if (style == TABLE_VIEW_STYLE_SECTION)
@@ -1254,29 +1244,68 @@ _TableViewPresenter::SetItemType(_TableViewItem* pItem, TableViewItemTag itemPos
                        pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TITLE);
                }
        }
-       else if (style == TABLE_VIEW_STYLE_SECTION || (itemPosition.groupIndex != GetGroupCount() - 1))
+       else
        {
-               if (lastItem == 0)
-               {
-                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_ONE);
-               }
-               else
+               int itemCount = GetItemCountAt(itemPosition.groupIndex);
+
+               if (itemPosition.itemIndex == 0)
                {
-                       if (itemPosition.itemIndex == 0)
+                       if (HasSectionFooter(itemPosition.groupIndex))
                        {
-                               pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TOP);
+                               if (itemCount == 1)
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_FOOTER);
+                               }
+                               else if (itemCount == 2)
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_ONE);
+                               }
+                               else
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TOP);
+                               }
                        }
-                       else if (itemPosition.itemIndex == lastItem)
+                       else
                        {
-                               pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_BOTTOM);
+                               if (itemCount == 1)
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_ONE);
+                               }
+                               else
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TOP);
+                               }
                        }
-                       else if (itemPosition.itemIndex == lastItem + 1)
-                       {       // this case is for TABLE_VIEW_STYLE_SECTION only
-                               pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_FOOTER);
+               }
+               else
+               {
+                       int lastItemIndex = itemCount - 1;
+
+                       if (HasSectionFooter(itemPosition.groupIndex))
+                       {
+                               if (itemPosition.itemIndex == lastItemIndex)
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_FOOTER);
+                               }
+                               else if (itemPosition.itemIndex == lastItemIndex - 1)
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_BOTTOM);
+                               }
+                               else
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_MIDDLE);
+                               }
                        }
                        else
                        {
-                               pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_MIDDLE);
+                               if (itemPosition.itemIndex == lastItemIndex)
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_BOTTOM);
+                               }
+                               else
+                               {
+                                       pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_MIDDLE);
+                               }
                        }
                }
        }
@@ -2992,6 +3021,8 @@ _TableViewPresenter::ScrollToItem(int groupIndex, int itemIndex, TableViewScroll
 {
        TableViewItemTag itemPos = {groupIndex, itemIndex};
 
+       StopAllItemAnimation();
+
        if (!__pListModel->IsLoadedItem(groupIndex, itemIndex))
        {
                ResetItemLayout(itemPos);