| 1006 | } |
| 1007 | |
| 1008 | void CRegistryManagerView::RefreshFull(HTREEITEM hItem) { |
| 1009 | hItem = m_Tree.GetChildItem(hItem); |
| 1010 | TreeHelper th(m_Tree); |
| 1011 | while (hItem) { |
| 1012 | auto state = m_Tree.GetItemState(hItem, TVIS_EXPANDED | TVIS_EXPANDEDONCE); |
| 1013 | if (state) { |
| 1014 | if (state == TVIS_EXPANDEDONCE) { |
| 1015 | CString text; |
| 1016 | if (m_Tree.GetChildItem(hItem) && m_Tree.GetItemText(m_Tree.GetChildItem(hItem), text) && text != L"\\\\") { |
| 1017 | // not expanded now,delete all items and insert a dummy item |
| 1018 | th.DeleteChildren(hItem); |
| 1019 | m_Tree.InsertItem(L"\\\\", hItem, TVI_LAST); |
| 1020 | } |
| 1021 | } |
| 1022 | else { |
| 1023 | // really expanded |
| 1024 | RefreshFull(hItem); |
| 1025 | auto key = Registry::OpenKey(GetFullNodePath(hItem), KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS); |
| 1026 | if (key) { |
| 1027 | auto keys = th.GetChildItems(hItem); |
| 1028 | Registry::EnumSubKeys(key.Get(), [&](auto name, const auto&) { |
| 1029 | if (!th.FindChild(hItem, name)) { |
| 1030 | // new sub key |
| 1031 | auto hChild = InsertKeyItem(hItem, name); |
| 1032 | } |
| 1033 | else { |
| 1034 | keys.erase(name); |
| 1035 | } |
| 1036 | return true; |
| 1037 | }); |
| 1038 | |
| 1039 | for (auto& [name, h] : keys) |
| 1040 | m_Tree.DeleteItem(h); |
| 1041 | |
| 1042 | if (m_Tree.GetChildItem(hItem) == nullptr) { |
| 1043 | // remove children indicator |
| 1044 | TVITEM tvi; |
| 1045 | tvi.hItem = hItem; |
| 1046 | tvi.mask = TVIF_CHILDREN; |
| 1047 | tvi.cChildren = 0; |
| 1048 | m_Tree.SetItem(&tvi); |
| 1049 | } |
| 1050 | else { |
| 1051 | m_Tree.SortChildren(hItem); |
| 1052 | } |
| 1053 | } |
| 1054 | } |
| 1055 | } |
| 1056 | else if (m_Tree.GetChildItem(hItem) == nullptr && (GetNodeData(hItem) & NodeType::AccessDenied) == NodeType::None) { |
| 1057 | // no children - check if new exist |
| 1058 | auto key = Registry::OpenKey(GetFullNodePath(hItem), KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS); |
| 1059 | if (Registry::GetSubKeyCount(key.Get()) > 0) { |
| 1060 | m_Tree.InsertItem(L"\\\\", hItem, TVI_LAST); |
| 1061 | TVITEM tvi; |
| 1062 | tvi.hItem = hItem; |
| 1063 | tvi.mask = TVIF_CHILDREN; |
| 1064 | tvi.cChildren = 1; |
| 1065 | m_Tree.SetItem(&tvi); |
nothing calls this directly
no test coverage detected