OSDN Git Service

Merge from feature_merge branch. Build TortoiseMerge successfully.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / refloglist.cpp
1 #include "stdafx.h"\r
2 #include "resource.h"\r
3 #include "RefLogDlg.h"\r
4 #include "git.h"\r
5 #include "RefLogList.h"\r
6 \r
7 IMPLEMENT_DYNAMIC(CRefLogList, CGitLogList)\r
8 \r
9 CRefLogList::CRefLogList()\r
10 {\r
11         m_ColumnRegKey=_T("reflog");\r
12 \r
13 }\r
14 \r
15 void CRefLogList::InsertRefLogColumn()\r
16 {\r
17         CString temp;\r
18 \r
19         int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
20         \r
21         while (c>=0)\r
22                 DeleteColumn(c--);\r
23         \r
24         temp=_T("Hash");\r
25         InsertColumn(REFLOG_HASH, temp);\r
26         \r
27         temp=_T("Ref");\r
28         InsertColumn(REFLOG_REF, temp);\r
29         \r
30         temp=_T("Action");\r
31         InsertColumn(REFLOG_ACTION, temp);\r
32         \r
33         temp=_T("Message");\r
34         InsertColumn(REFLOG_MESSAGE, temp);\r
35 \r
36 \r
37         SetRedraw(false);\r
38         ResizeAllListCtrlCols();\r
39         SetRedraw(true);\r
40 }\r
41 \r
42 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
43 {\r
44         NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
45 \r
46         // Create a pointer to the item\r
47         LV_ITEM* pItem = &(pDispInfo)->item;\r
48 \r
49         // Do the list need text information?\r
50         if (!(pItem->mask & LVIF_TEXT))\r
51                 return;\r
52 \r
53         // By default, clear text buffer.\r
54         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
55 \r
56         bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();\r
57         \r
58         *pResult = 0;\r
59         if (m_bNoDispUpdates || bOutOfRange)\r
60                 return;\r
61 \r
62         // Which item number?\r
63         int itemid = pItem->iItem;\r
64         GitRev * pLogEntry = NULL;\r
65         if (itemid < m_arShownList.GetCount())\r
66                 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));\r
67 \r
68         CString temp;\r
69             \r
70         // Which column?\r
71         switch (pItem->iSubItem)\r
72         {\r
73         case this->REFLOG_HASH: //Graphic\r
74                 if (pLogEntry)\r
75                 {\r
76                         lstrcpyn(pItem->pszText,pLogEntry->m_CommitHash, pItem->cchTextMax);\r
77                 }\r
78                 break;\r
79         case REFLOG_REF: //action -- no text in the column\r
80                 if(pLogEntry)\r
81                         lstrcpyn(pItem->pszText, pLogEntry->m_Ref, pItem->cchTextMax);\r
82                 break;\r
83         case REFLOG_ACTION: //Message\r
84                 if (pLogEntry)\r
85                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_RefAction, pItem->cchTextMax);\r
86                 break;\r
87         case REFLOG_MESSAGE: //Author\r
88                 if (pLogEntry)\r
89                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);\r
90                 break;\r
91                 \r
92         default:\r
93                 ASSERT(false);\r
94         }\r
95 }\r
96 \r
97 void CRefLogList::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
98 {\r
99 \r
100         NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );\r
101         // Take the default processing unless we set this to something else below.\r
102         *pResult = CDRF_DODEFAULT;\r
103 }