Fixed issue #4126: Capitalize the first letter in the Push dialog
[TortoiseGit.git] / src / TortoiseProc / WorktreeListDlg.h
bloba9a89601c39da3354725c87564a5f7a537d73db4
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2022-2024 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 #include "StandAloneDlg.h"
22 #include "GitHash.h"
23 #include "GitStatusListCtrl.h"
24 #include "GestureEnabledControl.h"
26 class WorktreeDetails
28 public:
29 WorktreeDetails(CString worktreeName, CString path, CGitHash hash, CString branch)
30 : m_WorktreeName(worktreeName)
31 , m_Path(path)
32 , m_Hash(hash)
33 , m_Branch(branch)
36 bool m_isBaseRepo = false;
37 CString m_WorktreeName;
38 CString m_Path;
39 CGitHash m_Hash;
40 CString m_Branch;
41 bool m_IsLocked = false;
42 CString m_LockedReason;
44 CString GetFullName() const
46 return m_WorktreeName;
50 class CWorktreeListDlg : public CResizableStandAloneDialog
52 DECLARE_DYNAMIC(CWorktreeListDlg)
54 public:
55 CWorktreeListDlg(CWnd* pParent = nullptr); // standard constructor
56 virtual ~CWorktreeListDlg();
58 // Dialog Data
59 enum
61 IDD = IDD_WORKTREE_LIST
64 enum eCmd
66 eCmd_Open = WM_APP,
67 eCmd_Remove,
68 eCmd_Lock,
69 eCmd_Unlock,
70 eCmd_RemoveWithForce,
73 enum eCol
75 eCol_Path,
76 eCol_Hash,
77 eCol_Branch,
78 eCol_Locked,
79 eCol_Reason,
82 private:
83 void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
85 DECLARE_MESSAGE_MAP()
87 afx_msg void OnOK() override;
88 afx_msg void OnDestroy();
89 BOOL OnInitDialog() override;
90 BOOL PreTranslateMessage(MSG* pMsg) override;
91 afx_msg void OnNMDblclkWorktreeList(NMHDR* pNMHDR, LRESULT* pResult);
92 afx_msg void OnBnClickedButtonAdd();
93 afx_msg void OnBnClickedButtonPrune();
95 CGestureEnabledControlTmpl<CListCtrl> m_WorktreeList;
96 ColumnManager m_ColumnManager;
98 std::vector<WorktreeDetails> m_Worktrees;
100 int m_nIconFolder = -1;
102 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
103 void OnContextMenu_WorktreeList(CPoint point);
104 void ShowContextMenu(CPoint point, std::vector<int>& indexes);
106 void Refresh();
107 int FillListCtrlWithWorktreeList(CString& error);
108 int GetWorktreeNames(STRING_VECTOR& list, CString& error);
110 bool RemoveWorktree(const CString& path, bool force);
111 bool PruneWorktrees();