From 5803a342d30b25f930fdf0b201c62bc2c6c5d624 Mon Sep 17 00:00:00 2001 From: Johan t Hart Date: Wed, 22 Apr 2009 23:55:07 +0200 Subject: [PATCH] Show selected refs in list ctrl --- src/Resources/TortoiseProcENG.rc | Bin 426060 -> 426356 bytes src/TortoiseProc/BrowseRefsDlg.cpp | 74 +++++++++++++++++++++++++++++++++---- src/TortoiseProc/BrowseRefsDlg.h | 11 +++++- src/TortoiseProc/resource.h | Bin 158454 -> 158546 bytes 4 files changed, 76 insertions(+), 9 deletions(-) diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 5983b58cc380ec6f0a515a5dae97cea9b6947ae6..6ad451202e959dee675cf9c37d4a7d860c57956d 100644 GIT binary patch delta 203 zcwRfxAoZn5s-cCkg{g(Pg{6gc3)_x#UK0j022%zd1_cHq2Gi*W`x*Tw%k@s1zAA%l z1E(=i1|(-ReWEQ>BBu$10fPmMD?8nQpIL9ZL>Ak=$pING+=ehoptK@Cv+MK)LCkF2 zZVd4ZJ`Ao5jtp*-7ygN#zTr8efv6GKP;($Q21Br>$qNsPZvT_T_KT6(1n7{7Q<)Q| e^DShSnBFjnS!(*EDL~eQ|IA$5>vGx72>}3EJ~wax delta 140 zcwYO`Bz2}is-cCkg{g(Pg{6gc3)_x#ULyuG24e;t1_cHnYr0}0lmBG7-f7cUWw34F zHDoXW%NYS_gXxOm_hTree==NULL) + + if(!refName.IsEmpty()) { - //New tree. Create node in control. - pNextTree->m_hTree=m_RefTreeCtrl.InsertItem(pNextTree->m_csName,pTreePos->m_hTree,NULL); - m_RefTreeCtrl.SetItemData(pNextTree->m_hTree,(DWORD_PTR)pNextTree); + //When the refName is not empty, this node is not a leaf, so lets add it to the tree control. + //Leafs are for the list control. + if(pNextTree->m_hTree==NULL) + { + //New tree. Create node in control. + pNextTree->m_hTree=m_RefTreeCtrl.InsertItem(pNextTree->m_csName,pTreePos->m_hTree,NULL); + m_RefTreeCtrl.SetItemData(pNextTree->m_hTree,(DWORD_PTR)pNextTree); + } } return GetTreeNode(refName,pNextTree); } + +void CBrowseRefsDlg::OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMTREEVIEW pNMTreeView = reinterpret_cast(pNMHDR); + *pResult = 0; + + FillListCtrlForTreeNode(pNMTreeView->itemNew.hItem); +} + +void CBrowseRefsDlg::FillListCtrlForTreeNode(HTREEITEM treeNode) +{ + m_ListRefLeafs.DeleteAllItems(); + + CShadowTree* pTree=(CShadowTree*)(m_RefTreeCtrl.GetItemData(treeNode)); + if(pTree==NULL) + { + ASSERT(FALSE); + return; + } + FillListCtrlForShadowTree(pTree,L"",true); +} + +void CBrowseRefsDlg::FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel) +{ + if(pTree->IsLeaf()) + { + int indexItem=m_ListRefLeafs.InsertItem(m_ListRefLeafs.GetItemCount(),L""); + + m_ListRefLeafs.SetItemData(indexItem,(DWORD_PTR)pTree); + m_ListRefLeafs.SetItemText(indexItem,0,refNamePrefix+pTree->m_csName); + m_ListRefLeafs.SetItemText(indexItem,3,pTree->m_csRef); + } + else + { + + CString csThisName; + if(!isFirstLevel) + csThisName=refNamePrefix+pTree->m_csName+L"/"; + for(CShadowTree::TShadowTreeMap::iterator itSubTree=pTree->m_ShadowTree.begin(); itSubTree!=pTree->m_ShadowTree.end(); ++itSubTree) + { + FillListCtrlForShadowTree(&itSubTree->second,csThisName,false); + } + } +} diff --git a/src/TortoiseProc/BrowseRefsDlg.h b/src/TortoiseProc/BrowseRefsDlg.h index ce31d639e..d1a1f4bbe 100644 --- a/src/TortoiseProc/BrowseRefsDlg.h +++ b/src/TortoiseProc/BrowseRefsDlg.h @@ -14,6 +14,8 @@ public: CShadowTree* GetNextSub(CString& nameLeft); + bool IsLeaf()const {return m_ShadowTree.empty();} + CString m_csName; CString m_csRef; @@ -43,12 +45,19 @@ public: afx_msg void OnBnClickedOk(); virtual BOOL OnInitDialog(); - void Refresh(); + void Refresh(); CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL); + void FillListCtrlForTreeNode(HTREEITEM treeNode); + + void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel); + +private: MAP_HASH_NAME m_RefMap; CShadowTree m_TreeRoot; CTreeCtrl m_RefTreeCtrl; + CListCtrl m_ListRefLeafs; + afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult); }; diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index 2d4a6a6eb257537fcc0a6975b29cc7eda877afd9..4af780c03db023694071f6e9016b4c65d4d037e3 100644 GIT binary patch delta 56 zcwYN