From 6e894b04f6153268b6bc57be0a9579e2921dab55 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Tue, 30 Dec 2008 14:05:35 +0800 Subject: [PATCH] Log Filter text work --- ext/scintilla/vcbuild/SciLexer.vcproj | 4 + src/Git/Git.vcproj | 4 - src/TortoiseProc/GitLogList.cpp | 46 ++++++ src/TortoiseProc/GitLogList.h | 13 +- src/TortoiseProc/LogDlg.cpp | 295 ++++++---------------------------- src/TortoiseProc/LogDlg.h | 2 +- 6 files changed, 114 insertions(+), 250 deletions(-) diff --git a/ext/scintilla/vcbuild/SciLexer.vcproj b/ext/scintilla/vcbuild/SciLexer.vcproj index 776c250..49141ab 100644 --- a/ext/scintilla/vcbuild/SciLexer.vcproj +++ b/ext/scintilla/vcbuild/SciLexer.vcproj @@ -2380,6 +2380,10 @@ + + diff --git a/src/Git/Git.vcproj b/src/Git/Git.vcproj index c2bdd05..e273009 100644 --- a/src/Git/Git.vcproj +++ b/src/Git/Git.vcproj @@ -246,10 +246,6 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > - - diff --git a/src/TortoiseProc/GitLogList.cpp b/src/TortoiseProc/GitLogList.cpp index 5a4d822..22b5b9d 100644 --- a/src/TortoiseProc/GitLogList.cpp +++ b/src/TortoiseProc/GitLogList.cpp @@ -2121,4 +2121,50 @@ BOOL CGitLogList::IsEntryInDateRange(int i) #endif; return TRUE; +} +void CGitLogList::StartFilter() +{ + InterlockedExchange(&m_bNoDispUpdates, TRUE); + RecalculateShownList(&m_arShownList); + InterlockedExchange(&m_bNoDispUpdates, FALSE); + + + DeleteAllItems(); + SetItemCountEx(ShownCountWithStopped()); + RedrawItems(0, ShownCountWithStopped()); + SetRedraw(false); + ResizeAllListCtrlCols(); + SetRedraw(true); + Invalidate(); +} +void CGitLogList::RemoveFilter() +{ + + InterlockedExchange(&m_bNoDispUpdates, TRUE); + + m_arShownList.RemoveAll(); + + // reset the time filter too +#if 0 + m_timFrom = (__time64_t(m_tFrom)); + m_timTo = (__time64_t(m_tTo)); + m_DateFrom.SetTime(&m_timFrom); + m_DateTo.SetTime(&m_timTo); + m_DateFrom.SetRange(&m_timFrom, &m_timTo); + m_DateTo.SetRange(&m_timFrom, &m_timTo); +#endif + + for (DWORD i=0; iShowWindow(SW_HIDE); GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW); GetDlgItem(IDC_SEARCHEDIT)->SetFocus(); UpdateLogInfoLabel(); -#endif + return 0L; } @@ -2383,205 +2356,13 @@ void CLogDlg::SetFilterCueText() temp = _T(" ")+temp; m_cFilter.SetCueBanner(temp); } -#if 0 -void CLogDlg::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult) -{ - NMLVDISPINFO *pDispInfo = reinterpret_cast(pNMHDR); - - // Create a pointer to the item - LV_ITEM* pItem = &(pDispInfo)->item; - - // Do the list need text information? - if (!(pItem->mask & LVIF_TEXT)) - return; - - // By default, clear text buffer. - lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax); - - bool bOutOfRange = pItem->iItem >= ShownCountWithStopped(); - - *pResult = 0; - if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange) - return; - - // Which item number? - int itemid = pItem->iItem; - GitRev * pLogEntry = NULL; - if (itemid < m_arShownList.GetCount()) - pLogEntry = reinterpret_cast(m_arShownList.GetAt(pItem->iItem)); - - // Which column? - switch (pItem->iSubItem) - { - case this->LOGLIST_GRAPH: //Graphic - if (pLogEntry) - { - } - break; - case this->LOGLIST_ACTION: //action -- no text in the column - break; - case this->LOGLIST_MESSAGE: //Message - if (pLogEntry) - lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax); - break; - case this->LOGLIST_AUTHOR: //Author - if (pLogEntry) - lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax); - break; - case this->LOGLIST_DATE: //Date - if (pLogEntry) - lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax); - break; - - case 5: - - break; - default: - ASSERT(false); - } -} -#endif -void CLogDlg::OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult) -{ - -#if 0 - NMLVDISPINFO *pDispInfo = reinterpret_cast(pNMHDR); - - //Create a pointer to the item - LV_ITEM* pItem= &(pDispInfo)->item; - - *pResult = 0; - if ((m_bNoDispUpdates)||(m_bThreadRunning)) - { - if (pItem->mask & LVIF_TEXT) - lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax); - return; - } - if ((m_currentChangedArray!=NULL)&&(pItem->iItem >= m_currentChangedArray->GetCount())) - { - if (pItem->mask & LVIF_TEXT) - lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax); - return; - } - if ((m_currentChangedArray==NULL)&&(pItem->iItem >= m_currentChangedPathList.GetCount())) - { - if (pItem->mask & LVIF_TEXT) - lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax); - return; - } - CTGitPath lcpath = NULL; - if (m_currentChangedArray) - lcpath = (*m_currentChangedArray)[pItem->iItem]; - //Does the list need text information? - if (pItem->mask & LVIF_TEXT) - { - //Which column? - switch (pItem->iSubItem) - { - case this->FILELIST_ACTION: //Action -#if 0 - if (lcpath) - lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->GetAction(), pItem->cchTextMax); - else - lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax); -#endif - lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetActionName(), pItem->cchTextMax); - - break; - - case this->FILELIST_ADD: //add -#if 0 - if (lcpath) - lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sPath, pItem->cchTextMax); - else - lstrcpyn(pItem->pszText, (LPCTSTR)m_currentChangedPathList[pItem->iItem].GetGitPathString(), pItem->cchTextMax); -#endif - lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatAdd, pItem->cchTextMax); - break; - - case this->FILELIST_DEL: //del -#if 0 - if (lcpath) - lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sCopyFromPath, pItem->cchTextMax); - else - lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax); -#endif - lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatDel, pItem->cchTextMax); - break; - case this->FILELIST_PATH: //path -#if 0 - if ((lcpath==NULL)||(lcpath->sCopyFromPath.IsEmpty())) - lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax); - else - _stprintf_s(pItem->pszText, pItem->cchTextMax, _T("%ld"), lcpath->lCopyFromRev); -#endif - lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetGitPathString(), pItem->cchTextMax); - break; - } - } -#endif - *pResult = 0; -} - -void CLogDlg::OnEnChangeSearchedit() -{ -#if 0 - UpdateData(); - if (m_sFilterText.IsEmpty()) - { - CStoreSelection storeselection(this); - // clear the filter, i.e. make all entries appear - theApp.DoWaitCursor(1); - KillTimer(LOGFILTER_TIMER); - FillLogMessageCtrl(false); - InterlockedExchange(&m_bNoDispUpdates, TRUE); - m_arShownList.RemoveAll(); - for (DWORD i=0; iShowWindow(SW_HIDE); - GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW); - GetDlgItem(IDC_SEARCHEDIT)->SetFocus(); - DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty())))); - return; - } - if (Validate(m_sFilterText)) - SetTimer(LOGFILTER_TIMER, 1000, NULL); - else - KillTimer(LOGFILTER_TIMER); -#endif -} - -bool CLogDlg::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */) -{ - try - { - tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript; - if (!bMatchCase) - type |= tr1::regex_constants::icase; - pat = tr1::wregex(regexp_str, type); - return true; - } - catch (exception) {} - return false; -} bool CLogDlg::Validate(LPCTSTR string) { if (!m_bFilterWithRegex) return true; tr1::wregex pat; - return ValidateRegexp(string, pat, false); + return m_LogList.ValidateRegexp(string, pat, false); } @@ -2598,7 +2379,7 @@ void CLogDlg::OnTimer(UINT_PTR nIDEvent) CWnd * focusWnd = GetFocus(); bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO)) && (focusWnd != GetDlgItem(IDC_LOGLIST))); - if (m_sFilterText.IsEmpty()) + if (m_LogList.m_sFilterText.IsEmpty()) { DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty())))); // do not return here! @@ -2612,23 +2393,13 @@ void CLogDlg::OnTimer(UINT_PTR nIDEvent) FillLogMessageCtrl(false); // now start filter the log list -// InterlockedExchange(&m_bNoDispUpdates, TRUE); -// RecalculateShownList(&m_LogList.m_arShownList); -// InterlockedExchange(&m_bNoDispUpdates, FALSE); + m_LogList.StartFilter(); - -// m_LogList.DeleteAllItems(); -// m_LogList.SetItemCountEx(m_LogList.ShownCountWithStopped()); -// m_LogList.RedrawItems(0, m_LogList.ShownCountWithStopped()); -// m_LogList.SetRedraw(false); -// m_LogList.ResizeAllListCtrlCols(); -// m_LogList.SetRedraw(true); -// m_LogList.Invalidate(); -// if ( m_LogList.GetItemCount()==1 ) -// { -// m_LogList.SetSelectionMark(0); -// m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED); -// } + if ( m_LogList.GetItemCount()==1 ) + { + m_LogList.SetSelectionMark(0); + m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED); + } theApp.DoWaitCursor(-1); GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE); GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW); @@ -3673,3 +3444,43 @@ CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url) } +void CLogDlg::OnEnChangeSearchedit() +{ + UpdateData(); + if (m_LogList.m_sFilterText.IsEmpty()) + { + CStoreSelection storeselection(this); + // clear the filter, i.e. make all entries appear + theApp.DoWaitCursor(1); + KillTimer(LOGFILTER_TIMER); + FillLogMessageCtrl(false); + m_LogList.StartFilter(); +#if 0 + InterlockedExchange(&m_bNoDispUpdates, TRUE); + m_arShownList.RemoveAll(); + for (DWORD i=0; iShowWindow(SW_HIDE); + GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW); + GetDlgItem(IDC_SEARCHEDIT)->SetFocus(); + DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty())))); + return; + } + if (Validate(m_LogList.m_sFilterText)) + SetTimer(LOGFILTER_TIMER, 1000, NULL); + else + KillTimer(LOGFILTER_TIMER); + +} \ No newline at end of file diff --git a/src/TortoiseProc/LogDlg.h b/src/TortoiseProc/LogDlg.h index b6ce6b9..818f253 100644 --- a/src/TortoiseProc/LogDlg.h +++ b/src/TortoiseProc/LogDlg.h @@ -252,7 +252,7 @@ private: CRect m_MsgViewOrigRect; CRect m_LogListOrigRect; CRect m_ChgOrigRect; - CString m_sFilterText; +// CString m_sFilterText; //volatile LONG m_bNoDispUpdates; CDateTimeCtrl m_DateFrom; -- 2.11.0