summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-09-26 11:01:47 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-09-26 11:01:47 +0000
commitf1f98fe541c790141fec87b943af535a943c7100 (patch)
tree7f86c2045262dca0f41b495bf6748f0b122667f5 /plugins/Clist_modern
parent5f5270854027fbafc77086cdfad554a9fee2faa2 (diff)
- 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
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp26
-rw-r--r--plugins/Clist_modern/src/modern_clc.h1
-rw-r--r--plugins/Clist_modern/src/modern_clcidents.cpp82
-rw-r--r--plugins/Clist_modern/src/modern_clcitems.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clcmsgs.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_commonprototypes.h54
-rw-r--r--plugins/Clist_modern/src/modern_contact.cpp3
7 files changed, 52 insertions, 122 deletions
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index 6d5f29ad3f..fcfbb3d154 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -526,7 +526,7 @@ static LRESULT clcOnKeyDown(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPARAM
if (ht) {
ClcContact *contact2;
ClcGroup *group2;
- if (FindItem(hwnd, dat, contact->hContact, &contact2, &group2, NULL, false)) {
+ if (Clist_FindItem(hwnd, dat, contact->hContact, &contact2, &group2, NULL)) {
int i = cliGetRowsPriorTo(&dat->list, group2, GetContactIndex(group2, contact2));
pcli->pfnEnsureVisible(hwnd, dat, i + contact->iSubAllocated, 0);
}
@@ -620,7 +620,7 @@ static LRESULT clcOnTimer(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPAR
int i = 0;
ClcContact *contact;
ClcGroup *group;
- if (FindItem(hwnd, dat, hitcontact->hContact, &contact, &group, NULL, false)) {
+ if (Clist_FindItem(hwnd, dat, hitcontact->hContact, &contact, &group, NULL)) {
i = cliGetRowsPriorTo(&dat->list, group, GetContactIndex(group, contact));
pcli->pfnEnsureVisible(hwnd, dat, i + hitcontact->iSubAllocated, 0);
}
@@ -1290,7 +1290,7 @@ static LRESULT clcOnIntmGroupChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wPara
BYTE flags = 0;
ClcContact *contact;
- if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
memset(iExtraImage, 0xFF, sizeof(iExtraImage));
else {
memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage));
@@ -1300,7 +1300,7 @@ static LRESULT clcOnIntmGroupChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wPara
if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !db_get_b(wParam, "CList", "Hidden", 0)) {
NMCLISTCONTROL nm;
pcli->pfnAddContactToTree(hwnd, dat, wParam, 1, 1);
- if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) {
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) {
memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage));
if (flags & CONTACTF_CHECKED)
contact->flags |= CONTACTF_CHECKED;
@@ -1344,13 +1344,13 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam
ClcGroup *group = NULL;
ClcContact *contact = NULL;
- if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) {
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL)) {
if (shouldShow && db_is_contact(wParam)) {
if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
pcli->pfnAddContactToTree(hwnd, dat, wParam, (style & CLS_CONTACTLIST) == 0, 0);
needRepaint = TRUE;
- pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL);
+ Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL);
if (contact) {
contact->iImage = lParam;
contact->bImageIsSpecial = bImageIsSpecial;
@@ -1391,7 +1391,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam
}
if (hSelItem) {
- if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
+ if (Clist_FindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact));
else
dat->selection = -1;
@@ -1415,7 +1415,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam
static LRESULT clcOnIntmAvatarChanged(ClcData *dat, HWND hwnd, UINT, WPARAM hContact, LPARAM)
{
ClcContact *contact;
- if (FindItem(hwnd, dat, hContact, &contact, NULL, NULL, false))
+ if (Clist_FindItem(hwnd, dat, hContact, &contact, NULL, NULL))
Cache_GetAvatar(dat, contact);
else if (hContact == 0)
UpdateAllAvatars(dat);
@@ -1427,7 +1427,7 @@ static LRESULT clcOnIntmAvatarChanged(ClcData *dat, HWND hwnd, UINT, WPARAM hCon
static LRESULT clcOnIntmTimeZoneChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ClcContact *contact;
- if (!FindItem(hwnd, dat, wParam, &contact, NULL, NULL, false))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
if (contact) {
@@ -1443,7 +1443,7 @@ static LRESULT clcOnIntmNameChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wP
LRESULT ret = corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
ClcContact *contact;
- if (FindItem(hwnd, dat, wParam, &contact, NULL, NULL, false))
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
Cache_GetText(dat, contact);
return ret;
@@ -1460,7 +1460,7 @@ static LRESULT clcOnIntmStatusMsgChanged(ClcData *dat, HWND hwnd, UINT msg, WPAR
return corecli.pfnContactListControlWndProc(hwnd, msg, hContact, lParam);
ClcContact *contact;
- if (!FindItem(hwnd, dat, hContact, &contact, NULL, NULL, false))
+ if (!Clist_FindItem(hwnd, dat, hContact, &contact, NULL, NULL))
return corecli.pfnContactListControlWndProc(hwnd, msg, hContact, lParam);
if (contact) {
@@ -1476,7 +1476,7 @@ static LRESULT clcOnIntmNotOnListChanged(ClcData *dat, HWND hwnd, UINT msg, WPAR
DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
ClcContact *contact;
- if (!FindItem(hwnd, dat, wParam, &contact, NULL, NULL, true))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) /////////////// ??
return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
if (contact->type != CLCIT_CONTACT)
@@ -1508,7 +1508,7 @@ static LRESULT clcOnIntmStatusChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM
if (wParam != 0) {
ClcContact *contact;
- if (FindItem(hwnd, dat, wParam, &contact, NULL, NULL, true)) {
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { /////////////////// ??
ClcCacheEntry *pdnce = contact->pce;
if (pdnce && pdnce->m_pszProto) {
if (!dat->bForceInDialog) {
diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h
index f8413b9bff..f05184b1d3 100644
--- a/plugins/Clist_modern/src/modern_clc.h
+++ b/plugins/Clist_modern/src/modern_clc.h
@@ -335,7 +335,6 @@ void ClcOptionsChanged(void);
// clcidents.c
int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex);
-int FindItem(HWND hwnd, ClcData *dat, DWORD hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible, bool isIgnoreSubcontacts);
int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup);
// clcitems.c
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;
}
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp
index c10c11a20e..513d431453 100644
--- a/plugins/Clist_modern/src/modern_clcitems.cpp
+++ b/plugins/Clist_modern/src/modern_clcitems.cpp
@@ -186,7 +186,7 @@ void cli_AddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int update
ClcGroup *group;
ClcContact *cont;
- if (FindItem(hwnd, dat, hContact, &cont, &group, NULL, false))
+ if (Clist_FindItem(hwnd, dat, hContact, &cont, &group, NULL))
_LoadDataToContact(cont, pdnce, group, dat, hContact);
}
@@ -213,7 +213,7 @@ int RestoreSelection(ClcData *dat, MCONTACT hSelected)
{
ClcGroup *selgroup = NULL;
ClcContact *selcontact = NULL;
- if (!hSelected || !pcli->pfnFindItem(dat->hWnd, dat, hSelected, &selcontact, &selgroup, NULL)) {
+ if (!hSelected || !Clist_FindItem(dat->hWnd, dat, hSelected, &selcontact, &selgroup, NULL)) {
dat->selection = -1;
return dat->selection;
}
diff --git a/plugins/Clist_modern/src/modern_clcmsgs.cpp b/plugins/Clist_modern/src/modern_clcmsgs.cpp
index 649d39736f..8960aaae5b 100644
--- a/plugins/Clist_modern/src/modern_clcmsgs.cpp
+++ b/plugins/Clist_modern/src/modern_clcmsgs.cpp
@@ -106,7 +106,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP
{
int i = 0;
if (wParam != CLGN_ROOT) {
- if (!pcli->pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL))
+ if (!Clist_FindItem(hwnd, dat, lParam, &contact, &group, NULL))
return NULL;
i = group->cl.indexOf(contact);
if (i < 0) return 0;
@@ -187,7 +187,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP
{
int index = -1;
int mainindex = -1;
- if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL))
break;
for (tgroup = group; tgroup; tgroup = tgroup->parent)
pcli->pfnSetGroupExpand(hwnd, dat, tgroup, 1);
diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h
index e48b78c646..c898f33c57 100644
--- a/plugins/Clist_modern/src/modern_commonprototypes.h
+++ b/plugins/Clist_modern/src/modern_commonprototypes.h
@@ -227,34 +227,36 @@ void ToolbarButtonUnloadModule();
// INTERFACES
-void cliCheckCacheItem(ClcCacheEntry *pdnce);
-void cliFreeCacheItem(ClcCacheEntry *p);
-void cliRebuildEntireList(HWND hwnd, ClcData *dat);
-void cliRecalcScrollBar(HWND hwnd, ClcData *dat);
-int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly);
-int cliFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk);
-int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex);
-int cli_IconFromStatusMode(const char *szProto, int nStatus, MCONTACT hContact);
-int cli_GetContactIcon(MCONTACT hContact);
-int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent);
-void cli_FreeContact(ClcContact*);
-void cli_SetContactCheckboxes(ClcContact*, int);
-LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam);
+void cliCheckCacheItem(ClcCacheEntry *pdnce);
+void cliFreeCacheItem(ClcCacheEntry *p);
+void cliRebuildEntireList(HWND hwnd, ClcData *dat);
+void cliRecalcScrollBar(HWND hwnd, ClcData *dat);
+int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly);
+int cliFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk);
+int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex);
+int cli_IconFromStatusMode(const char *szProto, int nStatus, MCONTACT hContact);
+int cli_GetContactIcon(MCONTACT hContact);
+int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent);
+void cli_FreeContact(ClcContact*);
+void cli_SetContactCheckboxes(ClcContact*, int);
+LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam);
+int cliShowHide(bool bAlwaysShow);
+BOOL cliInvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase);
+int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2);
+int cliTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam);
+void cliCluiProtocolStatusChanged(int status, const char *proto);
+void cliInvalidateDisplayNameCacheEntry(MCONTACT hContact);
+void CLUI_cli_LoadCluiGlobalOpts(void);
+INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam);
+int cliTrayIconInit(HWND hwnd);
+int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
+
CListEvent* cli_AddEvent(CLISTEVENT *cle);
+
LRESULT CALLBACK cli_ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-int cliShowHide(bool bAlwaysShow);
-BOOL cliInvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase);
-int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2);
-int cliFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible);
-int cliTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam);
-void cliCluiProtocolStatusChanged(int status, const char *proto);
-void cliInvalidateDisplayNameCacheEntry(MCONTACT hContact);
-void CLUI_cli_LoadCluiGlobalOpts(void);
-INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam);
-int cliTrayIconInit(HWND hwnd);
-int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
-
-ClcContact* cliCreateClcContact(void);
+
+ClcContact* cliFindItem(DWORD dwItem, ClcContact *contact);
+ClcContact* cliCreateClcContact(void);
ClcCacheEntry* cliCreateCacheItem(MCONTACT hContact);
#define WM_DWMCOMPOSITIONCHANGED 0x031E
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp
index 47ffcfc574..4cc7b523c6 100644
--- a/plugins/Clist_modern/src/modern_contact.cpp
+++ b/plugins/Clist_modern/src/modern_contact.cpp
@@ -90,9 +90,6 @@ int GetProtoIndex(char * szName)
int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2)
{
- if ((INT_PTR)contact1 < 100 || (INT_PTR)contact2 < 100)
- return 0;
-
ClcCacheEntry *c1 = contact1->pce, *c2 = contact2->pce;
for (int i = 0; i < _countof(g_CluiData.bSortByOrder); i++) {