From 64751211cc037081bc32d4c41c17e064162d6ca4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 20 Sep 2016 09:37:48 +0000 Subject: - fix for moving groups; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@17326 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_app/src/clc.cpp | 8 ++++++-- src/mir_app/src/clistgroups.cpp | 26 ++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 0af50af530..4074bb4a91 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -72,8 +72,12 @@ static int ClcSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; if (hContact == NULL) { - if (!strcmp(cws->szModule, "CListGroups") && !g_bGroupsLocked) - Clist_Broadcast(INTM_GROUPSCHANGED, hContact, lParam); + if (!strcmp(cws->szModule, "CListGroups")) { + if (g_bGroupsLocked) + Clist_Broadcast(CLM_AUTOREBUILD, 0, 0); + else + Clist_Broadcast(INTM_GROUPSCHANGED, hContact, lParam); + } return 0; } diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp index b8b3bbdb0e..524f91b9f0 100644 --- a/src/mir_app/src/clistgroups.cpp +++ b/src/mir_app/src/clistgroups.cpp @@ -268,30 +268,32 @@ MIR_APP_DLL(int) Clist_GroupMoveBefore(MGROUP hGroup, MGROUP hGroupBefore) if (hGroup == 0 || hGroup == hGroupBefore) return 0; - CGroupInternal *pGroup = arByIds.find(hGroup - 1); + hGroup--; + CGroupInternal *pGroup = arByIds.find(hGroup); if (pGroup == NULL) return 0; // shuffle list of groups up to fill gap int shuffleFrom, shuffleTo, shuffleStep; if (hGroupBefore == 0) { - shuffleFrom = hGroup - 1; - shuffleTo = -1; + shuffleFrom = 0; + shuffleTo = hGroup; shuffleStep = 1; } else { - CGroupInternal *pDest = arByIds.find(hGroupBefore - 1); + hGroupBefore--; + CGroupInternal *pDest = arByIds.find(hGroupBefore); if (pDest == NULL) return 0; if (hGroup < hGroupBefore) { - shuffleFrom = hGroup - 1; - shuffleTo = hGroupBefore - 2; + shuffleFrom = hGroup; + shuffleTo = hGroupBefore; shuffleStep = 1; } else { - shuffleFrom = hGroup - 1; - shuffleTo = hGroupBefore - 1; + shuffleFrom = hGroupBefore; + shuffleTo = hGroup; shuffleStep = -1; } } @@ -299,17 +301,18 @@ MIR_APP_DLL(int) Clist_GroupMoveBefore(MGROUP hGroup, MGROUP hGroupBefore) g_bGroupsLocked = true; arByIds.remove(pGroup); - for (int i = shuffleFrom; i != shuffleTo; i += shuffleStep) { - CGroupInternal *p = arByIds[i + shuffleStep]; + for (int i = shuffleFrom; i < shuffleTo; i++) { + CGroupInternal *p = arByIds[i]; p->groupId -= shuffleStep; p->save(); } - pGroup->groupId = shuffleTo; // reinsert group back + pGroup->groupId = hGroupBefore; // reinsert group back pGroup->save(); arByIds.insert(pGroup); g_bGroupsLocked = false; + Clist_BroadcastAsync(CLM_AUTOREBUILD, 0, 0); return shuffleTo + 1; } @@ -374,7 +377,6 @@ static int RenameGroupWithMove(int groupId, const wchar_t *szName, int move) } } } - Clist_BroadcastAsync(CLM_AUTOREBUILD, 0, 0); } const CLISTGROUPCHANGE grpChg = { sizeof(grpChg), oldName, (wchar_t*)szName }; -- cgit v1.2.3