summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-08-05 12:58:18 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-08-05 12:58:18 +0300
commitb2d136e6c0a2e654aa09adee6d01e2ebe9c02ce1 (patch)
tree2ba2d43fd7784da2b8cebf83e40b825a7c245dc0 /src
parentff9679b7f42879dde78c4f74682eff63ee152e7c (diff)
StdUserInfo: more compact variant of tree
Diffstat (limited to 'src')
-rw-r--r--src/core/stduserinfo/src/stdinfo.cpp1
-rw-r--r--src/core/stduserinfo/src/userinfo.cpp45
2 files changed, 17 insertions, 29 deletions
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<DetailsPageData> 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<std::wstring, HTREEITEM> parents;
-
LIST<DetailsPageData> 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));
}
}
}