diff options
author | George Hazan <george.hazan@gmail.com> | 2016-09-26 11:01:47 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-09-26 11:01:47 +0000 |
commit | f1f98fe541c790141fec87b943af535a943c7100 (patch) | |
tree | 7f86c2045262dca0f41b495bf6748f0b122667f5 /src | |
parent | 5f5270854027fbafc77086cdfad554a9fee2faa2 (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 'src')
-rw-r--r-- | src/mir_app/src/clc.cpp | 24 | ||||
-rw-r--r-- | src/mir_app/src/clc.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/clcidents.cpp | 29 | ||||
-rw-r--r-- | src/mir_app/src/clcitems.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/clcmsgs.cpp | 30 | ||||
-rw-r--r-- | src/mir_app/src/clistmod.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 |
8 files changed, 56 insertions, 40 deletions
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 4074bb4a91..3f56a2cb25 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -385,7 +385,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam int groupId = atoi(dbcws->szSetting) + 1;
int i, eq;
//check name of group and ignore message if just being expanded/collapsed
- if (cli.pfnFindItem(hwnd, dat, groupId | HCONTACT_ISGROUP, &contact, &group, NULL)) {
+ if (Clist_FindItem(hwnd, dat, groupId | HCONTACT_ISGROUP, &contact, &group, NULL)) {
CMStringW szFullName(contact->szText);
while (group->parent) {
ClcContact *cc = NULL;
@@ -436,7 +436,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN)
break;
if (dbcws->value.type == DBVT_DELETED || dbcws->value.bVal == 0) {
- if (cli.pfnFindItem(hwnd, dat, wParam, NULL, NULL, NULL))
+ if (Clist_FindItem(hwnd, dat, wParam, NULL, NULL, NULL))
break;
cli.pfnAddContactToTree(hwnd, dat, wParam, 1, 1);
cli.pfnNotifyNewContact(hwnd, wParam);
@@ -452,7 +452,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam {
WORD iExtraImage[EXTRA_ICON_COUNT];
BYTE flags = 0;
- if (!cli.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));
@@ -462,7 +462,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !db_get_b(wParam, "CList", "Hidden", 0)) {
NMCLISTCONTROL nm;
cli.pfnAddContactToTree(hwnd, dat, wParam, 1, 1);
- if (cli.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;
@@ -498,12 +498,12 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam contact = NULL;
group = NULL;
- if (!cli.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 && cli.pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
cli.pfnAddContactToTree(hwnd, dat, wParam, (style & CLS_CONTACTLIST) == 0, 0);
- cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL);
+ Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL);
if (contact) {
contact->iImage = (WORD)lParam;
cli.pfnNotifyNewContact(hwnd, wParam);
@@ -530,7 +530,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam }
if (hSelItem) {
ClcGroup *selgroup;
- if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
+ if (Clist_FindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact));
else
dat->selection = -1;
@@ -540,7 +540,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break;
case INTM_NAMECHANGED:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
break;
mir_wstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), _countof(contact->szText));
@@ -549,7 +549,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break;
case INTM_PROTOCHANGED:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
break;
contact->proto = GetContactProto(wParam);
@@ -559,7 +559,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break;
case INTM_NOTONLISTCHANGED:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
break;
if (contact->type == CLCIT_CONTACT) {
@@ -577,7 +577,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break;
case INTM_APPARENTMODECHANGED:
- if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) {
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) {
char *szProto = GetContactProto(wParam);
if (szProto == NULL)
break;
@@ -599,7 +599,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break;
case INTM_IDLECHANGED:
- if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) {
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) {
char *szProto = GetContactProto(wParam);
if (szProto == NULL)
break;
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h index b58e36d1fc..46ae0cebd7 100644 --- a/src/mir_app/src/clc.h +++ b/src/mir_app/src/clc.h @@ -46,9 +46,10 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, /* clcidents.c */
int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex);
-int fnFindItem(HWND hwnd, struct ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible);
int fnGetRowByIndex(struct ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup);
+ClcContact* fnFindItem(DWORD dwItem, ClcContact *contact);
+
/* clcitems.c */
ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const wchar_t *szName, DWORD flags, int groupId, int calcTotalMembers);
ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount);
diff --git a/src/mir_app/src/clcidents.cpp b/src/mir_app/src/clcidents.cpp index fe310a8c97..aa8849ecb1 100644 --- a/src/mir_app/src/clcidents.cpp +++ b/src/mir_app/src/clcidents.cpp @@ -73,7 +73,21 @@ int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) return -1;
}
-int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible)
+ClcContact* fnFindItem(DWORD dwItem, ClcContact *cc)
+{
+ if (IsHContactGroup(dwItem) && cc->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == cc->groupId)
+ return cc;
+
+ if (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->hContact == dwItem)
+ return cc;
+
+ if (IsHContactInfo(dwItem) && cc->type == CLCIT_INFO && cc->hContact == (dwItem & ~HCONTACT_ISINFO))
+ return cc;
+
+ return NULL;
+}
+
+MIR_APP_DLL(bool) Clist_FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible)
{
int index = 0;
int nowVisible = 1;
@@ -98,10 +112,8 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG 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)))
- {
+ ClcContact *res = cli.pfnFindItem(dwItem, cc);
+ if (res != NULL) {
if (isVisible) {
if (!nowVisible)
*isVisible = 0;
@@ -120,11 +132,12 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG }
}
if (contact)
- *contact = cc;
+ *contact = res;
if (subgroup)
*subgroup = group;
- return 1;
+ return true;
}
+
if (cc->type == CLCIT_GROUP) {
group = cc->group;
group->scanIndex = 0;
@@ -137,7 +150,7 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG if (isVisible) *isVisible = FALSE;
if (contact) *contact = NULL;
if (subgroup) *subgroup = NULL;
- return 0;
+ return false;
}
int fnGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup)
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index 7305d6658e..b25cf5f732 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -305,7 +305,7 @@ void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem) ClcGroup *group; ClcContact *contact; - if (!cli.pfnFindItem(hwnd, dat, hItem, &contact, &group, NULL)) { + if (!Clist_FindItem(hwnd, dat, hItem, &contact, &group, NULL)) { DBVARIANT dbv; int i, nameOffset; if (!IsHContactContact(hItem)) @@ -581,7 +581,7 @@ void fnSortCLC(HWND hwnd, ClcData *dat, int useInsertionSort) if (hSelItem) { ClcGroup *selgroup; - if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) + if (Clist_FindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); } @@ -702,7 +702,7 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) group = &dat->list; else { ClcContact *contact; - if (!cli.pfnFindItem(hwnd, dat, saveInfo[i].parentId | HCONTACT_ISGROUP, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, saveInfo[i].parentId | HCONTACT_ISGROUP, &contact, NULL, NULL)) continue; group = contact->group; } diff --git a/src/mir_app/src/clcmsgs.cpp b/src/mir_app/src/clcmsgs.cpp index 2aeecf815d..f5ab49e928 100644 --- a/src/mir_app/src/clcmsgs.cpp +++ b/src/mir_app/src/clcmsgs.cpp @@ -60,7 +60,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar if (cii->hParentGroup == NULL)
group = &dat->list;
else {
- if (!cli.pfnFindItem(hwnd, dat, INT_PTR(cii->hParentGroup) | HCONTACT_ISGROUP, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, INT_PTR(cii->hParentGroup) | HCONTACT_ISGROUP, &contact, NULL, NULL))
return NULL;
group = contact->group;
}
@@ -96,7 +96,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break;
case CLM_ENSUREVISIBLE:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL))
break;
for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent)
@@ -105,18 +105,18 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break;
case CLM_EXPAND:
- if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
if (contact->type == CLCIT_GROUP)
cli.pfnSetGroupExpand(hwnd, dat, contact->group, lParam);
break;
case CLM_FINDCONTACT:
- if (!cli.pfnFindItem(hwnd, dat, wParam, NULL, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, NULL, NULL, NULL))
return NULL;
return wParam;
case CLM_FINDGROUP:
- if (!cli.pfnFindItem(hwnd, dat, wParam | HCONTACT_ISGROUP, NULL, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam | HCONTACT_ISGROUP, NULL, NULL, NULL))
return NULL;
return wParam | HCONTACT_ISGROUP;
@@ -124,7 +124,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return dat->bkColour;
case CLM_GETCHECKMARK:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
return 0;
return (contact->flags & CONTACTF_CHECKED) != 0;
@@ -135,7 +135,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return (LRESULT)dat->hwndRenameEdit;
case CLM_GETEXPAND:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
return CLE_INVALID;
if (contact->type != CLCIT_GROUP)
return CLE_INVALID;
@@ -151,7 +151,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar case CLM_GETEXTRAIMAGE:
if (LOWORD(lParam) < dat->extraColumnsCount) {
- if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
return contact->iExtraImage[LOWORD(lParam)];
}
return EMPTY_EXTRA_ICON;
@@ -175,13 +175,13 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return mir_wstrlen(dat->szQuickSearch);
case CLM_GETITEMTEXT:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
return 0;
mir_wstrcpy((wchar_t*)lParam, contact->szText);
return mir_wstrlen(contact->szText);
case CLM_GETITEMTYPE:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
return CLCIT_INVALID;
return contact->type;
@@ -195,7 +195,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return NULL;
}
- if (!cli.pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL))
+ if (!Clist_FindItem(hwnd, dat, lParam, &contact, &group, NULL))
return NULL;
i = group->cl.indexOf(contact);
@@ -288,7 +288,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return Clist_ContactToHItem(contact);
case CLM_SELECTITEM:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL))
break;
for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent)
@@ -319,7 +319,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break;
case CLM_SETCHECKMARK:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
return 0;
if (lParam)
contact->flags |= CONTACTF_CHECKED;
@@ -340,7 +340,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar case CLM_SETEXTRAIMAGE:
if (LOWORD(lParam) < dat->extraColumnsCount) {
int bVisible;
- if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, &bVisible)) {
+ if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, &bVisible)) {
contact->iExtraImage[LOWORD(lParam)] = HIWORD(lParam);
if (bVisible)
cli.pfnInvalidateRect(hwnd, NULL, FALSE);
@@ -396,7 +396,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break;
case CLM_SETITEMTEXT:
- if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
+ if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL))
break;
mir_wstrncpy(contact->szText, (wchar_t*)lParam, _countof(contact->szText));
cli.pfnSortCLC(hwnd, dat, 1);
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index bd4569688c..ec0c5ecc5b 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -404,7 +404,7 @@ MIR_APP_DLL(int) Clist_ContactCompare(MCONTACT hContact1, MCONTACT hContact2) ClcData *dat = (ClcData*)GetWindowLongPtr(cli.hwndContactTree, 0);
if (dat != NULL) {
ClcContact *p1, *p2;
- if (cli.pfnFindItem(cli.hwndContactTree, dat, hContact1, &p1, NULL, NULL) && cli.pfnFindItem(cli.hwndContactTree, dat, hContact2, &p2, NULL, NULL))
+ if (Clist_FindItem(cli.hwndContactTree, dat, hContact1, &p1, NULL, NULL) && Clist_FindItem(cli.hwndContactTree, dat, hContact2, &p2, NULL, NULL))
return cli.pfnCompareContacts(p1, p2);
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index f01f362fa1..c6ec271572 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -310,3 +310,4 @@ Chat_SetStatusEx @310 Chat_Terminate @311
Chat_AddGroup @312
Chat_Control @313
+Clist_FindItem @314
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index b6dffa06a8..05b5e0945b 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -310,3 +310,4 @@ Chat_SetStatusEx @310 Chat_Terminate @311
Chat_AddGroup @312
Chat_Control @313
+Clist_FindItem @314
|