OSDN Git Service

Log Dialog refresh okay
authorFrank Li <lznuaa@gmail.com>
Mon, 29 Dec 2008 09:31:45 +0000 (17:31 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 29 Dec 2008 09:31:45 +0000 (17:31 +0800)
src/TortoiseProc/GitLogList.cpp
src/TortoiseProc/GitLogList.h
src/TortoiseProc/LogDlg.cpp

index 08a41db..c23d479 100644 (file)
@@ -257,6 +257,12 @@ void CGitLogList::ResizeAllListCtrlCols()
        }
 
 }
+
+void Refresh()
+{
+       
+}
+
 BOOL CGitLogList::GetShortName(CString ref, CString &shortname,CString prefix)
 {
        if(ref.Left(prefix.GetLength()) ==  prefix)
@@ -813,7 +819,7 @@ void CGitLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
        bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
        
        *pResult = 0;
-       if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)
+       if (m_bNoDispUpdates || bOutOfRange)
                return;
 
        // Which item number?
@@ -1805,6 +1811,7 @@ UINT CGitLogList::LogThread()
                m_ProcCallBack(m_ProcData,GITLOG_START);
 
        InterlockedExchange(&m_bThreadRunning, TRUE);
+       InterlockedExchange(&m_bNoDispUpdates, TRUE);
 
     //does the user force the cache to refresh (shift or control key down)?
     bool refresh =    (GetKeyState (VK_CONTROL) < 0) 
@@ -1819,7 +1826,7 @@ UINT CGitLogList::LogThread()
 
        FillGitShortLog();
        
-       InterlockedExchange(&m_bThreadRunning, FALSE);
+       
 
        RedrawItems(0, m_arShownList.GetCount());
        SetRedraw(false);
@@ -1877,6 +1884,24 @@ UINT CGitLogList::LogThread()
        if(m_ProcCallBack)
                m_ProcCallBack(m_ProcData,GITLOG_END);
 
+       InterlockedExchange(&m_bThreadRunning, FALSE);
+
        return 0;
 }
 
+void CGitLogList::Refresh()
+{
+       if(!m_bThreadRunning)
+       {
+               this->SetItemCountEx(0);
+               m_logEntries.clear();
+               InterlockedExchange(&m_bThreadRunning, TRUE);
+               InterlockedExchange(&m_bNoDispUpdates, TRUE);
+               if (AfxBeginThread(LogThreadEntry, this)==NULL)
+               {
+                       InterlockedExchange(&m_bThreadRunning, FALSE);
+                       InterlockedExchange(&m_bNoDispUpdates, FALSE);
+                       CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
+               }
+       }
+}
index 97a2634..d5cd33d 100644 (file)
@@ -126,6 +126,7 @@ public:
        inline int ShownCountWithStopped() const { return (int)m_arShownList.GetCount() + (m_bStrictStopped ? 1 : 0); }\r
        int FetchLogAsync(CALLBACK_PROCESS *proc=NULL, void * data=NULL);\r
        CPtrArray                       m_arShownList;\r
+       void Refresh();\r
 \r
 protected:\r
        DECLARE_MESSAGE_MAP()\r
@@ -147,6 +148,8 @@ protected:
        void paintGraphLane(HDC hdc,int laneHeight, int type, int x1, int x2,\r
                                       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
+\r
        \r
        CXPTheme                        m_Theme;\r
        BOOL                            m_bVista;\r
index abbe2ed..dd69ad1 100644 (file)
@@ -534,7 +534,7 @@ void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
                GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));\r
 \r
                // set the log message text\r
-               pMsgView->SetWindowText(_T("*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);\r
+               pMsgView->SetWindowText(_T("Commit:")+pLogEntry->m_CommitHash+_T("\r\n\r\n*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);\r
                // turn bug ID's into links if the bugtraq: properties have been set\r
                // and we can find a match of those in the log message\r
                m_ProjectProperties.FindBugID(pLogEntry->m_Body, pMsgView);\r
@@ -699,6 +699,8 @@ void CLogDlg::OnBnClickedRefresh()
 \r
 void CLogDlg::Refresh (bool autoGoOnline)\r
 {\r
+       m_LogList.Refresh();\r
+\r
 #if 0\r
        // refreshing means re-downloading the already shown log messages\r
        UpdateData();\r
@@ -1853,7 +1855,8 @@ BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
 \r
 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)\r
 {\r
-       if (this->IsThreadRunning())\r
+       //if (this->IsThreadRunning())\r
+       if(m_LogList.m_bNoDispUpdates)\r
        {\r
                // only show the wait cursor over the list control\r
                if ((pWnd)&&\r
@@ -1883,7 +1886,8 @@ void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
 {\r
        LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
        *pResult = 0;\r
-       if (this->IsThreadRunning())\r
+       //if (this->IsThreadRunning())\r
+       if(m_LogList.m_bNoDispUpdates)\r
                return;\r
        if (pNMLV->iItem >= 0)\r
        {\r
@@ -2844,22 +2848,22 @@ void CLogDlg::OnTimer(UINT_PTR nIDEvent)
 \r
                // now start filter the log list\r
 //             InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
-               RecalculateShownList(&m_LogList.m_arShownList);\r
+//             RecalculateShownList(&m_LogList.m_arShownList);\r
 //             InterlockedExchange(&m_bNoDispUpdates, FALSE);\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
+//             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
                theApp.DoWaitCursor(-1);\r
                GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
                GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
@@ -3264,22 +3268,22 @@ void CLogDlg::OnBnClickedIncludemerge()
 \r
 void CLogDlg::UpdateLogInfoLabel()\r
 {\r
-#if 0\r
-       git_revnum_t rev1 = 0;\r
-       git_revnum_t rev2 = 0;\r
-       long selectedrevs = 0;\r
-       if (m_arShownList.GetCount())\r
-       {\r
-               PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(0));\r
-               rev1 = pLogEntry->Rev;\r
-               pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));\r
-               rev2 = pLogEntry->Rev;\r
+\r
+       git_revnum_t rev1 ;\r
+       git_revnum_t rev2 ;\r
+       long selectedrevs ;\r
+       int count =m_LogList.m_arShownList.GetCount();\r
+       if (count)\r
+       {\r
+               rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(0)))->m_CommitHash;\r
+               //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_arShownList.GetCount()-1));\r
+               rev2 =  (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.GetAt(count-1)))->m_CommitHash;\r
                selectedrevs = m_LogList.GetSelectedCount();\r
        }\r
        CString sTemp;\r
-       sTemp.Format(IDS_LOG_LOGINFOSTRING, m_arShownList.GetCount(), rev2, rev1, selectedrevs);\r
+       sTemp.Format(_T("Showing %ld revision(s), from revision %s to revision %s - %ld revision(s) selected"), count, rev2.Left(6), rev1.Left(6), selectedrevs);\r
        m_sLogInfo = sTemp;\r
-#endif\r
+\r
        UpdateData(FALSE);\r
 }\r
 \r