From b2d136e6c0a2e654aa09adee6d01e2ebe9c02ce1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 5 Aug 2022 12:58:18 +0300 Subject: StdUserInfo: more compact variant of tree --- src/core/stduserinfo/src/stdinfo.cpp | 1 - src/core/stduserinfo/src/userinfo.cpp | 45 +++++++++++++---------------------- 2 files changed, 17 insertions(+), 29 deletions(-) (limited to 'src/core/stduserinfo') diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index 9b7f624307..aeefeda9a4 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -465,7 +465,6 @@ int DetailsInit(WPARAM wParam, LPARAM lParam) uip.flags = ODPF_ICON; uip.pDialog = new CSummaryDlg(); - uip.szGroup.a = LPGEN("General"); uip.szTitle.a = LPGEN("Summary"); uip.dwInitParam = (INT_PTR)g_plugin.getIconHandle(IDI_SUMMARY); g_plugin.addUserInfo(wParam, &uip); diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index 0d24f785b6..4c57fe75cf 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -109,13 +109,11 @@ class CUserInfoDlg : public CDlgBase OBJLIST m_pages; DetailsPageData *m_pCurrent = nullptr; - void PopulateContact(MCONTACT hContact, int iFolderImage) + void PopulateContact(MCONTACT hContact, int iFolderImage, wchar_t *pwszRoot) { ptrW ptszLastTab(g_plugin.getWStringA("LastTab")); m_pCurrent = nullptr; - std::map parents; - LIST items(1, PageSortProc); NotifyEventHooks(hDetailsInitEvent, (WPARAM)&items, hContact); @@ -131,31 +129,19 @@ class CUserInfoDlg : public CDlgBase if (items.getCount() == 0) return; - wchar_t *pwszGeneral = TranslateT("General"); + HTREEITEM hParent; + { + TVINSERTSTRUCT tvis = {}; + tvis.hInsertAfter = TVI_LAST; + tvis.item.lParam = (LPARAM)items[0]; + tvis.item.iImage = tvis.item.iSelectedImage = iFolderImage; + tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; + tvis.item.pszText = pwszRoot; + hParent = m_tree.InsertItem(&tvis); + } for (auto &it : items) { - wchar_t *pwszGroup = it->getGroup(); - wchar_t *pwszText = (pwszGroup == nullptr) ? pwszGeneral : pwszGroup; - - HTREEITEM hParent; - auto p = parents.find(pwszText); - if (p == parents.end()) { - TVINSERTSTRUCT tvis = {}; - tvis.hInsertAfter = TVI_LAST; - tvis.item.lParam = (LPARAM)it; - tvis.item.iImage = tvis.item.iSelectedImage = iFolderImage; - tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; - if (pwszGroup != nullptr) { - tvis.item.pszText = pwszGroup; - tvis.hParent = (m_bIsMeta) ? parents.find(pwszGeneral)->second : nullptr; - } - else tvis.item.pszText = pwszGeneral; - - hParent = parents[pwszText] = m_tree.InsertItem(&tvis); - } - else hParent = p->second; - int iImage = 1; if ((it->dwFlags & ODPF_ICON) && it->lParam) { HICON hIcon = IcoLib_GetIconByHandle((HANDLE)it->lParam); @@ -196,7 +182,7 @@ class CUserInfoDlg : public CDlgBase m_tree.SetImageList(m_imageList, TVSIL_NORMAL); - PopulateContact(m_hContact, 0); + PopulateContact(m_hContact, 0, TranslateT("General")); if (m_bIsMeta) { int nSubs = db_mc_getSubCount(m_hContact); @@ -205,7 +191,10 @@ class CUserInfoDlg : public CDlgBase MCONTACT hSub = db_mc_getSub(m_hContact, i); if (hSub > 0) { auto *szProto = Proto_GetBaseAccountName(hSub); - PopulateContact(hSub, ImageList_AddIcon(m_imageList, IcoLib_GetIconByHandle(Skin_GetProtoIcon(szProto, ID_STATUS_ONLINE)))); + auto *pa = Proto_GetAccount(szProto); + PopulateContact(hSub, + ImageList_AddIcon(m_imageList, IcoLib_GetIconByHandle(Skin_GetProtoIcon(szProto, ID_STATUS_ONLINE))), + pa ? pa->tszAccountName : _A2T(szProto)); } } } -- cgit v1.2.3