OSDN Git Service

Diff Dialog Okay
authorFrank Li <lznuaa@gmail.com>
Sun, 24 Jan 2010 10:08:44 +0000 (18:08 +0800)
committerFrank Li <lznuaa@gmail.com>
Sun, 24 Jan 2010 10:08:44 +0000 (18:08 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/FileDiffDlg.cpp
src/TortoiseProc/FileDiffDlg.h

index 4613889..25cba21 100644 (file)
@@ -89,8 +89,7 @@ BEGIN_MESSAGE_MAP(CFileDiffDlg, CResizableStandAloneDialog)
        ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)\r
        ON_EN_CHANGE(IDC_FILTER, &CFileDiffDlg::OnEnChangeFilter)\r
        ON_WM_TIMER()\r
-       ON_EN_CHANGE(IDC_REV1EDIT, &CFileDiffDlg::OnEnChangeRev1edit)\r
-       ON_EN_CHANGE(IDC_REV2EDIT, &CFileDiffDlg::OnEnChangeRev2edit)\r
+       ON_MESSAGE(ENAC_UPDATE, &CFileDiffDlg::OnEnUpdate)\r
        ON_MESSAGE(MSG_REF_LOADED, OnRefLoad)\r
 END_MESSAGE_MAP()\r
 \r
@@ -273,6 +272,8 @@ BOOL CFileDiffDlg::OnInitDialog()
 \r
        if(m_rev2.m_CommitHash.IsEmpty())\r
                m_SwitchButton.EnableWindow(FALSE);\r
+\r
+       KillTimer(IDT_INPUT);\r
        return FALSE;\r
 }\r
 \r
@@ -963,22 +964,44 @@ void CFileDiffDlg::OnBnClickedSwitchleftright()
 \r
 }\r
 \r
-void CFileDiffDlg::SetURLLabels()\r
+void CFileDiffDlg::SetURLLabels(int mask)\r
 {\r
 \r
 //     m_cRev1Btn.SetWindowText(m_rev1.m_CommitHash.ToString().Left(6));\r
 //     m_cRev2Btn.SetWindowText(m_rev2.m_CommitHash.ToString().Left(6));\r
 \r
-       SetDlgItemText(IDC_FIRSTURL, m_rev1.m_CommitHash.ToString().Left(8)+_T(": ")+m_rev1.m_Subject);\r
-       SetDlgItemText(IDC_SECONDURL,m_rev2.m_CommitHash.ToString().Left(8)+_T(": ")+m_rev2.m_Subject);\r
+       if(mask &0x1)\r
+       {\r
+               SetDlgItemText(IDC_FIRSTURL, m_rev1.m_CommitHash.ToString().Left(8)+_T(": ")+m_rev1.m_Subject);\r
+               m_tooltips.AddTool(IDC_FIRSTURL,  \r
+                       CAppUtils::FormatDateAndTime( m_rev1.m_AuthorDate, DATE_SHORTDATE, false )+_T("  ")+m_rev1.m_AuthorName);\r
+       \r
+       }\r
 \r
-       m_tooltips.AddTool(IDC_FIRSTURL,  \r
-               CAppUtils::FormatDateAndTime( m_rev1.m_AuthorDate, DATE_SHORTDATE, false )+_T("  ")+m_rev1.m_AuthorName);\r
-       m_tooltips.AddTool(IDC_SECONDURL, \r
-               CAppUtils::FormatDateAndTime( m_rev2.m_AuthorDate, DATE_SHORTDATE, false )+_T("  ")+m_rev2.m_AuthorName);\r
+       if(mask &0x2)\r
+       {\r
+               SetDlgItemText(IDC_SECONDURL,m_rev2.m_CommitHash.ToString().Left(8)+_T(": ")+m_rev2.m_Subject);\r
+\r
+               m_tooltips.AddTool(IDC_SECONDURL, \r
+                       CAppUtils::FormatDateAndTime( m_rev2.m_AuthorDate, DATE_SHORTDATE, false )+_T("  ")+m_rev2.m_AuthorName);\r
+       }\r
 \r
 }\r
 \r
+void CFileDiffDlg::ClearURLabels(int mask)\r
+{\r
+       if(mask&0x1)\r
+       {\r
+               SetDlgItemText(IDC_FIRSTURL, _T(""));\r
+               m_tooltips.AddTool(IDC_FIRSTURL,  _T(""));\r
+       }\r
+\r
+       if(mask&0x2)\r
+       {\r
+               SetDlgItemText(IDC_SECONDURL, _T(""));\r
+               m_tooltips.AddTool(IDC_SECONDURL,  _T(""));\r
+       }\r
+}\r
 BOOL CFileDiffDlg::PreTranslateMessage(MSG* pMsg)\r
 {\r
        m_tooltips.RelayEvent(pMsg);\r
@@ -1109,6 +1132,7 @@ void CFileDiffDlg::OnBnClickedRev1btn()
 {\r
        \r
        ClickRevButton(&this->m_cRev1Btn,&this->m_rev1, &this->m_ctrRev1Edit);\r
+       \r
 \r
 }\r
 \r
@@ -1170,6 +1194,7 @@ void CFileDiffDlg::ClickRevButton(CMenuButton *button, GitRev *rev, CACEdit *edi
                InterlockedExchange(&m_bThreadRunning, FALSE);\r
                CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
        }\r
+       KillTimer(IDT_INPUT);\r
 }\r
 \r
 void CFileDiffDlg::OnBnClickedRev2btn()\r
@@ -1230,18 +1255,58 @@ void CFileDiffDlg::OnTimer(UINT_PTR nIDEvent)
        if (m_bThreadRunning)\r
                return;\r
 \r
-       CString sFilterText;\r
-       KillTimer(IDT_FILTER);\r
-       m_cFilter.GetWindowText(sFilterText);\r
+       if( nIDEvent == IDT_FILTER)\r
+       {\r
 \r
-       m_cFileList.SetRedraw(FALSE);\r
-       m_cFileList.DeleteAllItems();\r
+               CString sFilterText;\r
+               KillTimer(IDT_FILTER);\r
+               m_cFilter.GetWindowText(sFilterText);\r
 \r
-       Filter(sFilterText);\r
+               m_cFileList.SetRedraw(FALSE);\r
+               m_cFileList.DeleteAllItems();\r
 \r
-       m_cFileList.SetRedraw(TRUE);\r
+               Filter(sFilterText);\r
+\r
+               m_cFileList.SetRedraw(TRUE);\r
+\r
+               __super::OnTimer(nIDEvent);\r
+       }\r
 \r
-       __super::OnTimer(nIDEvent);\r
+       if( nIDEvent == IDT_INPUT)\r
+       {\r
+               KillTimer(IDT_INPUT);\r
+               TRACE(_T("Input Timer\r\n"));\r
+\r
+               GitRev gitrev;\r
+               CString str;\r
+               int mask = 0;\r
+               this->m_ctrRev1Edit.GetWindowText(str);\r
+               if( !gitrev.GetCommit(str) )\r
+               {\r
+                       this->m_rev1=gitrev;\r
+                       mask |= 0x1;\r
+                       this->SetURLLabels(0x1);\r
+               }\r
+\r
+               this->m_ctrRev2Edit.GetWindowText(str);\r
+\r
+               if( !gitrev.GetCommit(str) )\r
+               {\r
+                       this->m_rev2=gitrev;\r
+                       mask |= 0x2;\r
+                       this->SetURLLabels(0x2);\r
+               }\r
+               \r
+               if(mask == 0x3)\r
+               {\r
+                       InterlockedExchange(&m_bThreadRunning, TRUE);\r
+                       if (AfxBeginThread(DiffThreadEntry, this)==NULL)\r
+                       {\r
+                               InterlockedExchange(&m_bThreadRunning, FALSE);\r
+                               CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
+                       }\r
+               }\r
+       }\r
 }\r
 \r
 void CFileDiffDlg::Filter(CString sFilterText)\r
@@ -1318,3 +1383,29 @@ LRESULT CFileDiffDlg::OnRefLoad(WPARAM wParam, LPARAM lParam)
        }\r
        return 0;\r
 }\r
+\r
+BOOL CFileDiffDlg::DestroyWindow()\r
+{\r
+       return CResizableStandAloneDialog::DestroyWindow();\r
+}\r
+\r
+LRESULT CFileDiffDlg::OnEnUpdate(WPARAM wParam, LPARAM lParam)\r
+{\r
+       if(lParam == IDC_REV1EDIT)\r
+       {\r
+               OnTextUpdate(&this->m_ctrRev1Edit);\r
+               ClearURLabels(1);\r
+       }\r
+       if(lParam == IDC_REV2EDIT)\r
+       {\r
+               OnTextUpdate(&this->m_ctrRev2Edit);\r
+               ClearURLabels(1<<1);\r
+       }\r
+       return 0;\r
+}\r
+\r
+void CFileDiffDlg::OnTextUpdate(CACEdit *pEdit)\r
+{\r
+       SetTimer(IDT_INPUT, 1000, NULL);\r
+       this->m_cFileList.ShowText(_T("Wait For input validate version"));\r
+}
\ No newline at end of file
index 163a194..817996f 100644 (file)
@@ -32,6 +32,7 @@
 #include "MenuButton.h"\r
 #include "ACEdit.h"\r
 #define IDT_FILTER             101\r
+#define IDT_INPUT              102\r
 \r
 /**\r
  * \ingroup TortoiseProc\r
@@ -87,6 +88,7 @@ protected:
        afx_msg void OnBnClickedRev1btn();\r
        afx_msg void OnBnClickedRev2btn();\r
        afx_msg LRESULT OnClickedCancelFilter(WPARAM wParam, LPARAM lParam);\r
+       afx_msg LRESULT OnEnUpdate(WPARAM wParam, LPARAM lParam);\r
        afx_msg void OnEnChangeFilter();\r
        afx_msg void OnTimer(UINT_PTR nIDEvent);\r
 \r
@@ -100,7 +102,8 @@ protected:
        int                                     AddEntry(const CTGitPath * fd);\r
        void                            DoDiff(int selIndex, bool blame);\r
        void                            DiffProps(int selIndex);\r
-       void                            SetURLLabels();\r
+       void                            SetURLLabels(int mask=0x3);\r
+       void                            ClearURLabels(int mask);\r
        void                            Filter(CString sFilterText);\r
        void                            CopySelectionToClipboard();\r
        \r
@@ -191,4 +194,6 @@ public:
 public:\r
        afx_msg void OnEnChangeRev1edit();\r
        afx_msg void OnEnChangeRev2edit();\r
+       virtual BOOL DestroyWindow();\r
+       void OnTextUpdate(CACEdit *pEdit);\r
 };\r