1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2011 - 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 // RefLogDlg.cpp : implementation file
24 #include "RefLogDlg.h"
30 IMPLEMENT_DYNAMIC(CRefLogDlg
, CResizableStandAloneDialog
)
32 CRefLogDlg::CRefLogDlg(CWnd
* pParent
/*=NULL*/)
33 : CResizableStandAloneDialog(CRefLogDlg::IDD
, pParent
)
38 CRefLogDlg::~CRefLogDlg()
42 void CRefLogDlg::DoDataExchange(CDataExchange
* pDX
)
44 CDialog::DoDataExchange(pDX
);
45 DDX_Control(pDX
, IDC_COMBOBOXEX_REF
, m_ChooseRef
);
46 DDX_Control(pDX
, IDC_REFLOG_LIST
, m_RefList
);
50 BEGIN_MESSAGE_MAP(CRefLogDlg
, CResizableStandAloneDialog
)
51 ON_BN_CLICKED(IDOK
, &CRefLogDlg::OnBnClickedOk
)
52 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_REF
, &CRefLogDlg::OnCbnSelchangeRef
)
53 ON_MESSAGE(MSG_REFLOG_CHANGED
,OnRefLogChanged
)
56 LRESULT
CRefLogDlg::OnRefLogChanged(WPARAM wParam
, LPARAM lParam
)
58 UNREFERENCED_PARAMETER(wParam
);
59 UNREFERENCED_PARAMETER(lParam
);
60 m_RefList
.m_RefMap
.clear();
65 BOOL
CRefLogDlg::OnInitDialog()
67 CResizableStandAloneDialog::OnInitDialog();
68 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
70 AddAnchor(IDOK
,BOTTOM_RIGHT
);
71 AddAnchor(IDCANCEL
,BOTTOM_RIGHT
);
73 AddAnchor(IDC_REFLOG_LIST
,TOP_LEFT
,BOTTOM_RIGHT
);
74 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
77 this->EnableSaveRestore(_T("RefLogDlg"));
80 GetWindowText(sWindowTitle
);
81 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, sWindowTitle
);
84 list
.push_back(_T("HEAD"));
85 g_Git
.GetRefList(list
);
87 m_ChooseRef
.SetMaxHistoryItems(0x7FFFFFFF);
88 this->m_ChooseRef
.AddString(list
);
90 this->m_RefList
.InsertRefLogColumn();
91 //m_RefList.m_logEntries.ParserFromRefLog(_T("master"));
92 if(this->m_CurrentBranch
.IsEmpty())
94 m_CurrentBranch
.Format(_T("refs/heads/%s"),g_Git
.GetCurrentBranch());
95 m_ChooseRef
.SetCurSel(0); /* Choose HEAD */
98 for(int i
=0;i
<list
.size();i
++)
100 if(list
[i
] == m_CurrentBranch
)
102 m_ChooseRef
.SetCurSel(i
);
113 // CRefLogDlg message handlers
115 void CRefLogDlg::OnBnClickedOk()
117 if (m_RefList
.GetSelectedCount() == 1)
119 // get the selected row
120 POSITION pos
= m_RefList
.GetFirstSelectedItemPosition();
121 int selIndex
= m_RefList
.GetNextSelectedItem(pos
);
122 if (selIndex
< m_RefList
.m_arShownList
.GetCount())
124 // all ok, pick up the revision
125 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_RefList
.m_arShownList
.GetAt(selIndex
));
127 m_SelectedHash
= pLogEntry
->m_CommitHash
;
134 void CRefLogDlg::OnCbnSelchangeRef()
136 CString ref
=m_ChooseRef
.GetString();
137 if(m_RefList
.m_RefMap
.find(ref
) == m_RefList
.m_RefMap
.end())
139 m_RefList
.m_RefMap
[ref
].m_pLogCache
= &m_RefList
.m_LogCache
;
140 m_RefList
.m_RefMap
[ref
].ParserFromRefLog(ref
);
142 m_RefList
.ClearText();
144 //this->m_logEntries.ParserFromLog();
145 m_RefList
.SetRedraw(false);
147 CLogDataVector
*plog
;
148 plog
= &m_RefList
.m_RefMap
[ref
];
150 m_RefList
.SetItemCountEx(plog
->size());
152 this->m_RefList
.m_arShownList
.RemoveAll();
154 for(unsigned int i
=0;i
<m_RefList
.m_RefMap
[ref
].size();i
++)
156 plog
->GetGitRevAt(i
).m_IsFull
=TRUE
;
157 this->m_RefList
.m_arShownList
.Add(&(plog
->GetGitRevAt(i
)));
161 m_RefList
.SetRedraw(true);
163 m_RefList
.Invalidate();