Merge branch 'restructure-tree'
[TortoiseGit.git] / src / TortoiseProc / refloglist.cpp
blob969241eaf52527a7873958c944470ba6e8bb0ab0
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");
12 this->m_ContextMenuMask |= this->GetContextMenuBit(ID_LOG);
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;
42 SetRedraw(false);
44 m_ColumnManager.SetNames(normal, sizeof(normal)/sizeof(UINT));
45 m_ColumnManager.ReadSettings(m_dwDefaultColumns,0, m_ColumnRegKey+_T("loglist"), sizeof(normal)/sizeof(UINT), with);
47 SetRedraw(true);
51 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
53 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
55 // Create a pointer to the item
56 LV_ITEM* pItem = &(pDispInfo)->item;
58 // Do the list need text information?
59 if (!(pItem->mask & LVIF_TEXT))
60 return;
62 // By default, clear text buffer.
63 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
65 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
67 *pResult = 0;
68 if (m_bNoDispUpdates || bOutOfRange)
69 return;
71 // Which item number?
72 int itemid = pItem->iItem;
73 GitRev * pLogEntry = NULL;
74 if (itemid < m_arShownList.GetCount())
75 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
77 CString temp;
79 // Which column?
80 switch (pItem->iSubItem)
82 case this->REFLOG_HASH:
83 if (pLogEntry)
85 lstrcpyn(pItem->pszText,pLogEntry->m_CommitHash.ToString(), pItem->cchTextMax);
87 break;
88 case REFLOG_REF:
89 if(pLogEntry)
90 lstrcpyn(pItem->pszText, pLogEntry->m_Ref, pItem->cchTextMax);
91 break;
92 case REFLOG_ACTION:
93 if (pLogEntry)
94 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_RefAction, pItem->cchTextMax);
95 break;
96 case REFLOG_MESSAGE:
97 if (pLogEntry)
98 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetSubject().Trim(), pItem->cchTextMax);
99 break;
101 default:
102 ASSERT(false);
106 void CRefLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
108 UNREFERENCED_PARAMETER(pNMHDR);
109 // Take the default processing unless we set this to something else below.
110 *pResult = CDRF_DODEFAULT;