From f095c5163e2eb688b83e94475e8a38622af66196 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Sat, 9 Mar 2013 16:53:15 +0800 Subject: [PATCH] Press F5 can refresh Submodule Diff Dialog Signed-off-by: Sup Yut Sum --- src/TortoiseProc/GitDiff.cpp | 15 ++++++++++++--- src/TortoiseProc/SubmoduleDiffDlg.cpp | 12 ++++++++++++ src/TortoiseProc/SubmoduleDiffDlg.h | 3 +++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/TortoiseProc/GitDiff.cpp b/src/TortoiseProc/GitDiff.cpp index 8d9aae309..9d4866871 100644 --- a/src/TortoiseProc/GitDiff.cpp +++ b/src/TortoiseProc/GitDiff.cpp @@ -80,6 +80,8 @@ int CGitDiff::SubmoduleDiffNull(CTGitPath *pPath, git_revnum_t &rev1) CSubmoduleDiffDlg submoduleDiffDlg; submoduleDiffDlg.SetDiff(pPath->GetWinPath(), false, oldhash, oldsub, true, newhash, newsub, toOK, dirty, CSubmoduleDiffDlg::NewSubmodule); submoduleDiffDlg.DoModal(); + if (submoduleDiffDlg.IsRefresh()) + return 1; return 0; } @@ -111,8 +113,10 @@ int CGitDiff::DiffNull(CTGitPath *pPath, git_revnum_t rev1,bool bIsAdd) if(pPath->IsDirectory()) { - git_revnum_t rev2; - return SubmoduleDiffNull(pPath,rev1); + int result; + // refresh if result = 1 + while ((result = SubmoduleDiffNull(pPath, rev1)) == 1) ; + return result; } if(rev1 != GIT_REV_ZERO ) @@ -337,6 +341,8 @@ int CGitDiff::SubmoduleDiff(CTGitPath * pPath,CTGitPath * /*pPath2*/, git_revnum CSubmoduleDiffDlg submoduleDiffDlg; submoduleDiffDlg.SetDiff(pPath->GetWinPath(), isWorkingCopy, oldhash, oldsub, oldOK, newhash, newsub, newOK, dirty, changeType); submoduleDiffDlg.DoModal(); + if (submoduleDiffDlg.IsRefresh()) + return 1; return 0; } @@ -374,7 +380,10 @@ int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t rev1, git_ if(pPath->IsDirectory() || pPath2->IsDirectory()) { - return SubmoduleDiff(pPath,pPath2,rev1,rev2); + int result; + // refresh if result = 1 + while ((result = SubmoduleDiff(pPath, pPath2, rev1, rev2)) == 1) ; + return result; } if(rev1 != GIT_REV_ZERO ) diff --git a/src/TortoiseProc/SubmoduleDiffDlg.cpp b/src/TortoiseProc/SubmoduleDiffDlg.cpp index 38eb50c1a..1139efc64 100644 --- a/src/TortoiseProc/SubmoduleDiffDlg.cpp +++ b/src/TortoiseProc/SubmoduleDiffDlg.cpp @@ -30,6 +30,7 @@ CSubmoduleDiffDlg::CSubmoduleDiffDlg(CWnd* pParent /*=NULL*/) , m_bToOK(false) , m_bDirty(false) , m_nChangeType(Unknown) + , m_bRefresh(false) { } @@ -187,6 +188,17 @@ HBRUSH CSubmoduleDiffDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) return CHorizontalResizableStandAloneDialog::OnCtlColor(pDC, pWnd, nCtlColor); } +BOOL CSubmoduleDiffDlg::PreTranslateMessage(MSG* pMsg) +{ + if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F5) + { + m_bRefresh = true; + EndDialog(0); + } + + return CResizableStandAloneDialog::PreTranslateMessage(pMsg); +} + void CSubmoduleDiffDlg::SetDiff(CString path, bool toIsWorkingCopy, CString fromHash, CString fromSubject, bool fromOK, CString toHash, CString toSubject, bool toOK, bool dirty, ChangeType changeType) { m_bToIsWorkingCopy = toIsWorkingCopy; diff --git a/src/TortoiseProc/SubmoduleDiffDlg.h b/src/TortoiseProc/SubmoduleDiffDlg.h index 26571d47c..88b46b61c 100644 --- a/src/TortoiseProc/SubmoduleDiffDlg.h +++ b/src/TortoiseProc/SubmoduleDiffDlg.h @@ -44,11 +44,13 @@ public: }; void SetDiff(CString path, bool toIsWorkingCopy, CString fromHash, CString fromSubject, bool fromOK, CString toHash, CString toSubject, bool toOK, bool dirty, ChangeType changeType); + bool IsRefresh() { return m_bRefresh; } protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); virtual HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); + virtual BOOL PreTranslateMessage(MSG* pMsg); afx_msg void OnBnClickedLog(); afx_msg void OnBnClickedLog2(); @@ -69,4 +71,5 @@ protected: bool m_bToOK; bool m_bDirty; ChangeType m_nChangeType; + bool m_bRefresh; }; -- 2.11.4.GIT