From 7d01efe711c9117569ea1c4c7b8334d784a7b6ca Mon Sep 17 00:00:00 2001 From: henrypp Date: Thu, 30 Apr 2020 14:16:36 +0600 Subject: [PATCH] added count marks for apps groups --- src/editor.cpp | 97 +++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/src/editor.cpp b/src/editor.cpp index 9342160e..9cc6a547 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -256,7 +256,9 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa { _r_str_trim (rule_single, DIVIDER_TRIM DIVIDER_RULE); + _r_fastlock_acquireshared (&lock_checkbox); _r_listview_additem (hwnd, IDC_RULE_REMOTE_ID, index, 0, rule_single, I_IMAGENONE, I_GROUPIDNONE, index); + _r_fastlock_releaseshared (&lock_checkbox); index += 1; } @@ -296,7 +298,9 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa { _r_str_trim (rule_single, DIVIDER_TRIM DIVIDER_RULE); + _r_fastlock_acquireshared (&lock_checkbox); _r_listview_additem (hwnd, IDC_RULE_LOCAL_ID, index, 0, rule_single, I_IMAGENONE, I_GROUPIDNONE, index); + _r_fastlock_releaseshared (&lock_checkbox); index += 1; } @@ -324,65 +328,60 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa _r_listview_setstyle (hwnd, IDC_RULE_APPS_ID, LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_CHECKBOXES, TRUE); - _r_listview_addcolumn (hwnd, IDC_RULE_APPS_ID, 0, app.LocaleString (IDS_NAME, nullptr), -100, LVCFMT_LEFT); + _r_listview_addcolumn (hwnd, IDC_RULE_APPS_ID, 0, app.LocaleString (IDS_NAME, nullptr), 0, LVCFMT_LEFT); - _r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 0, app.LocaleString (IDS_TAB_APPS, nullptr), 0, LVGS_COLLAPSIBLE); - _r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 1, app.LocaleString (IDS_TAB_SERVICES, nullptr), 0, LVGS_COLLAPSIBLE); - - if (_r_sys_validversion (6, 2)) - _r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 2, app.LocaleString (IDS_TAB_PACKAGES, nullptr), 0, LVGS_COLLAPSIBLE); + _r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 0, L"", 0, LVGS_COLLAPSIBLE); + _r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 1, L"", 0, LVGS_COLLAPSIBLE); + _r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 2, L"", 0, LVGS_COLLAPSIBLE); // apps (apply to) + for (auto &p : apps) { - _r_fastlock_acquireshared (&lock_access); + PR_OBJECT ptr_app_object = _r_obj_reference (p.second); - for (auto &p : apps) + if (!ptr_app_object) + continue; + + PITEM_APP ptr_app = (PITEM_APP)ptr_app_object->pdata; + + if (!ptr_app) { - PR_OBJECT ptr_app_object = _r_obj_reference (p.second); - - if (!ptr_app_object) - continue; - - PITEM_APP ptr_app = (PITEM_APP)ptr_app_object->pdata; - - if (!ptr_app) - { - _r_obj_dereference (ptr_app_object); - continue; - } - - INT group_id; - - if (ptr_app->type == DataAppUWP) - group_id = 2; - - else if (ptr_app->type == DataAppService) - group_id = 1; - - else - group_id = 0; - - // check for services - const bool is_enabled = (ptr_rule->apps.find (p.first) != ptr_rule->apps.end ()) || ptr_rule->is_forservices && (p.first == config.ntoskrnl_hash || p.first == config.svchost_hash); - - _r_fastlock_acquireshared (&lock_checkbox); - - _r_listview_additem (hwnd, IDC_RULE_APPS_ID, 0, 0, _r_path_getfilename (ptr_app->display_name), ptr_app->icon_id, group_id, p.first); - _r_listview_setitemcheck (hwnd, IDC_RULE_APPS_ID, 0, is_enabled); - - _r_fastlock_releaseshared (&lock_checkbox); - _r_obj_dereference (ptr_app_object); + continue; } - _r_fastlock_releaseshared (&lock_access); + INT group_id; - // resize column - _r_listview_setcolumn (hwnd, IDC_RULE_APPS_ID, 0, nullptr, -100); + if (ptr_app->type == DataAppUWP) + group_id = 2; - // sort column - _app_listviewsort (hwnd, IDC_RULE_APPS_ID); + else if (ptr_app->type == DataAppService) + group_id = 1; + + else + group_id = 0; + + // check for services + const bool is_enabled = (ptr_rule->apps.find (p.first) != ptr_rule->apps.end ()) || ptr_rule->is_forservices && (p.first == config.ntoskrnl_hash || p.first == config.svchost_hash); + + _r_fastlock_acquireshared (&lock_checkbox); + + _r_listview_additem (hwnd, IDC_RULE_APPS_ID, 0, 0, _r_path_getfilename (ptr_app->display_name), ptr_app->icon_id, group_id, p.first); + _r_listview_setitemcheck (hwnd, IDC_RULE_APPS_ID, 0, is_enabled); + + _r_fastlock_releaseshared (&lock_checkbox); + + _r_obj_dereference (ptr_app_object); } + + // resize column + _r_listview_setcolumn (hwnd, IDC_RULE_APPS_ID, 0, nullptr, -100); + + // localize groups + _app_refreshgroups (hwnd, IDC_RULE_APPS_ID); + + // sort column + _app_listviewsort (hwnd, IDC_RULE_APPS_ID); } // hints @@ -568,6 +567,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa if (_r_fastlock_islocked (&lock_checkbox)) break; + _app_refreshgroups (hwnd, listview_id); _app_listviewsort (hwnd, listview_id); } } @@ -704,7 +704,8 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa _r_fastlock_releaseshared (&lock_checkbox); - _app_listviewsort (hwnd, IDC_RULE_APPS_ID, 0); + _app_refreshgroups (hwnd, IDC_RULE_APPS_ID); + _app_listviewsort (hwnd, IDC_RULE_APPS_ID); break; }