Don't import ogdf namespace
[TortoiseGit.git] / src / TortoiseProc / refloglist.cpp
blobd764b824c00eb157f64f2f6db10161b8acb723da
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2011, 2013, 2015-2018 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 Init();
38 SetStyle();
40 static UINT normal[] =
42 IDS_HASH,
43 IDS_REF,
44 IDS_ACTION,
45 IDS_MESSAGE,
46 IDS_STATUSLIST_COLDATE,
49 static int with[] =
51 ICONITEMBORDER+16*4,
52 ICONITEMBORDER+16*4,
53 ICONITEMBORDER+16*4,
54 LOGLIST_MESSAGE_MIN,
55 ICONITEMBORDER+16*4,
57 m_dwDefaultColumns = 0xFFFF;
59 SetRedraw(false);
61 m_ColumnManager.SetNames(normal, _countof(normal));
62 m_ColumnManager.ReadSettings(m_dwDefaultColumns, 0, m_ColumnRegKey + L"loglist", _countof(normal), with);
64 SetRedraw(true);
67 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
69 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
71 // Create a pointer to the item
72 LV_ITEM* pItem = &(pDispInfo)->item;
74 // Do the list need text information?
75 if (!(pItem->mask & LVIF_TEXT))
76 return;
78 // By default, clear text buffer.
79 lstrcpyn(pItem->pszText, L"", pItem->cchTextMax);
81 bool bOutOfRange = pItem->iItem >= (int)m_arShownList.size();
83 *pResult = 0;
84 if (m_bNoDispUpdates || bOutOfRange)
85 return;
87 // Which item number?
88 GitRevLoglist* pLogEntry = m_arShownList.SafeGetAt(pItem->iItem);
90 CString temp;
92 // Which column?
93 switch (pItem->iSubItem)
95 case REFLOG_HASH:
96 if (pLogEntry)
98 lstrcpyn(pItem->pszText,pLogEntry->m_CommitHash.ToString(), pItem->cchTextMax - 1);
100 break;
101 case REFLOG_REF:
102 if(pLogEntry)
103 lstrcpyn(pItem->pszText, pLogEntry->m_Ref, pItem->cchTextMax - 1);
104 break;
105 case REFLOG_ACTION:
106 if (pLogEntry)
107 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_RefAction, pItem->cchTextMax - 1);
108 break;
109 case REFLOG_MESSAGE:
110 if (pLogEntry)
111 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetSubject().Trim(), pItem->cchTextMax - 1);
112 break;
113 case REFLOG_DATE:
114 if (pLogEntry)
115 lstrcpyn(pItem->pszText, (LPCTSTR)CLoglistUtils::FormatDateAndTime(pLogEntry->GetCommitterDate(), m_DateFormat, true, m_bRelativeTimes), pItem->cchTextMax - 1);
116 break;
118 default:
119 ASSERT(false);
123 void CRefLogList::OnNMCustomdrawLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
125 // Take the default processing unless we set this to something else below.
126 *pResult = CDRF_DODEFAULT;
129 BOOL CRefLogList::OnToolTipText(UINT /*id*/, NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
131 return FALSE;