OSDN Git Service

Only apply checked patch
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / ImportPatchDlg.cpp
index 0881ba0..c0f4544 100644 (file)
@@ -4,7 +4,7 @@
 #include "stdafx.h"\r
 #include "TortoiseProc.h"\r
 #include "ImportPatchDlg.h"\r
-\r
+#include "git.h"\r
 \r
 // CImportPatchDlg dialog\r
 \r
@@ -13,7 +13,7 @@ IMPLEMENT_DYNAMIC(CImportPatchDlg, CResizableStandAloneDialog)
 CImportPatchDlg::CImportPatchDlg(CWnd* pParent /*=NULL*/)\r
        : CResizableStandAloneDialog(CImportPatchDlg::IDD, pParent)\r
 {\r
-\r
+       m_cList.m_ContextMenuMask &=~ m_cList.GetMenuMask(CPatchListCtrl::MENU_APPLY);\r
 }\r
 \r
 CImportPatchDlg::~CImportPatchDlg()\r
@@ -40,7 +40,26 @@ BOOL CImportPatchDlg::OnInitDialog()
        AddAnchor(IDOK,BOTTOM_RIGHT);\r
        AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
 \r
+       this->AddOthersToAnchor();\r
+\r
+       m_PathList.SortByPathname(true);\r
+       m_cList.SetExtendedStyle( m_cList.GetExtendedStyle()| LVS_EX_CHECKBOXES );\r
+\r
+       for(int i=0;i<m_PathList.GetCount();i++)\r
+       {\r
+               m_cList.InsertItem(0,m_PathList[i].GetWinPath());\r
+               m_cList.SetCheck(0,true);\r
+       }\r
+\r
+       \r
+\r
+       //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID);\r
+\r
+       CString title;\r
+       this->GetWindowText(title);\r
+       this->SetWindowText(title+_T(" - ")+g_Git.m_CurrentDir);\r
        EnableSaveRestore(_T("ImportDlg"));\r
+\r
        return TRUE;\r
 }\r
 \r
@@ -87,7 +106,13 @@ void CImportPatchDlg::OnBnClickedButtonAdd()
                pos=dlg.GetStartPosition();\r
                while(pos)\r
                {\r
-                       m_cList.InsertItem(0,dlg.GetNextPathName(pos));\r
+                       CString file=dlg.GetNextPathName(pos);\r
+                       file.Trim();\r
+                       if(!file.IsEmpty())\r
+                       {\r
+                               m_cList.InsertItem(0,file);\r
+                               m_cList.SetCheck(0,true);\r
+                       }\r
                }\r
        }\r
 \r
@@ -145,11 +170,16 @@ void CImportPatchDlg::OnBnClickedButtonRemove()
 \r
 void CImportPatchDlg::OnBnClickedOk()\r
 {\r
+       m_PathList.Clear();\r
+\r
        for(int i=0;i<m_cList.GetItemCount();i++)\r
        {\r
-               CTGitPath path;\r
-               path.SetFromWin(m_cList.GetItemText(i,0));\r
-               m_PathList.AddPath(path);\r
+               if(m_cList.GetCheck(i))\r
+               {\r
+                       CTGitPath path;\r
+                       path.SetFromWin(m_cList.GetItemText(i,0));\r
+                       m_PathList.AddPath(path);\r
+               }\r
        }\r
        OnOK();\r
 }\r