diff options
| author | George Hazan <george.hazan@gmail.com> | 2025-04-16 18:12:45 +0300 |
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2025-04-16 18:12:45 +0300 |
| commit | 9f27827e9b6cb1462ec4c5e306ae7eec79ba6473 (patch) | |
| tree | f1ef929f04fcd32945dcf14ca3e7c108614d1039 | |
| parent | ff1711ee2ba946cf25becfbb34be4f6a018031c4 (diff) | |
rollback to the old groups management code
| -rw-r--r-- | src/mir_app/src/clc.h | 2 | ||||
| -rw-r--r-- | src/mir_app/src/clistgroups.cpp | 28 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h index 935baed370..1639d14692 100644 --- a/src/mir_app/src/clc.h +++ b/src/mir_app/src/clc.h @@ -177,7 +177,7 @@ struct CGroupInternal CGroupInternal(int _id, const wchar_t *_name, int _flags);
~CGroupInternal();
- int groupId, flags;
+ int groupId, flags, oldId;
bool bSaveExpanded;
wchar_t *groupName;
diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp index b8b660feed..41778fda45 100644 --- a/src/mir_app/src/clistgroups.cpp +++ b/src/mir_app/src/clistgroups.cpp @@ -152,7 +152,7 @@ static INT_PTR CreateGroupInternal(MGROUP hParent, const wchar_t *ptszName) mir_snwprintf(newName, L"%s (%d)", newBaseName, idCopy);
}
- int newId = arByIds.getCount() ? arByIds[arByIds.getCount() - 1]->groupId + 1 : 0;
+ int newId = arByIds.getCount();
CGroupInternal *pNew = new CGroupInternal(newId, newName, GROUPF_EXPANDED);
arByIds.insert(pNew);
arByName.insert(pNew);
@@ -253,15 +253,23 @@ MIR_APP_DLL(int) Clist_GroupDelete(MGROUP hGroup, bool bSilent) NotifyEventHooks(hGroupChangeEvent, hContact, (LPARAM)&grpChg);
}
- // remove all child groups
- for (auto &it : arByIds.rev_iter())
- if (isParentOf(wszOldName, it->groupName)) {
- auto *p = it;
- arByName.remove(it);
- arByIds.removeItem(&it);
- p->remove();
- delete p;
- }
+ // shuffle list of groups up to fill gap
+ for (auto &it : arByIds)
+ it->oldId = it->groupId;
+
+ for (auto &it : arByIds.rev_iter()) {
+ if (!isParentOf(wszOldName, it->groupName))
+ continue;
+
+ arByName.remove(it);
+ arByIds.removeItem(&it);
+ }
+
+ for (auto &it : arByIds) {
+ it->groupId = arByIds.indexOf(&it);
+ if (it->groupId != it->oldId)
+ it->save();
+ }
SetCursor(LoadCursor(nullptr, IDC_ARROW));
Clist_LoadContactTree();
|
