__pListModel->RestoreItemStatus();
- DeleteItemHeightList();
- CreateItemHeightList(defaultGroupHeight, defaultItemHeight);
+ RestoreItemHeightList(defaultGroupHeight, defaultItemHeight);
DeleteSectionAlignmentList();
CreateSectionAlignmentList();
itemTag.itemIndex++;
itemTag.itemIndex = startIndex + itemTag.itemIndex;
- __itemHeightList.GetAt(itemTag.itemIndex, itemHeight);
+ _TableViewItemHeight itemHeightListEntry;
+ __itemHeightList.GetAt(itemTag.itemIndex, itemHeightListEntry);
- return itemHeight;
+ return itemHeightListEntry.itemHeight;
}
float
_TableViewPresenter::SetItemHeight(TableViewItemTag itemTag, float height)
{
int startIndex = 0;
+ _TableViewItemHeight oldHeightEntry;
+ _TableViewItemHeight itemHeightListEntry;
+
+ itemHeightListEntry.itemHeight = height;
+ itemHeightListEntry.groupIndex = itemTag.groupIndex;
+ itemHeightListEntry.itemIndex = itemTag.itemIndex;
for (int i = 0; i < itemTag.groupIndex; i++)
{
itemTag.itemIndex++;
itemTag.itemIndex = startIndex + itemTag.itemIndex;
- float oldHeight = 0.0f;
- __itemHeightList.GetAt(itemTag.itemIndex, oldHeight);
- __itemHeightList.SetAt(height, itemTag.itemIndex);
+ __itemHeightList.GetAt(itemTag.itemIndex, oldHeightEntry);
- return oldHeight;
-}
+ itemHeightListEntry.isFooterItem = oldHeightEntry.isFooterItem;
+
+ __itemHeightList.SetAt(itemHeightListEntry, itemTag.itemIndex);
+ return oldHeightEntry.itemHeight;
+}
result
_TableViewPresenter::SetReorderMode(bool enabled)
{
int groupCount = GetGroupCount();
+ _TableViewItemHeight itemHeightEntry;
+
result r = __itemHeightList.SetCapacity(GetItemCount());
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
for (int i = 0; i < groupCount; i++)
{
int itemCount = GetItemCountAt(i);
-
+ itemHeightEntry.groupIndex = i;
if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE)
{
- __itemHeightList.Add(0.0f);
+ itemHeightEntry.itemIndex = -1;
+ itemHeightEntry.itemHeight = 0.0f;
+ itemHeightEntry.isFooterItem = false;
+ __itemHeightList.Add(itemHeightEntry);
}
else
{
- __itemHeightList.Add(defaultGroupItemHeight);
+ itemHeightEntry.itemIndex = -1;
+ itemHeightEntry.itemHeight = defaultGroupItemHeight;
+ itemHeightEntry.isFooterItem = false;
+ __itemHeightList.Add(itemHeightEntry);
}
for (int j = 0; j < itemCount; j++)
{
- __itemHeightList.Add(defaultItemHeight);
+ itemHeightEntry.itemIndex = j;
+ itemHeightEntry.itemHeight = defaultItemHeight;
+ itemHeightEntry.isFooterItem = false;
+ if (HasSectionFooter(i) && j == (itemCount - 1))
+ {
+ itemHeightEntry.isFooterItem = true;
+ }
+ __itemHeightList.Add(itemHeightEntry);
}
}
return false;
}
+bool
+_TableViewPresenter::RestoreItemHeightList(float defaultGroupHeight, float defaultItemHeight)
+{
+ _TableViewItemHeight backupItem;
+ _TableViewItemHeight currentItem;
+ _TableViewItemHeight itemHeightEntry;
+ int groupCount = GetGroupCount();
+ bool isGroupItem = true;
+ int itemCount = 0;
+ int groupIndex = 0;
+ int itemIndex = 0;
+
+ ArrayListT<_TableViewItemHeight> backupItemHeightList;
+ backupItemHeightList.Construct();
+
+ result r = backupItemHeightList.SetCapacity(__itemHeightList.GetCapacity());
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ for (int index = 0; index < __itemHeightList.GetCount(); index++)
+ {
+ __itemHeightList.GetAt(index, backupItem);
+ backupItemHeightList.Add(backupItem);
+ }
+
+ DeleteItemHeightList();
+
+ r = __itemHeightList.SetCapacity(GetItemCount());
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ for (int backUpListIndex = 0, actualListIndex = 0; actualListIndex < GetItemCount() && groupIndex < groupCount; )
+ {
+ backupItemHeightList.GetAt(backUpListIndex, backupItem);
+ if (groupIndex < groupCount)
+ {
+ itemCount = GetItemCountAt(groupIndex);
+ if (isGroupItem)
+ {
+ isGroupItem = false;
+ itemHeightEntry.groupIndex = groupIndex;
+ itemIndex = 0;
+ if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE)
+ {
+ itemHeightEntry.itemHeight = 0.0f;
+ }
+ else
+ {
+ itemHeightEntry.itemHeight = defaultGroupHeight;
+ }
+
+ itemHeightEntry.itemIndex = -1;
+ itemHeightEntry.isFooterItem = false;
+ __itemHeightList.Add(itemHeightEntry);
+ if (itemCount == 0)
+ {
+ isGroupItem = true;
+ groupIndex++;
+ }
+ }
+ else
+ {
+ itemHeightEntry.itemIndex = itemIndex;
+ itemHeightEntry.itemHeight = defaultItemHeight;
+ itemHeightEntry.isFooterItem = false;
+
+ if (HasSectionFooter(groupIndex) && itemIndex == (itemCount - 1))
+ {
+ itemHeightEntry.isFooterItem = true;
+ }
+ __itemHeightList.Add(itemHeightEntry);
+ itemIndex++;
+
+ if (itemIndex == itemCount)
+ {
+ isGroupItem = true;
+ groupIndex++;
+ }
+ }
+ }
+ if (actualListIndex < GetItemCount() && backUpListIndex < backupItemHeightList.GetCount())
+ {
+ __itemHeightList.GetAt(actualListIndex, currentItem);
+ if (backupItem.isFooterItem)
+ {
+ backUpListIndex++;
+ continue;
+ }
+
+ if(backupItem.groupIndex == currentItem.groupIndex && backupItem.itemIndex == currentItem.itemIndex)
+ {
+ currentItem.itemHeight = backupItem.itemHeight;
+ __itemHeightList.SetAt(currentItem, actualListIndex);
+ actualListIndex++;
+ backUpListIndex++;
+ }
+ else if (backupItem.groupIndex > currentItem.groupIndex)
+ {
+ actualListIndex++;
+ }
+ else if (backupItem.groupIndex < currentItem.groupIndex)
+ {
+ backUpListIndex++;
+ }
+ else
+ {
+ SysLog(NID_UI_CTRL, "System error has occurred. Failed to restore the height values.");
+ }
+ }
+ }
+ backupItemHeightList.RemoveAll();
+
+ return true;
+
+CATCH:
+ backupItemHeightList.RemoveAll();
+ DeleteItemHeightList();
+
+ return false;
+}
+
void
_TableViewPresenter::DeleteItemHeightList(void)
{
float defaultItemHeight = __pProviderAdaptor->GetDefaultItemHeight();
float defaultGroupItemHeight = __pProviderAdaptor->GetDefaultGroupItemHeight();
+ _TableViewItemHeight itemHeightEntry;
int startIndex = 0;
+
for (int i = 0; i < groupIndex; i++)
{
int itemCount = GetItemCountAt(i);
int itemCount = GetItemCountAt(groupIndex);
for (int i = 0; i < itemCount; i++)
{
- __itemHeightList.InsertAt(defaultItemHeight, targetIndex);
+ itemHeightEntry.groupIndex = groupIndex;
+ itemHeightEntry.itemIndex = (itemCount - 1) - i;
+ itemHeightEntry.itemHeight = defaultItemHeight;
+ itemHeightEntry.isFooterItem = false;
+ if (HasSectionFooter(groupIndex) && i == (itemCount - 1))
+ {
+ itemHeightEntry.isFooterItem = true;
+ }
+
+ __itemHeightList.InsertAt(itemHeightEntry, targetIndex);
}
- __itemHeightList.InsertAt(defaultGroupItemHeight, targetIndex);
+ itemHeightEntry.groupIndex = groupIndex;
+ itemHeightEntry.itemIndex = itemIndex;
+ itemHeightEntry.itemHeight = defaultGroupItemHeight;
+ itemHeightEntry.isFooterItem = false;
+ __itemHeightList.InsertAt(itemHeightEntry, targetIndex);
+ int updateIndex = targetIndex + itemCount + 1;// Increment the group Index below the added item by 1
+ int lastIndex = 0;
+ int groupCount = GetGroupCount();
+
+ for (int i = 0; i < groupCount; i++)
+ {
+ int itemCount = GetItemCountAt(i);
+ lastIndex = lastIndex + itemCount + 1;
+ }
+
+ for (int index = updateIndex; index < lastIndex; index++)
+ {
+ __itemHeightList.GetAt(index, itemHeightEntry);
+ itemHeightEntry.groupIndex = itemHeightEntry.groupIndex + 1;
+ __itemHeightList.SetAt(itemHeightEntry, index);
+ }
}
else
{
- __itemHeightList.InsertAt(defaultItemHeight, targetIndex);
+ itemHeightEntry.groupIndex = groupIndex;
+ itemHeightEntry.itemIndex = itemIndex;
+ itemHeightEntry.itemHeight = defaultItemHeight;
+ itemHeightEntry.isFooterItem = false;
+ __itemHeightList.InsertAt(itemHeightEntry, targetIndex);
+
+ int itemCount = GetItemCountAt(groupIndex);
+ int remainingItemCount = (itemCount - itemIndex);
+
+ for (int i = (targetIndex + 1); i < (targetIndex + remainingItemCount); i++)
+ {
+ __itemHeightList.GetAt(i, itemHeightEntry);
+ itemHeightEntry.groupIndex = groupIndex;
+ itemHeightEntry.itemIndex = itemHeightEntry.itemIndex + 1;
+ __itemHeightList.SetAt(itemHeightEntry, i);
+ }
}
}
else if (refreshType == TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE)
{
__itemHeightList.RemoveAt(targetIndex);
}
+
+ int updateIndex = targetIndex;// Decrement the group Index below the added item by 1
+ int lastIndex = 0;
+
+ for (int i = 0; i < (GetGroupCount() + 1); i++)
+ {
+ int itemCount = GetItemCountAt(i);
+ lastIndex = lastIndex + itemCount + 1;
+ }
+
+ for (int index = updateIndex; index < lastIndex; index++)
+ {
+ __itemHeightList.GetAt(index, itemHeightEntry);
+ itemHeightEntry.groupIndex = itemHeightEntry.groupIndex - 1;
+ __itemHeightList.SetAt(itemHeightEntry, index);
+ }
}
else
{
__itemHeightList.RemoveAt(targetIndex);
+ int itemCount = GetItemCountAt(groupIndex);
+ int remainingItemCount = itemCount - itemIndex;
+
+ for (int i = targetIndex; i < (targetIndex + remainingItemCount); i++)
+ {
+ __itemHeightList.GetAt(i, itemHeightEntry);
+ itemHeightEntry.groupIndex = groupIndex;
+ itemHeightEntry.itemIndex = (itemHeightEntry.itemIndex - 1);
+ __itemHeightList.SetAt(itemHeightEntry, i);
+ }
}
}
for (int i = 0; i < groupCount; i++)
{
-
__sectionAlignmentList.Add(alignment);
}
return true;
}
+bool
+_TableViewItemHeight::operator!= (const _TableViewItemHeight& rhs) const
+{
+ if (groupIndex == rhs.groupIndex && itemIndex == rhs.itemIndex && itemHeight == rhs.itemHeight && isFooterItem == rhs.isFooterItem)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+_TableViewItemHeight::operator== (const _TableViewItemHeight& rhs) const
+{
+ if (groupIndex == rhs.groupIndex && itemIndex == rhs.itemIndex && itemHeight == rhs.itemHeight && isFooterItem == rhs.isFooterItem)
+ {
+ return true;
+ }
+
+ return false;
+}
}}} // Tizen::Ui::Controls