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 --- 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 ++--- 6 files changed, 161 insertions(+), 169 deletions(-) (limited to 'src') 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