diff options
author | George Hazan <george.hazan@gmail.com> | 2016-05-28 09:39:09 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-05-28 09:39:09 +0000 |
commit | 3a80b03cb1b3813b47fa878fae9a61632bd25d51 (patch) | |
tree | 06e7572273baf8029e493381316600c8ba81db2a | |
parent | 22d42330716a38bfe2faef08eec2b2d3cab1886d (diff) |
duplicated code removed from clist_nicer
git-svn-id: http://svn.miranda-ng.org/main/trunk@16879 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Clist_nicer/src/clcitems.cpp | 72 | ||||
-rw-r--r-- | src/mir_app/src/clcitems.cpp | 19 |
2 files changed, 11 insertions, 80 deletions
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 70b1a19421..bf91386ba2 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -145,82 +145,12 @@ int AddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hContact) void RebuildEntireList(HWND hwnd, struct ClcData *dat)
{
- DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
- ClcGroup *group;
- DBVARIANT dbv = { 0 };
-
RowHeight::Clear(dat);
RowHeight::getMaxRowHeight(dat, hwnd);
- dat->list.expanded = 1;
- dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0);
- dat->list.cl.destroy();
- dat->list.totalMembers = 0;
- dat->selection = -1;
dat->SelectMode = db_get_b(NULL, "CLC", "SelectMode", 0);
- {
- for (int i = 1;; i++) {
- DWORD groupFlags;
- TCHAR *szGroupName = Clist_GroupGetName(i, &groupFlags);
- if (szGroupName == NULL)
- break;
- pcli->pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0);
- }
- }
-
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (style & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(hContact, NULL, dat)) {
- memset(&dbv, 0, sizeof(dbv));
- if (db_get_ts(hContact, "CList", "Group", &dbv))
- group = &dat->list;
- else {
- group = pcli->pfnAddGroup(hwnd, dat, dbv.ptszVal, (DWORD)-1, 0, 0);
- mir_free(dbv.ptszVal);
- }
-
- if (group != NULL) {
- group->totalMembers++;
- if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL) {
- if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE))
- AddContactToGroup(dat, group, hContact);
- }
- else if (!pcli->pfnIsHiddenMode(dat, (WORD)db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)))
- AddContactToGroup(dat, group, hContact);
- }
- else AddContactToGroup(dat, group, hContact);
- }
- }
- }
-
- if (style & CLS_HIDEEMPTYGROUPS) {
- group = &dat->list;
- group->scanIndex = 0;
- for (;;) {
- 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) {
- if (cc->group->cl.getCount() == 0)
- group = pcli->pfnRemoveItemFromGroup(hwnd, group, cc, 0);
- else {
- group = cc->group;
- group->scanIndex = 0;
- }
- continue;
- }
- group->scanIndex++;
- }
- }
- pcli->pfnSortCLC(hwnd, dat, 0);
- pcli->pfnSetAllExtraIcons(NULL);
+ coreCli.pfnRebuildEntireList(hwnd, dat);
}
/*
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index 9408a40320..be581876eb 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -339,11 +339,11 @@ void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem) void fnRebuildEntireList(HWND hwnd, ClcData *dat) { DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); - ClcGroup *group; dat->list.expanded = 1; - dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0) && style&CLS_USEGROUPS; + dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0) && (style & CLS_USEGROUPS); dat->list.cl.destroy(); + dat->list.totalMembers = 0;
dat->selection = -1; for (int i = 1;; i++) { @@ -356,13 +356,14 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat) for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { if (style & CLS_SHOWHIDDEN || !db_get_b(hContact, "CList", "Hidden", 0)) { - DBVARIANT dbv; - if (db_get_ts(hContact, "CList", "Group", &dbv)) - group = &dat->list; + ClcGroup *group; + ptrT tszGroupName(db_get_tsa(hContact, "CList", "Group"));
+ if (tszGroupName == NULL)
+ group = &dat->list;
else { - group = cli.pfnAddGroup(hwnd, dat, dbv.ptszVal, (DWORD)-1, 0, 0); - if (group == NULL && style & CLS_SHOWHIDDEN) group = &dat->list; - mir_free(dbv.ptszVal); + group = cli.pfnAddGroup(hwnd, dat, tszGroupName, (DWORD)-1, 0, 0); + if (group == NULL && style & CLS_SHOWHIDDEN) + group = &dat->list; } if (group != NULL) { @@ -391,7 +392,7 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat) } if (style & CLS_HIDEEMPTYGROUPS) { - group = &dat->list; + ClcGroup *group = &dat->list; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.getCount()) { |