Fixed issue #546: Exporting without specifying a zip filename sends all zip output...
[TortoiseGit.git] / src / TortoiseProc / ImportPatchDlg.cpp
blobf23abbb75f72e11cb215bb917303f967bf426c7c
1 // ImportPatchDlg.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "TortoiseProc.h"
6 #include "ImportPatchDlg.h"
7 #include "git.h"
9 // CImportPatchDlg dialog
11 IMPLEMENT_DYNAMIC(CImportPatchDlg, CResizableStandAloneDialog)
13 CImportPatchDlg::CImportPatchDlg(CWnd* pParent /*=NULL*/)
14 : CResizableStandAloneDialog(CImportPatchDlg::IDD, pParent)
16 m_cList.m_ContextMenuMask &=~ m_cList.GetMenuMask(CPatchListCtrl::MENU_APPLY);
19 CImportPatchDlg::~CImportPatchDlg()
24 void CImportPatchDlg::DoDataExchange(CDataExchange* pDX)
26 CDialog::DoDataExchange(pDX);
27 DDX_Control(pDX, IDC_LIST_PATCH,m_cList);
30 BOOL CImportPatchDlg::OnInitDialog()
32 CResizableStandAloneDialog::OnInitDialog();
34 AddAnchor(IDC_LIST_PATCH, TOP_LEFT, BOTTOM_RIGHT);
35 AddAnchor(IDC_BUTTON_ADD, TOP_RIGHT);
36 AddAnchor(IDC_BUTTON_UP, TOP_RIGHT);
37 AddAnchor(IDC_BUTTON_DOWN, TOP_RIGHT);
38 AddAnchor(IDC_BUTTON_REMOVE, TOP_RIGHT);
40 AddAnchor(IDOK,BOTTOM_RIGHT);
41 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
42 AddAnchor(IDHELP, BOTTOM_RIGHT);
44 this->AddOthersToAnchor();
46 m_PathList.SortByPathname(true);
47 m_cList.SetExtendedStyle( m_cList.GetExtendedStyle()| LVS_EX_CHECKBOXES );
49 for(int i=0;i<m_PathList.GetCount();i++)
51 m_cList.InsertItem(0,m_PathList[i].GetWinPath());
52 m_cList.SetCheck(0,true);
57 //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID);
59 CString title;
60 this->GetWindowText(title);
61 this->SetWindowText(title+_T(" - ")+g_Git.m_CurrentDir);
62 EnableSaveRestore(_T("ImportDlg"));
64 return TRUE;
67 BEGIN_MESSAGE_MAP(CImportPatchDlg, CResizableStandAloneDialog)
68 ON_LBN_SELCHANGE(IDC_LIST_PATCH, &CImportPatchDlg::OnLbnSelchangeListPatch)
69 ON_BN_CLICKED(IDC_BUTTON_ADD, &CImportPatchDlg::OnBnClickedButtonAdd)
70 ON_BN_CLICKED(IDC_BUTTON_UP, &CImportPatchDlg::OnBnClickedButtonUp)
71 ON_BN_CLICKED(IDC_BUTTON_DOWN, &CImportPatchDlg::OnBnClickedButtonDown)
72 ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CImportPatchDlg::OnBnClickedButtonRemove)
73 ON_BN_CLICKED(IDOK, &CImportPatchDlg::OnBnClickedOk)
74 END_MESSAGE_MAP()
77 // CImportPatchDlg message handlers
79 void CImportPatchDlg::OnLbnSelchangeListPatch()
81 // TODO: Add your control notification handler code here
82 if(m_cList.GetSelectedCount() == 0)
84 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(FALSE);
85 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(FALSE);
86 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);
87 }else
89 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(TRUE);
90 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(TRUE);
91 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);
97 void CImportPatchDlg::OnBnClickedButtonAdd()
100 CFileDialog dlg(TRUE,NULL,
101 NULL,
102 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
103 _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));
104 if(dlg.DoModal()==IDOK)
106 POSITION pos;
107 pos=dlg.GetStartPosition();
108 while(pos)
110 CString file=dlg.GetNextPathName(pos);
111 file.Trim();
112 if(!file.IsEmpty())
114 m_cList.InsertItem(0,file);
115 m_cList.SetCheck(0,true);
120 // TODO: Add your control notification handler code here
123 void CImportPatchDlg::OnBnClickedButtonUp()
125 // TODO: Add your control notification handler code here
126 POSITION pos;
127 pos=m_cList.GetFirstSelectedItemPosition();
128 while(pos)
130 int index=m_cList.GetNextSelectedItem(pos);
131 if(index>1)
133 CString old=m_cList.GetItemText(index,0);
134 m_cList.DeleteItem(index);
136 m_cList.InsertItem(index-1,old);
142 void CImportPatchDlg::OnBnClickedButtonDown()
144 // TODO: Add your control notification handler code here
145 POSITION pos;
146 pos=m_cList.GetFirstSelectedItemPosition();
147 while(pos)
149 int index=m_cList.GetNextSelectedItem(pos);
151 CString old=m_cList.GetItemText(index,0);
152 m_cList.DeleteItem(index);
154 m_cList.InsertItem(index+1,old);
159 void CImportPatchDlg::OnBnClickedButtonRemove()
161 // TODO: Add your control notification handler code here
162 POSITION pos;
163 pos=m_cList.GetFirstSelectedItemPosition();
164 while(pos)
166 int index=m_cList.GetNextSelectedItem(pos);
167 m_cList.DeleteItem(index);
168 pos=m_cList.GetFirstSelectedItemPosition();
172 void CImportPatchDlg::OnBnClickedOk()
174 m_PathList.Clear();
176 for(int i=0;i<m_cList.GetItemCount();i++)
178 if(m_cList.GetCheck(i))
180 CTGitPath path;
181 path.SetFromWin(m_cList.GetItemText(i,0));
182 m_PathList.AddPath(path);
185 OnOK();