From 03993769c47dc2d3229002439272454186d29bf8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 10 Apr 2021 20:57:40 +0300 Subject: fixes #2841 (DbEditor: allow to delete contacts from right panel) --- plugins/DbEditorPP/src/settinglist.cpp | 35 +++++++++++++++++++++++++++------- plugins/DbEditorPP/src/version.h | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'plugins/DbEditorPP') diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index 96264fd906..be155a86c8 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -126,25 +126,46 @@ void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *s if (g_plugin.bWarnOnDelete) { wchar_t text[MSG_SIZE]; - mir_snwprintf(text, TranslateT("Are you sure you want to delete setting(s): %d?"), count); + if (info.hContact == 0) + mir_snwprintf(text, TranslateT("Are you sure you want to delete %d contact(s)?"), count); + else + mir_snwprintf(text, TranslateT("Are you sure you want to delete %d setting(s)?"), count); if (dlg(text, MB_YESNO | MB_ICONEXCLAMATION) == IDNO) return; } - if (count == 1) - db_unset(hContact, module, setting); - else { + if (hContact == 0) { int items = ListView_GetItemCount(hwnd2List); for (int i = 0; i < items;) { if (ListView_GetItemState(hwnd2List, i, LVIS_SELECTED)) { - char text[FLD_SIZE]; - if (ListView_GetItemTextA(hwnd2List, i, 0, text, _countof(text))) - db_unset(hContact, module, text); + LVITEM lvi = {}; + lvi.mask = LVIF_PARAM; + lvi.iItem = i; + if (ListView_GetItem(hwnd2List, &lvi)) { + db_delete_contact(MCONTACT(lvi.lParam)); + ListView_DeleteItem(hwnd2List, i); + } items--; } else i++; } } + else { + if (count == 1) + db_unset(hContact, module, setting); + else { + int items = ListView_GetItemCount(hwnd2List); + for (int i = 0; i < items;) { + if (ListView_GetItemState(hwnd2List, i, LVIS_SELECTED)) { + char text[FLD_SIZE]; + if (ListView_GetItemTextA(hwnd2List, i, 0, text, _countof(text))) + db_unset(hContact, module, text); + items--; + } + else i++; + } + } + } if (ListView_GetItemCount(hwnd2List) == 0) replaceTreeItem(hContact, module, nullptr); diff --git a/plugins/DbEditorPP/src/version.h b/plugins/DbEditorPP/src/version.h index f731cc7a12..5d41638d3e 100644 --- a/plugins/DbEditorPP/src/version.h +++ b/plugins/DbEditorPP/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 4 #define __MINOR_VERSION 0 #define __RELEASE_NUM 2 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3