__pTemporaryItemBuffer = null;
}
- if (__backupGroupNodes.empty() == false)
+ if (!__backupGroupNodes.empty())
{
_ListViewGroupNode* pBackupedListGroupNode = null;
- for (int i = 0; i < __backupGroupNodes.size(); i++)
+ int count = __backupGroupNodes.size();
+ for (int i = 0; i < count; i++)
{
- pBackupedListGroupNode = __backupGroupNodes.at(i);
+ pBackupedListGroupNode = __backupGroupNodes.back();
+ __backupGroupNodes.pop_back();
delete pBackupedListGroupNode;
}
-
- __backupGroupNodes.clear();
}
DeleteAllGroupAndItem();
SysTryReturn(NID_UI_CTRL, pListGroupNode != null, null, GetLastResult(),
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
- _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
-
- _IListItemCommon* pItem = null;
int temporaryGroupIndex = -1;
int temporaryItemIndex = -1;
- while (theIter != pListGroupNode->__items.end())
+ _IListItemCommon* pItem = null;
+ _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
+ _LinkedList <_IListItemCommon*>::_Iterator theEndIter = pListGroupNode->__items.end();
+
+ while (theIter != theEndIter)
{
pItem = *theIter;
pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
return null;
}
- // if loaded item, call GetItemFromContainer()
- if (IsLoadedItem(groupIndex, itemIndex) == true)
- {
- return GetItemFromContainer(groupIndex, itemIndex);
- }
-
- _IListItemCommon* pItemCommon = __pListProviderAdaptor->LoadItem(groupIndex, itemIndex);
- if (pItemCommon != null)
+ // load item
+ _IListItemCommon* pItemCommon = GetItemFromContainer(groupIndex, itemIndex);
+ if (pItemCommon == null)
{
- if (IsItemChecked(groupIndex, itemIndex) == true)
+ pItemCommon = __pListProviderAdaptor->LoadItem(groupIndex, itemIndex);
+ if (pItemCommon != null)
{
- pItemCommon->SetChecked(true);
- }
+ pItemCommon->SetChecked(IsItemChecked(groupIndex, itemIndex));
+ pItemCommon->SetItemEnabled(IsItemEnabled(groupIndex, itemIndex));
+ pItemCommon->SetItemIndex(groupIndex, itemIndex);
- if (IsItemEnabled(groupIndex, itemIndex) == false)
- {
- pItemCommon->SetItemEnabled(false);
+ LoadItemToContainer(groupIndex, itemIndex, *pItemCommon);
}
-
- // push item to container
- pItemCommon->SetItemIndex(groupIndex, itemIndex);
- LoadItemToContainer(groupIndex, itemIndex, *pItemCommon);
}
return pItemCommon;
result
_ListViewModel::LoadItemToContainer(int groupIndex, int itemIndex, _IListItemCommon& item)
{
- _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex);
+ _ListViewGroupNode* pListGroupNode = __groupNodes.at(groupIndex);
SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(),
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
- _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
-
- _IListItemCommon* pItem = null;
- int temporaryGroupIndex = -1;
- int temporaryItemIndex = -1;
int overCount = 0;
bool pushToTopOrMiddle = true;
- if (pListGroupNode->__items.empty() == true)
+ if (pListGroupNode->__items.empty())
{
int loadedGroups = GetAllGroupCount();
_ListViewGroupNode* pTemporaryGroupNode = null;
}
else
{
- while (theIter != pListGroupNode->__items.end())
+ int temporaryGroupIndex = -1;
+ int temporaryItemIndex = -1;
+ _IListItemCommon* pItem = null;
+ _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
+ _LinkedList <_IListItemCommon*>::_Iterator theEndIter = pListGroupNode->__items.end();
+ while (theIter != theEndIter)
{
pItem = *theIter;
pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
return E_SUCCESS;
}
+ ++theIter;
+ }
- if (pItem == pListGroupNode->__items.back())
- {
- int lastLoadedItemIndex = -1;
- int lastLoadedGroupIndex = -1;
- GetLastLoadedItemIndex(lastLoadedGroupIndex,lastLoadedItemIndex);
- if (lastLoadedGroupIndex == temporaryGroupIndex && lastLoadedItemIndex == temporaryItemIndex)
- {
- pushToTopOrMiddle = false;
- }
- else
- {
- pushToTopOrMiddle = true;
- }
-
- break;
- }
-
- theIter++;
+ int lastLoadedItemIndex = -1;
+ int lastLoadedGroupIndex = -1;
+ GetLastLoadedItemIndex(lastLoadedGroupIndex, lastLoadedItemIndex);
+ if (lastLoadedGroupIndex == temporaryGroupIndex && lastLoadedItemIndex == temporaryItemIndex)
+ {
+ pushToTopOrMiddle = false;
+ }
+ else
+ {
+ pushToTopOrMiddle = true;
}
}
SysTryReturn(NID_UI_CTRL, (itemIndex < pListGroupNode->__itemCountInGroup), false, E_INVALID_ARG,
"[E_INVALID_ARG] Wrong item index(%d).", itemIndex);
- _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
-
- _IListItemCommon* pItem = null;
int temporaryGroupIndex = -1;
int temporaryItemIndex = -1;
- while (theIter != pListGroupNode->__items.end())
+
+ _IListItemCommon* pItem = null;
+ _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
+ _LinkedList <_IListItemCommon*>::_Iterator theEndIter = pListGroupNode->__items.end();
+
+ while (theIter != theEndIter)
{
pItem = *theIter;
pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
SysTryReturn(NID_UI_CTRL, itemCount >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The itemCount is not valid.");
- if (__groupNodes.empty() == true || groupIndex == GetAllGroupCount())
+ if (__groupNodes.empty() || groupIndex == GetAllGroupCount())
{
return AddGroup(itemCount);
}
result
_ListViewModel::UnloadAllItem(void)
{
- if (__groupNodes.empty() == true)
+ if (__groupNodes.empty())
{
return E_SUCCESS;
}
itemCount = pListGroupNode->__items.size();
for (int j = itemCount - 1; j >= 0; j--)
{
- pItem = pListGroupNode->__items.at(j);
+ pItem = pListGroupNode->__items.back();
pListGroupNode->__items.pop_back();
if (pItem != null)
__pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex);
}
}
-
- pListGroupNode->__items.clear();
}
}
result
_ListViewModel::RemoveAllItem(bool internalDestroy, bool backupItemStatus)
{
- if (__groupNodes.empty() == true)
+ if (__groupNodes.empty())
{
return E_SUCCESS;
}
__onRemovingAllItems = true;
- int groupCount = GetAllGroupCount();
+ _LinkedList <_ListViewGroupNode*> backupGroupNodes;
+ backupGroupNodes = __groupNodes;
+
+ __countOfAllGroups = 0;
+ __countOfAllItems = 0;
+
+ int groupCount = backupGroupNodes.size();
int itemCount = 0;
_ListViewGroupNode* pListGroupNode = null;
int itemIndex = -1;
for (int i = groupCount - 1; i >= 0; i--)
{
- pListGroupNode = GetGroupNode(i);
+ pListGroupNode = backupGroupNodes.at(i);
if (pListGroupNode != null)
{
for (int j = itemCount - 1; j >= 0; j--)
{
- pItem = pListGroupNode->__items.at(j);
+ pItem = pListGroupNode->__items.back();
pListGroupNode->__items.pop_back();
if (pItem != null)
{
pItem->GetItemIndex(groupIndex, itemIndex);
- if (internalDestroy == false)
+ if (!internalDestroy)
{
__pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex);
}
}
}
- pListGroupNode->__items.clear();
pListGroupNode->__itemCountInGroup = 0;
- if (backupItemStatus == false)
+ if (!backupItemStatus)
{
__groupNodes.remove(pListGroupNode);
delete pListGroupNode;
}
}
- __countOfAllGroups = 0;
- __countOfAllItems = 0;
-
- if (backupItemStatus == false)
- {
- __groupNodes.clear();
- }
- else
+ if (backupItemStatus)
{
- __backupGroupNodes = __groupNodes;
+ __backupGroupNodes = backupGroupNodes;
}
__onRemovingAllItems = false;
void
_ListViewModel::RestoreItemStatus(void)
{
- if (__backupGroupNodes.empty() == true)
+ if (__backupGroupNodes.empty())
{
return;
}
SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG,
"[E_INVALID_ARG] Wrong group index(%d).", groupIndex);
- if (IsLoadedItem(groupIndex, itemIndex) == false)
- {
- return E_SUCCESS;
- }
-
_ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex);
SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(),
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
- _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
-
- _IListItemCommon* pItem = null;
int temporaryGroupIndex = -1;
int temporaryItemIndex = -1;
- while (theIter != pListGroupNode->__items.end())
+ _IListItemCommon* pItem = null;
+ _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
+ _LinkedList <_IListItemCommon*>::_Iterator theEndIter = pListGroupNode->__items.end();
+
+ while (theIter != theEndIter)
{
pItem = *theIter;
pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG,
"[E_INVALID_ARG] Wrong group index(%d).", groupIndex);
- _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex);
- SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(),
- "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
if (itemIndex == -1)
{
return RemoveGroup(groupIndex);
}
- _IListItemCommon* pItem = GetItemFromContainer(groupIndex, itemIndex);
- if (pItem != null)
- {
- pListGroupNode->__items.remove(pItem);
+ _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex);
+ SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(),
+ "[%s] Propagating.", GetErrorMessage(GetLastResult()));
- if (internalDestroy == false)
- {
- __pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex);
- }
- else
- {
- __pListProviderAdaptor->DeleteItem(pItem, groupIndex, itemIndex);
- }
- }
+
+ _IListItemCommon* pItem = GetItemFromContainer(groupIndex, itemIndex);
int temporaryGroupIndex = -1;
int temporaryItemIndex = -1;
+ _IListItemCommon* pTemporaryItem = null;
_LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin();
while (theIter != pListGroupNode->__items.end())
{
- pItem = *theIter;
- pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
+ pTemporaryItem = *theIter;
+ pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
if (temporaryItemIndex > itemIndex)
{
- pItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex - 1);
+ pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex - 1);
}
theIter++;
MoveCheckedAndDisabledItemIndex(pListGroupNode, itemIndex, -1);
+ if (pItem != null)
+ {
+ pListGroupNode->__items.remove(pItem);
+ if (internalDestroy == false)
+ {
+ __pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex);
+ }
+ else
+ {
+ __pListProviderAdaptor->DeleteItem(pItem, groupIndex, itemIndex);
+ }
+ }
+
return E_SUCCESS;
}
SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG,
"[E_INVALID_ARG] Wrong group index(%d).", groupIndex);
- _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex);
- SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(),
+ _ListViewGroupNode* pRemoveGroupNode = GetGroupNode(groupIndex);
+ SysTryReturn(NID_UI_CTRL, pRemoveGroupNode != null, GetLastResult(), GetLastResult(),
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
- // remove group
- _IListItemCommon* pItem = null;
- int temporaryGroupIndex = -1;
- int temporaryItemIndex = -1;
- int itemCount = pListGroupNode->__items.size();
-
- for (int i = itemCount - 1; i >= 0; i--)
- {
- pItem = pListGroupNode->__items.at(i);
- pListGroupNode->__items.pop_back();
-
- if (pItem != null)
- {
- pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
- __pListProviderAdaptor->UnloadItem(pItem, temporaryGroupIndex, temporaryItemIndex);
- }
- }
- pListGroupNode->__items.clear();
+ // remove group from model
+ __groupNodes.erase(__groupNodes.begin() + groupIndex);
- __countOfAllItems -= (pListGroupNode->__itemCountInGroup + 1);
+ __countOfAllItems -= (pRemoveGroupNode->__itemCountInGroup + 1);
__countOfAllGroups--;
- __groupNodes.erase(__groupNodes.begin() + groupIndex);
+ _IListItemCommon* pItem = null;
+ _ListViewGroupNode* pListGroupNode = null;
- delete pListGroupNode;
+ int itemCount = 0;
+ int temporaryGroupIndex = -1;
+ int temporaryItemIndex = -1;
// reset item index
- int groupCount = GetAllGroupCount();
+ int groupCount = __groupNodes.size();
for (int i = groupCount - 1; i >= groupIndex; i--)
{
pListGroupNode = GetGroupNode(i);
}
}
+ // remove group
+ itemCount = pRemoveGroupNode->__items.size();
+
+ for (int i = itemCount - 1; i >= 0; i--)
+ {
+ pItem = pRemoveGroupNode->__items.at(i);
+ pRemoveGroupNode->__items.pop_back();
+
+ if (pItem != null)
+ {
+ pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
+ __pListProviderAdaptor->UnloadItem(pItem, temporaryGroupIndex, temporaryItemIndex);
+ }
+ }
+
+ delete pRemoveGroupNode;
+
return E_SUCCESS;
}
int
_ListViewModel::GetOverflowCount(void) const
{
- int loadedGroups = GetAllGroupCount();
int loadedItems = 0;
+ int loadedGroups = __groupNodes.size();
_ListViewGroupNode* pListGroupNode = null;
for (int i = 0; i < loadedGroups; i++)
{
- pListGroupNode = GetGroupNode(i);
+ pListGroupNode = __groupNodes.at(i);
if (pListGroupNode != null)
{
loadedItems += pListGroupNode->__items.size();
_ListViewModel::IsItemChecked(int groupIndex, int itemIndex) const
{
// check validation
- if (IsValidItem(groupIndex, itemIndex) == false)
+ if (!IsValidItem(groupIndex, itemIndex))
{
return false;
}
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
//radio style
- if (pListGroupNode->__usingRadioStyle == true)
+ if (pListGroupNode->__usingRadioStyle)
{
if (pListGroupNode->__radioCheckedItemIndex == itemIndex)
{
// origin & destination item must be loaded
result
-_ListViewModel::MoveItem(_ListItemPos originPosition, _ListItemPos destinationPosition)
+_ListViewModel::MoveItem(int originGroupIndex, int originItemIndex, int destinationGroupIndex, int destinationItemIndex)
{
- if (IsValidItem(originPosition.groupIndex, originPosition.itemIndex) == false
- || IsValidItem(destinationPosition.groupIndex, destinationPosition.itemIndex - 1) == false)
+ if (IsValidItem(originGroupIndex, originItemIndex) == false
+ || IsValidItem(destinationGroupIndex, destinationItemIndex - 1) == false)
{
SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Item index is not valid.");
return E_SYSTEM;
}
- _ListViewGroupNode* pOriginGroupNode = GetGroupNode(originPosition.groupIndex);
+ _ListViewGroupNode* pOriginGroupNode = GetGroupNode(originGroupIndex);
SysTryReturn(NID_UI_CTRL, pOriginGroupNode != null, GetLastResult(), GetLastResult(),
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
- _ListViewGroupNode* pDestinationGroupNode = GetGroupNode(destinationPosition.groupIndex);
+ _ListViewGroupNode* pDestinationGroupNode = GetGroupNode(destinationGroupIndex);
SysTryReturn(NID_UI_CTRL, pDestinationGroupNode != null, GetLastResult(), GetLastResult(),
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
- _IListItemCommon* pItem = GetItemFromContainer(originPosition.groupIndex, originPosition.itemIndex);
+ _IListItemCommon* pItem = GetItemFromContainer(originGroupIndex, originItemIndex);
SysTryReturn(NID_UI_CTRL, pItem != null, GetLastResult(), GetLastResult(),
"[%s] Propagating.", GetErrorMessage(GetLastResult()));
int indexCount = 0;
bool isFound = false;
- if (originPosition.groupIndex != destinationPosition.groupIndex) // different group
+ if (originGroupIndex != destinationGroupIndex) // different group
{
pOriginGroupNode->__items.remove(pItem);
pTemporaryItem = *theIter;
pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
- if (temporaryItemIndex > originPosition.itemIndex)
+ if (temporaryItemIndex > originItemIndex)
{
pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex - 1);
}
theIter++;
}
- pItem->SetItemIndex(destinationPosition.groupIndex, destinationPosition.itemIndex);
+ pItem->SetItemIndex(destinationGroupIndex, destinationItemIndex);
_LinkedList <_IListItemCommon*>::_Iterator destinationIter = pDestinationGroupNode->__items.begin();
while (destinationIter != pDestinationGroupNode->__items.end())
pTemporaryItem = *destinationIter;
pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
- if (temporaryItemIndex >= destinationPosition.itemIndex)
+ if (temporaryItemIndex >= destinationItemIndex)
{
pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex + 1);
- if (temporaryItemIndex == destinationPosition.itemIndex)
+ if (temporaryItemIndex == destinationItemIndex)
{
pDestinationGroupNode->__items.insert(destinationIter, pItem);
isFound = true;
}
// remove checked(radio/check) & disabled item index
- MoveCheckedAndDisabledItemIndex(pOriginGroupNode, originPosition.itemIndex, -1, pItem->IsChecked(), pItem->IsItemEnabled());
+ MoveCheckedAndDisabledItemIndex(pOriginGroupNode, originItemIndex, -1, pItem->IsChecked(), pItem->IsItemEnabled());
// insert checked(radio/check) & disabled item index
- MoveCheckedAndDisabledItemIndex(pDestinationGroupNode, -1, destinationPosition.itemIndex, pItem->IsChecked(), pItem->IsItemEnabled());
+ MoveCheckedAndDisabledItemIndex(pDestinationGroupNode, -1, destinationItemIndex, pItem->IsChecked(), pItem->IsItemEnabled());
pOriginGroupNode->__itemCountInGroup--;
pDestinationGroupNode->__itemCountInGroup++;
pTemporaryItem = *theIter;
pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex);
- if (temporaryItemIndex < originPosition.itemIndex && temporaryItemIndex >= destinationPosition.itemIndex)
+ if (temporaryItemIndex < originItemIndex && temporaryItemIndex >= destinationItemIndex)
{
pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex + 1);
}
- else if (temporaryItemIndex > originPosition.itemIndex && temporaryItemIndex <= destinationPosition.itemIndex)
+ else if (temporaryItemIndex > originItemIndex && temporaryItemIndex <= destinationItemIndex)
{
pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex - 1);
- if (temporaryItemIndex == destinationPosition.itemIndex)
+ if (temporaryItemIndex == destinationItemIndex)
{
indexCount++;
}
}
- else if (temporaryItemIndex > originPosition.itemIndex && temporaryItemIndex > destinationPosition.itemIndex)
+ else if (temporaryItemIndex > originItemIndex && temporaryItemIndex > destinationItemIndex)
{
break;
}
- if (temporaryItemIndex < destinationPosition.itemIndex)
+ if (temporaryItemIndex < destinationItemIndex)
{
indexCount++;
}
indexCount = 0;
}
- pItem->SetItemIndex(destinationPosition.groupIndex, destinationPosition.itemIndex);
+ pItem->SetItemIndex(destinationGroupIndex, destinationItemIndex);
pOriginGroupNode->__items.insert(pOriginGroupNode->__items.begin() + indexCount, pItem);
// move checked(radio/check) & disabled item index
- MoveCheckedAndDisabledItemIndex(pOriginGroupNode, originPosition.itemIndex, destinationPosition.itemIndex, pItem->IsChecked(), pItem->IsItemEnabled());
+ MoveCheckedAndDisabledItemIndex(pOriginGroupNode, originItemIndex, destinationItemIndex, pItem->IsChecked(), pItem->IsItemEnabled());
}
return E_SUCCESS;
}
+result
+_ListViewModel::MoveItem(_ListItemPos originPosition, _ListItemPos destinationPosition)
+{
+ return MoveItem(originPosition.groupIndex, originPosition.itemIndex, destinationPosition.groupIndex, destinationPosition.itemIndex);
+}
+
// insert mode : originItemIndex == -1
// remove mode : destinationItemIndex == -1
void
}
// move checked(radio/check) item index
- if (pListGroupNode->__usingRadioStyle == true)
+ if (pListGroupNode->__usingRadioStyle)
{
//radio style
if (checked == true || (pListGroupNode->__radioCheckedItemIndex == originItemIndex && originItemIndex != -1)) // for insert mode
else if (checkedItemIndex == originItemIndex)
{
pListGroupNode->__checkedItems.erase(theIter);
+ continue;
}
else if (checkedItemIndex > originItemIndex && checkedItemIndex > temporaryDestinationIndex)
{
else if (disabledItemIndex == originItemIndex)
{
pListGroupNode->__disabledItems.erase(theIter);
+ continue;
}
else if (disabledItemIndex > originItemIndex && disabledItemIndex > temporaryDestinationIndex)
{
_ListViewGroupNode*
_ListViewModel::GetGroupNode(int groupIndex) const
{
- if (__groupNodes.empty() == true)
+ if (__groupNodes.empty())
{
SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] GroupNode is Empty.");
return null;
_ReverseIterator(_ListNode* _p = null)
: __pPos(_p) {}
+ _Iterator base() const
+ {
+ _Iterator _retval(__pPos);
+ return _retval;
+ }
+
_ReverseIterator& operator ++(void)
{
__pPos = __pPos->pPrev;
_ReverseIterator operator --(int)
{
- _Iterator _retval = *this;
+ _ReverseIterator _retval = *this;
--*this;
return _retval;
} //post
_ReverseIterator rend(void) const { return _ReverseIterator(__pHead);}
private:
- void insert_node(_Iterator, _ListNode *, _ListNode *, const T &);
- void delete_node(_Iterator, _ListNode *, _ListNode*);
+ void insert_node(_ListNode *, _ListNode *, const T &);
+ void insert_node(_Iterator&, const T &);
+ void delete_node(_ListNode *, _ListNode*);
+ void delete_node(_Iterator&);
void swap_node(_ListNode*, _ListNode*);
void sort_node(bool (*)(T, T), _ListNode *, _ListNode*);
int count_node(_ListNode*, _ListNode*);
void
_LinkedList <T>::insert(_Iterator& _where, const T& _val)
{
- insert_node(_where, null, null, _val);
+ insert_node(_where, _val);
}
template<class T>
void
_LinkedList <T>::erase(_Iterator& _where)
{
- delete_node(_where, null, null);
+ delete_node(_where);
}
template<class T>
void
_LinkedList <T>::push_front(const T& _val)
{
- insert_node(null, __pHead->pNext, null, _val);
+ insert_node(__pHead->pNext, null, _val);
}
template<class T>
void
_LinkedList <T>::push_back(const T& _val)
{
- insert_node(null, null, __pTail->pPrev, _val);
+ insert_node(null, __pTail->pPrev, _val);
}
template<class T>
void
_LinkedList <T>::pop_front(void)
{
- delete_node(null, __pHead->pNext, null);
+ delete_node(__pHead->pNext, null);
}
template<class T>
void
_LinkedList <T>::pop_back(void)
{
- delete_node(null, null, __pTail->pPrev);
+ delete_node(null, __pTail->pPrev);
}
template<class T>
template<class T>
void
-_LinkedList <T>::insert_node(_Iterator _where, _ListNode* _first, _ListNode* _last, const T& _val)
+_LinkedList <T>::insert_node(_ListNode* _first, _ListNode* _last, const T& _val)
{
_ListNode* _pNewNode = new (std::nothrow) _ListNode;
_pNewNode->val = _val;
- if (_where == null)
+ if (!_first && !_last)
{
- if (!_first && !_last)
- {
- __pHead->pNext = _pNewNode;
- __pTail->pPrev = _pNewNode;
- }
- else if (_first)
- {
- _pNewNode->pPrev = __pHead;
- _pNewNode->pNext = __pHead->pNext;
- __pHead->pNext->pPrev = _pNewNode;
- __pHead->pNext = _pNewNode;
- }
- else
- {
- _pNewNode->pPrev = __pTail->pPrev;
- _pNewNode->pNext = __pTail;
- __pTail->pPrev->pNext = _pNewNode;
- __pTail->pPrev = _pNewNode;
- }
+ __pHead->pNext = _pNewNode;
+ __pTail->pPrev = _pNewNode;
+ }
+ else if (_first)
+ {
+ _pNewNode->pPrev = __pHead;
+ _pNewNode->pNext = __pHead->pNext;
+ __pHead->pNext->pPrev = _pNewNode;
+ __pHead->pNext = _pNewNode;
}
else
{
- if (_where.__pPos == __pHead->pNext)
- {
- _pNewNode->pPrev = __pHead;
- _pNewNode->pNext = __pHead->pNext;
- __pHead->pNext->pPrev = _pNewNode;
- __pHead->pNext = _pNewNode;
- }
- else if (_where.__pPos == __pTail)
- {
- _pNewNode->pPrev = __pTail->pPrev;
- _pNewNode->pNext = __pTail;
- __pTail->pPrev->pNext = _pNewNode;
- __pTail->pPrev = _pNewNode;
- }
- else
- {
- _pNewNode->pPrev = _where.__pPos->pPrev;
- _where.__pPos->pPrev->pNext = _pNewNode;
- _pNewNode->pNext = _where.__pPos;
- _where.__pPos->pPrev = _pNewNode;
- }
+ _pNewNode->pPrev = __pTail->pPrev;
+ _pNewNode->pNext = __pTail;
+ __pTail->pPrev->pNext = _pNewNode;
+ __pTail->pPrev = _pNewNode;
+ }
- _where++;
+ __length++;
+}
+
+
+template<class T>
+void
+_LinkedList <T>::insert_node(_Iterator& _where, const T& _val)
+{
+ _ListNode* _pNewNode = new (std::nothrow) _ListNode;
+ _pNewNode->val = _val;
+
+ if (_where.__pPos == __pHead->pNext)
+ {
+ _pNewNode->pPrev = __pHead;
+ _pNewNode->pNext = __pHead->pNext;
+ __pHead->pNext->pPrev = _pNewNode;
+ __pHead->pNext = _pNewNode;
+ }
+ else if (_where.__pPos == __pTail)
+ {
+ _pNewNode->pPrev = __pTail->pPrev;
+ _pNewNode->pNext = __pTail;
+ __pTail->pPrev->pNext = _pNewNode;
+ __pTail->pPrev = _pNewNode;
+ }
+ else
+ {
+ _pNewNode->pPrev = _where.__pPos->pPrev;
+ _where.__pPos->pPrev->pNext = _pNewNode;
+ _pNewNode->pNext = _where.__pPos;
+ _where.__pPos->pPrev = _pNewNode;
}
__length++;
template<class T>
void
-_LinkedList <T>::delete_node(_Iterator _where, _ListNode* _first, _ListNode* _last)
+_LinkedList <T>::delete_node(_ListNode* _first, _ListNode* _last)
{
if (__length <= 0)
{
return;
}
- if (_where == null)
+ if ((_first == __pHead->pNext) && (_first == __pTail->pPrev)) // only one node
{
- if ((_first == __pHead->pNext) && (_first == __pTail->pPrev)) // only one node
- {
- delete __pHead->pNext;
- __pHead->pNext = __pTail;
- __pTail->pPrev = __pHead;
- }
- else if (_first) // pop_front
+ delete __pHead->pNext;
+ __pHead->pNext = __pTail;
+ __pTail->pPrev = __pHead;
+ }
+ else if (_first) // pop_front
+ {
+ __pHead->pNext = __pHead->pNext->pNext;
+ delete __pHead->pNext->pPrev;
+ __pHead->pNext->pPrev = __pHead;
+ }
+ else if (_last) // pop_back
+ {
+ __pTail->pPrev = __pTail->pPrev->pPrev;
+ delete __pTail->pPrev->pNext;
+ __pTail->pPrev->pNext = __pTail;
+ }
+ else
+ {
+ return;
+ }
+
+ __length--;
+}
+
+template<class T>
+void
+_LinkedList <T>::delete_node(_Iterator& _where)
+{
+ if (__length <= 0)
+ {
+ return;
+ }
+
+ if ((_where.__pPos == __pHead->pNext) && (_where.__pPos == __pTail->pPrev))
+ {
+ delete __pHead->pNext;
+ __pHead->pNext = __pTail;
+ __pTail->pPrev = __pHead;
+
+ _where.__pPos = __pTail;
+ }
+ else
+ {
+ if (_where.__pPos == __pHead->pNext)
{
__pHead->pNext = __pHead->pNext->pNext;
delete __pHead->pNext->pPrev;
__pHead->pNext->pPrev = __pHead;
+
+ _where.__pPos = __pHead->pNext;
}
- else if (_last) // pop_back
+ else if (_where.__pPos == __pTail->pPrev)
{
__pTail->pPrev = __pTail->pPrev->pPrev;
delete __pTail->pPrev->pNext;
__pTail->pPrev->pNext = __pTail;
+
+ _where.__pPos = __pTail;
}
else
{
- return;
- }
- }
- else
- {
- if ((_where.__pPos == __pHead->pNext) && (_where.__pPos == __pTail->pPrev))
- {
- delete __pHead->pNext;
- __pHead->pNext = __pTail;
- __pTail->pPrev = __pHead;
- }
- else
- {
- if (_where.__pPos == __pHead->pNext)
- {
- __pHead->pNext = __pHead->pNext->pNext;
- delete __pHead->pNext->pPrev;
- __pHead->pNext->pPrev = __pHead;
- }
- else if (_where.__pPos == __pTail->pPrev)
- {
- __pTail->pPrev = __pTail->pPrev->pPrev;
- delete __pTail->pPrev->pNext;
- __pTail->pPrev->pNext = __pTail;
- }
- else
- {
- _where.__pPos->pPrev->pNext = _where.__pPos->pNext;
- _where.__pPos->pNext->pPrev = _where.__pPos->pPrev;
- delete _where.__pPos;
- _where.__pPos = null;
- }
+ _ListNode* pDeleteNode = _where.__pPos;
+
+ pDeleteNode->pPrev->pNext = pDeleteNode->pNext;
+ pDeleteNode->pNext->pPrev = pDeleteNode->pPrev;
+ _where.__pPos = pDeleteNode->pNext;
+// ++_where;
+
+ delete pDeleteNode;
}
}