//************************************************************************ // Adds a group //************************************************************************ CListContainer<CContactListEntry*,CContactListGroup*> *CContactList::AddGroupByString(tstring strGroup) { tstring strParse = strGroup; tstring strPath = _T(""); CListContainer<CContactListEntry*,CContactListGroup*> *pGroup = (CListContainer<CContactListEntry*,CContactListGroup*>*)this; CListContainer<CContactListEntry*,CContactListGroup*> *pGroup2 = NULL; tstring::size_type pos; while((pos = strParse.find('\\')) != tstring::npos ) { strGroup = strParse.substr(0,pos); strParse = strParse.substr(pos+1); strPath += strGroup; if(pGroup2 = FindGroupInGroup(strGroup,pGroup)) pGroup = pGroup2; else { CContactListGroup *pGroupObject = GetGroupObjectByPath(strPath); if(!pGroupObject) pGroupObject = CreateGroupObjectByPath(strPath); pGroup2 = pGroup->InsertGroup(pGroup->begin(),pGroupObject); pGroup->sort(CContactList::CompareEntries); pGroup = pGroup2; } ASSERT(pGroup != NULL); strPath += _T("\\"); } strPath += strParse; if(pGroup2 = FindGroupInGroup(strParse,pGroup)) return pGroup2; else { CContactListGroup *pGroupObject = GetGroupObjectByPath(strPath); if(!pGroupObject) pGroupObject = CreateGroupObjectByPath(strPath); pGroup2 = pGroup->InsertGroup(pGroup->begin(),pGroupObject); pGroup->sort(CContactList::CompareEntries); return pGroup2; } }