added new log filter (for subject)
[TortoiseGit.git] / src / TortoiseProc / RefLogDlg.cpp
blob9122a5b11e8fbb21f582151ec22c0c055ce1c813
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
22 #include "stdafx.h"
23 #include "resource.h"
24 #include "RefLogDlg.h"
25 #include "git.h"
26 #include "AppUtils.h"
28 // CRefLogDlg dialog
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)
54 END_MESSAGE_MAP()
56 LRESULT CRefLogDlg::OnRefLogChanged(WPARAM wParam, LPARAM lParam)
58 UNREFERENCED_PARAMETER(wParam);
59 UNREFERENCED_PARAMETER(lParam);
60 m_RefList.m_RefMap.clear();
61 OnCbnSelchangeRef();
62 return 0;
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);
76 AddOthersToAnchor();
77 this->EnableSaveRestore(_T("RefLogDlg"));
79 CString sWindowTitle;
80 GetWindowText(sWindowTitle);
81 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
83 STRING_VECTOR list;
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 */
97 else
99 for(int i=0;i<list.size();i++)
101 if(list[i] == m_CurrentBranch)
103 m_ChooseRef.SetCurSel(i);
104 break;
110 OnCbnSelchangeRef();
112 return TRUE;
114 // CRefLogDlg message handlers
116 void CRefLogDlg::OnBnClickedOk()
118 if (m_RefList.GetSelectedCount() == 1)
120 // get the selected row
121 POSITION pos = m_RefList.GetFirstSelectedItemPosition();
122 int selIndex = m_RefList.GetNextSelectedItem(pos);
123 if (selIndex < m_RefList.m_arShownList.GetCount())
125 // all ok, pick up the revision
126 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_RefList.m_arShownList.GetAt(selIndex));
127 // extract the hash
128 m_SelectedHash = pLogEntry->m_CommitHash;
132 OnOK();
135 void CRefLogDlg::OnCbnSelchangeRef()
137 CString ref=m_ChooseRef.GetString();
138 if(m_RefList.m_RefMap.find(ref) == m_RefList.m_RefMap.end())
140 m_RefList.m_RefMap[ref].m_pLogCache = &m_RefList.m_LogCache;
141 m_RefList.m_RefMap[ref].ParserFromRefLog(ref);
143 m_RefList.ClearText();
145 //this->m_logEntries.ParserFromLog();
146 m_RefList.SetRedraw(false);
148 CLogDataVector *plog;
149 plog = &m_RefList.m_RefMap[ref];
151 m_RefList.SetItemCountEx(plog->size());
153 this->m_RefList.m_arShownList.RemoveAll();
155 for(unsigned int i=0;i<m_RefList.m_RefMap[ref].size();i++)
157 plog->GetGitRevAt(i).m_IsFull=TRUE;
158 this->m_RefList.m_arShownList.Add(&(plog->GetGitRevAt(i)));
162 m_RefList.SetRedraw(true);
164 m_RefList.Invalidate();