Enable formatpatch at log dialog
[TortoiseGit.git] / src / TortoiseProc / refloglist.cpp
blob60236e02111a172271d6008a37168ce97cbabc8a
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 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
21 while (c>=0)
22 DeleteColumn(c--);
24 temp=_T("Hash");
25 InsertColumn(REFLOG_HASH, temp);
27 temp=_T("Ref");
28 InsertColumn(REFLOG_REF, temp);
30 temp=_T("Action");
31 InsertColumn(REFLOG_ACTION, temp);
33 temp=_T("Message");
34 InsertColumn(REFLOG_MESSAGE, temp);
37 SetRedraw(false);
38 ResizeAllListCtrlCols();
39 SetRedraw(true);
42 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
44 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
46 // Create a pointer to the item
47 LV_ITEM* pItem = &(pDispInfo)->item;
49 // Do the list need text information?
50 if (!(pItem->mask & LVIF_TEXT))
51 return;
53 // By default, clear text buffer.
54 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
56 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
58 *pResult = 0;
59 if (m_bNoDispUpdates || bOutOfRange)
60 return;
62 // Which item number?
63 int itemid = pItem->iItem;
64 GitRev * pLogEntry = NULL;
65 if (itemid < m_arShownList.GetCount())
66 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
68 CString temp;
70 // Which column?
71 switch (pItem->iSubItem)
73 case this->REFLOG_HASH: //Graphic
74 if (pLogEntry)
76 lstrcpyn(pItem->pszText,pLogEntry->m_CommitHash, pItem->cchTextMax);
78 break;
79 case REFLOG_REF: //action -- no text in the column
80 if(pLogEntry)
81 lstrcpyn(pItem->pszText, pLogEntry->m_Ref, pItem->cchTextMax);
82 break;
83 case REFLOG_ACTION: //Message
84 if (pLogEntry)
85 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_RefAction, pItem->cchTextMax);
86 break;
87 case REFLOG_MESSAGE: //Author
88 if (pLogEntry)
89 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
90 break;
92 default:
93 ASSERT(false);
97 void CRefLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
100 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
101 // Take the default processing unless we set this to something else below.
102 *pResult = CDRF_DODEFAULT;