Improve line margin icon for moved lines
[TortoiseGit.git] / src / TortoiseProc / refloglist.cpp
blob7ede1a35c3029efbf77d722262f5341251dc6aa6
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2011, 2013, 2015-2017 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 #include "stdafx.h"
20 #include "resource.h"
21 #include "refloglist.h"
22 #include "LoglistUtils.h"
24 IMPLEMENT_DYNAMIC(CRefLogList, CGitLogList)
26 CRefLogList::CRefLogList()
28 m_ColumnRegKey = L"reflog";
29 this->m_ContextMenuMask |= this->GetContextMenuBit(ID_LOG);
30 this->m_ContextMenuMask &= ~GetContextMenuBit(ID_COMPARETWOCOMMITCHANGES);
33 void CRefLogList::InsertRefLogColumn()
35 CString temp;
37 CRegDWORD regFullRowSelect(L"Software\\TortoiseGit\\FullRowSelect", TRUE);
38 DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES;
39 if (DWORD(regFullRowSelect))
40 exStyle |= LVS_EX_FULLROWSELECT;
41 SetExtendedStyle(exStyle);
43 static UINT normal[] =
45 IDS_HASH,
46 IDS_REF,
47 IDS_ACTION,
48 IDS_MESSAGE,
49 IDS_STATUSLIST_COLDATE,
52 static int with[] =
54 ICONITEMBORDER+16*4,
55 ICONITEMBORDER+16*4,
56 ICONITEMBORDER+16*4,
57 LOGLIST_MESSAGE_MIN,
58 ICONITEMBORDER+16*4,
60 m_dwDefaultColumns = 0xFFFF;
62 SetRedraw(false);
64 m_ColumnManager.SetNames(normal, _countof(normal));
65 m_ColumnManager.ReadSettings(m_dwDefaultColumns, 0, m_ColumnRegKey + L"loglist", _countof(normal), with);
67 SetRedraw(true);
70 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
72 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
74 // Create a pointer to the item
75 LV_ITEM* pItem = &(pDispInfo)->item;
77 // Do the list need text information?
78 if (!(pItem->mask & LVIF_TEXT))
79 return;
81 // By default, clear text buffer.
82 lstrcpyn(pItem->pszText, L"", pItem->cchTextMax);
84 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
86 *pResult = 0;
87 if (m_bNoDispUpdates || bOutOfRange)
88 return;
90 // Which item number?
91 GitRevLoglist* pLogEntry = m_arShownList.SafeGetAt(pItem->iItem);
93 CString temp;
95 // Which column?
96 switch (pItem->iSubItem)
98 case REFLOG_HASH:
99 if (pLogEntry)
101 lstrcpyn(pItem->pszText,pLogEntry->m_CommitHash.ToString(), pItem->cchTextMax - 1);
103 break;
104 case REFLOG_REF:
105 if(pLogEntry)
106 lstrcpyn(pItem->pszText, pLogEntry->m_Ref, pItem->cchTextMax - 1);
107 break;
108 case REFLOG_ACTION:
109 if (pLogEntry)
110 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_RefAction, pItem->cchTextMax - 1);
111 break;
112 case REFLOG_MESSAGE:
113 if (pLogEntry)
114 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetSubject().Trim(), pItem->cchTextMax - 1);
115 break;
116 case REFLOG_DATE:
117 if (pLogEntry)
118 lstrcpyn(pItem->pszText, (LPCTSTR)CLoglistUtils::FormatDateAndTime(pLogEntry->GetCommitterDate(), m_DateFormat, true, m_bRelativeTimes), pItem->cchTextMax - 1);
119 break;
121 default:
122 ASSERT(false);
126 void CRefLogList::OnNMCustomdrawLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
128 // Take the default processing unless we set this to something else below.
129 *pResult = CDRF_DODEFAULT;
132 BOOL CRefLogList::OnToolTipText(UINT /*id*/, NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
134 return FALSE;