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.
21 #include "refloglist.h"
22 #include "LoglistUtils.h"
25 IMPLEMENT_DYNAMIC(CRefLogList
, CGitLogList
)
27 CRefLogList::CRefLogList()
29 m_ColumnRegKey
= L
"reflog";
30 this->m_ContextMenuMask
|= this->GetContextMenuBit(ID_LOG
);
31 this->m_ContextMenuMask
&= ~GetContextMenuBit(ID_COMPARETWOCOMMITCHANGES
);
34 void CRefLogList::InsertRefLogColumn()
41 static UINT normal
[] =
47 IDS_STATUSLIST_COLDATE
,
58 m_dwDefaultColumns
= 0xFFFF;
62 m_ColumnManager
.SetNames(normal
, _countof(normal
));
63 m_ColumnManager
.ReadSettings(m_dwDefaultColumns
, 0, m_ColumnRegKey
+ L
"loglist", _countof(normal
), with
);
68 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
70 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
72 // Create a pointer to the item
73 LV_ITEM
* pItem
= &(pDispInfo
)->item
;
75 // Do the list need text information?
76 if (!(pItem
->mask
& LVIF_TEXT
))
79 // By default, clear text buffer.
80 lstrcpyn(pItem
->pszText
, L
"", pItem
->cchTextMax
);
82 bool bOutOfRange
= pItem
->iItem
>= (int)m_arShownList
.size();
85 if (m_bNoDispUpdates
|| bOutOfRange
)
89 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(pItem
->iItem
);
94 switch (pItem
->iSubItem
)
99 lstrcpyn(pItem
->pszText
,pLogEntry
->m_CommitHash
.ToString(), pItem
->cchTextMax
- 1);
104 lstrcpyn(pItem
->pszText
, pLogEntry
->m_Ref
, pItem
->cchTextMax
- 1);
108 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->m_RefAction
, pItem
->cchTextMax
- 1);
112 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetSubject().Trim(), pItem
->cchTextMax
- 1);
116 lstrcpyn(pItem
->pszText
, (LPCTSTR
)CLoglistUtils::FormatDateAndTime(pLogEntry
->GetCommitterDate(), m_DateFormat
, true, m_bRelativeTimes
), pItem
->cchTextMax
- 1);
124 void CRefLogList::OnNMDblclkLoglist(NMHDR
* /*pNMHDR*/, LRESULT
* pResult
)
126 // a double click on an entry in the revision list has happened
129 POSITION pos
= GetFirstSelectedItemPosition();
130 int indexNext
= GetNextSelectedItem(pos
);
134 auto pSelLogEntry
= m_arShownList
.SafeGetAt(indexNext
);
139 cmdline
.Format(L
"/command:log /path:\"%s\" /endrev:%s", (LPCTSTR
)g_Git
.CombinePath(m_Path
), (LPCTSTR
)pSelLogEntry
->m_CommitHash
.ToString());
140 CAppUtils::RunTortoiseGitProc(cmdline
);
143 void CRefLogList::OnNMCustomdrawLoglist(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
145 // Take the default processing unless we set this to something else below.
146 *pResult
= CDRF_DODEFAULT
;
149 BOOL
CRefLogList::OnToolTipText(UINT
/*id*/, NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)