cleanup
[TortoiseGit.git] / src / TortoiseProc / GitLogListBase.cpp
blobbd243c98a3c306de5578912bf09fc9641eba5eac
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2005-2007 Marco Costalba
5 // Copyright (C) 2011-2012 - Sven Strickroth <email@cs-ware.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 // GitLogList.cpp : implementation file
23 #include "stdafx.h"
24 #include "resource.h"
25 #include "GitLogListBase.h"
26 #include "GitRev.h"
27 //#include "VssStyle.h"
28 #include "IconMenu.h"
29 // CGitLogListBase
30 #include "cursor.h"
31 #include "InputDlg.h"
32 #include "GITProgressDlg.h"
33 #include "ProgressDlg.h"
34 //#include "RepositoryBrowser.h"
35 //#include "CopyDlg.h"
36 //#include "StatGraphDlg.h"
37 #include "Logdlg.h"
38 #include "MessageBox.h"
39 #include "Registry.h"
40 #include "AppUtils.h"
41 #include "PathUtils.h"
42 #include "StringUtils.h"
43 #include "UnicodeUtils.h"
44 #include "TempFile.h"
45 //#include "GitInfo.h"
46 //#include "GitDiff.h"
47 #include "IconMenu.h"
48 //#include "RevisionRangeDlg.h"
49 //#include "BrowseFolder.h"
50 //#include "BlameDlg.h"
51 //#include "Blame.h"
52 //#include "GitHelpers.h"
53 #include "GitStatus.h"
54 //#include "LogDlgHelper.h"
55 //#include "CachedLogInfo.h"
56 //#include "RepositoryInfo.h"
57 //#include "EditPropertiesDlg.h"
58 #include "FileDiffDlg.h"
59 #include "..\\TortoiseShell\\Resource.h"
60 #include "FindDlg.h"
61 #include "SysInfo.h"
63 const UINT CGitLogListBase::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING);
65 IMPLEMENT_DYNAMIC(CGitLogListBase, CHintListCtrl)
67 CGitLogListBase::CGitLogListBase():CHintListCtrl()
68 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
69 ,m_nSearchIndex(0)
70 ,m_bNoDispUpdates(FALSE)
71 , m_bThreadRunning(FALSE)
72 , m_bStrictStopped(false)
73 , m_pStoreSelection(NULL)
74 , m_nSelectedFilter(LOGFILTER_ALL)
75 , m_bShowWC(false)
76 , m_logEntries(&m_LogCache)
77 , m_pFindDialog(NULL)
78 , m_ColumnManager(this)
79 , m_dwDefaultColumns(0)
80 , m_arShownList(&m_critSec)
81 , m_hasWC(true)
83 // use the default GUI font, create a copy of it and
84 // change the copy to BOLD (leave the rest of the font
85 // the same)
86 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
87 LOGFONT lf = {0};
88 GetObject(hFont, sizeof(LOGFONT), &lf);
89 lf.lfWeight = FW_BOLD;
90 m_boldFont = CreateFontIndirect(&lf);
92 m_bShowBugtraqColumn=false;
94 m_IsIDReplaceAction=FALSE;
96 this->m_critSec.Init();
97 m_wcRev.m_CommitHash.Empty();
98 m_wcRev.GetSubject()=_T("Working dir changes");
99 m_wcRev.m_ParentHash.clear();
100 m_wcRev.m_Mark=_T('-');
101 m_wcRev.m_IsUpdateing=FALSE;
102 m_wcRev.m_IsFull = TRUE;
104 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
105 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
106 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
107 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
108 m_hFetchIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONFETCHING), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
110 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
112 g_Git.GetMapHashToFriendName(m_HashMap);
113 m_CurrentBranch=g_Git.GetCurrentBranch();
114 this->m_HeadHash=g_Git.GetHash(_T("HEAD"));
116 m_From=-1;;
117 m_To=-1;
119 m_ShowMask = 0;
120 m_LoadingThread = NULL;
122 InterlockedExchange(&m_bExitThread,FALSE);
123 m_IsOldFirst = FALSE;
124 m_IsRebaseReplaceGraph = FALSE;
127 for(int i=0;i<Lanes::COLORS_NUM;i++)
129 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
131 // get short/long datetime setting from registry
132 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
133 if ( RegUseShortDateFormat )
135 m_DateFormat = DATE_SHORTDATE;
137 else
139 m_DateFormat = DATE_LONGDATE;
141 // get relative time display setting from registry
142 DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);
143 m_bRelativeTimes = (regRelativeTimes != 0);
144 m_ContextMenuMask = 0xFFFFFFFFFFFFFFFF;
146 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_PICK);
147 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SQUASH);
148 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT);
149 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP);
150 m_ContextMenuMask &= ~GetContextMenuBit(ID_LOG);
151 m_ContextMenuMask &= ~GetContextMenuBit(ID_BLAME);
153 m_ColumnRegKey=_T("log");
155 m_AsyncThreadExit = FALSE;
156 m_AsyncDiffEvent = ::CreateEvent(NULL,FALSE,TRUE,NULL);
157 m_AsynDiffListLock.Init();
159 m_DiffingThread = AfxBeginThread(AsyncThread, this, THREAD_PRIORITY_BELOW_NORMAL);
160 if (m_DiffingThread ==NULL)
162 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
163 return;
168 int CGitLogListBase::AsyncDiffThread()
170 m_AsyncThreadExited = false;
171 while(!m_AsyncThreadExit)
173 ::WaitForSingleObject(m_AsyncDiffEvent, INFINITE);
175 GitRev *pRev = NULL;
176 while(!m_AsyncThreadExit && m_AsynDiffList.size() > 0)
178 m_AsynDiffListLock.Lock();
179 pRev = m_AsynDiffList.back();
180 m_AsynDiffList.pop_back();
181 m_AsynDiffListLock.Unlock();
183 if( pRev->m_CommitHash.IsEmpty() )
185 if(pRev->m_IsDiffFiles)
186 continue;
188 pRev->GetFiles(this).Clear();
189 pRev->m_ParentHash.clear();
190 pRev->m_ParentHash.push_back(m_HeadHash);
191 if(g_Git.IsInitRepos())
193 g_Git.GetInitAddList(pRev->GetFiles(this));
196 else
198 g_Git.GetCommitDiffList(pRev->m_CommitHash.ToString(),this->m_HeadHash.ToString(), pRev->GetFiles(this));
200 pRev->GetAction(this) = 0;
202 for(int j=0;j< pRev->GetFiles(this).GetCount();j++)
203 pRev->GetAction(this) |= pRev->GetFiles(this)[j].m_Action;
205 InterlockedExchange(&pRev->m_IsDiffFiles, TRUE);
206 InterlockedExchange(&pRev->m_IsFull, TRUE);
208 pRev->GetBody().Format(_T("%d files changed"),pRev->GetFiles(this).GetCount());
209 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0);
210 this->GetParent()->PostMessage(WM_COMMAND, MSG_FETCHED_DIFF, 0);
213 if(!pRev->CheckAndDiff())
214 { // fetch change file list
215 for(int i=GetTopIndex(); !m_AsyncThreadExit && i <= GetTopIndex()+GetCountPerPage(); i++)
217 if(i < m_arShownList.GetCount())
219 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(i);
220 if(data->m_CommitHash == pRev->m_CommitHash)
222 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
223 break;
228 if(!m_AsyncThreadExit && GetSelectedCount() == 1)
230 POSITION pos = GetFirstSelectedItemPosition();
231 int nItem = GetNextSelectedItem(pos);
233 if(nItem>=0)
235 GitRev* data = (GitRev*)m_arShownList[nItem];
236 if(data)
237 if(data->m_CommitHash == pRev->m_CommitHash)
239 this->GetParent()->PostMessage(WM_COMMAND, MSG_FETCHED_DIFF, 0);
246 m_AsyncThreadExited = true;
247 return 0;
249 void CGitLogListBase::hideFromContextMenu(unsigned __int64 hideMask, bool exclusivelyShow)
251 if (exclusivelyShow)
253 m_ContextMenuMask &= hideMask;
255 else
257 m_ContextMenuMask &= ~hideMask;
261 CGitLogListBase::~CGitLogListBase()
263 InterlockedExchange(&m_bNoDispUpdates, TRUE);
264 this->m_arShownList.SafeRemoveAll();
266 DestroyIcon(m_hModifiedIcon);
267 DestroyIcon(m_hReplacedIcon);
268 DestroyIcon(m_hAddedIcon);
269 DestroyIcon(m_hDeletedIcon);
270 m_logEntries.ClearAll();
272 if (m_boldFont)
273 DeleteObject(m_boldFont);
275 if ( m_pStoreSelection )
277 delete m_pStoreSelection;
278 m_pStoreSelection = NULL;
281 SafeTerminateThread();
282 SafeTerminateAsyncDiffThread();
284 if(m_AsyncDiffEvent)
285 CloseHandle(m_AsyncDiffEvent);
289 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
290 ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage)
291 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
292 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
293 ON_WM_CONTEXTMENU()
294 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
295 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
296 ON_WM_CREATE()
297 ON_WM_DESTROY()
298 ON_MESSAGE(MSG_LOADED,OnLoad)
299 ON_WM_MEASUREITEM()
300 ON_WM_MEASUREITEM_REFLECT()
301 ON_NOTIFY(HDN_BEGINTRACKA, 0, OnHdnBegintrack)
302 ON_NOTIFY(HDN_BEGINTRACKW, 0, OnHdnBegintrack)
303 ON_NOTIFY(HDN_ITEMCHANGINGA, 0, OnHdnItemchanging)
304 ON_NOTIFY(HDN_ITEMCHANGINGW, 0, OnHdnItemchanging)
305 ON_NOTIFY(HDN_ENDTRACK, 0, OnColumnResized)
306 ON_NOTIFY(HDN_ENDDRAG, 0, OnColumnMoved)
307 END_MESSAGE_MAP()
309 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
311 //if (m_nRowHeight>0)
313 lpMeasureItemStruct->itemHeight = 50;
317 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
319 PreSubclassWindow();
320 return CHintListCtrl::OnCreate(lpCreateStruct);
323 void CGitLogListBase::PreSubclassWindow()
325 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
326 // load the icons for the action columns
327 // m_Theme.Open(m_hWnd, L"ListView");
328 SetWindowTheme(m_hWnd, L"Explorer", NULL);
329 CHintListCtrl::PreSubclassWindow();
332 void CGitLogListBase::InsertGitColumn()
334 CString temp;
336 CRegDWORD regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE);
337 DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES;
338 if (DWORD(regFullRowSelect))
339 exStyle |= LVS_EX_FULLROWSELECT;
340 SetExtendedStyle(exStyle);
342 UpdateProjectProperties();
344 static UINT normal[] =
346 IDS_LOG_GRAPH,
347 IDS_LOG_REBASE,
348 IDS_LOG_ID,
349 IDS_LOG_HASH,
350 IDS_LOG_ACTIONS,
351 IDS_LOG_MESSAGE,
352 IDS_LOG_AUTHOR,
353 IDS_LOG_DATE,
354 IDS_LOG_EMAIL,
355 IDS_LOG_COMMIT_NAME,
356 IDS_LOG_COMMIT_EMAIL,
357 IDS_LOG_COMMIT_DATE,
358 IDS_LOG_BUGIDS,
361 static int with[] =
363 ICONITEMBORDER+16*4,
364 ICONITEMBORDER+16*4,
365 ICONITEMBORDER+16*4,
366 ICONITEMBORDER+16*4,
367 ICONITEMBORDER+16*4,
368 LOGLIST_MESSAGE_MIN,
369 ICONITEMBORDER+16*4,
370 ICONITEMBORDER+16*4,
371 ICONITEMBORDER+16*4,
372 ICONITEMBORDER+16*4,
373 ICONITEMBORDER+16*4,
374 ICONITEMBORDER+16*4,
375 ICONITEMBORDER+16*4,
377 m_dwDefaultColumns = GIT_LOG_GRAPH|GIT_LOG_ACTIONS|GIT_LOG_MESSAGE|GIT_LOG_AUTHOR|GIT_LOG_DATE;
379 DWORD hideColumns = 0;
380 if(this->m_IsRebaseReplaceGraph)
382 hideColumns |= GIT_LOG_GRAPH;
383 m_dwDefaultColumns |= GIT_LOG_REBASE;
385 else
387 hideColumns |= GIT_LOG_REBASE;
390 if(this->m_IsIDReplaceAction)
392 hideColumns |= GIT_LOG_ACTIONS;
393 m_dwDefaultColumns |= GIT_LOG_ID;
394 m_dwDefaultColumns |= GIT_LOG_HASH;
396 else
398 hideColumns |= GIT_LOG_ID;
400 if(this->m_bShowBugtraqColumn)
402 m_dwDefaultColumns |= GIT_LOGLIST_BUG;
404 else
406 hideColumns |= GIT_LOGLIST_BUG;
408 SetRedraw(false);
410 m_ColumnManager.SetNames(normal, _countof(normal));
411 m_ColumnManager.ReadSettings(m_dwDefaultColumns, hideColumns, m_ColumnRegKey+_T("loglist"), _countof(normal), with);
413 SetRedraw(true);
418 * Resizes all columns in a list control to values in registry.
420 void CGitLogListBase::ResizeAllListCtrlCols()
422 // column max and min widths to allow
423 static const int nMinimumWidth = 10;
424 static const int nMaximumWidth = 1000;
425 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
426 if (pHdrCtrl)
428 int numcols = pHdrCtrl->GetItemCount();
429 for (int col = 0; col < numcols; col++)
431 // get width for this col last time from registry
432 CString regentry;
433 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
434 CRegDWORD regwidth(regentry, 0);
435 int cx = regwidth;
436 if ( cx == 0 )
438 // no saved value, setup sensible defaults
439 if (col == this->LOGLIST_MESSAGE)
441 cx = LOGLIST_MESSAGE_MIN;
443 else
445 cx = ICONITEMBORDER+16*4;
448 if (cx < nMinimumWidth)
450 cx = nMinimumWidth;
452 else if (cx > nMaximumWidth)
454 cx = nMaximumWidth;
457 SetColumnWidth(col, cx);
464 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
466 //TRACE(_T("%s %s\r\n"),ref,prefix);
467 if(ref.Left(prefix.GetLength()) == prefix)
469 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
470 if(shortname.Right(3)==_T("^{}"))
471 shortname=shortname.Left(shortname.GetLength()-3);
472 return TRUE;
474 return FALSE;
477 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
479 LVITEM rItem;
480 SecureZeroMemory(&rItem, sizeof(LVITEM));
481 rItem.mask = LVIF_STATE;
482 rItem.iItem = Index;
483 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
484 GetItem(&rItem);
486 GitRev* pLogEntry = (GitRev*)m_arShownList.SafeGetAt(Index);
487 HBRUSH brush = NULL;
489 if (!(rItem.state & LVIS_SELECTED))
491 if(pLogEntry->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_SQUASH)
492 brush = ::CreateSolidBrush(RGB(156,156,156));
493 else if(pLogEntry->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_EDIT)
494 brush = ::CreateSolidBrush(RGB(200,200,128));
496 else if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
498 if (rItem.state & LVIS_SELECTED)
500 if (::GetFocus() == m_hWnd)
501 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
502 else
503 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
507 if (brush != NULL)
509 ::FillRect(hdc, &rect, brush);
510 ::DeleteObject(brush);
514 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
516 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(index);
517 CRect rt=rect;
518 LVITEM rItem;
519 SecureZeroMemory(&rItem, sizeof(LVITEM));
520 rItem.mask = LVIF_STATE;
521 rItem.iItem = index;
522 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
523 GetItem(&rItem);
525 CDC W_Dc;
526 W_Dc.Attach(hdc);
528 HTHEME hTheme = NULL;
529 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
530 hTheme = OpenThemeData(m_hWnd, L"Explorer::ListView;ListView");
532 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
534 CString str;
535 str=m_HashMap[data->m_CommitHash][i];
537 CString shortname;
538 HBRUSH brush = 0;
539 shortname = _T("");
540 COLORREF colRef = 0;
542 //Determine label color
543 if(GetShortName(str,shortname,_T("refs/heads/")))
545 if( shortname == m_CurrentBranch )
546 colRef = m_Colors.GetColor(CColors::CurrentBranch);
547 else
548 colRef = m_Colors.GetColor(CColors::LocalBranch);
551 else if(GetShortName(str,shortname,_T("refs/remotes/")))
553 colRef = m_Colors.GetColor(CColors::RemoteBranch);
555 else if(GetShortName(str,shortname,_T("refs/tags/")))
557 colRef = m_Colors.GetColor(CColors::Tag);
559 else if(GetShortName(str,shortname,_T("refs/stash")))
561 colRef = m_Colors.GetColor(CColors::Stash);
562 shortname=_T("stash");
564 else if(GetShortName(str,shortname,_T("refs/bisect/")))
566 if(shortname.Find(_T("good")) == 0)
568 colRef = m_Colors.GetColor(CColors::BisectGood);
569 shortname = _T("good");
572 if(shortname.Find(_T("bad")) == 0)
574 colRef = m_Colors.GetColor(CColors::BisectBad);
575 shortname = _T("bad");
579 //When row selected, ajust label color
580 if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
581 if (rItem.state & LVIS_SELECTED)
582 colRef = CColors::MixColors(colRef, ::GetSysColor(COLOR_HIGHLIGHT), 150);
584 brush = ::CreateSolidBrush(colRef);
586 if(!shortname.IsEmpty() && (rt.left<rect.right) )
588 SIZE size;
589 memset(&size,0,sizeof(SIZE));
590 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
592 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
593 rt.right+=8;
595 int textpos = DT_CENTER;
597 if(rt.right > rect.right)
599 rt.right = rect.right;
600 textpos =0;
603 //Fill interior of ref label
604 ::FillRect(hdc, &rt, brush);
606 //Draw edge of label
608 CRect rectEdge = rt;
610 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,100), m_Colors.Darken(colRef,100));
611 rectEdge.DeflateRect(1,1);
612 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,50), m_Colors.Darken(colRef,50));
614 //Draw text inside label
615 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
617 int txtState = LISS_NORMAL;
618 if (rItem.state & LVIS_SELECTED)
619 txtState = LISS_SELECTED;
621 DrawThemeText(hTheme,hdc, LVP_LISTITEM, txtState, shortname, -1, textpos | DT_SINGLELINE | DT_VCENTER, 0, &rt);
623 else
625 W_Dc.SetBkMode(TRANSPARENT);
626 if (rItem.state & LVIS_SELECTED)
628 COLORREF clrNew = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
629 COLORREF clrOld = ::SetTextColor(hdc,clrNew);
630 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,textpos | DT_SINGLELINE | DT_VCENTER);
631 ::SetTextColor(hdc,clrOld);
633 else
635 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,textpos | DT_SINGLELINE | DT_VCENTER);
639 //::MoveToEx(hdc,rt.left,rt.top,NULL);
640 //::LineTo(hdc,rt.right,rt.top);
641 //::LineTo(hdc,rt.right,rt.bottom);
642 //::LineTo(hdc,rt.left,rt.bottom);
643 //::LineTo(hdc,rt.left,rt.top);
645 rt.left=rt.right+1;
647 if(brush)
648 ::DeleteObject(brush);
650 rt.right=rect.right;
652 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
654 int txtState = LISS_NORMAL;
655 if (rItem.state & LVIS_SELECTED)
656 txtState = LISS_SELECTED;
658 DrawThemeText(hTheme,hdc, LVP_LISTITEM, txtState, data->GetSubject(), -1, DT_NOPREFIX | DT_LEFT | DT_SINGLELINE | DT_VCENTER, 0, &rt);
660 else
662 if (rItem.state & LVIS_SELECTED)
664 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
665 ::DrawText(hdc,data->GetSubject(),data->GetSubject().GetLength(),&rt,DT_NOPREFIX | DT_LEFT | DT_SINGLELINE | DT_VCENTER);
666 ::SetTextColor(hdc,clrOld);
668 else
670 ::DrawText(hdc,data->GetSubject(),data->GetSubject().GetLength(),&rt,DT_NOPREFIX | DT_LEFT | DT_SINGLELINE | DT_VCENTER);
674 if (hTheme)
675 CloseThemeData(hTheme);
677 W_Dc.Detach();
680 static COLORREF blend(const COLORREF& col1, const COLORREF& col2, int amount = 128) {
682 // Returns ((256 - amount)*col1 + amount*col2) / 256;
683 return RGB(((256 - amount)*GetRValue(col1) + amount*GetRValue(col2) ) / 256,
684 ((256 - amount)*GetGValue(col1) + amount*GetGValue(col2) ) / 256,
685 ((256 - amount)*GetBValue(col1) + amount*GetBValue(col2) ) / 256);
688 Gdiplus::Color GetGdiColor(COLORREF col)
690 return Gdiplus::Color(GetRValue(col),GetGValue(col),GetBValue(col));
692 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
693 const COLORREF& col,const COLORREF& activeColor, int top
696 int h = laneHeight / 2;
697 int m = (x1 + x2) / 2;
698 int r = (x2 - x1) / 3;
699 int d = 2 * r;
701 #define P_CENTER m , h+top
702 #define P_0 x2, h+top
703 #define P_90 m , 0+top-1
704 #define P_180 x1, h+top
705 #define P_270 m , 2 * h+top +1
706 #define R_CENTER m - r, h - r+top, d, d
709 #define DELTA_UR_B 2*(x1 - m), 2*h +top
710 #define DELTA_UR_E 0*16, 90*16 +top // -,
712 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
713 #define DELTA_DR_E 270*16, 90*16 +top // -'
715 #define DELTA_UL_B 2*(x2 - m), 2*h +top
716 #define DELTA_UL_E 90*16, 90*16 +top // ,-
718 #define DELTA_DL_B 2*(x2 - m),2*-h +top
719 #define DELTA_DL_E 180*16, 90*16 // '-
721 #define CENTER_UR x1, 2*h, 225
722 #define CENTER_DR x1, 0 , 135
723 #define CENTER_UL x2, 2*h, 315
724 #define CENTER_DL x2, 0 , 45
727 Gdiplus::Graphics graphics( hdc );
729 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
731 // arc
732 switch (type) {
733 case Lanes::JOIN:
734 case Lanes::JOIN_R:
735 case Lanes::HEAD:
736 case Lanes::HEAD_R:
738 Gdiplus::LinearGradientBrush gradient(
739 Gdiplus::Point(x1-2, h+top-2),
740 Gdiplus::Point(P_270),
741 GetGdiColor(activeColor),GetGdiColor(col));
744 Gdiplus::Pen mypen(&gradient,2);
745 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
747 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
748 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top+h-1, x2-x1,laneHeight,270,90);
749 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
751 break;
753 case Lanes::JOIN_L:
756 Gdiplus::LinearGradientBrush gradient(
757 Gdiplus::Point(P_270),
758 Gdiplus::Point(x2+1, h+top-1),
759 GetGdiColor(col),GetGdiColor(activeColor));
762 Gdiplus::Pen mypen(&gradient,2);
763 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
765 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
766 graphics.DrawArc(&mypen,x1+(x2-x1)/2,top+h-1, x2-x1,laneHeight,180,90);
767 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
770 break;
772 case Lanes::TAIL:
773 case Lanes::TAIL_R:
776 Gdiplus::LinearGradientBrush gradient(
777 Gdiplus::Point(x1-2, h+top-2),
778 Gdiplus::Point(P_90),
779 GetGdiColor(activeColor),GetGdiColor(col));
781 Gdiplus::Pen mypen(&gradient,2);
783 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top-h-1, x2-x1,laneHeight,0,90);
785 #if 0
786 QConicalGradient gradient(CENTER_DR);
787 gradient.setColorAt(0.375, activeCol);
788 gradient.setColorAt(0.625, col);
789 myPen.setBrush(gradient);
790 p->setPen(myPen);
791 p->drawArc(P_CENTER, DELTA_DR);
792 #endif
793 break;
795 default:
796 break;
800 //static QPen myPen(Qt::black, 2); // fast path here
801 CPen pen;
802 pen.CreatePen(PS_SOLID,2,col);
803 //myPen.setColor(col);
804 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
806 Gdiplus::Pen myPen(GetGdiColor(col),2);
808 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
810 //p->setPen(myPen);
812 // vertical line
813 switch (type) {
814 case Lanes::ACTIVE:
815 case Lanes::NOT_ACTIVE:
816 case Lanes::MERGE_FORK:
817 case Lanes::MERGE_FORK_R:
818 case Lanes::MERGE_FORK_L:
819 case Lanes::JOIN:
820 case Lanes::JOIN_R:
821 case Lanes::JOIN_L:
822 case Lanes::CROSS:
823 //DrawLine(hdc,P_90,P_270);
824 graphics.DrawLine(&myPen,P_90,P_270);
825 //p->drawLine(P_90, P_270);
826 break;
827 case Lanes::HEAD_L:
828 case Lanes::BRANCH:
829 //DrawLine(hdc,P_CENTER,P_270);
830 graphics.DrawLine(&myPen,P_CENTER,P_270);
831 //p->drawLine(P_CENTER, P_270);
832 break;
833 case Lanes::TAIL_L:
834 case Lanes::INITIAL:
835 case Lanes::BOUNDARY:
836 case Lanes::BOUNDARY_C:
837 case Lanes::BOUNDARY_R:
838 case Lanes::BOUNDARY_L:
839 //DrawLine(hdc,P_90, P_CENTER);
840 graphics.DrawLine(&myPen,P_90,P_CENTER);
841 //p->drawLine(P_90, P_CENTER);
842 break;
843 default:
844 break;
847 myPen.SetColor(GetGdiColor(activeColor));
849 // horizontal line
850 switch (type) {
851 case Lanes::MERGE_FORK:
852 case Lanes::JOIN:
853 case Lanes::HEAD:
854 case Lanes::TAIL:
855 case Lanes::CROSS:
856 case Lanes::CROSS_EMPTY:
857 case Lanes::BOUNDARY_C:
858 //DrawLine(hdc,P_180,P_0);
859 graphics.DrawLine(&myPen,P_180,P_0);
860 //p->drawLine(P_180, P_0);
861 break;
862 case Lanes::MERGE_FORK_R:
863 case Lanes::BOUNDARY_R:
864 //DrawLine(hdc,P_180,P_CENTER);
865 graphics.DrawLine(&myPen,P_180,P_CENTER);
866 //p->drawLine(P_180, P_CENTER);
867 break;
868 case Lanes::MERGE_FORK_L:
869 case Lanes::HEAD_L:
870 case Lanes::TAIL_L:
871 case Lanes::BOUNDARY_L:
872 //DrawLine(hdc,P_CENTER,P_0);
873 graphics.DrawLine(&myPen,P_CENTER,P_0);
874 //p->drawLine(P_CENTER, P_0);
875 break;
876 default:
877 break;
880 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
882 CBrush brush;
883 brush.CreateSolidBrush(col);
884 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
886 Gdiplus::SolidBrush myBrush(GetGdiColor(col));
887 // center symbol, e.g. rect or ellipse
888 switch (type) {
889 case Lanes::ACTIVE:
890 case Lanes::INITIAL:
891 case Lanes::BRANCH:
893 //p->setPen(Qt::NoPen);
894 //p->setBrush(col);
895 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
896 graphics.FillEllipse(&myBrush, R_CENTER);
897 //p->drawEllipse(R_CENTER);
898 break;
899 case Lanes::MERGE_FORK:
900 case Lanes::MERGE_FORK_R:
901 case Lanes::MERGE_FORK_L:
902 //p->setPen(Qt::NoPen);
903 //p->setBrush(col);
904 //p->drawRect(R_CENTER);
905 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
906 graphics.FillRectangle(&myBrush, R_CENTER);
907 break;
908 case Lanes::UNAPPLIED:
909 // Red minus sign
910 //p->setPen(Qt::NoPen);
911 //p->setBrush(Qt::red);
912 //p->drawRect(m - r, h - 1, d, 2);
913 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
914 graphics.FillRectangle(&myBrush,m-r,h-1,d,2);
915 break;
916 case Lanes::APPLIED:
917 // Green plus sign
918 //p->setPen(Qt::NoPen);
919 //p->setBrush(DARK_GREEN);
920 //p->drawRect(m - r, h - 1, d, 2);
921 //p->drawRect(m - 1, h - r, 2, d);
922 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
923 graphics.FillRectangle(&myBrush,m-r,h-1,d,2);
924 graphics.FillRectangle(&myBrush,m-1,h-r,2,d);
925 break;
926 case Lanes::BOUNDARY:
927 //p->setBrush(back);
928 //p->drawEllipse(R_CENTER);
929 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
930 graphics.DrawEllipse(&myPen, R_CENTER);
931 break;
932 case Lanes::BOUNDARY_C:
933 case Lanes::BOUNDARY_R:
934 case Lanes::BOUNDARY_L:
935 //p->setBrush(back);
936 //p->drawRect(R_CENTER);
937 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
938 graphics.FillRectangle(&myBrush,R_CENTER);
939 break;
940 default:
941 break;
944 ::SelectObject(hdc,oldpen);
945 ::SelectObject(hdc,oldbrush);
946 #undef P_CENTER
947 #undef P_0
948 #undef P_90
949 #undef P_180
950 #undef P_270
951 #undef R_CENTER
954 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
956 // TODO: unfinished
957 // return;
958 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(index);
959 if(data->m_CommitHash.IsEmpty())
960 return;
962 CRect rt=rect;
963 LVITEM rItem;
964 SecureZeroMemory(&rItem, sizeof(LVITEM));
965 rItem.mask = LVIF_STATE;
966 rItem.iItem = index;
967 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
968 GetItem(&rItem);
970 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
972 if (data->m_Lanes.size() == 0)
973 m_logEntries.setLane(data->m_CommitHash);
975 std::vector<int>& lanes=data->m_Lanes;
976 UINT laneNum = lanes.size();
977 UINT activeLane = 0;
978 for (UINT i = 0; i < laneNum; i++)
979 if (Lanes::isMerge(lanes[i])) {
980 activeLane = i;
981 break;
984 int x1 = 0, x2 = 0;
985 int maxWidth = rect.Width();
986 int lw = 3 * rect.Height() / 4; //laneWidth()
988 COLORREF activeColor = m_LineColors[activeLane % Lanes::COLORS_NUM];
989 //if (opt.state & QStyle::State_Selected)
990 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
992 for (unsigned int i = 0; i < laneNum && x2 < maxWidth; i++)
995 x1 = x2;
996 x2 += lw;
998 int ln = lanes[i];
999 if (ln == Lanes::EMPTY)
1000 continue;
1002 COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM];
1003 paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top);
1006 #if 0
1007 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
1009 x1 = x2;
1010 x2 += lw;
1012 int ln = lanes[i];
1013 if (ln == Lanes::EMPTY)
1014 continue;
1016 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
1017 || ln ==Lanes:: CROSS_EMPTY) ? activeLane : i;
1019 if (ln == Lanes::CROSS)
1021 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
1022 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[activeLane % Lanes::COLORS_NUM],rect.top);
1024 else
1025 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
1027 #endif
1031 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1034 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
1035 // Take the default processing unless we set this to something else below.
1036 *pResult = CDRF_DODEFAULT;
1038 if (m_bNoDispUpdates)
1039 return;
1041 switch (pLVCD->nmcd.dwDrawStage)
1043 case CDDS_PREPAINT:
1045 *pResult = CDRF_NOTIFYITEMDRAW;
1046 return;
1048 break;
1049 case CDDS_ITEMPREPAINT:
1051 // This is the prepaint stage for an item. Here's where we set the
1052 // item's text color.
1054 // Tell Windows to send draw notifications for each subitem.
1055 *pResult = CDRF_NOTIFYSUBITEMDRAW;
1057 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
1059 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
1061 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec);
1062 if (data)
1064 if (data->GetAction(this)& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
1065 crText = RGB(128,128,128);
1067 if(data->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_SQUASH)
1068 pLVCD->clrTextBk = RGB(156,156,156);
1069 else if(data->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_EDIT)
1070 pLVCD->clrTextBk = RGB(200,200,128);
1071 else
1072 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
1074 if(data->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_CURRENT)
1076 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1077 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1080 if(data->m_CommitHash.ToString() == m_HeadHash)
1082 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1083 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1086 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1087 // crText = GetSysColor(COLOR_GRAYTEXT);
1089 if (data->m_CommitHash.IsEmpty())
1091 //crText = GetSysColor(RGB(200,200,0));
1092 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1093 // We changed the font, so we're returning CDRF_NEWFONT. This
1094 // tells the control to recalculate the extent of the text.
1095 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1099 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
1101 if (m_bStrictStopped)
1102 crText = GetSysColor(COLOR_GRAYTEXT);
1104 // Store the color back in the NMLVCUSTOMDRAW struct.
1105 pLVCD->clrText = crText;
1106 return;
1108 break;
1109 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
1111 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
1113 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
1116 if (pLVCD->iSubItem == LOGLIST_GRAPH && m_sFilterText.IsEmpty())
1118 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
1120 CRect rect;
1121 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_LABEL, rect);
1123 //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
1124 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
1126 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec);
1127 if( !data ->m_CommitHash.IsEmpty())
1128 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
1130 *pResult = CDRF_SKIPDEFAULT;
1131 return;
1135 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
1137 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
1139 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec);
1140 //if(!data->m_IsFull)
1142 //if(data->SafeFetchFullInfo(&g_Git))
1143 // this->Invalidate();
1144 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
1147 if(m_HashMap[data->m_CommitHash].size()!=0)
1149 CRect rect;
1151 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
1153 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
1154 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
1156 *pResult = CDRF_SKIPDEFAULT;
1157 return;
1164 if (pLVCD->iSubItem == LOGLIST_ACTION)
1166 if(this->m_IsIDReplaceAction)
1168 *pResult = CDRF_DODEFAULT;
1169 return;
1171 *pResult = CDRF_DODEFAULT;
1173 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
1174 return;
1176 int nIcons = 0;
1177 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
1178 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
1180 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec));
1181 CRect rect;
1182 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
1183 //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
1184 // Get the selected state of the
1185 // item being drawn.
1187 // Fill the background if necessary
1188 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
1190 // Draw the icon(s) into the compatible DC
1191 pLogEntry->GetAction(this);
1193 if (!pLogEntry->m_IsDiffFiles)
1194 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hFetchIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1196 if (pLogEntry->GetAction(this) & CTGitPath::LOGACTIONS_MODIFIED)
1197 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1198 nIcons++;
1200 if (pLogEntry->GetAction(this) & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
1201 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1202 nIcons++;
1204 if (pLogEntry->GetAction(this) & CTGitPath::LOGACTIONS_DELETED)
1205 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1206 nIcons++;
1208 if (pLogEntry->GetAction(this) & CTGitPath::LOGACTIONS_REPLACED)
1209 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1210 nIcons++;
1211 *pResult = CDRF_SKIPDEFAULT;
1212 return;
1215 break;
1217 *pResult = CDRF_DODEFAULT;
1220 // CGitLogListBase message handlers
1222 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1224 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
1226 // Create a pointer to the item
1227 LV_ITEM* pItem = &(pDispInfo)->item;
1229 // Do the list need text information?
1230 if (!(pItem->mask & LVIF_TEXT))
1231 return;
1233 // By default, clear text buffer.
1234 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
1236 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
1238 *pResult = 0;
1239 if (m_bNoDispUpdates || bOutOfRange)
1240 return;
1242 // Which item number?
1243 int itemid = pItem->iItem;
1244 GitRev * pLogEntry = NULL;
1245 if (itemid < m_arShownList.GetCount())
1246 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(pItem->iItem));
1248 CString temp;
1249 if(m_IsOldFirst)
1251 temp.Format(_T("%d"),pItem->iItem+1);
1254 else
1256 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
1259 // Which column?
1260 switch (pItem->iSubItem)
1262 case this->LOGLIST_GRAPH: //Graphic
1263 break;
1264 case this->LOGLIST_REBASE:
1266 if(this->m_IsRebaseReplaceGraph)
1268 CTGitPath path;
1269 path.m_Action=pLogEntry->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
1270 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
1273 break;
1274 case this->LOGLIST_ACTION: //action -- no text in the column
1275 break;
1276 case this->LOGLIST_HASH:
1277 if(pLogEntry)
1278 lstrcpyn(pItem->pszText, pLogEntry->m_CommitHash.ToString(), pItem->cchTextMax);
1279 break;
1280 case this->LOGLIST_ID:
1281 if(this->m_IsIDReplaceAction)
1282 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
1283 break;
1284 case this->LOGLIST_MESSAGE: //Message
1285 if (pLogEntry)
1286 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetSubject(), pItem->cchTextMax);
1287 break;
1288 case this->LOGLIST_AUTHOR: //Author
1289 if (pLogEntry)
1290 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetAuthorName(), pItem->cchTextMax);
1291 break;
1292 case this->LOGLIST_DATE: //Date
1293 if ( pLogEntry && (!pLogEntry->m_CommitHash.IsEmpty()) )
1294 lstrcpyn(pItem->pszText,
1295 CAppUtils::FormatDateAndTime( pLogEntry->GetAuthorDate(), m_DateFormat, true, m_bRelativeTimes ),
1296 pItem->cchTextMax);
1297 break;
1299 case this->LOGLIST_EMAIL:
1300 if (pLogEntry)
1301 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetAuthorEmail(), pItem->cchTextMax);
1302 break;
1304 case this->LOGLIST_COMMIT_NAME: //Commit
1305 if (pLogEntry)
1306 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetCommitterName(), pItem->cchTextMax);
1307 break;
1309 case this->LOGLIST_COMMIT_EMAIL: //Commit Email
1310 if (pLogEntry)
1311 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetCommitterEmail(), pItem->cchTextMax);
1312 break;
1314 case this->LOGLIST_COMMIT_DATE: //Commit Date
1315 if (pLogEntry)
1316 lstrcpyn(pItem->pszText,
1317 CAppUtils::FormatDateAndTime( pLogEntry->GetCommitterDate(), m_DateFormat, true, m_bRelativeTimes ),
1318 pItem->cchTextMax);
1319 break;
1320 case this->LOGLIST_BUG: //Bug ID
1321 if(pLogEntry)
1322 lstrcpyn(pItem->pszText, (LPCTSTR)this->m_ProjectProperties.FindBugID(pLogEntry->GetSubject()), pItem->cchTextMax);
1323 break;
1325 default:
1326 ASSERT(false);
1330 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
1333 if (pWnd == GetHeaderCtrl())
1335 return m_ColumnManager.OnContextMenuHeader(pWnd,point,!!IsGroupViewEnabled());
1338 int selIndex = GetSelectionMark();
1339 if (selIndex < 0)
1340 return; // nothing selected, nothing to do with a context menu
1342 // if the user selected the info text telling about not all revisions shown due to
1343 // the "stop on copy/rename" option, we also don't show the context menu
1344 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
1345 return;
1347 // if the context menu is invoked through the keyboard, we have to use
1348 // a calculated position on where to anchor the menu on
1349 if ((point.x == -1) && (point.y == -1))
1351 CRect rect;
1352 GetItemRect(selIndex, &rect, LVIR_LABEL);
1353 ClientToScreen(&rect);
1354 point = rect.CenterPoint();
1356 m_nSearchIndex = selIndex;
1357 m_bCancelled = FALSE;
1359 // calculate some information the context menu commands can use
1360 // CString pathURL = GetURLFromPath(m_path);
1362 POSITION pos = GetFirstSelectedItemPosition();
1363 int indexNext = GetNextSelectedItem(pos);
1364 if (indexNext < 0)
1365 return;
1367 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(indexNext));
1368 #if 0
1369 GitRev revSelected = pSelLogEntry->Rev;
1370 GitRev revPrevious = git_revnum_t(revSelected)-1;
1371 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
1373 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
1375 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->SafeGetAt(i);
1376 if (changedpath->lCopyFromRev)
1377 revPrevious = changedpath->lCopyFromRev;
1380 GitRev revSelected2;
1381 if (pos)
1383 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
1384 revSelected2 = pLogEntry->Rev;
1386 bool bAllFromTheSameAuthor = true;
1387 CString firstAuthor;
1388 CLogDataVector selEntries;
1389 GitRev revLowest, revHighest;
1390 GitRevRangeArray revisionRanges;
1392 POSITION pos = GetFirstSelectedItemPosition();
1393 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
1394 revisionRanges.AddRevision(pLogEntry->Rev);
1395 selEntries.push_back(pLogEntry);
1396 firstAuthor = pLogEntry->sAuthor;
1397 revLowest = pLogEntry->Rev;
1398 revHighest = pLogEntry->Rev;
1399 while (pos)
1401 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
1402 revisionRanges.AddRevision(pLogEntry->Rev);
1403 selEntries.push_back(pLogEntry);
1404 if (firstAuthor.Compare(pLogEntry->sAuthor))
1405 bAllFromTheSameAuthor = false;
1406 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
1407 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
1411 #endif
1413 int FirstSelect=-1, LastSelect=-1;
1414 pos = GetFirstSelectedItemPosition();
1415 FirstSelect = GetNextSelectedItem(pos);
1416 while(pos)
1418 LastSelect = GetNextSelectedItem(pos);
1420 //entry is selected, now show the popup menu
1421 CIconMenu popup;
1422 CIconMenu subbranchmenu, submenu, gnudiffmenu,diffmenu;
1424 if (popup.CreatePopupMenu())
1426 bool isHeadCommit = (pSelLogEntry->m_CommitHash == m_HeadHash);
1427 CString currentBranch = _T("refs/heads/") + g_Git.GetCurrentBranch();
1429 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
1430 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_PICK, IDI_PICK);
1432 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
1433 popup.AppendMenuIcon(ID_REBASE_SQUASH, IDS_REBASE_SQUASH, IDI_SQUASH);
1435 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
1436 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
1438 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
1439 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
1441 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
1442 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
1443 popup.AppendMenu(MF_SEPARATOR, NULL);
1445 if (GetSelectedCount() == 1)
1449 if( !pSelLogEntry->m_CommitHash.IsEmpty())
1451 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE) && m_hasWC) // compare revision with WC
1452 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
1453 // TODO:
1454 // TortoiseMerge could be improved to take a /blame switch
1455 // and then not 'cat' the files from a unified diff but
1456 // blame then.
1457 // But until that's implemented, the context menu entry for
1458 // this feature is commented out.
1459 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
1461 else
1463 if(m_ContextMenuMask&GetContextMenuBit(ID_COMMIT))
1464 popup.AppendMenuIcon(ID_COMMIT, IDS_LOG_POPUP_COMMIT, IDI_COMMIT);
1466 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1) && m_hasWC) // compare with WC, unified
1468 GitRev *pRev=pSelLogEntry;
1469 if(pSelLogEntry->m_ParentHash.size()==0)
1471 pRev->GetParentFromHash(pRev->m_CommitHash);
1473 if(pRev->m_ParentHash.size()<=1)
1475 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
1478 else
1480 gnudiffmenu.CreatePopupMenu();
1481 popup.AppendMenuIcon(ID_GNUDIFF1,IDS_LOG_POPUP_GNUDIFF_PARENT, IDI_DIFF, gnudiffmenu.m_hMenu);
1483 gnudiffmenu.AppendMenuIcon(ID_GNUDIFF1+(0xFFFF<<16),_T("All Parents"));
1484 gnudiffmenu.AppendMenuIcon(ID_GNUDIFF1+(0xFFFE<<16),_T("Only Merged Files"));
1486 for(int i=0;i<pRev->m_ParentHash.size();i++)
1488 CString str;
1489 str.Format(_T("Parent %d"), i+1);
1490 gnudiffmenu.AppendMenuIcon(ID_GNUDIFF1+((i+1)<<16),str);
1495 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
1498 GitRev *pRev=pSelLogEntry;
1499 if(pSelLogEntry->m_ParentHash.size()==0)
1501 pRev->GetParentFromHash(pRev->m_CommitHash);
1503 if(pRev->m_ParentHash.size()<=1)
1505 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
1506 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
1507 popup.SetDefaultItem(ID_COMPAREWITHPREVIOUS, FALSE);
1509 else
1511 diffmenu.CreatePopupMenu();
1512 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF, diffmenu.m_hMenu);
1513 for(int i=0;i<pRev->m_ParentHash.size();i++)
1515 CString str;
1516 str.Format(_T("Parent %d"), i+1);
1517 diffmenu.AppendMenuIcon(ID_COMPAREWITHPREVIOUS +((i+1)<<16),str);
1518 if (i == 0 && CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
1520 popup.SetDefaultItem(ID_COMPAREWITHPREVIOUS, FALSE);
1521 diffmenu.SetDefaultItem(ID_COMPAREWITHPREVIOUS +((i+1)<<16), FALSE);
1527 if(m_ContextMenuMask&GetContextMenuBit(ID_BLAME))
1528 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
1530 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
1531 popup.AppendMenu(MF_SEPARATOR, NULL);
1534 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1535 // {
1536 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1537 // }
1538 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1539 // {
1540 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1541 // }
1542 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1543 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1544 // {
1545 // popup.AppendMenu(MF_SEPARATOR, NULL);
1546 // }
1548 CString str,format;
1549 //if (m_hasWC)
1550 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1552 if(!pSelLogEntry->m_CommitHash.IsEmpty())
1554 if((m_ContextMenuMask&GetContextMenuBit(ID_LOG)) &&
1555 GetSelectedCount() == 1)
1556 popup.AppendMenuIcon(ID_LOG, IDS_LOG_POPUP_LOG, IDI_LOG);
1558 format.LoadString(IDS_LOG_POPUP_MERGEREV);
1559 str.Format(format,g_Git.GetCurrentBranch());
1561 if (m_ContextMenuMask&GetContextMenuBit(ID_MERGEREV) && !isHeadCommit && m_hasWC)
1562 popup.AppendMenuIcon(ID_MERGEREV, str, IDI_MERGE);
1564 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
1565 str.Format(format,g_Git.GetCurrentBranch());
1567 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET) && m_hasWC)
1568 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
1571 // Add Switch Branch express Menu
1572 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end()
1573 && (m_ContextMenuMask&GetContextMenuBit(ID_SWITCHBRANCH) && m_hasWC)
1576 std::vector<CString *> branchs;
1577 for(int i=0;i<m_HashMap[pSelLogEntry->m_CommitHash].size();i++)
1579 CString ref = m_HashMap[pSelLogEntry->m_CommitHash][i];
1580 if(ref.Find(_T("refs/heads/")) == 0 && ref != currentBranch)
1582 branchs.push_back(&m_HashMap[pSelLogEntry->m_CommitHash][i]);
1586 CString str;
1587 str.LoadString(IDS_SWITCH_BRANCH);
1589 if(branchs.size() == 1)
1591 str+=_T(" ");
1592 str+= _T('"') + branchs[0]->Mid(11) + _T('"');
1593 popup.AppendMenuIcon(ID_SWITCHBRANCH,str,IDI_SWITCH);
1595 popup.SetMenuItemData(ID_SWITCHBRANCH,(ULONG_PTR)branchs[0]);
1598 else if(branchs.size() > 1)
1600 subbranchmenu.CreatePopupMenu();
1601 for(int i=0;i<branchs.size();i++)
1603 if (*branchs[i] != currentBranch)
1605 subbranchmenu.AppendMenuIcon(ID_SWITCHBRANCH+(i<<16), branchs[i]->Mid(11));
1606 subbranchmenu.SetMenuItemData(ID_SWITCHBRANCH+(i<<16), (ULONG_PTR) branchs[i]);
1610 popup.AppendMenuIcon(ID_SWITCHBRANCH, str, IDI_SWITCH, subbranchmenu.m_hMenu);
1614 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV) && !isHeadCommit && m_hasWC)
1615 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
1617 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
1618 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
1620 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
1621 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_TAG);
1623 format.LoadString(IDS_REBASE_THIS_FORMAT);
1624 str.Format(format,g_Git.GetCurrentBranch());
1626 if(pSelLogEntry->m_CommitHash != m_HeadHash && m_hasWC)
1627 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
1628 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
1630 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
1631 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
1633 if (m_ContextMenuMask&GetContextMenuBit(ID_REVERTREV) && m_hasWC)
1634 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
1636 if (m_ContextMenuMask&GetContextMenuBit(ID_EDITNOTE))
1637 popup.AppendMenuIcon(ID_EDITNOTE, IDS_EDIT_NOTES, IDI_EDIT);
1639 popup.AppendMenu(MF_SEPARATOR, NULL);
1644 if(!pSelLogEntry->m_Ref.IsEmpty() && GetSelectedCount() == 1)
1646 popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE);
1647 if (pSelLogEntry->m_Ref.Find(_T("refs/stash")) == 0)
1648 popup.AppendMenuIcon(ID_STASH_APPLY, IDS_MENUSTASHAPPLY, IDI_RELOCATE);
1649 popup.AppendMenu(MF_SEPARATOR, NULL);
1652 if (GetSelectedCount() >= 2)
1654 bool bAddSeparator = false;
1655 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
1657 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO)) // compare two revisions
1658 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
1661 if (GetSelectedCount() == 2)
1663 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
1664 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2) && m_hasWC) // compare two revisions, unified
1665 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
1666 bAddSeparator = true;
1669 if (m_hasWC)
1671 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
1672 // if (m_hasWC)
1673 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
1674 bAddSeparator = true;
1677 if (m_ContextMenuMask&GetContextMenuBit(ID_REVERTREV) && m_hasWC)
1678 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
1680 if (bAddSeparator)
1681 popup.AppendMenu(MF_SEPARATOR, NULL);
1684 if ( GetSelectedCount() >0 && (!pSelLogEntry->m_CommitHash.IsEmpty()))
1686 bool bAddSeparator = false;
1687 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
1689 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT) && m_hasWC)
1691 CString head;
1692 int headindex;
1693 headindex = this->GetHeadIndex();
1694 if(headindex>=0)
1696 head.Format(_T("HEAD~%d"),LastSelect-headindex);
1697 CGitHash hash=g_Git.GetHash(head);
1698 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(LastSelect));
1699 if(pLastEntry->m_CommitHash == hash) {
1700 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
1701 bAddSeparator = true;
1706 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK) && !isHeadCommit && m_hasWC) {
1707 if (GetSelectedCount() >= 2)
1708 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSIONS, IDI_EXPORT);
1709 else
1710 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
1711 bAddSeparator = true;
1714 if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))
1715 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH)) {
1716 popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH);
1717 bAddSeparator = true;
1720 if (bAddSeparator)
1721 popup.AppendMenu(MF_SEPARATOR, NULL);
1724 #if 0
1725 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
1726 // {
1727 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
1728 // }
1729 // if (GetSelectedCount() == 1)
1730 // {
1731 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
1732 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
1733 // popup.AppendMenu(MF_SEPARATOR, NULL);
1734 // }
1735 #endif
1737 if (GetSelectedCount() == 1)
1739 bool bAddSeparator = false;
1740 if(m_ContextMenuMask&GetContextMenuBit(ID_PUSH) && m_HashMap[pSelLogEntry->m_CommitHash].size() >= 1)
1742 // show the push-option only if the log entry has an associated local branch
1743 bool isLocal = false;
1744 for(int i=0; isLocal == false && i < m_HashMap[pSelLogEntry->m_CommitHash].size(); i++)
1746 if (m_HashMap[pSelLogEntry->m_CommitHash][i].Find(_T("refs/heads/")) == 0)
1747 isLocal = true;
1749 if (isLocal)
1751 popup.AppendMenuIcon(ID_PUSH, IDS_LOG_PUSH, IDI_PUSH);
1752 bAddSeparator = true;
1756 if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE))
1758 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() )
1760 std::vector<CString *> branchs;
1761 for (int i = 0; i < m_HashMap[pSelLogEntry->m_CommitHash].size(); i++)
1763 if(m_HashMap[pSelLogEntry->m_CommitHash][i] != currentBranch)
1764 branchs.push_back(&m_HashMap[pSelLogEntry->m_CommitHash][i]);
1766 CString str;
1767 if (branchs.size() == 1)
1769 str.LoadString(IDS_DELETE_BRANCHTAG_SHORT);
1770 str+=_T(" ");
1771 str += *branchs[0];
1772 popup.AppendMenuIcon(ID_DELETE, str, IDI_DELETE);
1773 popup.SetMenuItemData(ID_DELETE, (ULONG_PTR)branchs[0]);
1774 bAddSeparator = true;
1776 else if (branchs.size() > 1)
1778 str.LoadString(IDS_DELETE_BRANCHTAG);
1779 submenu.CreatePopupMenu();
1780 for (int i = 0; i < branchs.size(); i++)
1782 submenu.AppendMenuIcon(ID_DELETE + (i << 16), *branchs[i]);
1783 submenu.SetMenuItemData(ID_DELETE + (i << 16), (ULONG_PTR)branchs[i]);
1786 popup.AppendMenuIcon(ID_DELETE,str, IDI_DELETE, submenu.m_hMenu);
1787 bAddSeparator = true;
1790 } // m_ContextMenuMask &GetContextMenuBit(ID_DELETE)
1791 if (bAddSeparator)
1792 popup.AppendMenu(MF_SEPARATOR, NULL);
1793 } // GetSelectedCount() == 1
1795 if (GetSelectedCount() == 1)
1797 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
1798 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH, IDI_COPYCLIP);
1800 if (GetSelectedCount() != 0)
1802 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
1803 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD, IDI_COPYCLIP);
1806 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
1807 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND, IDI_FILTEREDIT);
1809 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
1810 // DialogEnableWindow(IDOK, FALSE);
1811 // SetPromptApp(&theApp);
1813 this->ContextMenuAction(cmd, FirstSelect, LastSelect, &popup);
1815 // EnableOKButton();
1816 } // if (popup.CreatePopupMenu())
1820 bool CGitLogListBase::IsSelectionContinuous()
1822 if ( GetSelectedCount()==1 )
1824 // if only one revision is selected, the selection is of course
1825 // continuous
1826 return true;
1829 POSITION pos = GetFirstSelectedItemPosition();
1830 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
1831 if (bContinuous)
1833 int itemindex = GetNextSelectedItem(pos);
1834 while (pos)
1836 int nextindex = GetNextSelectedItem(pos);
1837 if (nextindex - itemindex > 1)
1839 bContinuous = false;
1840 break;
1842 itemindex = nextindex;
1845 return bContinuous;
1848 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
1851 CString sClipdata;
1852 POSITION pos = GetFirstSelectedItemPosition();
1853 if (pos != NULL)
1855 CString sRev;
1856 sRev.LoadString(IDS_LOG_REVISION);
1857 CString sAuthor;
1858 sAuthor.LoadString(IDS_LOG_AUTHOR);
1859 CString sDate;
1860 sDate.LoadString(IDS_LOG_DATE);
1861 CString sMessage;
1862 sMessage.LoadString(IDS_LOG_MESSAGE);
1863 while (pos)
1865 CString sLogCopyText;
1866 CString sPaths;
1867 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
1869 if(!HashOnly)
1871 //pLogEntry->GetFiles(this)
1872 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
1874 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->GetFiles(this).GetCount(); ++cpPathIndex)
1876 sPaths += ((CTGitPath&)pLogEntry->GetFiles(this)[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->GetFiles(this)[cpPathIndex].GetGitPathString();
1877 sPaths += _T("\r\n");
1879 sPaths.Trim();
1880 CString body = pLogEntry->GetBody();
1881 body.Replace(_T("\n"), _T("\r\n"));
1882 sLogCopyText.Format(_T("%s: %s\r\n%s: %s\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),
1883 (LPCTSTR)sRev, pLogEntry->m_CommitHash.ToString(),
1884 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->GetAuthorName(),
1885 (LPCTSTR)sDate,
1886 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->GetAuthorDate(), m_DateFormat, true, m_bRelativeTimes ),
1887 (LPCTSTR)sMessage, pLogEntry->GetSubject().Trim() + _T("\r\n\r\n") + body.Trim(),
1888 (LPCTSTR)sPaths);
1889 sClipdata += sLogCopyText;
1891 else
1893 sClipdata += pLogEntry->m_CommitHash;
1894 break;
1898 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
1903 void CGitLogListBase::DiffSelectedRevWithPrevious()
1905 if (m_bThreadRunning)
1906 return;
1908 int FirstSelect=-1, LastSelect=-1;
1909 POSITION pos = GetFirstSelectedItemPosition();
1910 FirstSelect = GetNextSelectedItem(pos);
1911 while(pos)
1913 LastSelect = GetNextSelectedItem(pos);
1916 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect, NULL);
1918 #if 0
1919 UpdateLogInfoLabel();
1920 int selIndex = m_LogList.GetSelectionMark();
1921 if (selIndex < 0)
1922 return;
1923 int selCount = m_LogList.GetSelectedCount();
1924 if (selCount != 1)
1925 return;
1927 // Find selected entry in the log list
1928 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1929 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1930 long rev1 = pLogEntry->Rev;
1931 long rev2 = rev1-1;
1932 CTGitPath path = m_path;
1934 // See how many files under the relative root were changed in selected revision
1935 int nChanged = 0;
1936 LogChangedPath * changed = NULL;
1937 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
1939 LogChangedPath * cpath = pLogEntry->pArChangedPaths->SafeGetAt(c);
1940 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
1942 ++nChanged;
1943 changed = cpath;
1947 if (m_path.IsDirectory() && nChanged == 1)
1949 // We're looking at the log for a directory and only one file under dir was changed in the revision
1950 // Do diff on that file instead of whole directory
1951 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
1954 m_bCancelled = FALSE;
1955 DialogEnableWindow(IDOK, FALSE);
1956 SetPromptApp(&theApp);
1957 theApp.DoWaitCursor(1);
1959 if (PromptShown())
1961 GitDiff diff(this, m_hWnd, true);
1962 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
1963 diff.SetHEADPeg(m_LogRevision);
1964 diff.ShowCompare(path, rev2, path, rev1);
1966 else
1968 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
1971 theApp.DoWaitCursor(-1);
1972 EnableOKButton();
1973 #endif
1976 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1978 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
1979 *pResult = -1;
1981 if (pFindInfo->lvfi.flags & LVFI_PARAM)
1982 return;
1983 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
1984 return;
1985 if (pFindInfo->lvfi.psz == 0)
1986 return;
1987 #if 0
1988 CString sCmp = pFindInfo->lvfi.psz;
1989 CString sRev;
1990 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
1992 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(i));
1993 sRev.Format(_T("%ld"), pLogEntry->Rev);
1994 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
1996 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
1998 *pResult = i;
1999 return;
2002 else
2004 if (sCmp.Compare(sRev)==0)
2006 *pResult = i;
2007 return;
2011 if (pFindInfo->lvfi.flags & LVFI_WRAP)
2013 for (int i=0; i<pFindInfo->iStart; ++i)
2015 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(i));
2016 sRev.Format(_T("%ld"), pLogEntry->Rev);
2017 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
2019 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
2021 *pResult = i;
2022 return;
2025 else
2027 if (sCmp.Compare(sRev)==0)
2029 *pResult = i;
2030 return;
2035 #endif
2036 *pResult = -1;
2039 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
2041 ClearText();
2044 this->m_arShownList.SafeRemoveAll();
2046 this->m_logEntries.ClearAll();
2047 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
2049 //this->m_logEntries.ParserFromLog();
2050 SetItemCountEx(this->m_logEntries.size());
2052 for(unsigned int i=0;i<m_logEntries.size();i++)
2054 if(m_IsOldFirst)
2056 m_logEntries.GetGitRevAt(m_logEntries.size()-i-1).m_IsFull=TRUE;
2057 this->m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(m_logEntries.size()-i-1));
2060 else
2062 m_logEntries.GetGitRevAt(i).m_IsFull=TRUE;
2063 this->m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(i));
2067 if(path)
2068 m_Path=*path;
2069 return 0;
2073 int CGitLogListBase::BeginFetchLog()
2075 ClearText();
2077 this->m_arShownList.SafeRemoveAll();
2079 this->m_logEntries.ClearAll();
2080 git_init();
2082 this->m_LogCache.ClearAllParent();
2084 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
2086 CTGitPath *path;
2087 if(this->m_Path.IsEmpty())
2088 path=NULL;
2089 else
2090 path=&this->m_Path;
2092 CString hash;
2093 int mask;
2094 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
2095 // if(this->m_bAllBranch)
2096 mask |= m_ShowMask ;
2098 if(m_bShowWC)
2100 this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev.m_CommitHash);
2101 ResetWcRev();
2102 this->m_LogCache.m_HashMap[m_wcRev.m_CommitHash]=m_wcRev;
2105 CString *pFrom, *pTo;
2106 pFrom = pTo = NULL;
2107 CString head(_T("HEAD"));
2108 if(!this->m_startrev.IsEmpty())
2110 pFrom = &this->m_startrev;
2111 if(!this->m_endrev.IsEmpty())
2112 pTo = &this->m_endrev;
2113 else
2114 pTo = &head;
2117 CFilterData data;
2118 data.m_From = m_From;
2119 data.m_To =m_To;
2121 #if 0 /* use tortoiegit filter */
2122 if(this->m_nSelectedFilter == LOGFILTER_ALL || m_nSelectedFilter == LOGFILTER_AUTHORS)
2123 data.m_Author = this->m_sFilterText;
2125 if(this->m_nSelectedFilter == LOGFILTER_ALL || m_nSelectedFilter == LOGFILTER_MESSAGES)
2126 data.m_MessageFilter = this->m_sFilterText;
2128 data.m_IsRegex = m_bFilterWithRegex;
2129 #endif
2131 CString cmd=g_Git.GetLogCmd(m_StartRef,path,-1,mask,pFrom,pTo,true,&data);
2133 //this->m_logEntries.ParserFromLog();
2134 if(IsInWorkingThread())
2136 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
2138 else
2140 SetItemCountEx(this->m_logEntries.size());
2143 git_init();
2145 if(g_Git.IsInitRepos())
2146 return 0;
2148 if(git_open_log(&m_DllGitLog,CUnicodeUtils::GetMulti(cmd,CP_ACP).GetBuffer()))
2150 return -1;
2153 return 0;
2156 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
2158 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
2160 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
2162 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
2164 DiffSelectedRevWithPrevious();
2165 return TRUE;
2168 #if 0
2169 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
2171 DiffSelectedFile();
2172 return TRUE;
2174 #endif
2176 else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 'A' && GetAsyncKeyState(VK_CONTROL)&0x8000)
2178 // select all entries
2179 for (int i=0; i<GetItemCount(); ++i)
2181 SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
2183 return TRUE;
2186 #if 0
2187 if (m_hAccel && !bSkipAccelerator)
2189 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
2190 if (ret)
2191 return TRUE;
2194 #endif
2195 //m_tooltips.RelayEvent(pMsg);
2196 return __super::PreTranslateMessage(pMsg);
2199 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
2201 // a double click on an entry in the revision list has happened
2202 *pResult = 0;
2204 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
2205 DiffSelectedRevWithPrevious();
2208 int CGitLogListBase::FetchLogAsync(void * data)
2210 m_ProcData=data;
2211 m_bExitThread=FALSE;
2212 InterlockedExchange(&m_bThreadRunning, TRUE);
2213 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2214 m_LoadingThread = AfxBeginThread(LogThreadEntry, this, THREAD_PRIORITY_LOWEST);
2215 if (m_LoadingThread ==NULL)
2217 InterlockedExchange(&m_bThreadRunning, FALSE);
2218 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2219 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
2220 return -1;
2222 return 0;
2225 //this is the thread function which calls the subversion function
2226 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
2228 return ((CGitLogListBase*)pVoid)->LogThread();
2231 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
2233 //CTime time;
2234 oldest=CTime::GetCurrentTime();
2235 latest=CTime(1971,1,2,0,0,0);
2236 for(unsigned int i=0;i<m_logEntries.size();i++)
2238 if(m_logEntries[i].IsEmpty())
2239 continue;
2241 if(m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime() < oldest.GetTime())
2242 oldest = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
2244 if(m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime() > latest.GetTime())
2245 latest = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
2249 if(latest<oldest)
2250 latest=oldest;
2253 UINT CGitLogListBase::LogThread()
2255 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
2257 InterlockedExchange(&m_bThreadRunning, TRUE);
2258 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2260 ULONGLONG t1,t2;
2262 if(BeginFetchLog())
2264 InterlockedExchange(&m_bThreadRunning, FALSE);
2265 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2267 return -1;
2270 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
2271 bool bRegex = false;
2272 if (m_bFilterWithRegex)
2273 bRegex = ValidateRegexp(m_sFilterText, pat, false);
2275 TRACE(_T("\n===Begin===\n"));
2276 //Update work copy item;
2278 if( m_logEntries.size() > 0)
2280 GitRev *pRev = &m_logEntries.GetGitRevAt(0);
2282 m_arShownList.SafeAdd(pRev);
2286 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2288 // store commit number of the last selected commit/line before the refresh or -1
2289 int lastSelectedHashNItem = -1;
2291 if(!g_Git.IsInitRepos())
2293 g_Git.m_critGitDllSec.Lock();
2294 git_get_log_firstcommit(m_DllGitLog);
2295 int total = git_get_log_estimate_commit_count(m_DllGitLog);
2296 g_Git.m_critGitDllSec.Unlock();
2298 GIT_COMMIT commit;
2299 t2=t1=GetTickCount();
2300 int oldprecentage = 0;
2301 int oldsize=m_logEntries.size();
2302 int ret=0;
2303 while( ret== 0)
2305 g_Git.m_critGitDllSec.Lock();
2306 ret = git_get_log_nextcommit(this->m_DllGitLog, &commit, 0);
2307 g_Git.m_critGitDllSec.Unlock();
2309 if(ret)
2310 break;
2312 //printf("%s\r\n",commit.GetSubject());
2313 if(m_bExitThread)
2314 break;
2316 CGitHash hash = (char*)commit.m_hash ;
2318 GitRev *pRev = m_LogCache.GetCacheData(hash);
2319 pRev->m_GitCommit = commit;
2320 InterlockedExchange(&pRev->m_IsCommitParsed, FALSE);
2322 char *note=NULL;
2323 g_Git.m_critGitDllSec.Lock();
2324 git_get_notes(commit.m_hash,&note);
2325 g_Git.m_critGitDllSec.Unlock();
2327 if(note)
2329 pRev->m_Notes.Empty();
2330 g_Git.StringAppend(&pRev->m_Notes,(BYTE*)note);
2333 if(!pRev->m_IsDiffFiles)
2335 pRev->m_CallDiffAsync = DiffAsync;
2338 pRev->ParserParentFromCommit(&commit);
2340 #ifdef DEBUG
2341 pRev->DbgPrint();
2342 TRACE(_T("\n"));
2343 #endif
2345 if(!m_sFilterText.IsEmpty())
2347 if(!IsMatchFilter(bRegex,pRev,pat))
2348 continue;
2350 this->m_critSec.Lock();
2351 m_logEntries.push_back(hash);
2352 m_arShownList.SafeAdd(pRev);
2353 this->m_critSec.Unlock();
2355 if (lastSelectedHashNItem == -1 && hash == m_lastSelectedHash)
2356 lastSelectedHashNItem = m_arShownList.GetCount() - 1;
2358 t2=GetTickCount();
2360 if(t2-t1>500 || (m_logEntries.size()-oldsize >100))
2362 //update UI
2363 int percent=m_logEntries.size()*100/total + GITLOG_START+1;
2364 if(percent > 99)
2365 percent =99;
2366 if(percent < GITLOG_START)
2367 percent = GITLOG_START +1;
2369 oldsize = m_logEntries.size();
2370 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL);
2372 //if( percent > oldprecentage )
2374 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
2375 oldprecentage = percent;
2377 t1 = t2;
2380 g_Git.m_critGitDllSec.Lock();
2381 git_close_log(m_DllGitLog);
2382 g_Git.m_critGitDllSec.Unlock();
2386 // restore last selected item
2387 if (lastSelectedHashNItem >= 0)
2389 SetItemState(lastSelectedHashNItem, LVIS_SELECTED, LVIS_SELECTED);
2390 EnsureVisible(lastSelectedHashNItem, FALSE);
2393 //Update UI;
2394 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL);
2395 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
2397 InterlockedExchange(&m_bThreadRunning, FALSE);
2399 return 0;
2402 void CGitLogListBase::Refresh(BOOL IsCleanFilter)
2404 SafeTerminateThread();
2406 this->SetItemCountEx(0);
2407 this->Clear();
2409 ResetWcRev();
2411 //Update branch and Tag info
2412 ReloadHashMap();
2413 //Assume Thread have exited
2414 //if(!m_bThreadRunning)
2416 m_logEntries.clear();
2418 if(IsCleanFilter)
2420 m_sFilterText.Empty();
2421 m_From=-1;
2422 m_To=-1;
2425 InterlockedExchange(&m_bExitThread,FALSE);
2427 InterlockedExchange(&m_bThreadRunning, TRUE);
2428 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2429 if ( (m_LoadingThread=AfxBeginThread(LogThreadEntry, this)) ==NULL)
2431 InterlockedExchange(&m_bThreadRunning, FALSE);
2432 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2433 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
2437 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
2441 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
2442 if (!bMatchCase)
2443 type |= tr1::regex_constants::icase;
2444 pat = tr1::wregex(regexp_str, type);
2445 return true;
2447 catch (exception) {}
2448 return false;
2450 BOOL CGitLogListBase::IsMatchFilter(bool bRegex, GitRev *pRev, tr1::wregex &pat)
2453 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
2454 CString sRev;
2456 if ((bRegex)&&(m_bFilterWithRegex))
2458 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
2460 if(this->m_bShowBugtraqColumn)
2462 CString sBugIds = m_ProjectProperties.FindBugID(pRev->GetSubject());
2464 ATLTRACE(_T("bugID = \"%s\"\n"), sBugIds);
2465 if (regex_search(wstring(sBugIds), pat, flags))
2467 return TRUE;
2472 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_SUBJECT)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2474 ATLTRACE(_T("messge = \"%s\"\n"), pRev->GetSubject());
2475 if (regex_search(wstring((LPCTSTR)pRev->GetSubject()), pat, flags))
2477 return TRUE;
2481 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2483 ATLTRACE(_T("messge = \"%s\"\n"),pRev->GetBody());
2484 if (regex_search(wstring((LPCTSTR)pRev->GetBody()), pat, flags))
2486 return TRUE;
2490 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
2492 if (regex_search(wstring(pRev->GetAuthorName()), pat, flags))
2494 return TRUE;
2497 if (regex_search(wstring(pRev->GetCommitterName()), pat, flags))
2499 return TRUE;
2503 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
2505 sRev.Format(_T("%s"), pRev->m_CommitHash.ToString());
2506 if (regex_search(wstring((LPCTSTR)sRev), pat, flags))
2508 return TRUE;
2512 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
2514 CTGitPathList *pathList=NULL;
2515 if( pRev->m_IsDiffFiles)
2516 pathList = &pRev->GetFiles(this);
2517 else
2519 if(!pRev->m_IsSimpleListReady)
2520 pRev->SafeGetSimpleList(&g_Git);
2523 if(pathList)
2524 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList->GetCount(); ++cpPathIndex)
2526 if (regex_search(wstring((LPCTSTR)pathList->m_paths.at(cpPathIndex).GetGitOldPathString()), pat, flags))
2528 return true;
2530 if (regex_search(wstring((LPCTSTR)pathList->m_paths.at(cpPathIndex).GetGitPathString()), pat, flags))
2532 return true;
2536 for(INT_PTR i=0;i<pRev->m_SimpleFileList.size();i++)
2538 if (regex_search(wstring((LPCTSTR)pRev->m_SimpleFileList[i]), pat, flags))
2540 return true;
2545 else
2547 CString find = m_sFilterText;
2548 find.MakeLower();
2550 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
2552 if(this->m_bShowBugtraqColumn)
2554 CString sBugIds = m_ProjectProperties.FindBugID(pRev->GetSubject());
2556 sBugIds.MakeLower();
2557 if ((sBugIds.Find(find) >= 0))
2559 return TRUE;
2564 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_SUBJECT)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2566 CString msg = pRev->GetSubject();
2568 msg = msg.MakeLower();
2569 if ((msg.Find(find) >= 0))
2571 return TRUE;
2575 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2577 CString msg = pRev->GetBody();
2579 msg = msg.MakeLower();
2580 if ((msg.Find(find) >= 0))
2582 return TRUE;
2586 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
2588 CString msg = pRev->GetAuthorName();
2589 msg = msg.MakeLower();
2590 if ((msg.Find(find) >= 0))
2592 return TRUE;
2596 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
2598 sRev.Format(_T("%s"), pRev->m_CommitHash.ToString());
2599 if ((sRev.Find(find) >= 0))
2601 return TRUE;
2605 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
2607 CTGitPathList *pathList=NULL;
2608 if( pRev->m_IsDiffFiles)
2609 pathList = &pRev->GetFiles(this);
2610 else
2612 if(!pRev->m_IsSimpleListReady)
2613 pRev->SafeGetSimpleList(&g_Git);
2615 if(pathList)
2616 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList->GetCount() ; ++cpPathIndex)
2618 CTGitPath *cpath = &pathList->m_paths.at(cpPathIndex);
2619 CString path = cpath->GetGitOldPathString();
2620 path.MakeLower();
2621 if ((path.Find(find)>=0))
2623 return true;
2625 path = cpath->GetGitPathString();
2626 path.MakeLower();
2627 if ((path.Find(find)>=0))
2629 return true;
2633 for (INT_PTR i=0;i<pRev->m_SimpleFileList.size();i++)
2635 CString path = pRev->m_SimpleFileList[i];
2636 path.MakeLower();
2637 if ((path.Find(find)>=0))
2639 return true;
2643 } // else (from if (bRegex))
2644 return FALSE;
2648 void CGitLogListBase::RecalculateShownList(CThreadSafePtrArray * pShownlist)
2651 pShownlist->SafeRemoveAll();
2653 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
2654 bool bRegex = false;
2655 if (m_bFilterWithRegex)
2656 bRegex = ValidateRegexp(m_sFilterText, pat, false);
2658 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
2659 CString sRev;
2660 for (DWORD i=0; i<m_logEntries.size(); ++i)
2662 if ((bRegex)&&(m_bFilterWithRegex))
2664 #if 0
2665 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
2667 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
2668 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
2670 pShownlist->SafeAdd(m_logEntries[i]);
2671 continue;
2674 #endif
2675 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_SUBJECT)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2677 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).GetSubject());
2678 if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).GetSubject()), pat, flags)&&IsEntryInDateRange(i))
2680 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2681 continue;
2684 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2686 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).GetBody());
2687 if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).GetBody()), pat, flags)&&IsEntryInDateRange(i))
2689 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2690 continue;
2693 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
2695 CTGitPathList pathList = m_logEntries.GetGitRevAt(i).GetFiles(this);
2697 bool bGoing = true;
2698 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList.GetCount() && bGoing; ++cpPathIndex)
2700 CTGitPath cpath = pathList[cpPathIndex];
2701 if (regex_search(wstring((LPCTSTR)cpath.GetGitOldPathString()), pat, flags)&&IsEntryInDateRange(i))
2703 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2704 bGoing = false;
2705 continue;
2707 if (regex_search(wstring((LPCTSTR)cpath.GetGitPathString()), pat, flags)&&IsEntryInDateRange(i))
2709 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2710 bGoing = false;
2711 continue;
2713 if (regex_search(wstring((LPCTSTR)cpath.GetActionName()), pat, flags)&&IsEntryInDateRange(i))
2715 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2716 bGoing = false;
2717 continue;
2721 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
2723 if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).GetAuthorName()), pat, flags)&&IsEntryInDateRange(i))
2725 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2726 continue;
2729 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
2731 sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash.ToString());
2732 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
2734 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2735 continue;
2738 } // if (bRegex)
2739 else
2741 CString find = m_sFilterText;
2742 find.MakeLower();
2743 #if 0
2744 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
2746 CString sBugIDs = m_logEntries[i]->sBugIDs;
2748 sBugIDs = sBugIDs.MakeLower();
2749 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
2751 pShownlist->SafeAdd(m_logEntries[i]);
2752 continue;
2755 #endif
2756 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_SUBJECT)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2758 CString msg = m_logEntries.GetGitRevAt(i).GetSubject();
2760 msg = msg.MakeLower();
2761 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
2763 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2764 continue;
2767 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
2769 CString msg = m_logEntries.GetGitRevAt(i).GetBody();
2771 msg = msg.MakeLower();
2772 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
2774 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2775 continue;
2778 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
2780 CTGitPathList pathList = m_logEntries.GetGitRevAt(i).GetFiles(this);
2782 bool bGoing = true;
2783 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList.GetCount() && bGoing; ++cpPathIndex)
2785 CTGitPath cpath = pathList[cpPathIndex];
2786 CString path = cpath.GetGitOldPathString();
2787 path.MakeLower();
2788 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
2790 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2791 bGoing = false;
2792 continue;
2794 path = cpath.GetGitPathString();
2795 path.MakeLower();
2796 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
2798 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2799 bGoing = false;
2800 continue;
2802 path = cpath.GetActionName();
2803 path.MakeLower();
2804 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
2806 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2807 bGoing = false;
2808 continue;
2812 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
2814 CString msg = m_logEntries.GetGitRevAt(i).GetAuthorName();
2815 msg = msg.MakeLower();
2816 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
2818 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2819 continue;
2822 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
2824 sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash.ToString());
2825 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
2827 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
2828 continue;
2831 } // else (from if (bRegex))
2832 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
2836 BOOL CGitLogListBase::IsEntryInDateRange(int /*i*/)
2839 __time64_t time = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
2841 if(m_From == -1)
2842 if(m_To == -1)
2843 return true;
2844 else
2845 return time <= m_To;
2846 else
2847 if(m_To == -1)
2848 return time >= m_From;
2849 else
2850 return ((time >= m_From)&&(time <= m_To));
2852 return TRUE; /* git dll will filter time range */
2854 // return TRUE;
2856 void CGitLogListBase::StartFilter()
2858 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2859 RecalculateShownList(&m_arShownList);
2860 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2863 DeleteAllItems();
2864 SetItemCountEx(ShownCountWithStopped());
2865 RedrawItems(0, ShownCountWithStopped());
2866 Invalidate();
2869 void CGitLogListBase::RemoveFilter()
2872 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2874 m_arShownList.SafeRemoveAll();
2876 // reset the time filter too
2877 #if 0
2878 m_timFrom = (__time64_t(m_tFrom));
2879 m_timTo = (__time64_t(m_tTo));
2880 m_DateFrom.SetTime(&m_timFrom);
2881 m_DateTo.SetTime(&m_timTo);
2882 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
2883 m_DateTo.SetRange(&m_timFrom, &m_timTo);
2884 #endif
2886 for (DWORD i=0; i<m_logEntries.size(); ++i)
2888 if(this->m_IsOldFirst)
2890 m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(m_logEntries.size()-i-1));
2892 else
2894 m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(i));
2897 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
2898 DeleteAllItems();
2899 SetItemCountEx(ShownCountWithStopped());
2900 RedrawItems(0, ShownCountWithStopped());
2902 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2905 void CGitLogListBase::Clear()
2907 m_arShownList.SafeRemoveAll();
2908 DeleteAllItems();
2910 m_logEntries.ClearAll();
2914 void CGitLogListBase::OnDestroy()
2916 // save the column widths to the registry
2917 SaveColumnWidths();
2919 SafeTerminateThread();
2920 SafeTerminateAsyncDiffThread();
2922 int retry = 0;
2923 while(m_LogCache.SaveCache())
2925 if(retry > 5)
2926 break;
2927 Sleep(1000);
2929 retry++;
2931 //if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
2932 // MB_YESNO) == IDNO)
2933 // break;
2936 CHintListCtrl::OnDestroy();
2939 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
2941 UNREFERENCED_PARAMETER(lParam);
2942 CRect rect;
2943 int i=(int)wParam;
2944 this->GetItemRect(i,&rect,LVIR_BOUNDS);
2945 this->InvalidateRect(rect);
2947 return 0;
2951 * Save column widths to the registry
2953 void CGitLogListBase::SaveColumnWidths()
2955 int maxcol = m_ColumnManager.GetColumnCount();
2957 for (int col = 0; col < maxcol; col++)
2958 if (m_ColumnManager.IsVisible (col))
2959 m_ColumnManager.ColumnResized (col);
2961 m_ColumnManager.WriteSettings();
2964 int CGitLogListBase::GetHeadIndex()
2966 if(m_HeadHash.IsEmpty())
2967 return -1;
2969 for(int i=0;i<m_arShownList.GetCount();i++)
2971 GitRev *pRev = (GitRev*)m_arShownList[i];
2972 if(pRev)
2974 if(pRev->m_CommitHash.ToString() == m_HeadHash )
2975 return i;
2978 return -1;
2980 void CGitLogListBase::OnFind()
2982 if (!m_pFindDialog)
2984 m_pFindDialog = new CFindDlg(this);
2985 m_pFindDialog->Create(this);
2988 void CGitLogListBase::OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult)
2990 m_ColumnManager.OnHdnBegintrack(pNMHDR, pResult);
2992 void CGitLogListBase::OnHdnItemchanging(NMHDR *pNMHDR, LRESULT *pResult)
2994 if(!m_ColumnManager.OnHdnItemchanging(pNMHDR, pResult))
2995 Default();
2997 LRESULT CGitLogListBase::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
3000 ASSERT(m_pFindDialog != NULL);
3001 bool bFound = false;
3002 int i=0;
3004 if (m_pFindDialog->IsTerminating())
3006 // invalidate the handle identifying the dialog box.
3007 m_pFindDialog = NULL;
3008 return 0;
3011 if(m_pFindDialog->IsRef())
3013 CString str;
3014 str=m_pFindDialog->GetFindString();
3016 CGitHash hash;
3018 if(!str.IsEmpty())
3019 hash = g_Git.GetHash(str);
3021 if(!hash.IsEmpty())
3023 for (i = 0; i<m_arShownList.GetCount(); i++)
3025 GitRev* pLogEntry = (GitRev*)m_arShownList.SafeGetAt(i);
3026 if(pLogEntry && pLogEntry->m_CommitHash == hash)
3028 bFound = true;
3029 break;
3036 if(m_pFindDialog->FindNext())
3038 //read data from dialog
3039 CString FindText = m_pFindDialog->GetFindString();
3040 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
3042 tr1::wregex pat;
3043 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
3045 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;
3048 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)
3050 GitRev* pLogEntry = (GitRev*)m_arShownList.SafeGetAt(i);
3052 CString str;
3053 str+=pLogEntry->m_CommitHash.ToString();
3054 str+=_T("\n");
3056 for(int j=0;j<this->m_HashMap[pLogEntry->m_CommitHash].size();j++)
3058 str+=m_HashMap[pLogEntry->m_CommitHash][j];
3059 str+=_T("\n");
3062 str+=pLogEntry->GetAuthorEmail();
3063 str+=_T("\n");
3064 str+=pLogEntry->GetAuthorName();
3065 str+=_T("\n");
3066 str+=pLogEntry->GetBody();
3067 str+=_T("\n");
3068 str+=pLogEntry->GetCommitterEmail();
3069 str+=_T("\n");
3070 str+=pLogEntry->GetCommitterName();
3071 str+=_T("\n");
3072 str+=pLogEntry->GetSubject();
3073 str+=_T("\n");
3076 /*Because changed files list is loaded on demand when gui show,
3077 files will empty when files have not fetched.
3079 we can add it back by using one-way diff(with outnumber changed and rename detect.
3080 here just need changed filename list. one-way is much quicker.
3082 if(pLogEntry->m_IsFull)
3084 for(int i=0;i<pLogEntry->GetFiles(this).GetCount();i++)
3086 str+=pLogEntry->GetFiles(this)[i].GetWinPath();
3087 str+=_T("\n");
3088 str+=pLogEntry->GetFiles(this)[i].GetGitOldPathString();
3089 str+=_T("\n");
3092 else
3094 if(!pLogEntry->m_IsSimpleListReady)
3095 pLogEntry->SafeGetSimpleList(&g_Git);
3097 for(int i=0;i<pLogEntry->m_SimpleFileList.size();i++)
3099 str+=pLogEntry->m_SimpleFileList[i];
3100 str+=_T("\n");
3106 if (bRegex)
3108 if (regex_search(wstring(str), pat, flags))
3110 bFound = true;
3111 break;
3114 else
3116 if (bMatchCase)
3118 if (str.Find(FindText) >= 0)
3120 bFound = true;
3121 break;
3125 else
3127 CString msg = str;
3128 msg = msg.MakeLower();
3129 CString find = FindText.MakeLower();
3130 if (msg.Find(find) >= 0)
3132 bFound = TRUE;
3133 break;
3137 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
3139 } // if(m_pFindDialog->FindNext())
3140 //UpdateLogInfoLabel();
3142 if (bFound)
3144 this->m_nSearchIndex = i;
3145 EnsureVisible(i, FALSE);
3146 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED);
3147 SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
3148 SetSelectionMark(i);
3149 //FillLogMessageCtrl();
3150 UpdateData(FALSE);
3151 m_nSearchIndex++;
3152 if (m_nSearchIndex >= m_arShownList.GetCount())
3153 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
3156 return 0;
3159 void CGitLogListBase::OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult)
3161 m_ColumnManager.OnColumnResized(pNMHDR,pResult);
3163 *pResult = FALSE;
3166 void CGitLogListBase::OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult)
3168 m_ColumnManager.OnColumnMoved(pNMHDR, pResult);
3170 Invalidate(FALSE);