Make more use of theApp.m_pMainWnd
[TortoiseGit.git] / src / TortoiseProc / Commands / AddCommand.cpp
blob94dc4efb711217c2e76507c68ee3673371669490
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2016, 2018 - TortoiseGit
4 // Copyright (C) 2007-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "AddCommand.h"
23 #include "AddDlg.h"
24 #include "GitProgressDlg.h"
25 #include "ProgressCommands/AddProgressCommand.h"
26 #include "ShellUpdater.h"
28 bool AddCommand::Execute()
30 bool bRet = false;
31 if (parser.HasKey(L"noui"))
33 #if 0
34 SVN svn;
35 ProjectProperties props;
36 props.ReadPropsPathList(pathList);
37 bRet = !!svn.Add(pathList, &props, svn_depth_empty, FALSE, FALSE, TRUE);
38 CShellUpdater::Instance().AddPathsForUpdate(pathList);
39 #endif
41 else
43 if (pathList.AreAllPathsFiles())
45 CGitProgressDlg progDlg;
46 theApp.m_pMainWnd = &progDlg;
47 AddProgressCommand addCommand;
48 progDlg.SetCommand(&addCommand);
49 addCommand.SetPathList(pathList);
50 progDlg.SetItemCount(pathList.GetCount());
51 progDlg.DoModal();
53 bRet = !progDlg.DidErrorsOccur();
55 else
57 CAddDlg dlg;
58 theApp.m_pMainWnd = &dlg;
59 dlg.m_pathList = pathList;
60 if (dlg.DoModal() == IDOK)
62 if (dlg.m_pathList.IsEmpty())
63 return FALSE;
64 CGitProgressDlg progDlg;
65 theApp.m_pMainWnd = &progDlg;
66 AddProgressCommand addCommand;
67 progDlg.SetCommand(&addCommand);
68 addCommand.SetPathList(dlg.m_pathList);
69 progDlg.SetItemCount(dlg.m_pathList.GetCount());
70 progDlg.DoModal();
72 bRet = !progDlg.DidErrorsOccur();
77 CShellUpdater::Instance().Flush();
78 return bRet;