OSDN Git Service

Clone Dialog, Add auto fill module name at directory when change URL
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / CloneDlg.cpp
index b504b67..77b712d 100644 (file)
@@ -83,6 +83,10 @@ BEGIN_MESSAGE_MAP(CCloneDlg, CResizableStandAloneDialog)
        ON_BN_CLICKED(IDC_CLONE_DIR_BROWSE, &CCloneDlg::OnBnClickedCloneDirBrowse)\r
     ON_BN_CLICKED(IDC_PUTTYKEYFILE_BROWSE, &CCloneDlg::OnBnClickedPuttykeyfileBrowse)\r
     ON_BN_CLICKED(IDC_PUTTYKEY_AUTOLOAD, &CCloneDlg::OnBnClickedPuttykeyAutoload)\r
+       ON_CBN_SELCHANGE(IDC_URLCOMBO, &CCloneDlg::OnCbnSelchangeUrlcombo)\r
+       ON_NOTIFY(CBEN_BEGINEDIT, IDC_URLCOMBO, &CCloneDlg::OnCbenBegineditUrlcombo)\r
+       ON_NOTIFY(CBEN_ENDEDIT, IDC_URLCOMBO, &CCloneDlg::OnCbenEndeditUrlcombo)\r
+       ON_CBN_EDITCHANGE(IDC_URLCOMBO, &CCloneDlg::OnCbnEditchangeUrlcombo)\r
 END_MESSAGE_MAP()\r
 \r
 \r
@@ -174,3 +178,86 @@ void CCloneDlg::OnBnClickedPuttykeyAutoload()
     this->GetDlgItem(IDC_PUTTYKEYFILE_BROWSE)->EnableWindow(m_bAutoloadPuttyKeyFile);\r
 \r
 }\r
+\r
+void CCloneDlg::OnCbnSelchangeUrlcombo()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+}\r
+\r
+void CCloneDlg::OnCbenBegineditUrlcombo(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       *pResult = 0;\r
+}\r
+\r
+void CCloneDlg::OnCbenEndeditUrlcombo(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       *pResult = 0;\r
+}\r
+\r
+void CCloneDlg::OnCbnEditchangeUrlcombo()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       this->UpdateData();\r
+       CString url;\r
+       m_URLCombo.GetWindowText(url);\r
+       //if(url.IsEmpty())\r
+       //      return;\r
+\r
+       CString old;\r
+       old=m_ModuleName;\r
+\r
+       url.Replace(_T('\\'),_T('/'));\r
+       int start=url.ReverseFind(_T('/'));\r
+       if(start<0)\r
+               start = 0;\r
+\r
+       CString temp;\r
+       temp=url.Mid(start+1);\r
+       \r
+       temp=temp.MakeLower();\r
+\r
+       int end;\r
+       end=temp.Find(_T(".git"));\r
+       if(end<0)\r
+               end=temp.GetLength();\r
+\r
+       //CString modulename;\r
+       m_ModuleName=url.Mid(start+1,end);\r
+       \r
+       start = m_Directory.ReverseFind(_T('\\'));\r
+       if(start <0 )\r
+               start = m_Directory.ReverseFind(_T('/'));\r
+       if(start <0 )\r
+               start =0;\r
+\r
+       int dirstart=m_Directory.Find(old,start);\r
+       if(dirstart>=0 && (dirstart+old.GetLength() == m_Directory.GetLength()) )\r
+       {\r
+               m_Directory=m_Directory.Left(dirstart);\r
+               m_Directory+=m_ModuleName;\r
+\r
+       }else\r
+       {\r
+               if(m_Directory.GetLength()>0 && \r
+                       (m_Directory[m_Directory.GetLength()-1] != _T('\\') ||\r
+                       m_Directory[m_Directory.GetLength()-1] != _T('/') ) )\r
+               {\r
+                       m_Directory+=_T('\\');\r
+               }\r
+               m_Directory += m_ModuleName;\r
+       }\r
+\r
+       if(m_Directory.GetLength()>0)\r
+       {\r
+               if( m_Directory[m_Directory.GetLength()-1] == _T('\\') ||\r
+                       m_Directory[m_Directory.GetLength()-1] == _T('/')\r
+                  )\r
+               {\r
+                       m_Directory=m_Directory.Left(m_Directory.GetLength()-1);\r
+               }\r
+\r
+       }\r
+       this->UpdateData(FALSE);\r
+}\r