OSDN Git Service

Log Filter text work
authorFrank Li <lznuaa@gmail.com>
Tue, 30 Dec 2008 06:05:35 +0000 (14:05 +0800)
committerFrank Li <lznuaa@gmail.com>
Tue, 30 Dec 2008 06:05:35 +0000 (14:05 +0800)
ext/scintilla/vcbuild/SciLexer.vcproj
src/Git/Git.vcproj
src/TortoiseProc/GitLogList.cpp
src/TortoiseProc/GitLogList.h
src/TortoiseProc/LogDlg.cpp
src/TortoiseProc/LogDlg.h

index 776c250..49141ab 100644 (file)
                        </File>\r
                </Filter>\r
                <File\r
+                       RelativePath="..\..\..\src\Git\ReadMe.txt"\r
+                       >\r
+               </File>\r
+               <File\r
                        RelativePath="ReadMe.txt"\r
                        >\r
                </File>\r
index c2bdd05..e273009 100644 (file)
                        UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
                        >\r
                </Filter>\r
-               <File\r
-                       RelativePath=".\ReadMe.txt"\r
-                       >\r
-               </File>\r
        </Files>\r
        <Globals>\r
        </Globals>\r
index 5a4d822..22b5b9d 100644 (file)
@@ -2121,4 +2121,50 @@ BOOL CGitLogList::IsEntryInDateRange(int i)
 \r
 #endif;\r
        return TRUE;\r
+}\r
+void CGitLogList::StartFilter()\r
+{\r
+       InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
+       RecalculateShownList(&m_arShownList);\r
+       InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
+\r
+\r
+       DeleteAllItems();\r
+       SetItemCountEx(ShownCountWithStopped());\r
+       RedrawItems(0, ShownCountWithStopped());\r
+       SetRedraw(false);\r
+       ResizeAllListCtrlCols();\r
+       SetRedraw(true);\r
+       Invalidate();\r
+}\r
+void CGitLogList::RemoveFilter()\r
+{\r
+\r
+       InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
+\r
+       m_arShownList.RemoveAll();\r
+\r
+       // reset the time filter too\r
+#if 0\r
+       m_timFrom = (__time64_t(m_tFrom));\r
+       m_timTo = (__time64_t(m_tTo));\r
+       m_DateFrom.SetTime(&m_timFrom);\r
+       m_DateTo.SetTime(&m_timTo);\r
+       m_DateFrom.SetRange(&m_timFrom, &m_timTo);\r
+       m_DateTo.SetRange(&m_timFrom, &m_timTo);\r
+#endif\r
+\r
+       for (DWORD i=0; i<m_logEntries.size(); ++i)\r
+       {\r
+               m_arShownList.Add(&m_logEntries[i]);\r
+       }\r
+//     InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
+       DeleteAllItems();\r
+       SetItemCountEx(ShownCountWithStopped());\r
+       RedrawItems(0, ShownCountWithStopped());\r
+       SetRedraw(false);\r
+       ResizeAllListCtrlCols();\r
+       SetRedraw(true);\r
+\r
+       InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
 }
\ No newline at end of file
index 6b92589..901f38d 100644 (file)
@@ -138,6 +138,11 @@ public:
        void RecalculateShownList(CPtrArray * pShownlist);\r
 \r
        int                                     m_nSelectedFilter;\r
+       CLogDataVector          m_logEntries;\r
+       void RemoveFilter();\r
+       void StartFilter();\r
+       bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase = false );\r
+       CString                         m_sFilterText;\r
 \r
 protected:\r
        DECLARE_MESSAGE_MAP()\r
@@ -160,11 +165,13 @@ protected:
                                       const COLORREF& col,int top) ; \r
        void DrawLine(HDC hdc, int x1, int y1, int x2, int y2){::MoveToEx(hdc,x1,y1,NULL);::LineTo(hdc,x2,y2);}\r
 \r
-       bool ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase = false );\r
+\r
        BOOL IsEntryInDateRange(int i);\r
 \r
+\r
+\r
        bool                            m_bFilterWithRegex;\r
-       CString                         m_sFilterText;\r
+\r
        \r
        CXPTheme                        m_Theme;\r
        BOOL                            m_bVista;\r
@@ -178,7 +185,7 @@ protected:
 \r
        CRegDWORD                       m_regMaxBugIDColWidth;\r
        int                                     m_nSearchIndex;\r
-       CLogDataVector          m_logEntries;\r
+       \r
        CALLBACK_PROCESS    *m_ProcCallBack;\r
        void                            *m_ProcData;\r
        CStoreSelection*        m_pStoreSelection;\r
index 758d7b6..cc18f0a 100644 (file)
@@ -1,12 +1,9 @@
 // TortoiseGit - a Windows shell extension for easy version control\r
-\r
 // Copyright (C) 2003-2008 - TortoiseGit\r
-\r
 // This program is free software; you can redistribute it and/or\r
 // modify it under the terms of the GNU General Public License\r
 // as published by the Free Software Foundation; either version 2\r
 // of the License, or (at your option) any later version.\r
-\r
 // This program is distributed in the hope that it will be useful,\r
 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
@@ -53,8 +50,6 @@
 const UINT CLogDlg::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING);\r
 \r
 \r
-\r
-\r
 IMPLEMENT_DYNAMIC(CLogDlg, CResizableStandAloneDialog)\r
 CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)\r
        : CResizableStandAloneDialog(CLogDlg::IDD, pParent)\r
@@ -94,9 +89,6 @@ CLogDlg::~CLogDlg()
        \r
     m_CurrentFilteredChangedArray.RemoveAll();\r
        \r
-\r
-\r
-       \r
 }\r
 \r
 void CLogDlg::DoDataExchange(CDataExchange* pDX)\r
@@ -108,7 +100,7 @@ void CLogDlg::DoDataExchange(CDataExchange* pDX)
        DDX_Control(pDX, IDC_SPLITTERTOP, m_wndSplitter1);\r
        DDX_Control(pDX, IDC_SPLITTERBOTTOM, m_wndSplitter2);\r
        DDX_Check(pDX, IDC_CHECK_STOPONCOPY, m_bStrict);\r
-       DDX_Text(pDX, IDC_SEARCHEDIT, m_sFilterText);\r
+       DDX_Text(pDX, IDC_SEARCHEDIT, m_LogList.m_sFilterText);\r
        DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);\r
        DDX_Control(pDX, IDC_DATETO, m_DateTo);\r
        DDX_Control(pDX, IDC_HIDEPATHS, m_cHidePaths);\r
@@ -2318,42 +2310,23 @@ LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)
 \r
 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)\r
 {\r
-#if 0\r
+\r
        KillTimer(LOGFILTER_TIMER);\r
 \r
-       m_sFilterText.Empty();\r
+       m_LogList.m_sFilterText.Empty();\r
        UpdateData(FALSE);\r
        theApp.DoWaitCursor(1);\r
        CStoreSelection storeselection(this);\r
        FillLogMessageCtrl(false);\r
-       InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
-       m_arShownList.RemoveAll();\r
 \r
-       // reset the time filter too\r
-       m_timFrom = (__time64_t(m_tFrom));\r
-       m_timTo = (__time64_t(m_tTo));\r
-       m_DateFrom.SetTime(&m_timFrom);\r
-       m_DateTo.SetTime(&m_timTo);\r
-       m_DateFrom.SetRange(&m_timFrom, &m_timTo);\r
-       m_DateTo.SetRange(&m_timFrom, &m_timTo);\r
+       m_LogList.RemoveFilter();\r
 \r
-       for (DWORD i=0; i<m_logEntries.size(); ++i)\r
-       {\r
-               m_arShownList.Add(m_logEntries[i]);\r
-       }\r
-       InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
-       m_LogList.DeleteAllItems();\r
-       m_LogList.SetItemCountEx(ShownCountWithStopped());\r
-       m_LogList.RedrawItems(0, ShownCountWithStopped());\r
-       m_LogList.SetRedraw(false);\r
-       ResizeAllListCtrlCols();\r
-       m_LogList.SetRedraw(true);\r
        theApp.DoWaitCursor(-1);\r
        GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
        GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
        GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
        UpdateLogInfoLabel();\r
-#endif\r
+\r
        return 0L;      \r
 }\r
 \r
@@ -2383,205 +2356,13 @@ void CLogDlg::SetFilterCueText()
        temp = _T("   ")+temp;\r
        m_cFilter.SetCueBanner(temp);\r
 }\r
-#if 0\r
-void CLogDlg::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
-{\r
-       NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
-\r
-       // Create a pointer to the item\r
-       LV_ITEM* pItem = &(pDispInfo)->item;\r
-\r
-       // Do the list need text information?\r
-       if (!(pItem->mask & LVIF_TEXT))\r
-               return;\r
-\r
-       // By default, clear text buffer.\r
-       lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
-\r
-       bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();\r
-       \r
-       *pResult = 0;\r
-       if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)\r
-               return;\r
-\r
-       // Which item number?\r
-       int itemid = pItem->iItem;\r
-       GitRev * pLogEntry = NULL;\r
-       if (itemid < m_arShownList.GetCount())\r
-               pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));\r
-    \r
-       // Which column?\r
-       switch (pItem->iSubItem)\r
-       {\r
-       case this->LOGLIST_GRAPH:       //Graphic\r
-               if (pLogEntry)\r
-               {\r
-               }\r
-               break;\r
-       case this->LOGLIST_ACTION: //action -- no text in the column\r
-               break;\r
-       case this->LOGLIST_MESSAGE: //Message\r
-               if (pLogEntry)\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);\r
-               break;\r
-       case this->LOGLIST_AUTHOR: //Author\r
-               if (pLogEntry)\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);\r
-               break;\r
-       case this->LOGLIST_DATE: //Date\r
-               if (pLogEntry)\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);\r
-               break;\r
-               \r
-       case 5:\r
-\r
-               break;\r
-       default:\r
-               ASSERT(false);\r
-       }\r
-}\r
-#endif\r
-void CLogDlg::OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)\r
-{\r
-\r
-#if 0\r
-       NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
-\r
-       //Create a pointer to the item\r
-       LV_ITEM* pItem= &(pDispInfo)->item;\r
-\r
-       *pResult = 0;\r
-       if ((m_bNoDispUpdates)||(m_bThreadRunning))\r
-       {\r
-               if (pItem->mask & LVIF_TEXT)\r
-                       lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
-               return;\r
-       }\r
-       if ((m_currentChangedArray!=NULL)&&(pItem->iItem >= m_currentChangedArray->GetCount()))\r
-       {\r
-               if (pItem->mask & LVIF_TEXT)\r
-                       lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
-               return;\r
-       }\r
-       if ((m_currentChangedArray==NULL)&&(pItem->iItem >= m_currentChangedPathList.GetCount()))\r
-       {\r
-               if (pItem->mask & LVIF_TEXT)\r
-                       lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
-               return;\r
-       }\r
-       CTGitPath lcpath = NULL;\r
-       if (m_currentChangedArray)\r
-               lcpath = (*m_currentChangedArray)[pItem->iItem];\r
-       //Does the list need text information?\r
-       if (pItem->mask & LVIF_TEXT)\r
-       {\r
-               //Which column?\r
-               switch (pItem->iSubItem)\r
-               {\r
-               case this->FILELIST_ACTION:     //Action\r
-#if 0\r
-                       if (lcpath)\r
-                               lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->GetAction(), pItem->cchTextMax);\r
-                       else\r
-                               lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);                            \r
-#endif\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetActionName(), pItem->cchTextMax);\r
-\r
-                       break;\r
-\r
-               case this->FILELIST_ADD: //add\r
-#if 0\r
-                       if (lcpath)\r
-                               lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sPath, pItem->cchTextMax);\r
-                       else\r
-                               lstrcpyn(pItem->pszText, (LPCTSTR)m_currentChangedPathList[pItem->iItem].GetGitPathString(), pItem->cchTextMax);\r
-#endif\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatAdd, pItem->cchTextMax);\r
-                       break;\r
-\r
-               case this->FILELIST_DEL: //del\r
-#if 0\r
-                       if (lcpath)\r
-                               lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sCopyFromPath, pItem->cchTextMax);\r
-                       else\r
-                               lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
-#endif\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatDel, pItem->cchTextMax);\r
-                       break;\r
-               case this->FILELIST_PATH: //path\r
-#if 0\r
-                       if ((lcpath==NULL)||(lcpath->sCopyFromPath.IsEmpty()))\r
-                               lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
-                       else\r
-                               _stprintf_s(pItem->pszText, pItem->cchTextMax, _T("%ld"), lcpath->lCopyFromRev);\r
-#endif\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetGitPathString(), pItem->cchTextMax);\r
-                       break;\r
-               }\r
-       }\r
-#endif\r
-       *pResult = 0;\r
-}\r
-\r
-void CLogDlg::OnEnChangeSearchedit()\r
-{\r
-#if 0\r
-       UpdateData();\r
-       if (m_sFilterText.IsEmpty())\r
-       {\r
-               CStoreSelection storeselection(this);\r
-               // clear the filter, i.e. make all entries appear\r
-               theApp.DoWaitCursor(1);\r
-               KillTimer(LOGFILTER_TIMER);\r
-               FillLogMessageCtrl(false);\r
-               InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
-               m_arShownList.RemoveAll();\r
-               for (DWORD i=0; i<m_logEntries.size(); ++i)\r
-               {\r
-                       if (IsEntryInDateRange(i))\r
-                               m_arShownList.Add(m_logEntries[i]);\r
-               }\r
-               InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
-               m_LogList.DeleteAllItems();\r
-               m_LogList.SetItemCountEx(ShownCountWithStopped());\r
-               m_LogList.RedrawItems(0, ShownCountWithStopped());\r
-               m_LogList.SetRedraw(false);\r
-               ResizeAllListCtrlCols();\r
-               m_LogList.SetRedraw(true);\r
-               theApp.DoWaitCursor(-1);\r
-               GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
-               GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
-               GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
-               DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));\r
-               return;\r
-       }\r
-       if (Validate(m_sFilterText))\r
-               SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
-       else\r
-               KillTimer(LOGFILTER_TIMER);\r
-#endif\r
-}\r
-\r
-bool CLogDlg::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)\r
-{\r
-       try\r
-       {\r
-               tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;\r
-               if (!bMatchCase)\r
-                       type |= tr1::regex_constants::icase;\r
-               pat = tr1::wregex(regexp_str, type);\r
-               return true;\r
-       }\r
-       catch (exception) {}\r
-       return false;\r
-}\r
 \r
 bool CLogDlg::Validate(LPCTSTR string)\r
 {\r
        if (!m_bFilterWithRegex)\r
                return true;\r
        tr1::wregex pat;\r
-       return ValidateRegexp(string, pat, false);\r
+       return m_LogList.ValidateRegexp(string, pat, false);\r
 }\r
 \r
 \r
@@ -2598,7 +2379,7 @@ void CLogDlg::OnTimer(UINT_PTR nIDEvent)
                CWnd * focusWnd = GetFocus();\r
                bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))\r
                        && (focusWnd != GetDlgItem(IDC_LOGLIST)));\r
-               if (m_sFilterText.IsEmpty())\r
+               if (m_LogList.m_sFilterText.IsEmpty())\r
                {\r
                        DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));\r
                        // do not return here!\r
@@ -2612,23 +2393,13 @@ void CLogDlg::OnTimer(UINT_PTR nIDEvent)
                FillLogMessageCtrl(false);\r
 \r
                // now start filter the log list\r
-//             InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
-//             RecalculateShownList(&m_LogList.m_arShownList);\r
-//             InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
+               m_LogList.StartFilter();\r
 \r
-\r
-//             m_LogList.DeleteAllItems();\r
-//             m_LogList.SetItemCountEx(m_LogList.ShownCountWithStopped());\r
-//             m_LogList.RedrawItems(0, m_LogList.ShownCountWithStopped());\r
-//             m_LogList.SetRedraw(false);\r
-//             m_LogList.ResizeAllListCtrlCols();\r
-//             m_LogList.SetRedraw(true);\r
-//             m_LogList.Invalidate();\r
-//             if ( m_LogList.GetItemCount()==1 )\r
-//             {\r
-//                     m_LogList.SetSelectionMark(0);\r
-//                     m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);\r
-//             }\r
+               if ( m_LogList.GetItemCount()==1 )\r
+               {\r
+                       m_LogList.SetSelectionMark(0);\r
+                       m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);\r
+               }\r
                theApp.DoWaitCursor(-1);\r
                GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
                GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
@@ -3673,3 +3444,43 @@ CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
 }\r
 \r
 \r
+void CLogDlg::OnEnChangeSearchedit()\r
+{\r
+       UpdateData();\r
+       if (m_LogList.m_sFilterText.IsEmpty())\r
+       {\r
+               CStoreSelection storeselection(this);\r
+               // clear the filter, i.e. make all entries appear\r
+               theApp.DoWaitCursor(1);\r
+               KillTimer(LOGFILTER_TIMER);\r
+               FillLogMessageCtrl(false);\r
+               m_LogList.StartFilter();\r
+#if 0\r
+               InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
+               m_arShownList.RemoveAll();\r
+               for (DWORD i=0; i<m_logEntries.size(); ++i)\r
+               {\r
+                       if (IsEntryInDateRange(i))\r
+                               m_arShownList.Add(m_logEntries[i]);\r
+               }\r
+               InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
+               m_LogList.DeleteAllItems();\r
+               m_LogList.SetItemCountEx(ShownCountWithStopped());\r
+               m_LogList.RedrawItems(0, ShownCountWithStopped());\r
+               m_LogList.SetRedraw(false);\r
+               ResizeAllListCtrlCols();\r
+               m_LogList.SetRedraw(true);\r
+#endif\r
+               theApp.DoWaitCursor(-1);\r
+               GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
+               GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
+               GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
+               DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));\r
+               return;\r
+       }\r
+       if (Validate(m_LogList.m_sFilterText))\r
+               SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
+       else\r
+               KillTimer(LOGFILTER_TIMER);\r
+\r
+}
\ No newline at end of file
index b6ce6b9..818f253 100644 (file)
@@ -252,7 +252,7 @@ private:
        CRect                           m_MsgViewOrigRect;\r
        CRect                           m_LogListOrigRect;\r
        CRect                           m_ChgOrigRect;\r
-       CString                         m_sFilterText;\r
+//     CString                         m_sFilterText;\r
        \r
        //volatile LONG         m_bNoDispUpdates;\r
        CDateTimeCtrl           m_DateFrom;\r