From f1f98fe541c790141fec87b943af535a943c7100 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Sep 2016 11:01:47 +0000 Subject: - duplicated code removed from cliFindItem; - FindItem function removed completely; - CLIST_INTERFACE::pfnFindItem now only compare one item; - static function Clist_FindItem now serves as pcli->pfnFindItem git-svn-id: http://svn.miranda-ng.org/main/trunk@17335 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_clcidents.cpp | 82 +++------------------------ 1 file changed, 7 insertions(+), 75 deletions(-) (limited to 'plugins/Clist_modern/src/modern_clcidents.cpp') diff --git a/plugins/Clist_modern/src/modern_clcidents.cpp b/plugins/Clist_modern/src/modern_clcidents.cpp index f1d7a96ce8..03ef670329 100644 --- a/plugins/Clist_modern/src/modern_clcidents.cpp +++ b/plugins/Clist_modern/src/modern_clcidents.cpp @@ -77,84 +77,16 @@ int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) return -1; } -int cliFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible) +ClcContact* cliFindItem(DWORD dwItem, ClcContact *cc) { - return FindItem(hwnd, dat, dwItem, contact, subgroup, isVisible, false); -} - -int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible, bool isIgnoreSubcontacts) -{ - int index = 0; - int nowVisible = 1; - - ClcGroup *group = &dat->list; - group->scanIndex = 0; - group = &dat->list; - - for (;;) { - if (group->scanIndex == group->cl.getCount()) { - if ((group = group->parent) == NULL) - break; - - nowVisible = 1; - for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent) - if (!tgroup->expanded) { - nowVisible = 0; - break; - } - - group->scanIndex++; - continue; - } - - if (nowVisible) - index++; - - 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))) { - if (isVisible) { - if (!nowVisible) *isVisible = 0; - else { - int posy = cliGetRowTopY(dat, index + 1); - if (posy < dat->yScroll) - *isVisible = 0; - else { - RECT clRect; - GetClientRect(hwnd, &clRect); - *isVisible = (posy < dat->yScroll + clRect.bottom); - } - } - } - if (contact) *contact = cc; - if (subgroup) *subgroup = group; - - return 1; - } + if (corecli.pfnFindItem(dwItem, cc)) + return cc; - if (!isIgnoreSubcontacts && IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->iSubAllocated > 0) { - for (int i = 0; i < cc->iSubAllocated; i++) { - if (cc->subcontacts[i].hContact == dwItem) { - if (contact) *contact = &cc->subcontacts[i]; - if (subgroup) *subgroup = group; - return 1; - } - } - } - - if (cc->type == CLCIT_GROUP) { - group = cc->group; - group->scanIndex = 0; - nowVisible &= group->expanded; - continue; - } - group->scanIndex++; - } + if (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->iSubAllocated > 0) + for (int i = 0; i < cc->iSubAllocated; i++) + if (cc->subcontacts[i].hContact == dwItem) + return &cc->subcontacts[i]; - if (isVisible) *isVisible = FALSE; - if (contact) *contact = NULL; - if (subgroup) *subgroup = NULL; return 0; } -- cgit v1.2.3