From 1aaadab76188b1ca1e2074208e07354841f59e36 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 19 Jun 2012 20:22:15 +0200 Subject: [PATCH] RefBrowser: Added basic filter Signed-off-by: Sven Strickroth --- src/Resources/TortoiseProcENG.rc | 7 +++++-- src/TortoiseProc/BrowseRefsDlg.cpp | 28 ++++++++++++++++++++++++++-- src/TortoiseProc/BrowseRefsDlg.h | 5 +++++ src/TortoiseProc/resource.h | 2 ++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index d0028bee6..c658d2fa2 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -3556,9 +3556,11 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "OK",IDOK,285,234,50,14 PUSHBUTTON "Cancel",IDCANCEL,347,234,50,14 - CONTROL "",IDC_TREE_REF,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,108,224 - CONTROL "",IDC_LIST_REF_LEAFS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,125,7,333,224 PUSHBUTTON "Help",IDHELP,408,234,50,14 + CONTROL "",IDC_TREE_REF,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,108,224 + CONTROL "",IDC_LIST_REF_LEAFS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,125,7,333,206 + LTEXT "Filter:",IDC_BROWSEREFS_STATIC_FILTER,125,220,37,9 + EDITTEXT IDC_BROWSEREFS_EDIT_FILTER,164,219,294,12,ES_AUTOHSCROLL END IDD_ADD_REMOTE DIALOGEX 0, 0, 300, 84 @@ -3588,6 +3590,7 @@ BEGIN BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 458 + VERTGUIDE, 125 TOPMARGIN, 7 BOTTOMMARGIN, 248 HORZGUIDE, 231 diff --git a/src/TortoiseProc/BrowseRefsDlg.cpp b/src/TortoiseProc/BrowseRefsDlg.cpp index 0c191c7f9..cac18d061 100644 --- a/src/TortoiseProc/BrowseRefsDlg.cpp +++ b/src/TortoiseProc/BrowseRefsDlg.cpp @@ -80,6 +80,7 @@ void CBrowseRefsDlg::DoDataExchange(CDataExchange* pDX) CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_TREE_REF, m_RefTreeCtrl); DDX_Control(pDX, IDC_LIST_REF_LEAFS, m_ListRefLeafs); + DDX_Control(pDX, IDC_BROWSEREFS_EDIT_FILTER, m_ctrlFilter); } @@ -92,6 +93,8 @@ BEGIN_MESSAGE_MAP(CBrowseRefsDlg, CResizableStandAloneDialog) ON_NOTIFY(NM_DBLCLK, IDC_LIST_REF_LEAFS, &CBrowseRefsDlg::OnNMDblclkListRefLeafs) ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST_REF_LEAFS, &CBrowseRefsDlg::OnLvnEndlabeleditListRefLeafs) ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST_REF_LEAFS, &CBrowseRefsDlg::OnLvnBeginlabeleditListRefLeafs) + ON_EN_CHANGE(IDC_BROWSEREFS_EDIT_FILTER, &CBrowseRefsDlg::OnEnChangeEditFilter) + ON_WM_TIMER() END_MESSAGE_MAP() @@ -109,6 +112,8 @@ BOOL CBrowseRefsDlg::OnInitDialog() AddAnchor(IDC_TREE_REF, TOP_LEFT, BOTTOM_LEFT); AddAnchor(IDC_LIST_REF_LEAFS, TOP_LEFT, BOTTOM_RIGHT); + AddAnchor(IDC_BROWSEREFS_STATIC_FILTER, BOTTOM_LEFT); + AddAnchor(IDC_BROWSEREFS_EDIT_FILTER, BOTTOM_LEFT, BOTTOM_RIGHT); AddAnchor(IDHELP, BOTTOM_RIGHT); m_ListRefLeafs.SetExtendedStyle(m_ListRefLeafs.GetExtendedStyle()|LVS_EX_FULLROWSELECT); @@ -406,12 +411,15 @@ void CBrowseRefsDlg::FillListCtrlForShadowTree(CShadowTree* pTree, CString refNa { if(pTree->IsLeaf()) { - if (!(pTree->m_csRefName.IsEmpty() || pTree->m_csRefName == "refs" && pTree->m_pParent == NULL)) + CString filter; + m_ctrlFilter.GetWindowText(filter); + CString ref = refNamePrefix + pTree->m_csRefName; + if (!(pTree->m_csRefName.IsEmpty() || pTree->m_csRefName == "refs" && pTree->m_pParent == NULL) && ref.Find(filter) >= 0) { int indexItem = m_ListRefLeafs.InsertItem(m_ListRefLeafs.GetItemCount(), L""); m_ListRefLeafs.SetItemData(indexItem,(DWORD_PTR)pTree); - m_ListRefLeafs.SetItemText(indexItem,eCol_Name, refNamePrefix+pTree->m_csRefName); + m_ListRefLeafs.SetItemText(indexItem,eCol_Name, ref); m_ListRefLeafs.SetItemText(indexItem,eCol_Date, pTree->m_csDate); m_ListRefLeafs.SetItemText(indexItem,eCol_Msg, pTree->m_csSubject); m_ListRefLeafs.SetItemText(indexItem,eCol_Hash, pTree->m_csRefHash); @@ -1121,3 +1129,19 @@ void CBrowseRefsDlg::OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pRe return; } } + +void CBrowseRefsDlg::OnEnChangeEditFilter() +{ + SetTimer(IDT_FILTER, 1000, NULL); +} + +void CBrowseRefsDlg::OnTimer(UINT_PTR nIDEvent) +{ + if (nIDEvent == IDT_FILTER) + { + KillTimer(IDT_FILTER); + FillListCtrlForTreeNode(m_RefTreeCtrl.GetSelectedItem()); + } + + CResizableStandAloneDialog::OnTimer(nIDEvent); +} diff --git a/src/TortoiseProc/BrowseRefsDlg.h b/src/TortoiseProc/BrowseRefsDlg.h index 584ce3664..245cce21c 100644 --- a/src/TortoiseProc/BrowseRefsDlg.h +++ b/src/TortoiseProc/BrowseRefsDlg.h @@ -21,6 +21,7 @@ #include "Git.h" #include #include "StandAloneDlg.h" +#include "afxwin.h" const int gPickRef_Head = 1; const int gPickRef_Tag = 2; @@ -138,6 +139,10 @@ private: CTreeCtrl m_RefTreeCtrl; CListCtrl m_ListRefLeafs; + CEdit m_ctrlFilter; + afx_msg void OnEnChangeEditFilter(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + int m_currSortCol; bool m_currSortDesc; afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult); diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index 2b3b0285f..970197f06 100644 --- a/src/TortoiseProc/resource.h +++ b/src/TortoiseProc/resource.h @@ -861,6 +861,8 @@ #define IDC_BUGTRAQPROVIDERLABEL 1475 #define IDC_BUGTRAQPROVIDERCOMBO 1476 #define IDC_BUGTRAQPARAMETERSLABEL 1477 +#define IDC_BROWSEREFS_EDIT_FILTER 1478 +#define IDC_BROWSEREFS_STATIC_FILTER 1479 #define IDC_SHOWEXTERNALS 1480 #define IDC_FORCE 1480 #define IDC_UNVERSIONEDITEMS 1481 -- 2.11.4.GIT