From 22d42330716a38bfe2faef08eec2b2d3cab1886d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 28 May 2016 09:20:04 +0000 Subject: SortedList emulation expunged git-svn-id: http://svn.miranda-ng.org/main/trunk@16878 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_clistint.h | 19 +- plugins/Clist_modern/src/modern_cachefuncs.cpp | 20 +- plugins/Clist_modern/src/modern_clc.cpp | 8 +- plugins/Clist_modern/src/modern_clcidents.cpp | 16 +- plugins/Clist_modern/src/modern_clcitems.cpp | 35 ++-- plugins/Clist_modern/src/modern_clcmsgs.cpp | 54 ++--- plugins/Clist_modern/src/modern_clcpaint.cpp | 40 ++-- plugins/Clist_modern/src/modern_clcutils.cpp | 6 +- .../Clist_modern/src/modern_rowheight_funcs.cpp | 18 +- plugins/Clist_nicer/src/clc.cpp | 4 +- plugins/Clist_nicer/src/clcitems.cpp | 14 +- plugins/Clist_nicer/src/clcpaint.cpp | 20 +- plugins/Clist_nicer/src/rowheight_funcs.cpp | 4 +- plugins/TipperYM/src/mir_smileys.h | 2 +- plugins/UserInfoEx/src/svc_constants.cpp | 2 +- plugins/Variables/src/tokenregister.cpp | 6 +- src/core/stdclist/src/clcpaint.cpp | 4 +- src/mir_app/src/clc.cpp | 15 +- src/mir_app/src/clcidents.cpp | 12 +- src/mir_app/src/clcitems.cpp | 219 ++++++++++----------- src/mir_app/src/clcmsgs.cpp | 54 ++--- src/mir_app/src/clcutils.cpp | 26 +-- 22 files changed, 294 insertions(+), 304 deletions(-) diff --git a/include/m_clistint.h b/include/m_clistint.h index 61d0188423..8c312f4d63 100644 --- a/include/m_clistint.h +++ b/include/m_clistint.h @@ -78,16 +78,13 @@ struct ClcContact; struct ClcData; struct ClcCacheEntry; -struct ContactList +struct ClcGroup : public MZeroedObject { - struct ClcContact** items; - int count, limit, increment; - void* sortFunc; -}; + __forceinline ClcGroup(int _limit) : + cl(_limit) + {} -struct ClcGroup -{ - ContactList cl; + LIST cl; int expanded, hideOffline, groupId; ClcGroup *parent; int scanIndex; @@ -121,8 +118,12 @@ struct ClcContactBase ClcCacheEntry *pce; // cache is persistent, contacts aren't }; -struct ClcDataBase +struct ClcDataBase : public MZeroedObject { + __forceinline ClcDataBase() : + list(50) + {} + ClcGroup list; int rowHeight; int yScroll; diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 99d5a93fcc..de7d5078df 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -65,8 +65,8 @@ void Cache_GetText(ClcData *dat, ClcContact *contact) if (!dat->force_in_dialog) { if (dat->secondLine.show) - Cache_GetNthLineText(dat, contact->pce, 2); - if (dat->thirdLine.show) + Cache_GetNthLineText(dat, contact->pce, 2); + if (dat->thirdLine.show) Cache_GetNthLineText(dat, contact->pce, 3); } } @@ -602,19 +602,19 @@ static BOOL ExecuteOnAllContactsOfGroup(ClcGroup *group, ExecuteOnAllContactsFun if (!group) return TRUE; - for (int scanIndex = 0; scanIndex < group->cl.count; scanIndex++) { - if (group->cl.items[scanIndex]->type == CLCIT_CONTACT) { - if (!func(group->cl.items[scanIndex], FALSE, param)) + for (int scanIndex = 0; scanIndex < group->cl.getCount(); scanIndex++) { + if (group->cl[scanIndex]->type == CLCIT_CONTACT) { + if (!func(group->cl[scanIndex], FALSE, param)) return FALSE; - if (group->cl.items[scanIndex]->iSubAllocated > 0) { - for (int i = 0; i < group->cl.items[scanIndex]->iSubAllocated; i++) - if (!func(&group->cl.items[scanIndex]->subcontacts[i], TRUE, param)) + if (group->cl[scanIndex]->iSubAllocated > 0) { + for (int i = 0; i < group->cl[scanIndex]->iSubAllocated; i++) + if (!func(&group->cl[scanIndex]->subcontacts[i], TRUE, param)) return FALSE; } } - else if (group->cl.items[scanIndex]->type == CLCIT_GROUP) - if (!ExecuteOnAllContactsOfGroup(group->cl.items[scanIndex]->group, func, param)) + else if (group->cl[scanIndex]->type == CLCIT_GROUP) + if (!ExecuteOnAllContactsOfGroup(group->cl[scanIndex]->group, func, param)) return FALSE; } diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index b4fdd72147..187c06b76d 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -211,14 +211,14 @@ static int clcSearchNextContact(HWND hwnd, ClcData *dat, int index, const TCHAR if (index == -1) fReturnAsFound = TRUE; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type != CLCIT_DIVIDER) { bool found; if (cc->type == CLCIT_GROUP) { @@ -281,7 +281,7 @@ static BOOL clcItemNotHiddenOffline(ClcGroup *group, ClcContact *contact) static LRESULT clcOnCreate(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - dat = (ClcData*)mir_calloc(sizeof(ClcData)); + dat = new ClcData(); SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat); dat->hCheckBoxTheme = xpt_AddThemeHandle(hwnd, L"BUTTON"); dat->m_paintCouter = 0; @@ -1404,7 +1404,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam if (hSelItem) { if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) - dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact)); + dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); else dat->selection = -1; } diff --git a/plugins/Clist_modern/src/modern_clcidents.cpp b/plugins/Clist_modern/src/modern_clcidents.cpp index 27d645eb3c..8cb539e218 100644 --- a/plugins/Clist_modern/src/modern_clcidents.cpp +++ b/plugins/Clist_modern/src/modern_clcidents.cpp @@ -26,8 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int GetContactIndex(ClcGroup *group, ClcContact *contact) { - for (int i = 0; i < group->cl.count; i++) - if (group->cl.items[i]->hContact == contact->hContact) + for (int i = 0; i < group->cl.getCount(); i++) + if (group->cl[i]->hContact == contact->hContact) return i; return -1; @@ -40,7 +40,7 @@ int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) bool bMetaExpanding = db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT) != 0; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; @@ -49,7 +49,7 @@ int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) if (group == subgroup && contactIndex - subcontactscount == group->scanIndex) return count; count++; - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { if (cc->group == subgroup && contactIndex == -1) return count - 1; @@ -92,7 +92,7 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro group = &dat->list; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; @@ -110,7 +110,7 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro if (nowVisible) index++; - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if ((IsHContactGroup(dwItem) && cc->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == cc->groupId) || (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->hContact == dwItem) || (IsHContactInfo(dwItem) && cc->type == CLCIT_INFO && cc->hContact == (dwItem & ~HCONTACT_ISINFO))) { @@ -167,14 +167,14 @@ int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (testindex == index) { if (contact) *contact = cc; if (subgroup) *subgroup = group; diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index fc14c85bc9..578a8b8fd0 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -172,14 +172,14 @@ static ClcContact* AddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hCo dat->bNeedsResort = true; int i; - for (i = group->cl.count - 1; i >= 0; i--) - if (group->cl.items[i]->type != CLCIT_INFO || !(group->cl.items[i]->flags & CLCIIF_BELOWCONTACTS)) + for (i = group->cl.getCount() - 1; i >= 0; i--) + if (group->cl[i]->type != CLCIT_INFO || !(group->cl[i]->flags & CLCIIF_BELOWCONTACTS)) break; i = pcli->pfnAddItemToGroup(group, i + 1); - _LoadDataToContact(group->cl.items[i], group, dat, hContact); - return group->cl.items[i]; + _LoadDataToContact(group->cl[i], group, dat, hContact); + return group->cl[i]; } void cli_AddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int updateTotalCount, int checkHideOffline) @@ -228,9 +228,9 @@ int RestoreSelection(ClcData *dat, MCONTACT hSelected) } if (!selcontact->iSubNumber) - dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact)); + dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); else { - dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact->subcontacts)); + dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact->subcontacts)); if (dat->selection != -1) dat->selection += selcontact->iSubNumber; } @@ -251,9 +251,8 @@ void cliRebuildEntireList(HWND hwnd, ClcData *dat) RowHeights_GetMaxRowHeight(dat, hwnd); dat->list.expanded = 1; - dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", SETTING_HIDEOFFLINEATROOT_DEFAULT) && style&CLS_USEGROUPS; - dat->list.cl.count = dat->list.cl.limit = 0; - dat->list.cl.increment = 50; + dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", SETTING_HIDEOFFLINEATROOT_DEFAULT) && style & CLS_USEGROUPS; + dat->list.cl.destroy(); dat->bNeedsResort = true; MCONTACT hSelected = SaveSelection(dat); @@ -307,16 +306,16 @@ void cliRebuildEntireList(HWND hwnd, ClcData *dat) group = &dat->list; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { - if (cc->group->cl.count == 0) + if (cc->group->cl.getCount() == 0) group = pcli->pfnRemoveItemFromGroup(hwnd, group, cc, 0); else { group = cc->group; @@ -351,7 +350,7 @@ int GetNewSelection(ClcGroup *group, int selection, int direction) group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; @@ -366,7 +365,7 @@ int GetNewSelection(ClcGroup *group, int selection, int direction) if (!direction && count > selection) return lastcount; - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP && (cc->group->expanded)) { group = cc->group; group->scanIndex = 0; @@ -431,12 +430,12 @@ void cli_SetContactCheckboxes(ClcContact *cc, int checked) int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly) { - int count = group->cl.count; + int count = group->cl.getCount(); ClcGroup *topgroup = group; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if (group == topgroup) break; group = group->parent; @@ -444,11 +443,11 @@ int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly) continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP && (!(visibleOnly & 0x01) || cc->group->expanded)) { group = cc->group; group->scanIndex = 0; - count += group->cl.count; + count += group->cl.getCount(); continue; } if (cc->type == CLCIT_CONTACT && cc->subcontacts != NULL && (cc->bSubExpanded || !visibleOnly)) diff --git a/plugins/Clist_modern/src/modern_clcmsgs.cpp b/plugins/Clist_modern/src/modern_clcmsgs.cpp index 0f21a91832..8d540bf13b 100644 --- a/plugins/Clist_modern/src/modern_clcmsgs.cpp +++ b/plugins/Clist_modern/src/modern_clcmsgs.cpp @@ -108,68 +108,68 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP if (wParam != CLGN_ROOT) { if (!pcli->pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL)) return NULL; - i = List_IndexOf((SortedList*)&group->cl, contact); + i = group->cl.indexOf(contact); if (i < 0) return 0; } switch (wParam) { case CLGN_ROOT: - if (dat->list.cl.count) - return (LRESULT)pcli->pfnContactToHItem(dat->list.cl.items[0]); + if (dat->list.cl.getCount()) + return (LRESULT)pcli->pfnContactToHItem(dat->list.cl[0]); else return NULL; case CLGN_CHILD: if (contact->type != CLCIT_GROUP) return NULL; group = contact->group; - if (group->cl.count == 0) + if (group->cl.getCount() == 0) return NULL; - return (LRESULT)pcli->pfnContactToHItem(group->cl.items[0]); + return (LRESULT)pcli->pfnContactToHItem(group->cl[0]); case CLGN_PARENT: return group->groupId | HCONTACT_ISGROUP; case CLGN_NEXT: do { - if (++i >= group->cl.count) + if (++i >= group->cl.getCount()) return NULL; - } while (group->cl.items[i]->type == CLCIT_DIVIDER); - return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]); + } while (group->cl[i]->type == CLCIT_DIVIDER); + return (LRESULT)pcli->pfnContactToHItem(group->cl[i]); case CLGN_PREVIOUS: do { if (--i < 0) return NULL; - } while (group->cl.items[i]->type == CLCIT_DIVIDER); - return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]); + } while (group->cl[i]->type == CLCIT_DIVIDER); + return (LRESULT)pcli->pfnContactToHItem(group->cl[i]); case CLGN_NEXTCONTACT: - for (i++; i < group->cl.count; i++) - if (group->cl.items[i]->type == CLCIT_CONTACT) + for (i++; i < group->cl.getCount(); i++) + if (group->cl[i]->type == CLCIT_CONTACT) break; - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; - return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]); + return (LRESULT)pcli->pfnContactToHItem(group->cl[i]); case CLGN_PREVIOUSCONTACT: - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; for (i--; i >= 0; i--) - if (group->cl.items[i]->type == CLCIT_CONTACT) + if (group->cl[i]->type == CLCIT_CONTACT) break; if (i < 0) return NULL; - return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]); + return (LRESULT)pcli->pfnContactToHItem(group->cl[i]); case CLGN_NEXTGROUP: - for (i++; i < group->cl.count; i++) - if (group->cl.items[i]->type == CLCIT_GROUP) + for (i++; i < group->cl.getCount(); i++) + if (group->cl[i]->type == CLCIT_GROUP) break; - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; - return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]); + return (LRESULT)pcli->pfnContactToHItem(group->cl[i]); case CLGN_PREVIOUSGROUP: - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; for (i--; i >= 0; i--) - if (group->cl.items[i]->type == CLCIT_GROUP) + if (group->cl[i]->type == CLCIT_GROUP) break; if (i < 0) return NULL; - return (LRESULT)pcli->pfnContactToHItem(group->cl.items[i]); + return (LRESULT)pcli->pfnContactToHItem(group->cl[i]); } } return NULL; @@ -185,11 +185,11 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP pcli->pfnSetGroupExpand(hwnd, dat, tgroup, 1); if (!contact->iSubNumber) { - index = List_IndexOf((SortedList*)&group->cl, contact); + index = group->cl.indexOf(contact); mainindex = index; } else { - index = List_IndexOf((SortedList*)&group->cl, contact->subcontacts); + index = group->cl.indexOf(contact->subcontacts); mainindex = index; index += contact->iSubNumber; } @@ -197,7 +197,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP BYTE k = db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT); if (k) { for (int i = 0; i < mainindex; i++) { - ClcContact *tempCont = group->cl.items[i]; + ClcContact *tempCont = group->cl[i]; if (tempCont->type == CLCIT_CONTACT && tempCont->iSubAllocated && tempCont->bSubExpanded) index += tempCont->iSubAllocated; } diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index 2c89f39c2f..0091db8bce 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -544,7 +544,7 @@ MODERNMASK* CLCPaint::_GetCLCContactRowBackModernMask(ClcGroup *group, ClcContac _AddParamShort(mpModernMask, hi_Type, hi_Group); if (Drawing->group) { _AddParamShort(mpModernMask, hi_Open, Drawing->group->expanded ? hi_True : hi_False); - _AddParamShort(mpModernMask, hi_IsEmpty, (Drawing->group->cl.count == 0) ? hi_True : hi_False); + _AddParamShort(mpModernMask, hi_IsEmpty, (Drawing->group->cl.getCount() == 0) ? hi_True : hi_False); } break; @@ -598,11 +598,11 @@ MODERNMASK* CLCPaint::_GetCLCContactRowBackModernMask(ClcGroup *group, ClcContac break; } - if (group->scanIndex == 0 && group->cl.count == 1) + if (group->scanIndex == 0 && group->cl.getCount() == 1) _AddParamShort(mpModernMask, hi_GroupPos, hi_First_Single); else if (group->scanIndex == 0) _AddParamShort(mpModernMask, hi_GroupPos, hi_First); - else if (group->scanIndex + 1 == group->cl.count) + else if (group->scanIndex + 1 == group->cl.getCount()) _AddParamShort(mpModernMask, hi_GroupPos, hi_Last); else _AddParamShort(mpModernMask, hi_GroupPos, hi_Mid); @@ -625,7 +625,7 @@ MODERNMASK* CLCPaint::_GetCLCContactRowBackModernMask(ClcGroup *group, ClcContac } if (group->parent) { - TCHAR *b2 = NEWTSTR_ALLOCA(group->parent->cl.items[0]->szText); + TCHAR *b2 = NEWTSTR_ALLOCA(group->parent->cl[0]->szText); for (int i = 0; b2[i] != 0; i++) if (b2[i] == _T(',')) b2[i] = _T('.'); @@ -663,7 +663,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R if (Drawing->type == CLCIT_GROUP && Drawing->group->parent->groupId == 0 && - Drawing->group->parent->cl.items[0] != Drawing) { + Drawing->group->parent->cl[0] != Drawing) { dg = dat->row_before_group_space; free_row_rc.top += dg; height -= dg; @@ -1619,7 +1619,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint, while (y < rcPaint->bottom) { if (subindex == -1) { - if (group->scanIndex >= group->cl.count) { + if (group->scanIndex >= group->cl.getCount()) { group = group->parent; indent--; if (group == NULL) break; // Finished list @@ -1638,11 +1638,11 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint, // Get item to draw int subident = 0; ClcContact *Drawing; - if (group->scanIndex < group->cl.count) { + if (group->scanIndex < group->cl.getCount()) { if (subindex == -1) - Drawing = group->cl.items[group->scanIndex]; + Drawing = group->cl[group->scanIndex]; else { - Drawing = &group->cl.items[group->scanIndex]->subcontacts[subindex]; + Drawing = &group->cl[group->scanIndex]->subcontacts[subindex]; subident = dat->subIndent; } } @@ -1702,8 +1702,8 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint, RECT mrc = row_rc; if (group->parent == 0 && group->scanIndex != 0 - && group->scanIndex < group->cl.count - && group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { + && group->scanIndex < group->cl.getCount() + && group->cl[group->scanIndex]->type == CLCIT_GROUP) { mrc.top += dat->row_before_group_space; } SkinDrawGlyphMask(pc.hdcMem, &mrc, rcPaint, mpRequest); @@ -1712,7 +1712,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint, RECT mrc = row_rc; if (Drawing->type == CLCIT_GROUP && Drawing->group->parent->groupId == 0 && - Drawing->group->parent->cl.items[0] != Drawing) { + Drawing->group->parent->cl[0] != Drawing) { mrc.top += dat->row_before_group_space; } // Selection background ( only if hole line - full/less ) @@ -1789,7 +1789,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint, RECT mrc = row_rc; if (Drawing->type == CLCIT_GROUP && Drawing->group->parent->groupId == 0 && - Drawing->group->parent->cl.items[0] != Drawing) { + Drawing->group->parent->cl[0] != Drawing) { mrc.top += dat->row_before_group_space; } SkinDrawGlyphMask(pc.hdcMem, &mrc, rcPaint, mpRequest); @@ -1802,17 +1802,17 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint, y += iRowHeight; // increment by subcontacts - if ((group->cl.items && group->scanIndex < group->cl.count && group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP) - && (group->cl.items[group->scanIndex]->bSubExpanded && dat->expandMeta)) { - if (subindex < group->cl.items[group->scanIndex]->iSubAllocated - 1) + ClcContact *cc = group->cl[group->scanIndex]; + if (cc != NULL && cc->subcontacts != NULL && cc->type != CLCIT_GROUP && cc->bSubExpanded && dat->expandMeta) { + if (subindex < cc->iSubAllocated - 1) subindex++; else subindex = -1; } - if (subindex == -1 && group->scanIndex < group->cl.count) { - if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) { - group = group->cl.items[group->scanIndex]->group; + if (cc && subindex == -1) { + if (cc->type == CLCIT_GROUP && cc->group->expanded) { + group = cc->group; indent++; group->scanIndex = 0; subindex = -1; @@ -1820,7 +1820,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint, } group->scanIndex++; } - else if (group->scanIndex >= group->cl.count) { + else if (group->scanIndex >= group->cl.getCount()) { subindex = -1; } } diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index 6c0364836f..fa95b706b5 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -341,7 +341,7 @@ int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt) ok = 1; } else if ((pt.y + dat->yScroll >= cliGetRowTopY(dat, hit + 1) - dat->insertionMarkHitHeight) - || (contact->type == CLCIT_GROUP && contact->group->expanded && contact->group->cl.count > 0)) { + || (contact->type == CLCIT_GROUP && contact->group->expanded && contact->group->cl.getCount() > 0)) { //could be insertion mark (below) topItem = hit; bottomItem = hit + 1; topcontact = contact; topgroup = group; @@ -664,14 +664,14 @@ int cliFindRowByText(HWND hwnd, ClcData *dat, const TCHAR *text, int prefixOk) group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type != CLCIT_DIVIDER) { bool found; if (dat->bFilterSearch) { diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp index d57c546a3a..b239ea046e 100644 --- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp @@ -78,7 +78,7 @@ int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item) tmp = max(tmp, ICON_HEIGHT); tmp = max(tmp, dat->row_min_heigh); tmp += dat->row_border * 2; - if (contact->type == CLCIT_GROUP && contact->group->parent->groupId == 0 && contact->group->parent->cl.items[0] != contact) + if (contact->type == CLCIT_GROUP && contact->group->parent->groupId == 0 && contact->group->parent->cl[0] != contact) tmp += dat->row_before_group_space; if (item != -1) dat->row_heights[item] = tmp; @@ -417,7 +417,7 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd) int subident; ClcContact *Drawing; if (subindex == -1) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; @@ -426,12 +426,12 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd) } // Get item to draw - Drawing = group->cl.items[group->scanIndex]; + Drawing = group->cl[group->scanIndex]; subident = 0; } else { // Get item to draw - Drawing = &group->cl.items[group->scanIndex]->subcontacts[subindex]; + Drawing = &group->cl[group->scanIndex]->subcontacts[subindex]; subident = dat->subIndent; } @@ -444,9 +444,9 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd) RowHeight_CalcRowHeight(dat, Drawing, line_num); // increment by subcontacts - if (group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP) { - if (group->cl.items[group->scanIndex]->bSubExpanded && dat->expandMeta) { - if (subindex < group->cl.items[group->scanIndex]->iSubAllocated - 1) + if (group->cl[group->scanIndex]->subcontacts != NULL && group->cl[group->scanIndex]->type != CLCIT_GROUP) { + if (group->cl[group->scanIndex]->bSubExpanded && dat->expandMeta) { + if (subindex < group->cl[group->scanIndex]->iSubAllocated - 1) subindex++; else subindex = -1; @@ -454,8 +454,8 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd) } if (subindex == -1) { - if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && group->cl.items[group->scanIndex]->group->expanded) { - group = group->cl.items[group->scanIndex]->group; + if (group->cl[group->scanIndex]->type == CLCIT_GROUP && group->cl[group->scanIndex]->group->expanded) { + group = group->cl[group->scanIndex]->group; indent++; group->scanIndex = 0; subindex = -1; diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 789afa91ac..d49cd4a0e7 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -232,7 +232,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L switch (msg) { case WM_CREATE: - dat = (struct ClcData *)mir_calloc(sizeof(struct ClcData)); + dat = new ClcData(); SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat); RowHeight::Init(dat); @@ -358,7 +358,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L if (hSelItem) { ClcGroup *selgroup; if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) - dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)& selgroup->cl, selcontact)); + dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); else dat->selection = -1; } diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index a73a0827e2..70b1a19421 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -57,7 +57,7 @@ int AddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText) { int i = coreCli.pfnAddInfoItemToGroup(group, flags, pszText); - ClcContact* p = group->cl.items[i]; + ClcContact* p = group->cl[i]; p->avatarLeft = p->extraIconRightBegin = -1; return i; } @@ -66,7 +66,7 @@ ClcGroup *AddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, DWORD fl { ClcGroup *p = coreCli.pfnAddGroup(hwnd, dat, szName, flags, groupId, calcTotalMembers); if (p && p->parent) - RTL_DetectGroupName(p->parent->cl.items[p->parent->cl.count - 1]); + RTL_DetectGroupName(p->parent->cl[p->parent->cl.getCount() - 1]); return p; } @@ -100,7 +100,7 @@ void LoadAvatarForContact(ClcContact *p) int AddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hContact) { int i = coreCli.pfnAddContactToGroup(dat, group, hContact); - ClcContact* p = group->cl.items[i]; + ClcContact* p = group->cl[i]; p->wStatus = db_get_w(hContact, p->proto, "Status", ID_STATUS_OFFLINE); p->xStatus = db_get_b(hContact, p->proto, "XStatusId", 0); @@ -154,7 +154,7 @@ void RebuildEntireList(HWND hwnd, struct ClcData *dat) dat->list.expanded = 1; dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0); - dat->list.cl.count = 0; + dat->list.cl.destroy(); dat->list.totalMembers = 0; dat->selection = -1; dat->SelectMode = db_get_b(NULL, "CLC", "SelectMode", 0); @@ -198,16 +198,16 @@ void RebuildEntireList(HWND hwnd, struct ClcData *dat) group = &dat->list; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { - if (cc->group->cl.count == 0) + if (cc->group->cl.getCount() == 0) group = pcli->pfnRemoveItemFromGroup(hwnd, group, cc, 0); else { group = cc->group; diff --git a/plugins/Clist_nicer/src/clcpaint.cpp b/plugins/Clist_nicer/src/clcpaint.cpp index e79d0838b4..d54a4a6bcc 100644 --- a/plugins/Clist_nicer/src/clcpaint.cpp +++ b/plugins/Clist_nicer/src/clcpaint.cpp @@ -589,7 +589,7 @@ set_bg_l: // check for special cases (first item, single item, last item) // this will only change the shape for this status. Color will be blended over with ALPHA value - if (!ssingleitem->IGNORED && scanIndex == 0 && group->cl.count == 1 && group->parent != NULL) { + if (!ssingleitem->IGNORED && scanIndex == 0 && group->cl.getCount() == 1 && group->parent != NULL) { rc.left = ssingleitem->MARGIN_LEFT + bg_indent_l; rc.top = y + ssingleitem->MARGIN_TOP; rc.right = clRect->right - ssingleitem->MARGIN_RIGHT - bg_indent_r; @@ -613,7 +613,7 @@ set_bg_l: if (check_selected) DrawAlpha(hdcMem, &rc, ssingleitem->COLOR, ssingleitem->ALPHA, ssingleitem->COLOR2, ssingleitem->COLOR2_TRANSPARENT, ssingleitem->GRADIENT, ssingleitem->CORNER, ssingleitem->BORDERSTYLE, ssingleitem->imageItem); } - else if (scanIndex == 0 && group->cl.count > 1 && !sfirstitem->IGNORED && group->parent != NULL) { + else if (scanIndex == 0 && group->cl.getCount() > 1 && !sfirstitem->IGNORED && group->parent != NULL) { rc.left = sfirstitem->MARGIN_LEFT + bg_indent_l; rc.top = y + sfirstitem->MARGIN_TOP; rc.right = clRect->right - sfirstitem->MARGIN_RIGHT - bg_indent_r; @@ -637,7 +637,7 @@ set_bg_l: if (check_selected) DrawAlpha(hdcMem, &rc, sfirstitem->COLOR, sfirstitem->ALPHA, sfirstitem->COLOR2, sfirstitem->COLOR2_TRANSPARENT, sfirstitem->GRADIENT, sfirstitem->CORNER, sfirstitem->BORDERSTYLE, sfirstitem->imageItem); } - else if (scanIndex == group->cl.count - 1 && !slastitem->IGNORED && group->parent != NULL) { + else if (scanIndex == group->cl.getCount() - 1 && !slastitem->IGNORED && group->parent != NULL) { // last item of group rc.left = slastitem->MARGIN_LEFT + bg_indent_l; rc.top = y + slastitem->MARGIN_TOP; @@ -663,7 +663,7 @@ set_bg_l: DrawAlpha(hdcMem, &rc, slastitem->COLOR, slastitem->ALPHA, slastitem->COLOR2, slastitem->COLOR2_TRANSPARENT, slastitem->GRADIENT, slastitem->CORNER, slastitem->BORDERSTYLE, slastitem->imageItem); } // --- Non-grouped items --- - else if (type != CLCIT_GROUP && group->parent == NULL && !sfirstitem_NG->IGNORED && scanIndex != group->cl.count - 1 && !(*bFirstNGdrawn)) { + else if (type != CLCIT_GROUP && group->parent == NULL && !sfirstitem_NG->IGNORED && scanIndex != group->cl.getCount() - 1 && !(*bFirstNGdrawn)) { // first NON-grouped *bFirstNGdrawn = TRUE; rc.left = sfirstitem_NG->MARGIN_LEFT + bg_indent_l; @@ -689,7 +689,7 @@ set_bg_l: if (check_selected) DrawAlpha(hdcMem, &rc, sfirstitem_NG->COLOR, sfirstitem_NG->ALPHA, sfirstitem_NG->COLOR2, sfirstitem_NG->COLOR2_TRANSPARENT, sfirstitem_NG->GRADIENT, sfirstitem_NG->CORNER, sfirstitem->BORDERSTYLE, sfirstitem->imageItem); } - else if (type != CLCIT_GROUP && group->parent == NULL && !slastitem_NG->IGNORED && scanIndex == group->cl.count - 1 && (*bFirstNGdrawn)) { + else if (type != CLCIT_GROUP && group->parent == NULL && !slastitem_NG->IGNORED && scanIndex == group->cl.getCount() - 1 && (*bFirstNGdrawn)) { // last item of list (NON-group) // last NON-grouped rc.left = slastitem_NG->MARGIN_LEFT + bg_indent_l; @@ -766,7 +766,7 @@ set_bg_l: StatusItems_t *scollapsed = arStatusItems[ID_EXTBKCOLLAPSEDDGROUP - ID_STATUS_OFFLINE]; ChangeToFont(hdcMem, dat, FONTID_GROUPS, &fontHeight); - if (contact->group->cl.count == 0) { + if (contact->group->cl.getCount() == 0) { if (!sempty->IGNORED) { rc.left = sempty->MARGIN_LEFT + bg_indent_l; rc.top = y + sempty->MARGIN_TOP; @@ -1422,14 +1422,14 @@ bgdone: g_list_avatars = 0; while (true) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->cFlags & ECF_AVATAR) g_list_avatars++; @@ -1447,7 +1447,7 @@ bgdone: int indent = 0; for (int index = 0; y < rcPaint->bottom;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; @@ -1456,7 +1456,7 @@ bgdone: } line_num++; - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cfg::dat.bForceRefetchOnPaint) cc->ace = (struct avatarCacheEntry*) - 1; diff --git a/plugins/Clist_nicer/src/rowheight_funcs.cpp b/plugins/Clist_nicer/src/rowheight_funcs.cpp index 0fbe7ebe01..cce362b4f0 100644 --- a/plugins/Clist_nicer/src/rowheight_funcs.cpp +++ b/plugins/Clist_nicer/src/rowheight_funcs.cpp @@ -139,7 +139,7 @@ void RowHeight::calcRowHeights(ClcData *dat, HWND hwnd) Clear(dat); while (true) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { group = group->parent; if (group == NULL) break; // Finished list group->scanIndex++; @@ -147,7 +147,7 @@ void RowHeight::calcRowHeights(ClcData *dat, HWND hwnd) } // Get item to draw - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; line_num++; // Calc row height diff --git a/plugins/TipperYM/src/mir_smileys.h b/plugins/TipperYM/src/mir_smileys.h index 04d6256331..0e95710240 100644 --- a/plugins/TipperYM/src/mir_smileys.h +++ b/plugins/TipperYM/src/mir_smileys.h @@ -59,7 +59,7 @@ int InitTipperSmileys(); SMILEYPARSEINFO Smileys_PreParse(LPCTSTR lpString, int nCount, const char *protocol); void Smileys_FreeParse(SMILEYPARSEINFO parseInfo); -SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height); +SortedList* ReplaceSmileys(const TCHAR *text, int text_size, const char *protocol, int *max_smiley_height); SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTextFormat, int max_width); void DrawTextSmiley(HDC hdcMem, RECT free_rc, const TCHAR *szText, int len, SMILEYPARSEINFO info, UINT uTextFormat); void DestroySmileyList(SortedList* p_list); diff --git a/plugins/UserInfoEx/src/svc_constants.cpp b/plugins/UserInfoEx/src/svc_constants.cpp index c378cb0bb5..899d944700 100644 --- a/plugins/UserInfoEx/src/svc_constants.cpp +++ b/plugins/UserInfoEx/src/svc_constants.cpp @@ -271,7 +271,7 @@ static int __cdecl ListSortProc(const LPIDSTRLIST p1, const LPIDSTRLIST p2) * @return nothing **/ -static void SvcConstantsTranslateList(LPIDSTRLIST pList, UINT nListCount/*, SortedList *pSorted*/) +static void SvcConstantsTranslateList(LPIDSTRLIST pList, UINT nListCount) { if (!pList[0].ptszTranslated) { for (UINT i = 0; i < nListCount; i++) diff --git a/plugins/Variables/src/tokenregister.cpp b/plugins/Variables/src/tokenregister.cpp index 2e6bc5fd80..7cf2fb0300 100644 --- a/plugins/Variables/src/tokenregister.cpp +++ b/plugins/Variables/src/tokenregister.cpp @@ -77,7 +77,7 @@ int deRegisterToken(TCHAR *token) if (tre == NULL) return -1; - List_RemovePtr((SortedList*)&tokens, tre); + tokens.remove(tre); } if (!(tre->tr.flags & TRF_PARSEFUNC) && tre->tr.szService != NULL) @@ -99,7 +99,6 @@ int deRegisterToken(TCHAR *token) INT_PTR registerToken(WPARAM, LPARAM lParam) { DWORD hash; - int idx; TOKENREGISTEREX *newVr = (TOKENREGISTEREX*)lParam; if (newVr == NULL || newVr->szTokenString == NULL || newVr->cbSize <= 0) @@ -140,8 +139,7 @@ INT_PTR registerToken(WPARAM, LPARAM lParam) tre->tr.szCleanupService = mir_strdup(newVr->szCleanupService); mir_cslock lck(csRegister); - List_GetIndex((SortedList*)&tokens, tre, &idx); - List_Insert((SortedList*)&tokens, tre, idx); + tokens.insert(tre); return 0; } diff --git a/src/core/stdclist/src/clcpaint.cpp b/src/core/stdclist/src/clcpaint.cpp index 49afb4ab9f..d95d126fbd 100644 --- a/src/core/stdclist/src/clcpaint.cpp +++ b/src/core/stdclist/src/clcpaint.cpp @@ -265,7 +265,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) group->scanIndex = 0; int indent = 0; for (int index = 0; y < rcPaint->bottom;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; @@ -273,7 +273,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint) continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (y > rcPaint->top - dat->rowHeight) { int iImage = -1; int selected = index == dat->selection && (dat->bShowSelAlways || dat->exStyle & CLS_EX_SHOWSELALWAYS || GetFocus() == hwnd) && cc->type != CLCIT_DIVIDER; diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index b19d169efa..9f3f8c46c4 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -252,7 +252,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam WindowList_Add(hClcWindowList, hwnd, NULL); cli.pfnRegisterFileDropping(hwnd); if (dat == NULL) { - dat = (ClcData *) mir_calloc(sizeof(ClcData)); + dat = new ClcData(); SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat); } { @@ -269,7 +269,6 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam dat->iHotTrack = -1; dat->infoTipTimeout = db_get_w(NULL, "CLC", "InfoTipHoverTime", 750); dat->extraColumnSpacing = 20; - dat->list.cl.increment = 30; dat->bNeedsResort = true; cli.pfnLoadClcOptions(hwnd, dat, TRUE); if (!IsWindowVisible(hwnd)) @@ -386,12 +385,12 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam CMString szFullName(contact->szText); while (group->parent) { ClcContact *cc; - for (i = 0; i < group->parent->cl.count; i++) { - cc = group->parent->cl.items[i]; + for (i = 0; i < group->parent->cl.getCount(); i++) { + cc = group->parent->cl[i]; if (cc->group == group) break; } - if (i == group->parent->cl.count) { + if (i == group->parent->cl.getCount()) { szFullName.Empty(); break; } @@ -528,7 +527,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (hSelItem) { ClcGroup *selgroup; if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) - dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact)); + dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); else dat->selection = -1; } @@ -923,7 +922,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam cli.pfnSetGroupExpand(hwnd, dat, contact->group, -1); if (dat->selection != -1) { dat->selection = - cli.pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact)); + cli.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); if (dat->selection == -1) dat->selection = cli.pfnGetRowsPriorTo(&dat->list, contact->group, -1); } @@ -1287,7 +1286,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (dat->hBmpBackground) DeleteObject(dat->hBmpBackground); cli.pfnFreeGroup(&dat->list); - mir_free(dat); + delete dat; cli.pfnUnregisterFileDropping(hwnd); WindowList_Remove(hClcWindowList, hwnd); } diff --git a/src/mir_app/src/clcidents.cpp b/src/mir_app/src/clcidents.cpp index 2256ff3c83..a287626133 100644 --- a/src/mir_app/src/clcidents.cpp +++ b/src/mir_app/src/clcidents.cpp @@ -48,7 +48,7 @@ int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; @@ -58,7 +58,7 @@ int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) return count; count++; - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { if (cc->group == subgroup && contactIndex == -1) return count - 1; @@ -81,7 +81,7 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; @@ -97,7 +97,7 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG if (nowVisible) index++; - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if ((IsHContactGroup(dwItem) && cc->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == cc->groupId) || (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->hContact == dwItem) || (IsHContactInfo(dwItem) && cc->type == CLCIT_INFO && cc->hContact == (dwItem & ~HCONTACT_ISINFO))) @@ -150,14 +150,14 @@ int fnGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (testindex == index) { if (contact) *contact = cc; diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index b81c8d7d98..9408a40320 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -34,14 +34,13 @@ int fnAddItemToGroup(ClcGroup *group, int iAboveItem) newItem->flags = 0; newItem->szText[0] = '\0'; memset(newItem->iExtraImage, 0xFF, sizeof(newItem->iExtraImage)); - - List_Insert((SortedList*)&group->cl, newItem, iAboveItem); + group->cl.insert(newItem, iAboveItem); return iAboveItem; } ClcGroup* fnAddGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers) { - dat->bNeedsResort = true; + dat->bNeedsResort = true; if (!(GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_USEGROUPS)) return &dat->list; @@ -58,8 +57,8 @@ ClcGroup* fnAddGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, } int i, compareResult = 1; - for (i = 0; i < group->cl.count; i++) { - ClcContact *cc = group->cl.items[i]; + for (i = 0; i < group->cl.getCount(); i++) { + ClcContact *cc = group->cl[i]; if (cc->type == CLCIT_CONTACT) break; if (cc->type != CLCIT_GROUP) @@ -86,15 +85,14 @@ ClcGroup* fnAddGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, if (groupId == 0) return NULL; - ClcContact *cc = group->cl.items[cli.pfnAddItemToGroup(group, i)]; + ClcContact *cc = group->cl[cli.pfnAddItemToGroup(group, i)]; cc->type = CLCIT_GROUP; mir_tstrncpy(cc->szText, pThisField, _countof(cc->szText)); cc->groupId = (WORD)(pNextField ? 0 : groupId); - cc->group = (ClcGroup *)mir_alloc(sizeof(ClcGroup)); + cc->group = new ClcGroup(10); cc->group->parent = group; group = cc->group; - memset(&group->cl, 0, sizeof(group->cl)); - group->cl.increment = 10; + if (flags == (DWORD)-1 || pNextField != NULL) { group->expanded = 0; group->hideOffline = 0; @@ -122,8 +120,7 @@ void fnFreeContact(ClcContact* p) { if (p->type == CLCIT_GROUP) { cli.pfnFreeGroup(p->group); - mir_free(p->group); - p->group = NULL; + delete p->group; p->group = NULL; } } @@ -132,15 +129,11 @@ void fnFreeGroup(ClcGroup *group) if (!group) return; - if (group->cl.items) { - for (int i = 0; i < group->cl.count; i++) { - cli.pfnFreeContact(group->cl.items[i]); - mir_free(group->cl.items[i]); - } - mir_free(group->cl.items); - group->cl.items = NULL; + for (int i = 0; i < group->cl.getCount(); i++) { + cli.pfnFreeContact(group->cl[i]); + mir_free(group->cl[i]); } - group->cl.limit = group->cl.count = 0; + group->cl.destroy(); } static int iInfoItemUniqueHandle = 0; @@ -149,24 +142,24 @@ int fnAddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText) int i = 0; if (flags & CLCIIF_BELOWCONTACTS) - i = group->cl.count; + i = group->cl.getCount(); else if (flags & CLCIIF_BELOWGROUPS) { - for (; i < group->cl.count; i++) - if (group->cl.items[i]->type == CLCIT_CONTACT) + for (; i < group->cl.getCount(); i++) + if (group->cl[i]->type == CLCIT_CONTACT) break; } else - for (; i < group->cl.count; i++) - if (group->cl.items[i]->type != CLCIT_INFO) + for (; i < group->cl.getCount(); i++) + if (group->cl[i]->type != CLCIT_INFO) break; i = cli.pfnAddItemToGroup(group, i); iInfoItemUniqueHandle = LOWORD(iInfoItemUniqueHandle + 1); if (iInfoItemUniqueHandle == 0) ++iInfoItemUniqueHandle; - group->cl.items[i]->type = CLCIT_INFO; - group->cl.items[i]->flags = (BYTE)flags; - group->cl.items[i]->hContact = (MCONTACT)++iInfoItemUniqueHandle; - mir_tstrncpy(group->cl.items[i]->szText, pszText, _countof(group->cl.items[i]->szText)); + group->cl[i]->type = CLCIT_INFO; + group->cl[i]->flags = (BYTE)flags; + group->cl[i]->hContact = (MCONTACT)++iInfoItemUniqueHandle; + mir_tstrncpy(group->cl[i]->szText, pszText, _countof(group->cl[i]->szText)); return i; } @@ -174,13 +167,13 @@ int fnAddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hContact) { int i, index = -1; - dat->bNeedsResort = true; - for (i = group->cl.count - 1; i >= 0; i--) { - if (group->cl.items[i]->hContact == hContact) + dat->bNeedsResort = true; + for (i = group->cl.getCount() - 1; i >= 0; i--) { + if (group->cl[i]->hContact == hContact) return i; if (index == -1) - if (group->cl.items[i]->type != CLCIT_INFO || !(group->cl.items[i]->flags & CLCIIF_BELOWCONTACTS)) + if (group->cl[i]->type != CLCIT_INFO || !(group->cl[i]->flags & CLCIIF_BELOWCONTACTS)) index = i; } @@ -191,7 +184,7 @@ int fnAddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hContact) i = cli.pfnAddItemToGroup(group, index + 1); - ClcContact *cc = group->cl.items[i]; + ClcContact *cc = group->cl[i]; cc->type = CLCIT_CONTACT; cc->iImage = cli.pfnGetContactIcon(hContact); cc->hContact = hContact; @@ -221,7 +214,7 @@ void fnAddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int updateTo WORD status = ID_STATUS_OFFLINE; char *szProto = GetContactProto(hContact); - dat->bNeedsResort = true; + dat->bNeedsResort = true; if (style & CLS_NOHIDEOFFLINE) checkHideOffline = 0; if (checkHideOffline) @@ -282,7 +275,7 @@ void fnAddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int updateTo ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount) { - int iContact = List_IndexOf((SortedList*)&group->cl, contact); + int iContact = group->cl.indexOf(contact); if (iContact == -1) return group; @@ -293,14 +286,14 @@ ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, cli.pfnInvalidateDisplayNameCacheEntry(contact->hContact); } - cli.pfnFreeContact(group->cl.items[iContact]); - mir_free(group->cl.items[iContact]); - List_Remove((SortedList*)&group->cl, iContact); + cli.pfnFreeContact(group->cl[iContact]); + mir_free(group->cl[iContact]); + group->cl.remove(iContact); - if ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) && group->cl.count == 0 && group->parent != NULL) - for (int i = 0; i < group->parent->cl.count; i++) - if (group->parent->cl.items[i]->type == CLCIT_GROUP && group->parent->cl.items[i]->groupId == group->groupId) - return cli.pfnRemoveItemFromGroup(hwnd, group->parent, group->parent->cl.items[i], 0); + if ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) && group->cl.getCount() == 0 && group->parent != NULL) + for (int i = 0; i < group->parent->cl.getCount(); i++) + if (group->parent->cl[i]->type == CLCIT_GROUP && group->parent->cl[i]->groupId == group->groupId) + return cli.pfnRemoveItemFromGroup(hwnd, group->parent, group->parent->cl[i], 0); return group; } @@ -308,7 +301,7 @@ ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem) { ClcData *dat = (ClcData*)GetWindowLongPtr(hwnd, 0); - dat->bNeedsResort = true; + dat->bNeedsResort = true; ClcGroup *group; ClcContact *contact; @@ -324,10 +317,10 @@ void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem) group = &dat->list; nameOffset = 0; for (i = 0;; i++) { - if (group->scanIndex == group->cl.count) + if (group->scanIndex == group->cl.getCount()) break; - ClcContact *cc = group->cl.items[i]; + ClcContact *cc = group->cl[i]; if (cc->type == CLCIT_GROUP) { size_t len = mir_tstrlen(cc->szText); if (!_tcsncmp(cc->szText, dbv.ptszVal + nameOffset, len) && @@ -350,7 +343,7 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat) dat->list.expanded = 1; dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0) && style&CLS_USEGROUPS; - dat->list.cl.count = dat->list.cl.limit = 0; + dat->list.cl.destroy(); dat->selection = -1; for (int i = 1;; i++) { @@ -401,16 +394,16 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat) group = &dat->list; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { - if ((group = group->parent) == NULL) - break; - group->scanIndex++; - continue; + if (group->scanIndex == group->cl.getCount()) { + if ((group = group->parent) == NULL) + break; + group->scanIndex++; + continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { - if (cc->group->cl.count == 0) { + if (cc->group->cl.getCount() == 0) { group = cli.pfnRemoveItemFromGroup(hwnd, group, cc, 0); } else { @@ -429,24 +422,24 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat) int fnGetGroupContentsCount(ClcGroup *group, int visibleOnly) { - int count = group->cl.count; + int count = group->cl.getCount(); ClcGroup *topgroup = group; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if (group == topgroup) break; group = group->parent; - group->scanIndex++; - continue; - } - - ClcContact *cc = group->cl.items[group->scanIndex]; + group->scanIndex++; + continue; + } + + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP && (!visibleOnly || cc->group->expanded)) { group = cc->group; group->scanIndex = 0; - count += group->cl.count; + count += group->cl.getCount(); continue; } group->scanIndex++; @@ -494,51 +487,51 @@ static void SortGroup(ClcData *dat, ClcGroup *group, int useInsertionSort) { int i, sortCount; - for (i = group->cl.count - 1; i >= 0; i--) { - if (group->cl.items[i]->type == CLCIT_DIVIDER) { - mir_free(group->cl.items[i]); - List_Remove((SortedList*)&group->cl, i); + for (i = group->cl.getCount() - 1; i >= 0; i--) { + if (group->cl[i]->type == CLCIT_DIVIDER) { + mir_free(group->cl[i]); + group->cl.remove(i); } } - for (i = 0; i < group->cl.count; i++) - if (group->cl.items[i]->type != CLCIT_INFO) + for (i = 0; i < group->cl.getCount(); i++) + if (group->cl[i]->type != CLCIT_INFO) break; - if (i > group->cl.count - 2) + if (i > group->cl.getCount() - 2) return; - if (group->cl.items[i]->type == CLCIT_GROUP) { + if (group->cl[i]->type == CLCIT_GROUP) { if (dat->exStyle & CLS_EX_SORTGROUPSALPHA) { - for (sortCount = 0; i + sortCount < group->cl.count; sortCount++) - if (group->cl.items[i + sortCount]->type != CLCIT_GROUP) + for (sortCount = 0; i + sortCount < group->cl.getCount(); sortCount++) + if (group->cl[i + sortCount]->type != CLCIT_GROUP) break; - qsort(group->cl.items + i, sortCount, sizeof(void*), GroupSortProc); + qsort(group->cl.getArray() + i, sortCount, sizeof(void*), GroupSortProc); i = i + sortCount; } - for (; i < group->cl.count; i++) - if (group->cl.items[i]->type == CLCIT_CONTACT) + for (; i < group->cl.getCount(); i++) + if (group->cl[i]->type == CLCIT_CONTACT) break; - if (group->cl.count - i < 2) + if (group->cl.getCount() - i < 2) return; } - for (sortCount = 0; i + sortCount < group->cl.count; sortCount++) - if (group->cl.items[i + sortCount]->type != CLCIT_CONTACT) + for (sortCount = 0; i + sortCount < group->cl.getCount(); sortCount++) + if (group->cl[i + sortCount]->type != CLCIT_CONTACT) break; if (useInsertionSort) - InsertionSort(group->cl.items + i, sortCount, ContactSortProc); + InsertionSort(group->cl.getArray() + i, sortCount, ContactSortProc); else - qsort(group->cl.items + i, sortCount, sizeof(void*), ContactSortProc); + qsort(group->cl.getArray() + i, sortCount, sizeof(void*), ContactSortProc); if (dat->exStyle & CLS_EX_DIVIDERONOFF) { int prevContactOnline = 0; - for (i = 0; i < group->cl.count; i++) { - if (group->cl.items[i]->type != CLCIT_CONTACT) + for (i = 0; i < group->cl.getCount(); i++) { + if (group->cl[i]->type != CLCIT_CONTACT) continue; - if (group->cl.items[i]->flags & CONTACTF_ONLINE) + if (group->cl[i]->flags & CONTACTF_ONLINE) prevContactOnline = 1; else { if (prevContactOnline) { i = cli.pfnAddItemToGroup(group, i); - group->cl.items[i]->type = CLCIT_DIVIDER; - mir_tstrcpy(group->cl.items[i]->szText, TranslateT("Offline")); + group->cl[i]->type = CLCIT_DIVIDER; + mir_tstrcpy(group->cl[i]->szText, TranslateT("Offline")); } break; } @@ -560,14 +553,14 @@ void fnSortCLC(HWND hwnd, ClcData *dat, int useInsertionSort) group->scanIndex = 0; SortGroup(dat, group, useInsertionSort); for (;;) { - if (group->scanIndex == group->cl.count) { - if ((group = group->parent) == NULL) - break; - group->scanIndex++; - continue; - } - - ClcContact *cc = group->cl.items[group->scanIndex]; + if (group->scanIndex == group->cl.getCount()) { + if ((group = group->parent) == NULL) + break; + group->scanIndex++; + continue; + } + + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { group = cc->group; group->scanIndex = 0; @@ -580,7 +573,7 @@ void fnSortCLC(HWND hwnd, ClcData *dat, int useInsertionSort) if (hSelItem) { ClcGroup *selgroup; if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) - dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact)); + dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); } cli.pfnRecalcScrollBar(hwnd, dat); @@ -618,24 +611,24 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) KillTimer(hwnd, TIMERID_RENAME); cli.pfnEndRename(hwnd, dat, 1); - dat->bLockScrollbar = true; + dat->bLockScrollbar = true; OBJLIST saveContact(10, NumericKeySortT); OBJLIST saveGroup(100, NumericKeySortT); OBJLIST saveInfo(10, NumericKeySortT); - dat->bNeedsResort = true; + dat->bNeedsResort = true; group = &dat->list; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { - if ((group = group->parent) == NULL) - break; - group->scanIndex++; - continue; - } - - ClcContact *cc = group->cl.items[group->scanIndex]; + if (group->scanIndex == group->cl.getCount()) { + if ((group = group->parent) == NULL) + break; + group->scanIndex++; + continue; + } + + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { group = cc->group; group->scanIndex = 0; @@ -668,14 +661,14 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) group = &dat->list; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { - if ((group = group->parent) == NULL) - break; - group->scanIndex++; - continue; - } - - ClcContact *cc = group->cl.items[group->scanIndex]; + if (group->scanIndex == group->cl.getCount()) { + if ((group = group->parent) == NULL) + break; + group->scanIndex++; + continue; + } + + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { group = cc->group; group->scanIndex = 0; @@ -708,10 +701,10 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) group = contact->group; } j = cli.pfnAddInfoItemToGroup(group, saveInfo[i].contact.flags, _T("")); - *group->cl.items[j] = saveInfo[i].contact; + *group->cl[j] = saveInfo[i].contact; } - dat->bLockScrollbar = false; + dat->bLockScrollbar = false; cli.pfnRecalculateGroupCheckboxes(hwnd, dat); cli.pfnRecalcScrollBar(hwnd, dat); diff --git a/src/mir_app/src/clcmsgs.cpp b/src/mir_app/src/clcmsgs.cpp index 089f780a15..5c260bc000 100644 --- a/src/mir_app/src/clcmsgs.cpp +++ b/src/mir_app/src/clcmsgs.cpp @@ -71,7 +71,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar } else i = cli.pfnAddInfoItemToGroup(group, cii->flags, cii->pszText); cli.pfnRecalcScrollBar(hwnd, dat); - return (LRESULT)group->cl.items[i]->hContact | HCONTACT_ISINFO; + return (LRESULT)group->cl[i]->hContact | HCONTACT_ISINFO; } case CLM_AUTOREBUILD: @@ -99,7 +99,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent) cli.pfnSetGroupExpand(hwnd, dat, tgroup, 1); - cli.pfnEnsureVisible(hwnd, dat, cli.pfnGetRowsPriorTo(&dat->list, group, List_IndexOf((SortedList*)&group->cl, contact)), 0); + cli.pfnEnsureVisible(hwnd, dat, cli.pfnGetRowsPriorTo(&dat->list, group, group->cl.indexOf(contact)), 0); break; case CLM_EXPAND: @@ -188,76 +188,76 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar case CLM_GETNEXTITEM: if (wParam == CLGN_ROOT) { - if (dat->list.cl.count) - return (LRESULT)cli.pfnContactToHItem(dat->list.cl.items[0]); + if (dat->list.cl.getCount()) + return (LRESULT)cli.pfnContactToHItem(dat->list.cl[0]); return NULL; } if (!cli.pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL)) return NULL; - i = List_IndexOf((SortedList*)&group->cl, contact); + i = group->cl.indexOf(contact); switch (wParam) { case CLGN_CHILD: if (contact->type != CLCIT_GROUP) return NULL; group = contact->group; - if (group->cl.count == 0) + if (group->cl.getCount() == 0) return NULL; - return (LRESULT)cli.pfnContactToHItem(group->cl.items[0]); + return (LRESULT)cli.pfnContactToHItem(group->cl[0]); case CLGN_PARENT: return group->groupId | HCONTACT_ISGROUP; case CLGN_NEXT: do { - if (++i >= group->cl.count) + if (++i >= group->cl.getCount()) return NULL; - } while (group->cl.items[i]->type == CLCIT_DIVIDER); - return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); + } while (group->cl[i]->type == CLCIT_DIVIDER); + return (LRESULT)cli.pfnContactToHItem(group->cl[i]); case CLGN_PREVIOUS: do { if (--i < 0) return NULL; - } while (group->cl.items[i]->type == CLCIT_DIVIDER); - return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); + } while (group->cl[i]->type == CLCIT_DIVIDER); + return (LRESULT)cli.pfnContactToHItem(group->cl[i]); case CLGN_NEXTCONTACT: - for (i++; i < group->cl.count; i++) - if (group->cl.items[i]->type == CLCIT_CONTACT) + for (i++; i < group->cl.getCount(); i++) + if (group->cl[i]->type == CLCIT_CONTACT) break; - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; - return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); + return (LRESULT)cli.pfnContactToHItem(group->cl[i]); case CLGN_PREVIOUSCONTACT: - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; for (i--; i >= 0; i--) - if (group->cl.items[i]->type == CLCIT_CONTACT) + if (group->cl[i]->type == CLCIT_CONTACT) break; if (i < 0) return NULL; - return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); + return (LRESULT)cli.pfnContactToHItem(group->cl[i]); case CLGN_NEXTGROUP: - for (i++; i < group->cl.count; i++) - if (group->cl.items[i]->type == CLCIT_GROUP) + for (i++; i < group->cl.getCount(); i++) + if (group->cl[i]->type == CLCIT_GROUP) break; - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; - return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); + return (LRESULT)cli.pfnContactToHItem(group->cl[i]); case CLGN_PREVIOUSGROUP: - if (i >= group->cl.count) + if (i >= group->cl.getCount()) return NULL; for (i--; i >= 0; i--) - if (group->cl.items[i]->type == CLCIT_GROUP) + if (group->cl[i]->type == CLCIT_GROUP) break; if (i < 0) return NULL; - return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); + return (LRESULT)cli.pfnContactToHItem(group->cl[i]); } return NULL; @@ -291,7 +291,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent) cli.pfnSetGroupExpand(hwnd, dat, tgroup, 1); - dat->selection = cli.pfnGetRowsPriorTo(&dat->list, group, List_IndexOf((SortedList*)&group->cl, contact)); + dat->selection = cli.pfnGetRowsPriorTo(&dat->list, group, group->cl.indexOf(contact)); cli.pfnEnsureVisible(hwnd, dat, dat->selection, 0); break; diff --git a/src/mir_app/src/clcutils.cpp b/src/mir_app/src/clcutils.cpp index aed2da5faf..da0f86b0ad 100644 --- a/src/mir_app/src/clcutils.cpp +++ b/src/mir_app/src/clcutils.cpp @@ -39,7 +39,7 @@ TCHAR* fnGetGroupCountsText(ClcData *dat, ClcContact *contact) int totalCount = group->totalMembers; group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if (group == topgroup) break; group = group->parent; @@ -47,7 +47,7 @@ TCHAR* fnGetGroupCountsText(ClcData *dat, ClcContact *contact) continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { group = cc->group; group->scanIndex = 0; @@ -367,14 +367,14 @@ int fnFindRowByText(HWND hwnd, ClcData *dat, const TCHAR *text, int prefixOk) group->scanIndex = 0; for (;;) { - if (group->scanIndex == group->cl.count) { + if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } - ClcContact *cc = group->cl.items[group->scanIndex]; + ClcContact *cc = group->cl[group->scanIndex]; if (cc->type != CLCIT_DIVIDER) { bool show; if (dat->bFilterSearch) { @@ -794,27 +794,27 @@ void fnRecalculateGroupCheckboxes(HWND, ClcData *dat) ClcGroup *group = &dat->list; group->scanIndex = GSIF_ALLCHECKED; for (;;) { - if ((group->scanIndex & GSIF_INDEXMASK) == group->cl.count) { + if ((group->scanIndex & GSIF_INDEXMASK) == group->cl.getCount()) { int check = (group->scanIndex & (GSIF_HASMEMBERS | GSIF_ALLCHECKED)) == (GSIF_HASMEMBERS | GSIF_ALLCHECKED); if (group->parent == NULL) break; group->parent->scanIndex |= group->scanIndex & GSIF_HASMEMBERS; group = group->parent; if (check) - group->cl.items[(group->scanIndex & GSIF_INDEXMASK)]->flags |= CONTACTF_CHECKED; + group->cl[(group->scanIndex & GSIF_INDEXMASK)]->flags |= CONTACTF_CHECKED; else { - group->cl.items[(group->scanIndex & GSIF_INDEXMASK)]->flags &= ~CONTACTF_CHECKED; + group->cl[(group->scanIndex & GSIF_INDEXMASK)]->flags &= ~CONTACTF_CHECKED; group->scanIndex &= ~GSIF_ALLCHECKED; } } - else if (group->cl.items[(group->scanIndex & GSIF_INDEXMASK)]->type == CLCIT_GROUP) { - group = group->cl.items[(group->scanIndex & GSIF_INDEXMASK)]->group; + else if (group->cl[(group->scanIndex & GSIF_INDEXMASK)]->type == CLCIT_GROUP) { + group = group->cl[(group->scanIndex & GSIF_INDEXMASK)]->group; group->scanIndex = GSIF_ALLCHECKED; continue; } - else if (group->cl.items[(group->scanIndex & GSIF_INDEXMASK)]->type == CLCIT_CONTACT) { + else if (group->cl[(group->scanIndex & GSIF_INDEXMASK)]->type == CLCIT_CONTACT) { group->scanIndex |= GSIF_HASMEMBERS; - if (!(group->cl.items[(group->scanIndex & GSIF_INDEXMASK)]->flags & CONTACTF_CHECKED)) + if (!(group->cl[(group->scanIndex & GSIF_INDEXMASK)]->flags & CONTACTF_CHECKED)) group->scanIndex &= ~GSIF_ALLCHECKED; } group->scanIndex++; @@ -831,8 +831,8 @@ void fnSetContactCheckboxes(ClcContact *cc, int checked) void fnSetGroupChildCheckboxes(ClcGroup *group, int checked) { - for (int i = 0; i < group->cl.count; i++) { - ClcContact *cc = group->cl.items[i]; + for (int i = 0; i < group->cl.getCount(); i++) { + ClcContact *cc = group->cl[i]; if (cc->type == CLCIT_GROUP) { cli.pfnSetGroupChildCheckboxes(cc->group, checked); cli.pfnSetContactCheckboxes(cc, checked); -- cgit v1.2.3