Fixed issue #220: Enhancement, support creating bare repositories
[TortoiseGit.git] / src / TortoiseProc / refloglist.cpp
blob9dcde85d1760c58b7b49dc1d2e021a8fd8f851e3
1 #include "stdafx.h"
2 #include "resource.h"
3 #include "RefLogDlg.h"
4 #include "git.h"
5 #include "RefLogList.h"
7 IMPLEMENT_DYNAMIC(CRefLogList, CGitLogList)
9 CRefLogList::CRefLogList()
11 m_ColumnRegKey=_T("reflog");
15 void CRefLogList::InsertRefLogColumn()
17 CString temp;
19 CRegDWORD regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE);
20 DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES;
21 if (DWORD(regFullRowSelect))
22 exStyle |= LVS_EX_FULLROWSELECT;
23 SetExtendedStyle(exStyle);
25 static UINT normal[] =
27 IDS_HASH,
28 IDS_REF,
29 IDS_ACTION,
30 IDS_MESSAGE,
33 static int with[] =
35 ICONITEMBORDER+16*4,
36 ICONITEMBORDER+16*4,
37 ICONITEMBORDER+16*4,
38 LOGLIST_MESSAGE_MIN,
40 m_dwDefaultColumns = 0xFFFF;
43 SetRedraw(false);
45 m_ColumnManager.SetNames(normal, sizeof(normal)/sizeof(UINT));
46 m_ColumnManager.ReadSettings(m_dwDefaultColumns, m_ColumnRegKey+_T("loglist"), sizeof(normal)/sizeof(UINT), with);
48 SetRedraw(true);
52 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
54 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
56 // Create a pointer to the item
57 LV_ITEM* pItem = &(pDispInfo)->item;
59 // Do the list need text information?
60 if (!(pItem->mask & LVIF_TEXT))
61 return;
63 // By default, clear text buffer.
64 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
66 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
68 *pResult = 0;
69 if (m_bNoDispUpdates || bOutOfRange)
70 return;
72 // Which item number?
73 int itemid = pItem->iItem;
74 GitRev * pLogEntry = NULL;
75 if (itemid < m_arShownList.GetCount())
76 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
78 CString temp;
80 // Which column?
81 switch (pItem->iSubItem)
83 case this->REFLOG_HASH: //Graphic
84 if (pLogEntry)
86 lstrcpyn(pItem->pszText,pLogEntry->m_CommitHash.ToString(), pItem->cchTextMax);
88 break;
89 case REFLOG_REF: //action -- no text in the column
90 if(pLogEntry)
91 lstrcpyn(pItem->pszText, pLogEntry->m_Ref, pItem->cchTextMax);
92 break;
93 case REFLOG_ACTION: //Message
94 if (pLogEntry)
95 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_RefAction, pItem->cchTextMax);
96 break;
97 case REFLOG_MESSAGE: //Author
98 if (pLogEntry)
99 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
100 break;
102 default:
103 ASSERT(false);
107 void CRefLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
110 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
111 // Take the default processing unless we set this to something else below.
112 *pResult = CDRF_DODEFAULT;