summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-05-24 13:54:36 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-05-24 13:54:36 +0000
commitb3efd156b2ded1777ee2b4522acba1fa2d666ca7 (patch)
tree7a14d93203f83e33e7100fb0f7e4e48c4831bb2e /plugins
parent35b85950a7e144da1c1390e6cd5dcae5adea61bc (diff)
group processing code standardization
git-svn-id: http://svn.miranda-ng.org/main/trunk@16869 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp47
-rw-r--r--plugins/Clist_modern/src/modern_clc.h2
-rw-r--r--plugins/Clist_modern/src/modern_clcidents.cpp69
-rw-r--r--plugins/Clist_modern/src/modern_clcitems.cpp52
-rw-r--r--plugins/Clist_modern/src/modern_clcmsgs.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clcpaint.cpp14
-rw-r--r--plugins/Clist_modern/src/modern_clcutils.cpp61
-rw-r--r--plugins/Clist_modern/src/modern_rowheight_funcs.cpp14
-rw-r--r--plugins/Clist_nicer/src/clcitems.cpp15
-rw-r--r--plugins/Clist_nicer/src/clcpaint.cpp34
10 files changed, 160 insertions, 152 deletions
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index 249f1eb8b8..61a07f0e63 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -212,24 +212,25 @@ static int clcSearchNextContact(HWND hwnd, ClcData *dat, int index, const TCHAR
group->scanIndex = 0;
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL)
+ if ((group = group->parent) == NULL)
break;
group->scanIndex++;
continue;
}
- if (group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER) {
+
+ ClcContact *cc = group->cl.items[group->scanIndex];
+ if (cc->type != CLCIT_DIVIDER) {
bool found;
- if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
+ if (cc->type == CLCIT_GROUP) {
found = true;
}
else if (dat->bFilterSearch) {
- TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(group->cl.items[group->scanIndex]->szText));
+ TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(cc->szText));
TCHAR *lowered_search = CharLowerW(NEWTSTR_ALLOCA(dat->szQuickSearch));
found = _tcsstr(lowered_szText, lowered_search) != NULL;
}
else {
- found = ((prefixOk && CSTR_EQUAL == CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, text, -1, group->cl.items[group->scanIndex]->szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, group->cl.items[group->scanIndex]->szText)));
+ found = ((prefixOk && CSTR_EQUAL == CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, text, -1, cc->szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, cc->szText)));
}
if (found) {
ClcGroup *contactGroup = group;
@@ -249,9 +250,9 @@ static int clcSearchNextContact(HWND hwnd, ClcData *dat, int index, const TCHAR
group = contactGroup;
group->scanIndex = contactScanIndex;
}
- if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
- if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || group->cl.items[group->scanIndex]->group->expanded) {
- group = group->cl.items[group->scanIndex]->group;
+ if (cc->type == CLCIT_GROUP) {
+ if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->expanded) {
+ group = cc->group;
group->scanIndex = 0;
continue;
}
@@ -509,12 +510,12 @@ static LRESULT clcOnKeyDown(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPARAM
return 0;
}
- if (contact->type == CLCIT_CONTACT && (contact->nSubContacts || contact->iSubAllocated > 0)) {
- if (contact->nSubContacts && changeGroupExpand == 1) {
- dat->selection -= contact->nSubContacts;
+ if (contact->type == CLCIT_CONTACT && (contact->iSubNumber || contact->iSubAllocated > 0)) {
+ if (contact->iSubNumber && changeGroupExpand == 1) {
+ dat->selection -= contact->iSubNumber;
selMoved = 1;
}
- else if (!contact->nSubContacts && contact->iSubAllocated > 0) {
+ else if (!contact->iSubNumber && contact->iSubAllocated > 0) {
if (changeGroupExpand == 1 && !contact->bSubExpanded) {
dat->selection = cliGetRowsPriorTo(&dat->list, group, -1);
selMoved = 1;
@@ -590,8 +591,6 @@ static LRESULT clcOnKeyDown(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPARAM
cliInvalidateRect(hwnd, NULL, FALSE);
pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0);
UpdateWindow(hwnd);
- SetCapture(hwnd);
- return 0;
}
SetCapture(hwnd);
return 0;
@@ -745,7 +744,7 @@ static LRESULT clcOnLButtonDown(ClcData *dat, HWND hwnd, UINT, WPARAM, LPARAM lP
}
}
- if (hit != -1 && !(hitFlags & CLCHT_NOWHERE) && contact->type == CLCIT_CONTACT && contact->iSubAllocated && !contact->nSubContacts)
+ if (hit != -1 && !(hitFlags & CLCHT_NOWHERE) && contact->type == CLCIT_CONTACT && contact->iSubAllocated && !contact->iSubNumber)
if (hitFlags & CLCHT_ONITEMICON && dat->expandMeta) {
hitcontact = contact;
HitPoint.x = (short)LOWORD(lParam);
@@ -972,7 +971,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR
if (contSour->isChat())
break;
if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->proto, META_PROTO)) {
- if (!contSour->nSubContacts)
+ if (!contSour->iSubNumber)
hNewCursor = LoadCursor(g_hMirApp, MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
else
hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DROPMETA));
@@ -985,7 +984,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR
if (contSour->isChat() || contDest->isChat())
break;
if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->proto, META_PROTO)) {
- if (!contSour->nSubContacts)
+ if (!contSour->iSubNumber)
hNewCursor = LoadCursor(g_hMirApp, MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
else if (contSour->subcontacts == contDest)
hNewCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DEFAULTSUB)); ///MakeDefault
@@ -1000,7 +999,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR
if (contSour->isChat() || contDest->isChat())
break;
if (contSour->type == CLCIT_CONTACT && mir_strcmp(contSour->proto, META_PROTO)) {
- if (!contSour->nSubContacts)
+ if (!contSour->iSubNumber)
hNewCursor = LoadCursor(g_hMirApp, MAKEINTRESOURCE(IDC_DROPUSER)); /// Add to meta
else if (contDest->subcontacts == contSour->subcontacts)
break;
@@ -1048,7 +1047,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR
cliGetRowByIndex(dat, dat->iDragItem, NULL, &group);
if (group && group->parent) {
cliGetRowByIndex(dat, dat->iDragItem, &contSour, NULL);
- if (!contSour->nSubContacts)
+ if (!contSour->iSubNumber)
hNewCursor = LoadCursor(g_hMirApp, MAKEINTRESOURCE(IDC_DROPUSER));
}
break;
@@ -1104,7 +1103,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
if (contSour->type == CLCIT_CONTACT) {
MCONTACT hcontact = contSour->hContact;
if (mir_strcmp(contSour->proto, META_PROTO)) {
- if (!contSour->nSubContacts) {
+ if (!contSour->iSubNumber) {
MCONTACT hDest = contDest->hContact;
mir_sntprintf(Wording, TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it?"), contDest->szText, contSour->szText);
int res = MessageBox(hwnd, Wording, TranslateT("Converting to metacontact"), MB_OKCANCEL | MB_ICONQUESTION);
@@ -1142,7 +1141,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
if (contSour->type == CLCIT_CONTACT) {
if (!mir_strcmp(contSour->proto, META_PROTO))
break;
- if (!contSour->nSubContacts) {
+ if (!contSour->iSubNumber) {
MCONTACT hcontact = contSour->hContact;
MCONTACT handle = contDest->hContact;
mir_sntprintf(Wording, TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->szText);
@@ -1184,7 +1183,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
if (contSour->type == CLCIT_CONTACT) {
if (!mir_strcmp(contSour->proto, META_PROTO))
break;
- if (!contSour->nSubContacts) {
+ if (!contSour->iSubNumber) {
MCONTACT hcontact = contSour->hContact;
MCONTACT handle = contDest->subcontacts->hContact;
mir_sntprintf(Wording, TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->subcontacts->szText);
@@ -1544,7 +1543,7 @@ static LRESULT clcOnIntmStatusChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM
if (contact->type == CLCIT_CONTACT) {
if (!contact->bImageIsSpecial && pdnce->getStatus() > ID_STATUS_OFFLINE)
contact->iImage = corecli.pfnGetContactIcon(wParam);
- if (contact->nSubContacts && contact->subcontacts && contact->subcontacts->type == CLCIT_CONTACT)
+ if (contact->iSubNumber && contact->subcontacts && contact->subcontacts->type == CLCIT_CONTACT)
pcli->pfnClcBroadcast(INTM_STATUSCHANGED, contact->subcontacts->hContact, 0); //forward status changing to host meta contact
}
}
diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h
index 5e457b7b94..f4ed7279c4 100644
--- a/plugins/Clist_modern/src/modern_clc.h
+++ b/plugins/Clist_modern/src/modern_clc.h
@@ -181,7 +181,7 @@ struct tContactItems
struct ClcContact : public ClcContactBase
{
ClcContact *subcontacts;
- int iSubAllocated, nSubContacts;
+ int iSubAllocated, iSubNumber;
bool bSubExpanded, bImageIsSpecial;
diff --git a/plugins/Clist_modern/src/modern_clcidents.cpp b/plugins/Clist_modern/src/modern_clcidents.cpp
index 8afc03b8b6..27d645eb3c 100644
--- a/plugins/Clist_modern/src/modern_clcidents.cpp
+++ b/plugins/Clist_modern/src/modern_clcidents.cpp
@@ -41,34 +41,34 @@ int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex)
group->scanIndex = 0;
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL) break;
+ if ((group = group->parent) == NULL)
+ break;
group->scanIndex++;
continue;
}
if (group == subgroup && contactIndex - subcontactscount == group->scanIndex) return count;
count++;
- ClcContact *c = group->cl.items[group->scanIndex];
- if (c->type == CLCIT_GROUP) {
- if (c->group == subgroup && contactIndex == -1)
+ ClcContact *cc = group->cl.items[group->scanIndex];
+ if (cc->type == CLCIT_GROUP) {
+ if (cc->group == subgroup && contactIndex == -1)
return count - 1;
- if (c->group->expanded) {
- group = c->group;
+ if (cc->group->expanded) {
+ group = cc->group;
group->scanIndex = 0;
subcontactscount = 0;
continue;
}
}
- int iRows = (bMetaExpanding && c->bSubExpanded) ? c->iSubAllocated : 0;
+ int iRows = (bMetaExpanding && cc->bSubExpanded) ? cc->iSubAllocated : 0;
if (group == subgroup) {
- if (c->type == CLCIT_CONTACT && c->iSubAllocated) {
+ if (cc->type == CLCIT_CONTACT && cc->iSubAllocated) {
if (group->scanIndex + iRows >= contactIndex)
return count + (contactIndex - group->scanIndex) - 1;
}
}
- if (c->type == CLCIT_CONTACT) {
+ if (cc->type == CLCIT_CONTACT) {
count += iRows;
subcontactscount += iRows;
}
@@ -93,8 +93,7 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL)
+ if ((group = group->parent) == NULL)
break;
nowVisible = 1;
@@ -111,10 +110,10 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro
if (nowVisible)
index++;
- ClcContact *c = group->cl.items[group->scanIndex];
- if ((IsHContactGroup(dwItem) && c->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == c->groupId) ||
- (IsHContactContact(dwItem) && c->type == CLCIT_CONTACT && c->hContact == dwItem) ||
- (IsHContactInfo(dwItem) && c->type == CLCIT_INFO && c->hContact == (dwItem & ~HCONTACT_ISINFO))) {
+ ClcContact *cc = group->cl.items[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 {
@@ -128,24 +127,24 @@ int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGro
}
}
}
- if (contact) *contact = c;
+ if (contact) *contact = cc;
if (subgroup) *subgroup = group;
return 1;
}
- if (!isIgnoreSubcontacts && IsHContactContact(dwItem) && c->type == CLCIT_CONTACT && c->iSubAllocated > 0) {
- for (int i = 0; i < c->iSubAllocated; i++) {
- if (c->subcontacts[i].hContact == dwItem) {
- if (contact) *contact = &c->subcontacts[i];
+ 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 (c->type == CLCIT_GROUP) {
- group = c->group;
+ if (cc->type == CLCIT_GROUP) {
+ group = cc->group;
group->scanIndex = 0;
nowVisible &= group->expanded;
continue;
@@ -169,28 +168,28 @@ int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup
group->scanIndex = 0;
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL) break;
+ if ((group = group->parent) == NULL)
+ break;
group->scanIndex++;
continue;
}
- ClcContact *c = group->cl.items[group->scanIndex];
+ ClcContact *cc = group->cl.items[group->scanIndex];
if (testindex == index) {
- if (contact) *contact = c;
+ if (contact) *contact = cc;
if (subgroup) *subgroup = group;
return index;
}
- if (c->type == CLCIT_CONTACT)
- if (c->iSubAllocated)
- if (c->bSubExpanded && dat->expandMeta) {
- for (i = 0; i < c->iSubAllocated; i++) {
+ if (cc->type == CLCIT_CONTACT)
+ if (cc->iSubAllocated)
+ if (cc->bSubExpanded && dat->expandMeta) {
+ for (i = 0; i < cc->iSubAllocated; i++) {
index++;
if (testindex == index) {
if (contact) {
- *contact = &c->subcontacts[i];
- (*contact)->subcontacts = c;
+ *contact = &cc->subcontacts[i];
+ (*contact)->subcontacts = cc;
}
if (subgroup) *subgroup = group;
@@ -200,8 +199,8 @@ int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup
}
index++;
- if (c->type == CLCIT_GROUP && c->group->expanded) {
- group = c->group;
+ if (cc->type == CLCIT_GROUP && cc->group->expanded) {
+ group = cc->group;
group->scanIndex = 0;
continue;
}
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp
index d8a14a5753..fc14c85bc9 100644
--- a/plugins/Clist_modern/src/modern_clcitems.cpp
+++ b/plugins/Clist_modern/src/modern_clcitems.cpp
@@ -29,13 +29,13 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
cont->bSubExpanded = db_get_b(cont->hContact, "CList", "Expanded", 0) && db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT);
int subcount = db_mc_getSubCount(cont->hContact);
if (subcount <= 0) {
- cont->nSubContacts = 0;
+ cont->iSubNumber = 0;
cont->subcontacts = NULL;
cont->iSubAllocated = 0;
return;
}
- cont->nSubContacts = 0;
+ cont->iSubNumber = 0;
mir_free(cont->subcontacts);
cont->subcontacts = (ClcContact *)mir_calloc(sizeof(ClcContact)*subcount);
cont->iSubAllocated = subcount;
@@ -61,7 +61,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
p.proto = cacheEntry->m_pszProto;
p.type = CLCIT_CONTACT;
p.flags = 0;//CONTACTF_ONLINE;
- p.nSubContacts = i + 1;
+ p.iSubNumber = i + 1;
p.lastPaintCounter = 0;
p.subcontacts = cont;
p.bImageIsSpecial = false;
@@ -90,7 +90,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
void cli_FreeContact(ClcContact *p)
{
if (p->iSubAllocated) {
- if (p->subcontacts && !p->nSubContacts) {
+ if (p->subcontacts && !p->iSubNumber) {
for (int i = 0; i < p->iSubAllocated; i++) {
p->subcontacts[i].ssText.DestroySmileyList();
if (p->subcontacts[i].avatar_pos == AVATAR_POS_ANIMATED)
@@ -120,7 +120,7 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat,
cont->type = CLCIT_CONTACT;
cont->pce = cacheEntry;
cont->iSubAllocated = 0;
- cont->nSubContacts = 0;
+ cont->iSubNumber = 0;
cont->subcontacts = NULL;
cont->szText[0] = 0;
cont->lastPaintCounter = 0;
@@ -227,13 +227,12 @@ int RestoreSelection(ClcData *dat, MCONTACT hSelected)
return dat->selection;
}
- if (!selcontact->nSubContacts)
+ if (!selcontact->iSubNumber)
dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact));
else {
dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact->subcontacts));
-
if (dat->selection != -1)
- dat->selection += selcontact->nSubContacts;
+ dat->selection += selcontact->iSubNumber;
}
return dat->selection;
}
@@ -309,15 +308,18 @@ void cliRebuildEntireList(HWND hwnd, ClcData *dat)
group->scanIndex = 0;
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL)
+ if ((group = group->parent) == NULL)
break;
+ group->scanIndex++;
+ continue;
}
- else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
- if (group->cl.items[group->scanIndex]->group->cl.count == 0)
- group = pcli->pfnRemoveItemFromGroup(hwnd, group, group->cl.items[group->scanIndex], 0);
+
+ ClcContact *cc = group->cl.items[group->scanIndex];
+ if (cc->type == CLCIT_GROUP) {
+ if (cc->group->cl.count == 0)
+ group = pcli->pfnRemoveItemFromGroup(hwnd, group, cc, 0);
else {
- group = group->cl.items[group->scanIndex]->group;
+ group = cc->group;
group->scanIndex = 0;
}
continue;
@@ -350,8 +352,8 @@ int GetNewSelection(ClcGroup *group, int selection, int direction)
group->scanIndex = 0;
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL) break;
+ if ((group = group->parent) == NULL)
+ break;
group->scanIndex++;
continue;
}
@@ -364,8 +366,9 @@ int GetNewSelection(ClcGroup *group, int selection, int direction)
if (!direction && count > selection)
return lastcount;
- if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (group->cl.items[group->scanIndex]->group->expanded)) {
- group = group->cl.items[group->scanIndex]->group;
+ ClcContact *cc = group->cl.items[group->scanIndex];
+ if (cc->type == CLCIT_GROUP && (cc->group->expanded)) {
+ group = cc->group;
group->scanIndex = 0;
continue;
}
@@ -448,11 +451,9 @@ int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly)
count += group->cl.count;
continue;
}
- else if ((cc->type == CLCIT_CONTACT) &&
- (cc->subcontacts != NULL) &&
- ((cc->bSubExpanded || (!visibleOnly)))) {
- count += group->cl.items[group->scanIndex]->iSubAllocated;
- }
+ if (cc->type == CLCIT_CONTACT && cc->subcontacts != NULL && (cc->bSubExpanded || !visibleOnly))
+ count += cc->iSubAllocated;
+
group->scanIndex++;
}
return count;
@@ -487,6 +488,7 @@ int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, Clc
TCHAR *lowered_search = CharLowerW(NEWTSTR_ALLOCA(dat->szQuickSearch));
searchResult = _tcsstr(lowered_name, lowered_search) ? 0 : 1;
}
+
if (pdnce && g_CluiData.bFilterEffective && dat != NULL && !dat->force_in_dialog) {
if (szProto == NULL)
szProto = GetContactProto(hContact);
@@ -500,11 +502,13 @@ int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, Clc
return 0 | searchResult;
}
}
+
// check the proto, use it as a base filter result for all further checks
if (g_CluiData.bFilterEffective & CLVM_FILTER_PROTOS) {
mir_snprintf(szTemp, "%s|", szProto);
filterResult = strstr(g_CluiData.protoFilter, szTemp) ? 1 : 0;
}
+
if (g_CluiData.bFilterEffective & CLVM_FILTER_GROUPS) {
if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
mir_sntprintf(szGroupMask, _T("%s|"), &dbv.ptszVal[0]);
@@ -516,10 +520,12 @@ int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, Clc
else
filterResult = (g_CluiData.filterFlags & CLVM_PROTOGROUP_OP) ? filterResult : filterResult & 0;
}
+
if (g_CluiData.bFilterEffective & CLVM_FILTER_STATUS) {
WORD wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
filterResult = (g_CluiData.filterFlags & CLVM_GROUPSTATUS_OP) ? ((filterResult | ((1 << (wStatus - ID_STATUS_OFFLINE)) & g_CluiData.statusMaskFilter ? 1 : 0))) : (filterResult & ((1 << (wStatus - ID_STATUS_OFFLINE)) & g_CluiData.statusMaskFilter ? 1 : 0));
}
+
if (g_CluiData.bFilterEffective & CLVM_FILTER_LASTMSG) {
if (pdnce->dwLastMsgTime != -1) {
DWORD now = g_CluiData.t_now;
diff --git a/plugins/Clist_modern/src/modern_clcmsgs.cpp b/plugins/Clist_modern/src/modern_clcmsgs.cpp
index 0edbb82ae8..0f21a91832 100644
--- a/plugins/Clist_modern/src/modern_clcmsgs.cpp
+++ b/plugins/Clist_modern/src/modern_clcmsgs.cpp
@@ -184,14 +184,14 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP
for (tgroup = group; tgroup; tgroup = tgroup->parent)
pcli->pfnSetGroupExpand(hwnd, dat, tgroup, 1);
- if (!contact->nSubContacts) {
+ if (!contact->iSubNumber) {
index = List_IndexOf((SortedList*)&group->cl, contact);
mainindex = index;
}
else {
index = List_IndexOf((SortedList*)&group->cl, contact->subcontacts);
mainindex = index;
- index += contact->nSubContacts;
+ index += contact->iSubNumber;
}
BYTE k = db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT);
diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp
index 8c759b9af4..a910fb0ea8 100644
--- a/plugins/Clist_modern/src/modern_clcpaint.cpp
+++ b/plugins/Clist_modern/src/modern_clcpaint.cpp
@@ -554,13 +554,13 @@ MODERNMASK* CLCPaint::_GetCLCContactRowBackModernMask(ClcGroup *group, ClcContac
case CLCIT_CONTACT:
{
ClcContact *mCont = Drawing;
- if (Drawing->nSubContacts) {
+ if (Drawing->iSubNumber) {
_AddParamShort(mpModernMask, hi_Type, hi_SubContact);
- if (Drawing->nSubContacts == 1 && Drawing->subcontacts->iSubAllocated == 1)
+ if (Drawing->iSubNumber == 1 && Drawing->subcontacts->iSubAllocated == 1)
_AddParamShort(mpModernMask, hi_SubPos, hi_First_Single);
- else if (Drawing->nSubContacts == 1)
+ else if (Drawing->iSubNumber == 1)
_AddParamShort(mpModernMask, hi_SubPos, hi_First);
- else if (Drawing->nSubContacts == Drawing->subcontacts->iSubAllocated)
+ else if (Drawing->iSubNumber == Drawing->subcontacts->iSubAllocated)
_AddParamShort(mpModernMask, hi_SubPos, hi_Last);
else
_AddParamShort(mpModernMask, hi_SubPos, hi_Middle);
@@ -1323,7 +1323,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
case TC_EXTRA:
if (Drawing->type == CLCIT_CONTACT &&
- (!Drawing->nSubContacts || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0)) {
+ (!Drawing->iSubNumber || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0)) {
int BlendedInActiveState = dat->dbbBlendInActiveState;
int BlendValue = dat->dbbBlend25 ? ILD_BLEND25 : ILD_BLEND50;
int count = 0;
@@ -1375,7 +1375,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
case TC_EXTRA7:
case TC_EXTRA8:
case TC_EXTRA9:
- if (Drawing->type == CLCIT_CONTACT && (!Drawing->nSubContacts || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0)) {
+ if (Drawing->type == CLCIT_CONTACT && (!Drawing->iSubNumber || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0)) {
int eNum = gl_RowTabAccess[i]->type - TC_EXTRA1;
if (eNum < dat->extraColumnsCount) {
if (Drawing->iExtraImage[eNum] != EMPTY_EXTRA_ICON) {
@@ -2160,7 +2160,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT
case ITEM_EXTRA_ICONS: //////////////////////////////////////////////////////////////////////////////////////////////
// Draw extra icons
- if (!Drawing->nSubContacts || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0) {
+ if (!Drawing->iSubNumber || dat->dbbMetaHideExtra == 0 && dat->extraColumnsCount > 0) {
int iImage;
int count = 0;
diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp
index 1899349d80..a18420734d 100644
--- a/plugins/Clist_modern/src/modern_clcutils.cpp
+++ b/plugins/Clist_modern/src/modern_clcutils.cpp
@@ -67,9 +67,9 @@ int cliHitTest(HWND hwnd, ClcData *dat, int testx, int testy, ClcContact **conta
if (flags) *flags |= CLCHT_NOWHERE | CLCHT_BELOWITEMS;
return -1;
}
+
if (contact) *contact = hitcontact;
if (group) *group = hitgroup;
- /////////
if (((testx < hitcontact->pos_indent) && !dat->text_rtl) || ((testx>clRect.right - hitcontact->pos_indent) && dat->text_rtl)) {
if (flags) *flags |= CLCHT_ONITEMINDENT;
@@ -252,7 +252,7 @@ void cliBeginRenameSelection(HWND hwnd, ClcData *dat)
return;
int indent, subindent;
- if (contact->type == CLCIT_CONTACT && contact->nSubContacts)
+ if (contact->type == CLCIT_CONTACT && contact->iSubNumber)
subindent = dat->subIndent;
else
subindent = 0;
@@ -411,7 +411,7 @@ int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt)
if (!mir_strcmp(contact->proto, META_PROTO))
return DROPTARGET_ONMETACONTACT;
- if (contact->nSubContacts)
+ if (contact->iSubNumber)
return DROPTARGET_ONSUBCONTACT;
return DROPTARGET_ONCONTACT;
}
@@ -663,72 +663,73 @@ int cliFindRowByText(HWND hwnd, ClcData *dat, const TCHAR *text, int prefixOk)
{
ClcGroup *group = &dat->list;
int testlen = (int)mir_tstrlen(text);
- ClcContact *contact = NULL;
int SubCount = 0;
group->scanIndex = 0;
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL)
+ if ((group = group->parent) == NULL)
break;
group->scanIndex++;
continue;
}
- contact = group->cl.items[group->scanIndex];
- if (contact->type != CLCIT_DIVIDER) {
+
+ ClcContact *cc = group->cl.items[group->scanIndex];
+ if (cc->type != CLCIT_DIVIDER) {
bool found;
if (dat->bFilterSearch) {
- TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(contact->szText));
+ TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(cc->szText));
TCHAR *lowered_text = CharLowerW(NEWTSTR_ALLOCA(text));
found = _tcsstr(lowered_szText, lowered_text) != NULL;
}
- else found = (prefixOk && !_tcsnicmp(text, contact->szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, contact->szText));
+ else found = (prefixOk && !_tcsnicmp(text, cc->szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, cc->szText));
if (found) {
- ClcGroup *contactGroup = group;
- int contactScanIndex = group->scanIndex;
+ ClcGroup *ccGroup = group;
+ int ccScanIndex = group->scanIndex;
for (; group; group = group->parent)
pcli->pfnSetGroupExpand(hwnd, dat, group, 1);
- return pcli->pfnGetRowsPriorTo(&dat->list, contactGroup, contactScanIndex + SubCount);
+ return pcli->pfnGetRowsPriorTo(&dat->list, ccGroup, ccScanIndex + SubCount);
}
- if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
- if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || group->cl.items[group->scanIndex]->group->expanded) {
- group = group->cl.items[group->scanIndex]->group;
+
+ if (cc->type == CLCIT_GROUP) {
+ if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->expanded) {
+ group = cc->group;
group->scanIndex = 0;
SubCount = 0;
continue;
}
}
}
- if (contact->type == CLCIT_CONTACT && contact->iSubAllocated) {
- if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || contact->bSubExpanded) {
- int i = 0;
- for (i = 0; i < contact->iSubAllocated; i++) {
- ClcContact *subcontact = &(contact->subcontacts[i]);
+
+ if (cc->type == CLCIT_CONTACT && cc->iSubAllocated) {
+ if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->bSubExpanded) {
+ for (int i = 0; i < cc->iSubAllocated; i++) {
+ const ClcContact &ccSub = cc->subcontacts[i];
bool found;
if (dat->bFilterSearch) {
- TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(subcontact->szText));
+ TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(ccSub.szText));
TCHAR *lowered_text = CharLowerW(NEWTSTR_ALLOCA(text));
found = _tcsstr(lowered_szText, lowered_text) != NULL;
}
- else found = (prefixOk && !_tcsnicmp(text, subcontact->szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, subcontact->szText));
+ else found = (prefixOk && !_tcsnicmp(text, ccSub.szText, testlen)) || (!prefixOk && !mir_tstrcmpi(text, ccSub.szText));
if (found) {
- ClcGroup *contactGroup = group;
- int contactScanIndex = group->scanIndex;
+ ClcGroup *ccGroup = group;
+ int ccScanIndex = group->scanIndex;
for (; group; group = group->parent)
pcli->pfnSetGroupExpand(hwnd, dat, group, 1);
- if (!contact->bSubExpanded)
- ExpandMetaContact(hwnd, contact, dat);
- return pcli->pfnGetRowsPriorTo(&dat->list, contactGroup, contactScanIndex + SubCount + i + 1);
+ if (!cc->bSubExpanded)
+ ExpandMetaContact(hwnd, cc, dat);
+ return pcli->pfnGetRowsPriorTo(&dat->list, ccGroup, ccScanIndex + SubCount + i + 1);
}
}
}
}
- if (contact->type == CLCIT_CONTACT && contact->iSubAllocated && contact->bSubExpanded)
- SubCount += contact->iSubAllocated;
+
+ if (cc->type == CLCIT_CONTACT && cc->iSubAllocated && cc->bSubExpanded)
+ SubCount += cc->iSubAllocated;
group->scanIndex++;
}
return -1;
diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
index 38d843c130..fbd3362f7e 100644
--- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
+++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
@@ -199,7 +199,7 @@ int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item)
case TC_EXTRA: // Draw extra icons
if (contact->type == CLCIT_CONTACT &&
- (!contact->nSubContacts || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
+ (!contact->iSubNumber || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
BOOL hasExtra = FALSE;
int width = 0;
for (int k = 0; k < dat->extraColumnsCount; k++)
@@ -225,7 +225,7 @@ int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item)
case TC_EXTRA8:
case TC_EXTRA9:
if (contact->type == CLCIT_CONTACT &&
- (!contact->nSubContacts || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
+ (!contact->iSubNumber || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
int eNum = pCell->type - TC_EXTRA1;
if (eNum < dat->extraColumnsCount)
if (contact->iExtraImage[eNum] != EMPTY_EXTRA_ICON || !dat->MetaIgnoreEmptyExtra) {
@@ -413,15 +413,15 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd)
RowHeights_Clear(dat);
- while (TRUE) {
+ while (true) {
int subident;
ClcContact *Drawing;
if (subindex == -1) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- indent--;
- if (group == NULL) break; // Finished list
+ if ((group = group->parent) == NULL)
+ break;
group->scanIndex++;
+ indent--;
continue;
}
@@ -431,7 +431,7 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd)
}
else {
// Get item to draw
- Drawing = &(group->cl.items[group->scanIndex]->subcontacts[subindex]);
+ Drawing = &group->cl.items[group->scanIndex]->subcontacts[subindex];
subident = dat->subIndent;
}
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp
index 5bcbdfd9ad..a73a0827e2 100644
--- a/plugins/Clist_nicer/src/clcitems.cpp
+++ b/plugins/Clist_nicer/src/clcitems.cpp
@@ -199,15 +199,18 @@ void RebuildEntireList(HWND hwnd, struct ClcData *dat)
group->scanIndex = 0;
for (;;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL)
+ if ((group = group->parent) == NULL)
break;
+ group->scanIndex++;
+ continue;
}
- else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
- if (group->cl.items[group->scanIndex]->group->cl.count == 0)
- group = pcli->pfnRemoveItemFromGroup(hwnd, group, group->cl.items[group->scanIndex], 0);
+
+ ClcContact *cc = group->cl.items[group->scanIndex];
+ if (cc->type == CLCIT_GROUP) {
+ if (cc->group->cl.count == 0)
+ group = pcli->pfnRemoveItemFromGroup(hwnd, group, cc, 0);
else {
- group = group->cl.items[group->scanIndex]->group;
+ group = cc->group;
group->scanIndex = 0;
}
continue;
diff --git a/plugins/Clist_nicer/src/clcpaint.cpp b/plugins/Clist_nicer/src/clcpaint.cpp
index 2a17249a7e..e79d0838b4 100644
--- a/plugins/Clist_nicer/src/clcpaint.cpp
+++ b/plugins/Clist_nicer/src/clcpaint.cpp
@@ -1423,17 +1423,18 @@ bgdone:
g_list_avatars = 0;
while (true) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- if (group == NULL) break; // Finished list
+ if ((group = group->parent) == NULL)
+ break;
group->scanIndex++;
continue;
}
- if (group->cl.items[group->scanIndex]->cFlags & ECF_AVATAR)
+ ClcContact *cc = group->cl.items[group->scanIndex];
+ if (cc->cFlags & ECF_AVATAR)
g_list_avatars++;
- 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->type == CLCIT_GROUP && (cc->group->expanded)) {
+ group = cc->group;
group->scanIndex = 0;
continue;
}
@@ -1443,33 +1444,32 @@ bgdone:
group = &dat->list;
group->scanIndex = 0;
- int indent = 0;
+ int indent = 0;
for (int index = 0; y < rcPaint->bottom;) {
if (group->scanIndex == group->cl.count) {
- group = group->parent;
- indent--;
- if (group == NULL)
+ if ((group = group->parent) == NULL)
break;
-
group->scanIndex++;
+ indent--;
continue;
}
line_num++;
+ ClcContact *cc = group->cl.items[group->scanIndex];
if (cfg::dat.bForceRefetchOnPaint)
- group->cl.items[group->scanIndex]->ace = (struct avatarCacheEntry*) - 1;
+ cc->ace = (struct avatarCacheEntry*) - 1;
if (y > rcPaint->top - dat->row_heights[line_num] && y <= rcPaint->bottom) {
- if (group->cl.items[group->scanIndex]->ace == (struct avatarCacheEntry*) - 1)
- group->cl.items[group->scanIndex]->ace = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)group->cl.items[group->scanIndex]->hContact, 0);
- RowHeight::getRowHeight(dat, group->cl.items[group->scanIndex], line_num, style);
- PaintItem(hdcMem, group, group->cl.items[group->scanIndex], indent, y, dat, index, hwnd, style, &clRect, &bFirstNGdrawn, groupCountsFontTopShift, dat->row_heights[line_num]);
+ if (cc->ace == (struct avatarCacheEntry*) - 1)
+ cc->ace = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)cc->hContact, 0);
+ RowHeight::getRowHeight(dat, cc, line_num, style);
+ PaintItem(hdcMem, group, cc, indent, y, dat, index, hwnd, style, &clRect, &bFirstNGdrawn, groupCountsFontTopShift, dat->row_heights[line_num]);
}
index++;
y += dat->row_heights[line_num];
- 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->type == CLCIT_GROUP && (cc->group->expanded)) {
+ group = cc->group;
indent++;
group->scanIndex = 0;
continue;