OSDN Git Service

Log Dlg Statbutton work'
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / LogDlg.cpp
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseGit\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #include "stdafx.h"\r
20 #include "TortoiseProc.h"\r
21 #include "cursor.h"\r
22 #include "InputDlg.h"\r
23 #include "PropDlg.h"\r
24 #include "SVNProgressDlg.h"\r
25 #include "ProgressDlg.h"\r
26 //#include "RepositoryBrowser.h"\r
27 //#include "CopyDlg.h"\r
28 #include "StatGraphDlg.h"\r
29 #include "Logdlg.h"\r
30 #include "MessageBox.h"\r
31 #include "Registry.h"\r
32 #include "AppUtils.h"\r
33 #include "PathUtils.h"\r
34 #include "StringUtils.h"\r
35 #include "UnicodeUtils.h"\r
36 #include "TempFile.h"\r
37 //#include "GitInfo.h"\r
38 //#include "GitDiff.h"\r
39 #include "IconMenu.h"\r
40 //#include "RevisionRangeDlg.h"\r
41 //#include "BrowseFolder.h"\r
42 //#include "BlameDlg.h"\r
43 //#include "Blame.h"\r
44 //#include "GitHelpers.h"\r
45 #include "GitStatus.h"\r
46 //#include "LogDlgHelper.h"\r
47 //#include "CachedLogInfo.h"\r
48 //#include "RepositoryInfo.h"\r
49 //#include "EditPropertiesDlg.h"\r
50 #include "FileDiffDlg.h"\r
51 \r
52 \r
53 const UINT CLogDlg::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING);\r
54 \r
55 \r
56 \r
57 \r
58 IMPLEMENT_DYNAMIC(CLogDlg, CResizableStandAloneDialog)\r
59 CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)\r
60         : CResizableStandAloneDialog(CLogDlg::IDD, pParent)\r
61         , m_logcounter(0)\r
62         , m_nSearchIndex(0)\r
63         , m_wParam(0)\r
64         , m_currentChangedArray(NULL)\r
65         , m_nSortColumn(0)\r
66         , m_bShowedAll(false)\r
67         , m_bSelect(false)\r
68         , m_regLastStrict(_T("Software\\TortoiseGit\\LastLogStrict"), FALSE)\r
69         \r
70         , m_bSelectionMustBeContinuous(false)\r
71         , m_bShowBugtraqColumn(false)\r
72         , m_lowestRev(_T(""))\r
73         \r
74         , m_sLogInfo(_T(""))\r
75         , m_pFindDialog(NULL)\r
76         , m_bCancelled(FALSE)\r
77         , m_pNotifyWindow(NULL)\r
78         \r
79         , m_bAscending(FALSE)\r
80 \r
81         , m_limit(0)\r
82         , m_childCounter(0)\r
83         , m_maxChild(0)\r
84         , m_bIncludeMerges(FALSE)\r
85         , m_hAccel(NULL)\r
86         , m_bVista(false)\r
87 {\r
88         m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);\r
89         \r
90 }\r
91 \r
92 CLogDlg::~CLogDlg()\r
93 {\r
94         \r
95     m_CurrentFilteredChangedArray.RemoveAll();\r
96         \r
97 \r
98 \r
99         \r
100 }\r
101 \r
102 void CLogDlg::DoDataExchange(CDataExchange* pDX)\r
103 {\r
104         CResizableStandAloneDialog::DoDataExchange(pDX);\r
105         DDX_Control(pDX, IDC_LOGLIST, m_LogList);\r
106         DDX_Control(pDX, IDC_LOGMSG, m_ChangedFileListCtrl);\r
107         DDX_Control(pDX, IDC_PROGRESS, m_LogProgress);\r
108         DDX_Control(pDX, IDC_SPLITTERTOP, m_wndSplitter1);\r
109         DDX_Control(pDX, IDC_SPLITTERBOTTOM, m_wndSplitter2);\r
110         DDX_Check(pDX, IDC_CHECK_STOPONCOPY, m_bStrict);\r
111         DDX_Text(pDX, IDC_SEARCHEDIT, m_sFilterText);\r
112         DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);\r
113         DDX_Control(pDX, IDC_DATETO, m_DateTo);\r
114         DDX_Control(pDX, IDC_HIDEPATHS, m_cHidePaths);\r
115         DDX_Control(pDX, IDC_GETALL, m_btnShow);\r
116         DDX_Text(pDX, IDC_LOGINFO, m_sLogInfo);\r
117         DDX_Check(pDX, IDC_INCLUDEMERGE, m_bIncludeMerges);\r
118         DDX_Control(pDX, IDC_SEARCHEDIT, m_cFilter);\r
119 }\r
120 \r
121 BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)\r
122         ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage) \r
123         ON_BN_CLICKED(IDC_GETALL, OnBnClickedGetall)\r
124         //ON_NOTIFY(NM_DBLCLK, IDC_LOGMSG, OnNMDblclkChangedFileList)\r
125         ON_WM_CONTEXTMENU()\r
126         ON_WM_SETCURSOR()\r
127         ON_BN_CLICKED(IDHELP, OnBnClickedHelp)\r
128         ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGLIST, OnLvnItemchangedLoglist)\r
129         ON_NOTIFY(EN_LINK, IDC_MSGVIEW, OnEnLinkMsgview)\r
130         ON_BN_CLICKED(IDC_STATBUTTON, OnBnClickedStatbutton)\r
131         \r
132         ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)\r
133         ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)\r
134         \r
135         ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)\r
136         ON_WM_TIMER()\r
137         ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)\r
138         ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)\r
139         ON_BN_CLICKED(IDC_NEXTHUNDRED, OnBnClickedNexthundred)\r
140         //ON_NOTIFY(NM_CUSTOMDRAW, IDC_LOGMSG, OnNMCustomdrawChangedFileList)\r
141         //ON_NOTIFY(LVN_GETDISPINFO, IDC_LOGMSG, OnLvnGetdispinfoChangedFileList)\r
142         ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST   , OnLvnColumnclick)\r
143         //ON_NOTIFY(LVN_COLUMNCLICK, IDC_LOGMSG, OnLvnColumnclickChangedFileList)\r
144         ON_BN_CLICKED(IDC_HIDEPATHS, OnBnClickedHidepaths)\r
145         \r
146         ON_BN_CLICKED(IDC_CHECK_STOPONCOPY, &CLogDlg::OnBnClickedCheckStoponcopy)\r
147         ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)\r
148         ON_NOTIFY(DTN_DROPDOWN, IDC_DATETO, &CLogDlg::OnDtnDropdownDateto)\r
149         ON_WM_SIZE()\r
150         ON_BN_CLICKED(IDC_INCLUDEMERGE, &CLogDlg::OnBnClickedIncludemerge)\r
151         ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)\r
152         ON_COMMAND(ID_LOGDLG_REFRESH,&CLogDlg::OnRefresh)\r
153         ON_COMMAND(ID_LOGDLG_FIND,&CLogDlg::OnFind)\r
154         ON_COMMAND(ID_LOGDLG_FOCUSFILTER,&CLogDlg::OnFocusFilter)\r
155         ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)\r
156 END_MESSAGE_MAP()\r
157 \r
158 void CLogDlg::SetParams(const CTGitPath& path, GitRev pegrev, GitRev startrev, GitRev endrev, int limit, BOOL bStrict /* = FALSE */, BOOL bSaveStrict /* = TRUE */)\r
159 {\r
160         m_path = path;\r
161         m_pegrev = pegrev;\r
162         m_startrev = startrev;\r
163         m_LogRevision = startrev;\r
164         m_endrev = endrev;\r
165         m_hasWC = !path.IsUrl();\r
166         m_bStrict = bStrict;\r
167         m_bSaveStrict = bSaveStrict;\r
168         m_limit = limit;\r
169         if (::IsWindow(m_hWnd))\r
170                 UpdateData(FALSE);\r
171 }\r
172 \r
173 BOOL CLogDlg::OnInitDialog()\r
174 {\r
175         CResizableStandAloneDialog::OnInitDialog();\r
176 \r
177         m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));\r
178 \r
179         OSVERSIONINFOEX inf;\r
180         SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));\r
181         inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);\r
182         GetVersionEx((OSVERSIONINFO *)&inf);\r
183         WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);\r
184         m_bVista = (fullver >= 0x0600);\r
185 \r
186         // use the state of the "stop on copy/rename" option from the last time\r
187         if (!m_bStrict)\r
188                 m_bStrict = m_regLastStrict;\r
189         UpdateData(FALSE);\r
190         CString temp;\r
191         if (m_limit)\r
192                 temp.Format(IDS_LOG_SHOWNEXT, m_limit);\r
193         else\r
194                 temp.Format(IDS_LOG_SHOWNEXT, (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100));\r
195 \r
196         SetDlgItemText(IDC_NEXTHUNDRED, temp);\r
197 \r
198         // set the font to use in the log message view, configured in the settings dialog\r
199         CAppUtils::CreateFontForLogs(m_logFont);\r
200         GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);\r
201         // automatically detect URLs in the log message and turn them into links\r
202         GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_AUTOURLDETECT, TRUE, NULL);\r
203         // make the log message rich edit control send a message when the mouse pointer is over a link\r
204         GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK);\r
205         //m_LogList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_SUBITEMIMAGES);\r
206 \r
207         // the "hide unrelated paths" checkbox should be indeterminate\r
208         m_cHidePaths.SetCheck(BST_INDETERMINATE);\r
209 \r
210         \r
211         // if there is a working copy, load the project properties\r
212         // to get information about the bugtraq: integration\r
213         if (m_hasWC)\r
214                 m_ProjectProperties.ReadProps(m_path);\r
215 \r
216         // the bugtraq issue id column is only shown if the bugtraq:url or bugtraq:regex is set\r
217         if ((!m_ProjectProperties.sUrl.IsEmpty())||(!m_ProjectProperties.sCheckRe.IsEmpty()))\r
218                 m_bShowBugtraqColumn = true;\r
219 \r
220         //theme.SetWindowTheme(m_LogList.GetSafeHwnd(), L"Explorer", NULL);\r
221         //theme.SetWindowTheme(m_ChangedFileListCtrl.GetSafeHwnd(), L"Explorer", NULL);\r
222 \r
223         // set up the columns\r
224         m_LogList.DeleteAllItems();\r
225         m_LogList.InsertGitColumn();\r
226 \r
227         m_ChangedFileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |IDS_STATUSLIST_COLADD|IDS_STATUSLIST_COLDEL , _T("LogDlg"));\r
228 \r
229         GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);\r
230 \r
231         m_logcounter = 0;\r
232         m_sMessageBuf.Preallocate(100000);\r
233 \r
234         // set the dialog title to "Log - path/to/whatever/we/show/the/log/for"\r
235         SetDlgTitle(false);\r
236 \r
237         m_tooltips.Create(this);\r
238         CheckRegexpTooltip();\r
239 \r
240         SetSplitterRange();\r
241         \r
242         // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap\r
243         m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);\r
244         m_cFilter.SetInfoIcon(IDI_LOGFILTER);\r
245         m_cFilter.SetValidator(this);\r
246         \r
247         AdjustControlSize(IDC_HIDEPATHS);\r
248         AdjustControlSize(IDC_CHECK_STOPONCOPY);\r
249         AdjustControlSize(IDC_INCLUDEMERGE);\r
250 \r
251         GetClientRect(m_DlgOrigRect);\r
252         m_LogList.GetClientRect(m_LogListOrigRect);\r
253         GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);\r
254         m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);\r
255 \r
256         m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);\r
257         m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);\r
258 \r
259         // resizable stuff\r
260         AddAnchor(IDC_FROMLABEL, TOP_LEFT);\r
261         AddAnchor(IDC_DATEFROM, TOP_LEFT);\r
262         AddAnchor(IDC_TOLABEL, TOP_LEFT);\r
263         AddAnchor(IDC_DATETO, TOP_LEFT);\r
264 \r
265         SetFilterCueText();\r
266         AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);\r
267         \r
268         AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);\r
269         AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);\r
270         AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);\r
271         AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);\r
272         AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);\r
273 \r
274         AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);      \r
275         AddAnchor(IDC_HIDEPATHS, BOTTOM_LEFT);  \r
276         AddAnchor(IDC_CHECK_STOPONCOPY, BOTTOM_LEFT);\r
277         AddAnchor(IDC_INCLUDEMERGE, BOTTOM_LEFT);\r
278         AddAnchor(IDC_GETALL, BOTTOM_LEFT);\r
279         AddAnchor(IDC_NEXTHUNDRED, BOTTOM_LEFT);\r
280         AddAnchor(IDC_REFRESH, BOTTOM_LEFT);\r
281         AddAnchor(IDC_STATBUTTON, BOTTOM_RIGHT);\r
282         AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);\r
283         AddAnchor(IDOK, BOTTOM_RIGHT);\r
284         AddAnchor(IDCANCEL, BOTTOM_RIGHT);\r
285         AddAnchor(IDHELP, BOTTOM_RIGHT);\r
286 \r
287 //      SetPromptParentWindow(m_hWnd);\r
288 \r
289         if (hWndExplorer)\r
290                 CenterWindow(CWnd::FromHandle(hWndExplorer));\r
291         EnableSaveRestore(_T("LogDlg"));\r
292 \r
293         DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));\r
294         DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));\r
295         RECT rcDlg, rcLogList, rcChgMsg;\r
296         GetClientRect(&rcDlg);\r
297         m_LogList.GetWindowRect(&rcLogList);\r
298         ScreenToClient(&rcLogList);\r
299         m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);\r
300         ScreenToClient(&rcChgMsg);\r
301         if (yPos1)\r
302         {\r
303                 RECT rectSplitter;\r
304                 m_wndSplitter1.GetWindowRect(&rectSplitter);\r
305                 ScreenToClient(&rectSplitter);\r
306                 int delta = yPos1 - rectSplitter.top;\r
307 \r
308                 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))\r
309                 {\r
310                         m_wndSplitter1.SetWindowPos(NULL, 0, yPos1, 0, 0, SWP_NOSIZE);\r
311                         DoSizeV1(delta);\r
312                 }\r
313         }\r
314         if (yPos2)\r
315         {\r
316                 RECT rectSplitter;\r
317                 m_wndSplitter2.GetWindowRect(&rectSplitter);\r
318                 ScreenToClient(&rectSplitter);\r
319                 int delta = yPos2 - rectSplitter.top;\r
320 \r
321                 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))\r
322                 {\r
323                         m_wndSplitter2.SetWindowPos(NULL, 0, yPos2, 0, 0, SWP_NOSIZE);\r
324                         DoSizeV2(delta);\r
325                 }\r
326         }\r
327 \r
328         \r
329         if (m_bSelect)\r
330         {\r
331                 // the dialog is used to select revisions\r
332                 if (m_bSelectionMustBeContinuous)\r
333                         DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));\r
334                 else\r
335                         DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);\r
336         }\r
337         else\r
338         {\r
339                 // the dialog is used to just view log messages\r
340                 GetDlgItemText(IDOK, temp);\r
341                 SetDlgItemText(IDCANCEL, temp);\r
342                 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);\r
343         }\r
344         \r
345         // set the choices for the "Show All" button\r
346         temp.LoadString(IDS_LOG_SHOWALL);\r
347         m_btnShow.AddEntry(temp);\r
348         temp.LoadString(IDS_LOG_SHOWRANGE);\r
349         m_btnShow.AddEntry(temp);\r
350         m_btnShow.SetCurrentEntry((LONG)CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry")));\r
351 \r
352         m_mergedRevs.clear();\r
353 \r
354         // first start a thread to obtain the log messages without\r
355         // blocking the dialog\r
356         m_tTo = 0;\r
357         m_tFrom = (DWORD)-1;\r
358 \r
359         m_LogList.FetchLogAsync(LogCallBack,this);\r
360 \r
361         GetDlgItem(IDC_LOGLIST)->SetFocus();\r
362         return FALSE;\r
363 }\r
364 \r
365 void CLogDlg::LogRunStatus(int cur)\r
366 {\r
367         if( cur == GITLOG_START )\r
368         {\r
369                 CString temp;\r
370                 temp.LoadString(IDS_PROGRESSWAIT);\r
371 \r
372                 // change the text of the close button to "Cancel" since now the thread\r
373                 // is running, and simply closing the dialog doesn't work.\r
374                 if (!GetDlgItem(IDOK)->IsWindowVisible())\r
375                 {\r
376                         temp.LoadString(IDS_MSGBOX_CANCEL);\r
377                         SetDlgItemText(IDCANCEL, temp);\r
378                 }\r
379 \r
380                 // We use a progress bar while getting the logs \r
381                 m_LogProgress.SetRange32(0, 100);\r
382                 m_LogProgress.SetPos(0);\r
383 \r
384                 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);\r
385 \r
386                 DialogEnableWindow(IDC_GETALL, FALSE);\r
387                 DialogEnableWindow(IDC_NEXTHUNDRED, FALSE);\r
388                 DialogEnableWindow(IDC_CHECK_STOPONCOPY, FALSE);\r
389                 DialogEnableWindow(IDC_INCLUDEMERGE, FALSE);\r
390                 DialogEnableWindow(IDC_STATBUTTON, FALSE);\r
391                 DialogEnableWindow(IDC_REFRESH, FALSE);\r
392                 DialogEnableWindow(IDC_HIDEPATHS,FALSE);\r
393         }\r
394 \r
395         if( cur == GITLOG_END)\r
396         {\r
397                 \r
398                 if (!m_bShowedAll)\r
399                         DialogEnableWindow(IDC_NEXTHUNDRED, TRUE);\r
400 \r
401                 //DialogEnableWindow(IDC_CHECK_STOPONCOPY, TRUE);\r
402                 //DialogEnableWindow(IDC_INCLUDEMERGE, TRUE);\r
403                 DialogEnableWindow(IDC_STATBUTTON, TRUE);\r
404                 DialogEnableWindow(IDC_REFRESH, TRUE);\r
405 \r
406                 PostMessage(WM_TIMER, LOGFILTER_TIMER);\r
407 \r
408         }\r
409 \r
410         m_LogProgress.SetPos(cur);\r
411 }\r
412 void CLogDlg::SetDlgTitle(bool bOffline)\r
413 {\r
414         if (m_sTitle.IsEmpty())\r
415                 GetWindowText(m_sTitle);\r
416 \r
417         if (bOffline)\r
418         {\r
419                 CString sTemp;\r
420                 if (m_path.IsUrl())\r
421                         sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetUIPathString());\r
422                 else if (m_path.IsDirectory())\r
423                         sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetWinPathString());\r
424                 else\r
425                         sTemp.Format(IDS_LOG_DLGTITLEOFFLINE, (LPCTSTR)m_sTitle, (LPCTSTR)m_path.GetFilename());\r
426                 SetWindowText(sTemp);\r
427         }\r
428         else\r
429         {\r
430                 if (m_path.IsUrl())\r
431                         SetWindowText(m_sTitle + _T(" - ") + m_path.GetUIPathString());\r
432                 else if (m_path.IsDirectory())\r
433                         SetWindowText(m_sTitle + _T(" - ") + m_path.GetWinPathString());\r
434                 else\r
435                         SetWindowText(m_sTitle + _T(" - ") + m_path.GetFilename());\r
436         }\r
437 }\r
438 \r
439 void CLogDlg::CheckRegexpTooltip()\r
440 {\r
441         CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);\r
442         // Since tooltip describes regexp features, show it only if regexps are enabled.\r
443         if (m_bFilterWithRegex)\r
444         {\r
445                 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);\r
446         }\r
447         else\r
448                 m_tooltips.DelTool(pWnd);\r
449 }\r
450 \r
451 void CLogDlg::EnableOKButton()\r
452 {\r
453         if (m_bSelect)\r
454         {\r
455                 // the dialog is used to select revisions\r
456                 if (m_bSelectionMustBeContinuous)\r
457                         DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));\r
458                 else\r
459                         DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);\r
460         }\r
461         else\r
462                 DialogEnableWindow(IDOK, TRUE);\r
463 }\r
464 \r
465 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)\r
466 {\r
467         // we fill here the log message rich edit control,\r
468         // and also populate the changed files list control\r
469         // according to the selected revision(s).\r
470 \r
471         CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);\r
472         // empty the log message view\r
473         pMsgView->SetWindowText(_T(" "));\r
474         // empty the changed files list\r
475         m_ChangedFileListCtrl.SetRedraw(FALSE);\r
476 //      InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
477         m_currentChangedArray = NULL;\r
478         //m_ChangedFileListCtrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );\r
479         m_ChangedFileListCtrl.DeleteAllItems();\r
480         \r
481         // if we're not here to really show a selected revision, just\r
482         // get out of here after clearing the views, which is what is intended\r
483         // if that flag is not set.\r
484         if (!bShow)\r
485         {\r
486                 // force a redraw\r
487                 m_ChangedFileListCtrl.Invalidate();\r
488 //              InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
489                 m_ChangedFileListCtrl.SetRedraw(TRUE);\r
490                 return;\r
491         }\r
492 \r
493         // depending on how many revisions are selected, we have to do different\r
494         // tasks.\r
495         int selCount = m_LogList.GetSelectedCount();\r
496         if (selCount == 0)\r
497         {\r
498                 // if nothing is selected, we have nothing more to do\r
499 //              InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
500                 m_ChangedFileListCtrl.SetRedraw(TRUE);\r
501                 return;\r
502         }\r
503         else if (selCount == 1)\r
504         {\r
505                 // if one revision is selected, we have to fill the log message view\r
506                 // with the corresponding log message, and also fill the changed files\r
507                 // list fully.\r
508                 POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
509                 int selIndex = m_LogList.GetNextSelectedItem(pos);\r
510                 if (selIndex >= m_LogList.m_arShownList.GetCount())\r
511                 {\r
512 //                      InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
513                         m_ChangedFileListCtrl.SetRedraw(TRUE);\r
514                         return;\r
515                 }\r
516                 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.GetAt(selIndex));\r
517 \r
518                 // set the log message text\r
519                 pMsgView->SetWindowText(_T("Commit:")+pLogEntry->m_CommitHash+_T("\r\n\r\n*")+pLogEntry->m_Subject+_T("\n\n")+pLogEntry->m_Body);\r
520                 // turn bug ID's into links if the bugtraq: properties have been set\r
521                 // and we can find a match of those in the log message\r
522                 m_ProjectProperties.FindBugID(pLogEntry->m_Body, pMsgView);\r
523                 CAppUtils::FormatTextInRichEditControl(pMsgView);\r
524 \r
525                 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->m_Files);\r
526                 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;\r
527                 m_ChangedFileListCtrl.Show(0);\r
528 \r
529                 m_ChangedFileListCtrl.SetRedraw(TRUE);\r
530                 return;\r
531 #if 0\r
532                 // fill in the changed files list control\r
533                 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)\r
534                 {\r
535                         m_CurrentFilteredChangedArray.RemoveAll();\r
536                         for (INT_PTR c = 0; c < m_currentChangedArray->GetCount(); ++c)\r
537                         {\r
538                                 LogChangedPath * cpath = m_currentChangedArray->GetAt(c);\r
539                                 if (cpath == NULL)\r
540                                         continue;\r
541                                 if (m_currentChangedArray->GetAt(c)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)\r
542                                 {\r
543                                         m_CurrentFilteredChangedArray.Add(cpath);\r
544                                 }\r
545                         }\r
546                         m_currentChangedArray = &m_CurrentFilteredChangedArray;\r
547                 }\r
548 #endif\r
549         }\r
550         else\r
551         {\r
552                 // more than one revision is selected:\r
553                 // the log message view must be emptied\r
554                 // the changed files list contains all the changed paths from all\r
555                 // selected revisions, with 'doubles' removed\r
556                 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);\r
557         }\r
558         \r
559         // redraw the views\r
560 //      InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
561         if (m_currentChangedArray)\r
562         {\r
563                 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());\r
564                 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());\r
565         }\r
566         else if (m_currentChangedPathList.GetCount())\r
567         {\r
568                 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());\r
569                 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());\r
570         }\r
571         else\r
572         {\r
573                 m_ChangedFileListCtrl.SetItemCountEx(0);\r
574                 m_ChangedFileListCtrl.Invalidate();\r
575         }\r
576         CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl);\r
577         // sort according to the settings\r
578         if (m_nSortColumnPathList > 0)\r
579                 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);\r
580         else\r
581                 SetSortArrow(&m_ChangedFileListCtrl, -1, false);\r
582         m_ChangedFileListCtrl.SetRedraw(TRUE);\r
583 \r
584 }\r
585 \r
586 void CLogDlg::OnBnClickedGetall()\r
587 {\r
588         GetAll();\r
589 }\r
590 \r
591 void CLogDlg::GetAll(bool bForceAll /* = false */)\r
592 {\r
593 #if 0\r
594         // fetch all requested log messages, either the specified range or\r
595         // really *all* available log messages.\r
596         UpdateData();\r
597         INT_PTR entry = m_btnShow.GetCurrentEntry();\r
598         if (bForceAll)\r
599                 entry = 0;\r
600 \r
601         switch (entry)\r
602         {\r
603         case 0: // show all\r
604         \r
605                 m_endrev = 0;\r
606                 m_startrev = m_LogRevision;\r
607                 if (m_bStrict)\r
608                         m_bShowedAll = true;\r
609 \r
610                 break;\r
611         case 1: // show range\r
612                 {\r
613 \r
614                         // ask for a revision range\r
615                         CRevisionRangeDlg dlg;\r
616                         dlg.SetStartRevision(m_startrev);\r
617                         dlg.SetEndRevision( (m_endrev>=0) ? m_endrev : 0);\r
618                         if (dlg.DoModal()!=IDOK)\r
619                         {\r
620                                 return;\r
621                         }\r
622                         m_endrev = dlg.GetEndRevision();\r
623                         m_startrev = dlg.GetStartRevision();\r
624                         if (((m_endrev.IsNumber())&&(m_startrev.IsNumber()))||\r
625                                 (m_endrev.IsHead()||m_startrev.IsHead()))\r
626                         {\r
627                                 if (((LONG)m_startrev < (LONG)m_endrev)||\r
628                                         (m_endrev.IsHead()))\r
629                                 {\r
630                                         git_revnum_t temp = m_startrev;\r
631                                         m_startrev = m_endrev;\r
632                                         m_endrev = temp;\r
633                                 }\r
634                         }\r
635                         m_bShowedAll = false;\r
636                 }\r
637 \r
638                 break;\r
639         }\r
640         m_ChangedFileListCtrl.SetItemCountEx(0);\r
641         m_ChangedFileListCtrl.Invalidate();\r
642         // We need to create CStoreSelection on the heap or else\r
643         // the variable will run out of the scope before the\r
644         // thread ends. Therefore we let the thread delete\r
645         // the instance.\r
646         m_pStoreSelection = new CStoreSelection(this);\r
647         m_LogList.SetItemCountEx(0);\r
648         m_LogList.Invalidate();\r
649         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
650         CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);\r
651         pMsgView->SetWindowText(_T(""));\r
652 \r
653         SetSortArrow(&m_LogList, -1, true);\r
654 \r
655         m_LogList.DeleteAllItems();\r
656         m_arShownList.RemoveAll();\r
657         m_logEntries.ClearAll();\r
658 \r
659         m_logcounter = 0;\r
660         m_bCancelled = FALSE;\r
661         m_tTo = 0;\r
662         m_tFrom = (DWORD)-1;\r
663         m_limit = 0;\r
664 \r
665         InterlockedExchange(&m_bThreadRunning, TRUE);\r
666         if (AfxBeginThread(LogThreadEntry, this)==NULL)\r
667         {\r
668                 InterlockedExchange(&m_bThreadRunning, FALSE);\r
669                 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
670         }\r
671         GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);\r
672         InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
673 #endif\r
674 }\r
675 \r
676 void CLogDlg::OnBnClickedRefresh()\r
677 {\r
678         m_limit = 0;\r
679         Refresh (true);\r
680 }\r
681 \r
682 void CLogDlg::Refresh (bool autoGoOnline)\r
683 {\r
684         m_LogList.Refresh();\r
685 }\r
686 \r
687 void CLogDlg::OnBnClickedNexthundred()\r
688 {\r
689 #if 0\r
690         UpdateData();\r
691         // we have to fetch the next X log messages.\r
692         if (m_logEntries.size() < 1)\r
693         {\r
694                 // since there weren't any log messages fetched before, just\r
695                 // fetch all since we don't have an 'anchor' to fetch the 'next'\r
696                 // messages from.\r
697                 return GetAll(true);\r
698         }\r
699         git_revnum_t rev = m_logEntries[m_logEntries.size()-1]->Rev;\r
700 \r
701         if (rev < 1)\r
702                 return;         // do nothing! No more revisions to get\r
703 \r
704         m_startrev = rev;\r
705         m_endrev = 0;\r
706         m_bCancelled = FALSE;\r
707 \r
708     // rev is is revision we already have and we will receive it again\r
709     // -> fetch one extra revision to get NumberOfLogs *new* revisions\r
710 \r
711         m_limit = (int)(DWORD)CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100) +1;\r
712         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
713         SetSortArrow(&m_LogList, -1, true);\r
714         InterlockedExchange(&m_bThreadRunning, TRUE);\r
715         // We need to create CStoreSelection on the heap or else\r
716         // the variable will run out of the scope before the\r
717         // thread ends. Therefore we let the thread delete\r
718         // the instance.\r
719         m_pStoreSelection = new CStoreSelection(this);\r
720 \r
721         // since we fetch the log from the last revision we already have,\r
722         // we have to remove that revision entry to avoid getting it twice\r
723         m_logEntries.pop_back();\r
724         if (AfxBeginThread(LogThreadEntry, this)==NULL)\r
725         {\r
726                 InterlockedExchange(&m_bThreadRunning, FALSE);\r
727                 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
728         }\r
729         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
730         GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);\r
731 #endif\r
732 }\r
733 \r
734 BOOL CLogDlg::Cancel()\r
735 {\r
736         return m_bCancelled;\r
737 }\r
738 \r
739 void CLogDlg::SaveSplitterPos()\r
740 {\r
741         if (!IsIconic())\r
742         {\r
743                 CRegDWORD regPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));\r
744                 CRegDWORD regPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));\r
745                 RECT rectSplitter;\r
746                 m_wndSplitter1.GetWindowRect(&rectSplitter);\r
747                 ScreenToClient(&rectSplitter);\r
748                 regPos1 = rectSplitter.top;\r
749                 m_wndSplitter2.GetWindowRect(&rectSplitter);\r
750                 ScreenToClient(&rectSplitter);\r
751                 regPos2 = rectSplitter.top;\r
752         }\r
753 }\r
754 \r
755 void CLogDlg::OnCancel()\r
756 {\r
757         // canceling means stopping the working thread if it's still running.\r
758         // we do this by using the Subversion cancel callback.\r
759         // But canceling can also mean just to close the dialog, depending on the\r
760         // text shown on the cancel button (it could simply read "OK").\r
761         CString temp, temp2;\r
762         GetDlgItemText(IDOK, temp);\r
763         temp2.LoadString(IDS_MSGBOX_CANCEL);\r
764         if ((temp.Compare(temp2)==0)||(this->IsThreadRunning()))\r
765         {\r
766                 m_bCancelled = true;\r
767                 return;\r
768         }\r
769         UpdateData();\r
770         if (m_bSaveStrict)\r
771                 m_regLastStrict = m_bStrict;\r
772         CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));\r
773         reg = m_btnShow.GetCurrentEntry();\r
774         SaveSplitterPos();\r
775         __super::OnCancel();\r
776 }\r
777 \r
778 CString CLogDlg::MakeShortMessage(const CString& message)\r
779 {\r
780         bool bFoundShort = true;\r
781         CString sShortMessage = m_ProjectProperties.GetLogSummary(message);\r
782         if (sShortMessage.IsEmpty())\r
783         {\r
784                 bFoundShort = false;\r
785                 sShortMessage = message;\r
786         }\r
787         // Remove newlines and tabs 'cause those are not shown nicely in the list control\r
788         sShortMessage.Replace(_T("\r"), _T(""));\r
789         sShortMessage.Replace(_T("\t"), _T(" "));\r
790         \r
791         // Suppose the first empty line separates 'summary' from the rest of the message.\r
792         int found = sShortMessage.Find(_T("\n\n"));\r
793         // To avoid too short 'short' messages \r
794         // (e.g. if the message looks something like "Bugfix:\n\n*done this\n*done that")\r
795         // only use the empty newline as a separator if it comes after at least 15 chars.\r
796         if ((!bFoundShort)&&(found >= 15))\r
797         {\r
798                 sShortMessage = sShortMessage.Left(found);\r
799         }\r
800         sShortMessage.Replace('\n', ' ');\r
801         return sShortMessage;\r
802 }\r
803 \r
804 BOOL CLogDlg::Log(git_revnum_t rev, const CString& author, const CString& date, const CString& message, LogChangedPathArray * cpaths,  int filechanges, BOOL copies, DWORD actions, BOOL haschildren)\r
805 {\r
806 #if 0\r
807         if (rev == SVN_INVALID_REVNUM)\r
808         {\r
809                 m_childCounter--;\r
810                 return TRUE;\r
811         }\r
812 \r
813         // this is the callback function which receives the data for every revision we ask the log for\r
814         // we store this information here one by one.\r
815         m_logcounter += 1;\r
816         if (m_startrev == -1)\r
817                 m_startrev = rev;\r
818         if (m_limit != 0)\r
819         {\r
820                 m_limitcounter--;\r
821                 m_LogProgress.SetPos(m_limit - m_limitcounter);\r
822         }\r
823         else if (m_startrev.IsNumber() && m_startrev.IsNumber())\r
824                 m_LogProgress.SetPos((git_revnum_t)m_startrev-rev+(git_revnum_t)m_endrev);\r
825         __time64_t ttime = time/1000000L;\r
826         if (m_tTo < (DWORD)ttime)\r
827                 m_tTo = (DWORD)ttime;\r
828         if (m_tFrom > (DWORD)ttime)\r
829                 m_tFrom = (DWORD)ttime;\r
830         if ((m_lowestRev > rev)||(m_lowestRev < 0))\r
831                 m_lowestRev = rev;\r
832         // Add as many characters from the log message to the list control\r
833         PLOGENTRYDATA pLogItem = new LOGENTRYDATA;\r
834         pLogItem->bCopies = !!copies;\r
835         \r
836         // find out if this item was copied in the revision\r
837         BOOL copiedself = FALSE;\r
838         if (copies)\r
839         {\r
840                 for (INT_PTR cpPathIndex = 0; cpPathIndex < cpaths->GetCount(); ++cpPathIndex)\r
841                 {\r
842                         LogChangedPath * cpath = cpaths->GetAt(cpPathIndex);\r
843                         if (!cpath->sCopyFromPath.IsEmpty() && (cpath->sPath.Compare(m_sSelfRelativeURL) == 0))\r
844                         {\r
845                                 // note: this only works if the log is fetched top-to-bottom\r
846                                 // but since we do that, it shouldn't be a problem\r
847                                 m_sSelfRelativeURL = cpath->sCopyFromPath;\r
848                                 copiedself = TRUE;\r
849                                 break;\r
850                         }\r
851                 }\r
852         }\r
853         pLogItem->bCopiedSelf = copiedself;\r
854         pLogItem->tmDate = ttime;\r
855         pLogItem->sAuthor = author;\r
856         pLogItem->sDate = date;\r
857         pLogItem->sShortMessage = MakeShortMessage(message);\r
858         pLogItem->dwFileChanges = filechanges;\r
859         pLogItem->actions = actions;\r
860         pLogItem->haschildren = haschildren;\r
861         pLogItem->childStackDepth = m_childCounter;\r
862         m_maxChild = max(m_childCounter, m_maxChild);\r
863         if (haschildren)\r
864                 m_childCounter++;\r
865         pLogItem->sBugIDs = m_ProjectProperties.FindBugID(message).Trim();\r
866         \r
867         // split multi line log entries and concatenate them\r
868         // again but this time with \r\n as line separators\r
869         // so that the edit control recognizes them\r
870         try\r
871         {\r
872                 if (message.GetLength()>0)\r
873                 {\r
874                         m_sMessageBuf = message;\r
875                         m_sMessageBuf.Replace(_T("\n\r"), _T("\n"));\r
876                         m_sMessageBuf.Replace(_T("\r\n"), _T("\n"));\r
877                         if (m_sMessageBuf.Right(1).Compare(_T("\n"))==0)\r
878                                 m_sMessageBuf = m_sMessageBuf.Left(m_sMessageBuf.GetLength()-1);\r
879                 }\r
880                 else\r
881                         m_sMessageBuf.Empty();\r
882         pLogItem->sMessage = m_sMessageBuf;\r
883         pLogItem->Rev = rev;\r
884 \r
885         // move-construct path array\r
886 \r
887         pLogItem->pArChangedPaths = new LogChangedPathArray (*cpaths);\r
888         cpaths->RemoveAll();\r
889         }\r
890         catch (CException * e)\r
891         {\r
892                 ::MessageBox(NULL, _T("not enough memory!"), _T("TortoiseGit"), MB_ICONERROR);\r
893                 e->Delete();\r
894                 m_bCancelled = TRUE;\r
895         }\r
896         m_logEntries.push_back(pLogItem);\r
897         m_arShownList.Add(pLogItem);\r
898 #endif\r
899         return TRUE;\r
900 }\r
901 \r
902 GitRev g_rev;\r
903 //this is the thread function which calls the subversion function\r
904 \r
905 \r
906 \r
907 \r
908 void CLogDlg::CopyChangedSelectionToClipBoard()\r
909 {\r
910 #if 0\r
911         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
912         if (pos == NULL)\r
913                 return; // nothing is selected, get out of here\r
914 \r
915         CString sPaths;\r
916 \r
917         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
918         if (pos)\r
919         {\r
920                 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();\r
921                 while (pos)\r
922                 {\r
923                         int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);\r
924                         sPaths += m_currentChangedPathList[nItem].GetGitPathString();\r
925                         sPaths += _T("\r\n");\r
926                 }\r
927         }\r
928         else\r
929         {\r
930                 // only one revision is selected in the log dialog top pane\r
931                 // but multiple items could be selected  in the changed items list\r
932                 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();\r
933                 while (pos)\r
934                 {\r
935                         int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);\r
936                         LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->GetAt(nItem);\r
937 \r
938                         if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)\r
939                         {\r
940                                 // some items are hidden! So find out which item the user really selected\r
941                                 INT_PTR selRealIndex = -1;\r
942                                 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)\r
943                                 {\r
944                                         if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)\r
945                                                 selRealIndex++;\r
946                                         if (selRealIndex == nItem)\r
947                                         {\r
948                                                 changedlogpath = pLogEntry->pArChangedPaths->GetAt(hiddenindex);\r
949                                                 break;\r
950                                         }\r
951                                 }\r
952                         }\r
953                         if (changedlogpath)\r
954                         {\r
955                                 sPaths += changedlogpath->sPath;\r
956                                 sPaths += _T("\r\n");\r
957                         }\r
958                 }\r
959         }\r
960         sPaths.Trim();\r
961         CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());\r
962 #endif\r
963 }\r
964 \r
965 BOOL CLogDlg::IsDiffPossible(LogChangedPath * changedpath, git_revnum_t rev)\r
966 {\r
967 #if 0\r
968         CString added, deleted;\r
969         if (changedpath == NULL)\r
970                 return false;\r
971 \r
972         if ((rev > 1)&&(changedpath->action != LOGACTIONS_DELETED))\r
973         {\r
974                 if (changedpath->action == LOGACTIONS_ADDED) // file is added\r
975                 {\r
976                         if (changedpath->lCopyFromRev == 0)\r
977                                 return FALSE; // but file was not added with history\r
978                 }\r
979                 return TRUE;\r
980         }\r
981 #endif\r
982         return FALSE;\r
983 }\r
984 \r
985 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)\r
986 {\r
987         // we have two separate context menus:\r
988         // one shown on the log message list control,\r
989         // the other shown in the changed-files list control\r
990         int selCount = m_LogList.GetSelectedCount();\r
991         if (pWnd == &m_LogList)\r
992         {\r
993                 //ShowContextMenuForRevisions(pWnd, point);\r
994         }\r
995         else if (pWnd == &m_ChangedFileListCtrl)\r
996         {\r
997                 //ShowContextMenuForChangedpaths(pWnd, point);\r
998         }\r
999         else if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))\r
1000         {\r
1001                 POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
1002                 int selIndex = -1;\r
1003                 if (pos)\r
1004                         selIndex = m_LogList.GetNextSelectedItem(pos);\r
1005                 if ((point.x == -1) && (point.y == -1))\r
1006                 {\r
1007                         CRect rect;\r
1008                         GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);\r
1009                         ClientToScreen(&rect);\r
1010                         point = rect.CenterPoint();\r
1011                 }\r
1012                 CString sMenuItemText;\r
1013                 CMenu popup;\r
1014                 if (popup.CreatePopupMenu())\r
1015                 {\r
1016                         // add the 'default' entries\r
1017                         sMenuItemText.LoadString(IDS_SCIEDIT_COPY);\r
1018                         popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);\r
1019                         sMenuItemText.LoadString(IDS_SCIEDIT_SELECTALL);\r
1020                         popup.AppendMenu(MF_STRING | MF_ENABLED, EM_SETSEL, sMenuItemText);\r
1021 \r
1022                         //if (selIndex >= 0)\r
1023                         //{\r
1024                         //      popup.AppendMenu(MF_SEPARATOR);\r
1025                         //      sMenuItemText.LoadString(IDS_LOG_POPUP_EDITLOG);\r
1026                         //      popup.AppendMenu(MF_STRING | MF_ENABLED, CGitLogList::ID_EDITAUTHOR, sMenuItemText);\r
1027                         //}\r
1028 \r
1029                         int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
1030                         switch (cmd)\r
1031                         {\r
1032                         case 0:\r
1033                                 break;  // no command selected\r
1034                         case EM_SETSEL:\r
1035                         case WM_COPY:\r
1036                                 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);\r
1037                                 break;\r
1038                         case CGitLogList::ID_EDITAUTHOR:\r
1039                                 EditLogMessage(selIndex);\r
1040                                 break;\r
1041                         }\r
1042                 }\r
1043         }\r
1044 }\r
1045 \r
1046 \r
1047 LRESULT CLogDlg::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)\r
1048 {\r
1049 #if 0\r
1050     ASSERT(m_pFindDialog != NULL);\r
1051 \r
1052     if (m_pFindDialog->IsTerminating())\r
1053     {\r
1054             // invalidate the handle identifying the dialog box.\r
1055         m_pFindDialog = NULL;\r
1056         return 0;\r
1057     }\r
1058 \r
1059     if(m_pFindDialog->FindNext())\r
1060     {\r
1061         //read data from dialog\r
1062         CString FindText = m_pFindDialog->GetFindString();\r
1063         bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);\r
1064                 bool bFound = false;\r
1065                 tr1::wregex pat;\r
1066                 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);\r
1067 \r
1068                 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_not_null;\r
1069 \r
1070                 int i;\r
1071                 for (i = this->m_nSearchIndex; i<m_arShownList.GetCount()&&!bFound; i++)\r
1072                 {\r
1073                         if (bRegex)\r
1074                         {\r
1075                                 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));\r
1076 \r
1077                                 if (regex_search(wstring((LPCTSTR)pLogEntry->sMessage), pat, flags))\r
1078                                 {\r
1079                                         bFound = true;\r
1080                                         break;\r
1081                                 }\r
1082                                 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
1083                                 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
1084                                 {\r
1085                                         LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
1086                                         if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags))\r
1087                                         {\r
1088                                                 bFound = true;\r
1089                                                 --i;\r
1090                                                 break;\r
1091                                         }\r
1092                                         if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags))\r
1093                                         {\r
1094                                                 bFound = true;\r
1095                                                 --i;\r
1096                                                 break;\r
1097                                         }\r
1098                                 }\r
1099                         }\r
1100                         else\r
1101                         {\r
1102                                 if (bMatchCase)\r
1103                                 {\r
1104                                         if (m_logEntries[i]->sMessage.Find(FindText) >= 0)\r
1105                                         {\r
1106                                                 bFound = true;\r
1107                                                 break;\r
1108                                         }\r
1109                                         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));\r
1110                                         LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
1111                                         for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
1112                                         {\r
1113                                                 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
1114                                                 if (cpath->sCopyFromPath.Find(FindText)>=0)\r
1115                                                 {\r
1116                                                         bFound = true;\r
1117                                                         --i;\r
1118                                                         break;\r
1119                                                 }\r
1120                                                 if (cpath->sPath.Find(FindText)>=0)\r
1121                                                 {\r
1122                                                         bFound = true;\r
1123                                                         --i;\r
1124                                                         break;\r
1125                                                 }\r
1126                                         }\r
1127                                 }\r
1128                                 else\r
1129                                 {\r
1130                                     PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));\r
1131                                         CString msg = pLogEntry->sMessage;\r
1132                                         msg = msg.MakeLower();\r
1133                                         CString find = FindText.MakeLower();\r
1134                                         if (msg.Find(find) >= 0)\r
1135                                         {\r
1136                                                 bFound = TRUE;\r
1137                                                 break;\r
1138                                         }\r
1139                                         LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
1140                                         for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
1141                                         {\r
1142                                                 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
1143                                                 CString lowerpath = cpath->sCopyFromPath;\r
1144                                                 lowerpath.MakeLower();\r
1145                                                 if (lowerpath.Find(find)>=0)\r
1146                                                 {\r
1147                                                         bFound = TRUE;\r
1148                                                         --i;\r
1149                                                         break;\r
1150                                                 }\r
1151                                                 lowerpath = cpath->sPath;\r
1152                                                 lowerpath.MakeLower();\r
1153                                                 if (lowerpath.Find(find)>=0)\r
1154                                                 {\r
1155                                                         bFound = TRUE;\r
1156                                                         --i;\r
1157                                                         break;\r
1158                                                 }\r
1159                                         }\r
1160                                 } \r
1161                         }\r
1162                 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)\r
1163                 if (bFound)\r
1164                 {\r
1165                         this->m_nSearchIndex = (i+1);\r
1166                         m_LogList.EnsureVisible(i, FALSE);\r
1167                         m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED);\r
1168                         m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);\r
1169                         m_LogList.SetSelectionMark(i);\r
1170                         FillLogMessageCtrl();\r
1171                         UpdateData(FALSE);\r
1172                         m_nSearchIndex++;\r
1173                         if (m_nSearchIndex >= m_arShownList.GetCount())\r
1174                                 m_nSearchIndex = (int)m_arShownList.GetCount()-1;\r
1175                 }\r
1176     } // if(m_pFindDialog->FindNext()) \r
1177         UpdateLogInfoLabel();\r
1178 #endif\r
1179     return 0;\r
1180 }\r
1181 \r
1182 void CLogDlg::OnOK()\r
1183 {\r
1184 #if 0 \r
1185         // since the log dialog is also used to select revisions for other\r
1186         // dialogs, we have to do some work before closing this dialog\r
1187         if (GetFocus() != GetDlgItem(IDOK))\r
1188                 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter\r
1189         if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))\r
1190                 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.\r
1191 \r
1192         CString temp;\r
1193         CString buttontext;\r
1194         GetDlgItemText(IDOK, buttontext);\r
1195         temp.LoadString(IDS_MSGBOX_CANCEL);\r
1196         if (temp.Compare(buttontext) != 0)\r
1197                 __super::OnOK();        // only exit if the button text matches, and that will match only if the thread isn't running anymore\r
1198         m_bCancelled = TRUE;\r
1199         m_selectedRevs.Clear();\r
1200         m_selectedRevsOneRange.Clear();\r
1201         if (m_pNotifyWindow)\r
1202         {\r
1203                 int selIndex = m_LogList.GetSelectionMark();\r
1204                 if (selIndex >= 0)\r
1205                 {       \r
1206                     PLOGENTRYDATA pLogEntry = NULL;\r
1207                         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
1208                         pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1209                         m_selectedRevs.AddRevision(pLogEntry->Rev);\r
1210                         git_revnum_t lowerRev = pLogEntry->Rev;\r
1211                         git_revnum_t higherRev = lowerRev;\r
1212                         while (pos)\r
1213                         {\r
1214                             pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1215                                 git_revnum_t rev = pLogEntry->Rev;\r
1216                                 m_selectedRevs.AddRevision(pLogEntry->Rev);\r
1217                                 if (lowerRev > rev)\r
1218                                         lowerRev = rev;\r
1219                                 if (higherRev < rev)\r
1220                                         higherRev = rev;\r
1221                         }\r
1222                         if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())\r
1223                         {\r
1224                                 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);\r
1225                         }\r
1226                         BOOL bSentMessage = FALSE;\r
1227                         if (m_LogList.GetSelectedCount() == 1)\r
1228                         {\r
1229                                 // if only one revision is selected, check if the path/url with which the dialog was started\r
1230                                 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.\r
1231                                 // if it was copied, use the copy from revision as lowerRev\r
1232                                 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))\r
1233                                 {\r
1234                                         CString sUrl = m_path.GetGitPathString();\r
1235                                         if (!m_path.IsUrl())\r
1236                                         {\r
1237                                                 sUrl = GetURLFromPath(m_path);\r
1238                                         }\r
1239                                         sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());\r
1240                                         for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)\r
1241                                         {\r
1242                                                 LogChangedPath * pData = pLogEntry->pArChangedPaths->GetAt(cp);\r
1243                                                 if (pData)\r
1244                                                 {\r
1245                                                         if (sUrl.Compare(pData->sPath) == 0)\r
1246                                                         {\r
1247                                                                 if (!pData->sCopyFromPath.IsEmpty())\r
1248                                                                 {\r
1249                                                                         lowerRev = pData->lCopyFromRev;\r
1250                                                                         m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);\r
1251                                                                         m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);\r
1252                                                                         m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);\r
1253                                                                         bSentMessage = TRUE;\r
1254                                                                 }\r
1255                                                         }\r
1256                                                 }\r
1257                                         }\r
1258                                 }\r
1259                         }\r
1260                         if ( !bSentMessage )\r
1261                         {\r
1262                                 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);\r
1263                                 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);\r
1264                                 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);\r
1265                                 if (m_selectedRevsOneRange.GetCount())\r
1266                                         m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);\r
1267                         }\r
1268                 }\r
1269         }\r
1270         UpdateData();\r
1271         if (m_bSaveStrict)\r
1272                 m_regLastStrict = m_bStrict;\r
1273         CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\ShowAllEntry"));\r
1274         reg = m_btnShow.GetCurrentEntry();\r
1275         SaveSplitterPos();\r
1276 #endif \r
1277 }\r
1278 \r
1279 void CLogDlg::OnNMDblclkChangedFileList(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
1280 {\r
1281         // a double click on an entry in the changed-files list has happened\r
1282         *pResult = 0;\r
1283 \r
1284         DiffSelectedFile();\r
1285 }\r
1286 \r
1287 void CLogDlg::DiffSelectedFile()\r
1288 {\r
1289 #if 0\r
1290         if (m_bThreadRunning)\r
1291                 return;\r
1292         UpdateLogInfoLabel();\r
1293         INT_PTR selIndex = m_ChangedFileListCtrl.GetSelectionMark();\r
1294         if (selIndex < 0)\r
1295                 return;\r
1296         if (m_ChangedFileListCtrl.GetSelectedCount() == 0)\r
1297                 return;\r
1298         // find out if there's an entry selected in the log list\r
1299         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
1300         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1301         git_revnum_t rev1 = pLogEntry->Rev;\r
1302         git_revnum_t rev2 = rev1;\r
1303         if (pos)\r
1304         {\r
1305                 while (pos)\r
1306                 {\r
1307                         // there's at least a second entry selected in the log list: several revisions selected!\r
1308                         pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));\r
1309                         if (pLogEntry)\r
1310                         {\r
1311                                 rev1 = max(rev1,(long)pLogEntry->Rev);\r
1312                                 rev2 = min(rev2,(long)pLogEntry->Rev);\r
1313                         }\r
1314                 }\r
1315                 rev2--;\r
1316                 // now we have both revisions selected in the log list, so we can do a diff of the selected\r
1317                 // entry in the changed files list with these two revisions.\r
1318                 DoDiffFromLog(selIndex, rev1, rev2, false, false);\r
1319         }\r
1320         else\r
1321         {\r
1322                 rev2 = rev1-1;\r
1323                 // nothing or only one revision selected in the log list\r
1324                 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);\r
1325 \r
1326                 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)\r
1327                 {\r
1328                         // some items are hidden! So find out which item the user really clicked on\r
1329                         INT_PTR selRealIndex = -1;\r
1330                         for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)\r
1331                         {\r
1332                                 if (pLogEntry->pArChangedPaths->GetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)\r
1333                                         selRealIndex++;\r
1334                                 if (selRealIndex == selIndex)\r
1335                                 {\r
1336                                         selIndex = hiddenindex;\r
1337                                         changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);\r
1338                                         break;\r
1339                                 }\r
1340                         }\r
1341                 }\r
1342 \r
1343                 if (IsDiffPossible(changedpath, rev1))\r
1344                 {\r
1345                         // diffs with renamed files are possible\r
1346                         if ((changedpath)&&(!changedpath->sCopyFromPath.IsEmpty()))\r
1347                                 rev2 = changedpath->lCopyFromRev;\r
1348                         else\r
1349                         {\r
1350                                 // if the path was modified but the parent path was 'added with history'\r
1351                                 // then we have to use the copy from revision of the parent path\r
1352                                 CTGitPath cpath = CTGitPath(changedpath->sPath);\r
1353                                 for (int flist = 0; flist < pLogEntry->pArChangedPaths->GetCount(); ++flist)\r
1354                                 {\r
1355                                         CTGitPath p = CTGitPath(pLogEntry->pArChangedPaths->GetAt(flist)->sPath);\r
1356                                         if (p.IsAncestorOf(cpath))\r
1357                                         {\r
1358                                                 if (!pLogEntry->pArChangedPaths->GetAt(flist)->sCopyFromPath.IsEmpty())\r
1359                                                         rev2 = pLogEntry->pArChangedPaths->GetAt(flist)->lCopyFromRev;\r
1360                                         }\r
1361                                 }\r
1362                         }\r
1363                         DoDiffFromLog(selIndex, rev1, rev2, false, false);\r
1364                 }\r
1365                 else \r
1366                 {\r
1367                         CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));\r
1368                         CTGitPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(changedpath->sPath));\r
1369                         GitRev r = rev1;\r
1370                         // deleted files must be opened from the revision before the deletion\r
1371                         if (changedpath->action == LOGACTIONS_DELETED)\r
1372                                 r = rev1-1;\r
1373                         m_bCancelled = false;\r
1374 \r
1375                         CProgressDlg progDlg;\r
1376                         progDlg.SetTitle(IDS_APPNAME);\r
1377                         progDlg.SetAnimation(IDR_DOWNLOAD);\r
1378                         CString sInfoLine;\r
1379                         sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)(m_sRepositoryRoot + changedpath->sPath), (LPCTSTR)r.ToString());\r
1380                         progDlg.SetLine(1, sInfoLine, true);\r
1381                         SetAndClearProgressInfo(&progDlg);\r
1382                         progDlg.ShowModeless(m_hWnd);\r
1383 \r
1384                         if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), r, r, tempfile))\r
1385                         {\r
1386                                 m_bCancelled = false;\r
1387                                 if (!Cat(CTGitPath(m_sRepositoryRoot + changedpath->sPath), GitRev::REV_HEAD, r, tempfile))\r
1388                                 {\r
1389                                         progDlg.Stop();\r
1390                                         SetAndClearProgressInfo((HWND)NULL);\r
1391                                         CMessageBox::Show(m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1392                                         return;\r
1393                                 }\r
1394                         }\r
1395                         progDlg.Stop();\r
1396                         SetAndClearProgressInfo((HWND)NULL);\r
1397 \r
1398                         CString sName1, sName2;\r
1399                         sName1.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1);\r
1400                         sName2.Format(_T("%s - Revision %ld"), (LPCTSTR)CPathUtils::GetFileNameFromPath(changedpath->sPath), (git_revnum_t)rev1-1);\r
1401                         CAppUtils::DiffFlags flags;\r
1402                         flags.AlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));\r
1403                         if (changedpath->action == LOGACTIONS_DELETED)\r
1404                                 CAppUtils::StartExtDiff(tempfile, tempfile2, sName2, sName1, flags);\r
1405                         else\r
1406                                 CAppUtils::StartExtDiff(tempfile2, tempfile, sName2, sName1, flags);\r
1407                 }\r
1408         }\r
1409 #endif \r
1410 }\r
1411 \r
1412 \r
1413 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool blame, bool unified)\r
1414 {\r
1415         DialogEnableWindow(IDOK, FALSE);\r
1416 //      SetPromptApp(&theApp);\r
1417         theApp.DoWaitCursor(1);\r
1418 \r
1419         CString temppath;\r
1420         GetTempPath(temppath);\r
1421         \r
1422         CString file1;\r
1423         file1.Format(_T("%s%s_%s%s"),\r
1424                                 temppath,                                               \r
1425                                 (*m_currentChangedArray)[selIndex].GetBaseFilename(),\r
1426                                 rev1->m_CommitHash.Left(6),\r
1427                                 (*m_currentChangedArray)[selIndex].GetFileExtension());\r
1428 \r
1429         CString file2;\r
1430         file2.Format(_T("%s\\%s_%s%s"),\r
1431                                 temppath,                                               \r
1432                                 (*m_currentChangedArray)[selIndex].GetBaseFilename(),\r
1433                                 rev2->m_CommitHash.Left(6),\r
1434                                 (*m_currentChangedArray)[selIndex].GetFileExtension());\r
1435 \r
1436         CString cmd;\r
1437 \r
1438         cmd.Format(_T("git.exe cat-file -p %s:%s"),rev1->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());\r
1439         g_Git.RunLogFile(cmd,file1);\r
1440         cmd.Format(_T("git.exe cat-file -p %s:%s"),rev2->m_CommitHash,(*m_currentChangedArray)[selIndex].GetGitPathString());\r
1441         g_Git.RunLogFile(cmd,file2);\r
1442 \r
1443         CAppUtils::DiffFlags flags;\r
1444         CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),flags);\r
1445 \r
1446 #if 0\r
1447         //get the filename\r
1448         CString filepath;\r
1449         if (Git::PathIsURL(m_path))\r
1450         {\r
1451                 filepath = m_path.GetGitPathString();\r
1452         }\r
1453         else\r
1454         {\r
1455                 filepath = GetURLFromPath(m_path);\r
1456                 if (filepath.IsEmpty())\r
1457                 {\r
1458                         theApp.DoWaitCursor(-1);\r
1459                         CString temp;\r
1460                         temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);\r
1461                         CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);\r
1462                         TRACE(_T("could not retrieve the URL of the file!\n"));\r
1463                         EnableOKButton();\r
1464                         theApp.DoWaitCursor(-11);\r
1465                         return;         //exit\r
1466                 }\r
1467         }\r
1468         m_bCancelled = FALSE;\r
1469         filepath = GetRepositoryRoot(CTGitPath(filepath));\r
1470 \r
1471         CString firstfile, secondfile;\r
1472         if (m_LogList.GetSelectedCount()==1)\r
1473         {\r
1474                 int s = m_LogList.GetSelectionMark();\r
1475                 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(s));\r
1476                 LogChangedPath * changedpath = pLogEntry->pArChangedPaths->GetAt(selIndex);\r
1477                 firstfile = changedpath->sPath;\r
1478                 secondfile = firstfile;\r
1479                 if ((rev2 == rev1-1)&&(changedpath->lCopyFromRev > 0)) // is it an added file with history?\r
1480                 {\r
1481                         secondfile = changedpath->sCopyFromPath;\r
1482                         rev2 = changedpath->lCopyFromRev;\r
1483                 }\r
1484         }\r
1485         else\r
1486         {\r
1487                 firstfile = m_currentChangedPathList[selIndex].GetGitPathString();\r
1488                 secondfile = firstfile;\r
1489         }\r
1490 \r
1491         firstfile = filepath + firstfile.Trim();\r
1492         secondfile = filepath + secondfile.Trim();\r
1493 \r
1494         GitDiff diff(this, this->m_hWnd, true);\r
1495         diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));\r
1496         diff.SetHEADPeg(m_LogRevision);\r
1497         if (unified)\r
1498         {\r
1499                 if (PromptShown())\r
1500                         diff.ShowUnifiedDiff(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1);\r
1501                 else\r
1502                         CAppUtils::StartShowUnifiedDiff(m_hWnd, CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), m_LogRevision);\r
1503         }\r
1504         else\r
1505         {\r
1506                 if (diff.ShowCompare(CTGitPath(secondfile), rev2, CTGitPath(firstfile), rev1, GitRev(), false, blame))\r
1507                 {\r
1508                         if (firstfile.Compare(secondfile)==0)\r
1509                         {\r
1510                                 git_revnum_t baseRev = 0;\r
1511                                 diff.DiffProps(CTGitPath(firstfile), rev2, rev1, baseRev);\r
1512                         }\r
1513                 }\r
1514         }\r
1515 \r
1516 #endif\r
1517 \r
1518         theApp.DoWaitCursor(-1);\r
1519         EnableOKButton();\r
1520 }\r
1521 \r
1522 BOOL CLogDlg::Open(bool bOpenWith,CString changedpath, git_revnum_t rev)\r
1523 {\r
1524 #if 0\r
1525         DialogEnableWindow(IDOK, FALSE);\r
1526         SetPromptApp(&theApp);\r
1527         theApp.DoWaitCursor(1);\r
1528         CString filepath;\r
1529         if (Git::PathIsURL(m_path))\r
1530         {\r
1531                 filepath = m_path.GetGitPathString();\r
1532         }\r
1533         else\r
1534         {\r
1535                 filepath = GetURLFromPath(m_path);\r
1536                 if (filepath.IsEmpty())\r
1537                 {\r
1538                         theApp.DoWaitCursor(-1);\r
1539                         CString temp;\r
1540                         temp.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)filepath);\r
1541                         CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR);\r
1542                         TRACE(_T("could not retrieve the URL of the file!\n"));\r
1543                         EnableOKButton();\r
1544                         return FALSE;\r
1545                 }\r
1546         }\r
1547         m_bCancelled = false;\r
1548         filepath = GetRepositoryRoot(CTGitPath(filepath));\r
1549         filepath += changedpath;\r
1550 \r
1551         CProgressDlg progDlg;\r
1552         progDlg.SetTitle(IDS_APPNAME);\r
1553         progDlg.SetAnimation(IDR_DOWNLOAD);\r
1554         CString sInfoLine;\r
1555         sInfoLine.Format(IDS_PROGRESSGETFILEREVISION, (LPCTSTR)filepath, (LPCTSTR)GitRev(rev).ToString());\r
1556         progDlg.SetLine(1, sInfoLine, true);\r
1557         SetAndClearProgressInfo(&progDlg);\r
1558         progDlg.ShowModeless(m_hWnd);\r
1559 \r
1560         CTGitPath tempfile = CTempFiles::Instance().GetTempFilePath(false, CTGitPath(filepath), rev);\r
1561         m_bCancelled = false;\r
1562         if (!Cat(CTGitPath(filepath), GitRev(rev), rev, tempfile))\r
1563         {\r
1564                 progDlg.Stop();\r
1565                 SetAndClearProgressInfo((HWND)NULL);\r
1566                 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1567                 EnableOKButton();\r
1568                 theApp.DoWaitCursor(-1);\r
1569                 return FALSE;\r
1570         }\r
1571         progDlg.Stop();\r
1572         SetAndClearProgressInfo((HWND)NULL);\r
1573         SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);\r
1574         if (!bOpenWith)\r
1575         {\r
1576                 int ret = (int)ShellExecute(this->m_hWnd, NULL, tempfile.GetWinPath(), NULL, NULL, SW_SHOWNORMAL);\r
1577                 if (ret <= HINSTANCE_ERROR)\r
1578                         bOpenWith = true;\r
1579         }\r
1580         if (bOpenWith)\r
1581         {\r
1582                 CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL ");\r
1583                 cmd += tempfile.GetWinPathString() + _T(" ");\r
1584                 CAppUtils::LaunchApplication(cmd, NULL, false);\r
1585         }\r
1586         EnableOKButton();\r
1587         theApp.DoWaitCursor(-1);\r
1588 #endif\r
1589         return TRUE;\r
1590 }\r
1591 \r
1592 void CLogDlg::EditAuthor(const CLogDataVector& logs)\r
1593 {\r
1594 #if 0\r
1595         CString url;\r
1596         CString name;\r
1597         if (logs.size() == 0)\r
1598                 return;\r
1599         DialogEnableWindow(IDOK, FALSE);\r
1600         SetPromptApp(&theApp);\r
1601         theApp.DoWaitCursor(1);\r
1602         if (Git::PathIsURL(m_path))\r
1603                 url = m_path.GetGitPathString();\r
1604         else\r
1605         {\r
1606                 url = GetURLFromPath(m_path);\r
1607         }\r
1608         name = Git_PROP_REVISION_AUTHOR;\r
1609 \r
1610         CString value = RevPropertyGet(name, CTGitPath(url), logs[0]->Rev);\r
1611         CString sOldValue = value;\r
1612         value.Replace(_T("\n"), _T("\r\n"));\r
1613         CInputDlg dlg(this);\r
1614         dlg.m_sHintText.LoadString(IDS_LOG_AUTHOR);\r
1615         dlg.m_sInputText = value;\r
1616         dlg.m_sTitle.LoadString(IDS_LOG_AUTHOREDITTITLE);\r
1617         dlg.m_pProjectProperties = &m_ProjectProperties;\r
1618         dlg.m_bUseLogWidth = false;\r
1619         if (dlg.DoModal() == IDOK)\r
1620         {\r
1621                 dlg.m_sInputText.Replace(_T("\r"), _T(""));\r
1622 \r
1623                 LogCache::CCachedLogInfo* toUpdate \r
1624                         = GetLogCache (CTGitPath (m_sRepositoryRoot));\r
1625 \r
1626                 CProgressDlg progDlg;\r
1627                 progDlg.SetTitle(IDS_APPNAME);\r
1628                 progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT)));\r
1629                 progDlg.SetTime(true);\r
1630                 progDlg.SetShowProgressBar(true);\r
1631                 progDlg.ShowModeless(m_hWnd);\r
1632                 for (DWORD i=0; i<logs.size(); ++i)\r
1633                 {\r
1634                         if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), logs[i]->Rev))\r
1635                         {\r
1636                                 progDlg.Stop();\r
1637                                 CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1638                                 break;\r
1639                         }\r
1640                         else\r
1641                         {\r
1642 \r
1643                                 logs[i]->sAuthor = dlg.m_sInputText;\r
1644                                 m_LogList.Invalidate();\r
1645 \r
1646                                 // update the log cache \r
1647 \r
1648                                 if (toUpdate != NULL)\r
1649                                 {\r
1650                                         // log caching is active\r
1651 \r
1652                                         LogCache::CCachedLogInfo newInfo;\r
1653                                         newInfo.Insert ( logs[i]->Rev\r
1654                                                 , (const char*) CUnicodeUtils::GetUTF8 (logs[i]->sAuthor)\r
1655                                                 , ""\r
1656                                                 , 0\r
1657                                                 , LogCache::CRevisionInfoContainer::HAS_AUTHOR);\r
1658 \r
1659                                         toUpdate->Update (newInfo);\r
1660                                 }\r
1661                         }\r
1662                         progDlg.SetProgress64(i, logs.size());\r
1663                 }\r
1664                 progDlg.Stop();\r
1665         }\r
1666         theApp.DoWaitCursor(-1);\r
1667         EnableOKButton();\r
1668 #endif\r
1669 }\r
1670 \r
1671 void CLogDlg::EditLogMessage(int index)\r
1672 {\r
1673 #if 0\r
1674         CString url;\r
1675         CString name;\r
1676         DialogEnableWindow(IDOK, FALSE);\r
1677         SetPromptApp(&theApp);\r
1678         theApp.DoWaitCursor(1);\r
1679         if (Git::PathIsURL(m_path))\r
1680                 url = m_path.GetGitPathString();\r
1681         else\r
1682         {\r
1683                 url = GetURLFromPath(m_path);\r
1684         }\r
1685         name = Git_PROP_REVISION_LOG;\r
1686 \r
1687         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(index));\r
1688         m_bCancelled = FALSE;\r
1689         CString value = RevPropertyGet(name, CTGitPath(url), pLogEntry->Rev);\r
1690         CString sOldValue = value;\r
1691         value.Replace(_T("\n"), _T("\r\n"));\r
1692         CInputDlg dlg(this);\r
1693         dlg.m_sHintText.LoadString(IDS_LOG_MESSAGE);\r
1694         dlg.m_sInputText = value;\r
1695         dlg.m_sTitle.LoadString(IDS_LOG_MESSAGEEDITTITLE);\r
1696         dlg.m_pProjectProperties = &m_ProjectProperties;\r
1697         dlg.m_bUseLogWidth = true;\r
1698         if (dlg.DoModal() == IDOK)\r
1699         {\r
1700                 dlg.m_sInputText.Replace(_T("\r"), _T(""));\r
1701                 if (!RevPropertySet(name, dlg.m_sInputText, sOldValue, CTGitPath(url), pLogEntry->Rev))\r
1702                 {\r
1703                         CMessageBox::Show(this->m_hWnd, GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
1704                 }\r
1705                 else\r
1706                 {\r
1707                         pLogEntry->sShortMessage = MakeShortMessage(dlg.m_sInputText);\r
1708                         // split multi line log entries and concatenate them\r
1709                         // again but this time with \r\n as line separators\r
1710                         // so that the edit control recognizes them\r
1711                         if (dlg.m_sInputText.GetLength()>0)\r
1712                         {\r
1713                                 m_sMessageBuf = dlg.m_sInputText;\r
1714                                 dlg.m_sInputText.Replace(_T("\n\r"), _T("\n"));\r
1715                                 dlg.m_sInputText.Replace(_T("\r\n"), _T("\n"));\r
1716                                 if (dlg.m_sInputText.Right(1).Compare(_T("\n"))==0)\r
1717                                         dlg.m_sInputText = dlg.m_sInputText.Left(dlg.m_sInputText.GetLength()-1);\r
1718                         } \r
1719                         else\r
1720                                 dlg.m_sInputText.Empty();\r
1721                         pLogEntry->sMessage = dlg.m_sInputText;\r
1722                         pLogEntry->sBugIDs = m_ProjectProperties.FindBugID(dlg.m_sInputText);\r
1723                         CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);\r
1724                         pMsgView->SetWindowText(_T(" "));\r
1725                         pMsgView->SetWindowText(dlg.m_sInputText);\r
1726                         m_ProjectProperties.FindBugID(dlg.m_sInputText, pMsgView);\r
1727                         m_LogList.Invalidate();\r
1728         \r
1729             // update the log cache \r
1730 \r
1731             LogCache::CCachedLogInfo* toUpdate \r
1732                 = GetLogCache (CTGitPath (m_sRepositoryRoot));\r
1733             if (toUpdate != NULL)\r
1734             {\r
1735                 // log caching is active\r
1736 \r
1737                 LogCache::CCachedLogInfo newInfo;\r
1738                 newInfo.Insert ( pLogEntry->Rev\r
1739                                , ""\r
1740                                , (const char*) CUnicodeUtils::GetUTF8 (pLogEntry->sMessage)\r
1741                                , 0\r
1742                                , LogCache::CRevisionInfoContainer::HAS_COMMENT);\r
1743 \r
1744                 toUpdate->Update (newInfo);\r
1745             }\r
1746         }\r
1747         }\r
1748         theApp.DoWaitCursor(-1);\r
1749         EnableOKButton();\r
1750 #endif\r
1751 }\r
1752 #if 0\r
1753 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)\r
1754 {\r
1755         // Skip Ctrl-C when copying text out of the log message or search filter\r
1756         BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );\r
1757         if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')\r
1758         {\r
1759                 if (GetFocus()==GetDlgItem(IDC_LOGLIST))\r
1760                 {\r
1761                         if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))\r
1762                         {\r
1763                                 DiffSelectedRevWithPrevious();\r
1764                                 return TRUE;\r
1765                         }\r
1766                 }\r
1767                 if (GetFocus()==GetDlgItem(IDC_LOGMSG))\r
1768                 {\r
1769                         DiffSelectedFile();\r
1770                         return TRUE;\r
1771                 }\r
1772         }\r
1773         if (m_hAccel && !bSkipAccelerator)\r
1774         {\r
1775                 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);\r
1776                 if (ret)\r
1777                         return TRUE;\r
1778         }\r
1779         \r
1780         m_tooltips.RelayEvent(pMsg);\r
1781         return __super::PreTranslateMessage(pMsg);\r
1782 }\r
1783 #endif\r
1784 \r
1785 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)\r
1786 {\r
1787         //if (this->IsThreadRunning())\r
1788         if(m_LogList.m_bNoDispUpdates)\r
1789         {\r
1790                 // only show the wait cursor over the list control\r
1791                 if ((pWnd)&&\r
1792                         ((pWnd == GetDlgItem(IDC_LOGLIST))||\r
1793                         (pWnd == GetDlgItem(IDC_MSGVIEW))||\r
1794                         (pWnd == GetDlgItem(IDC_LOGMSG))))\r
1795                 {\r
1796                         HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));\r
1797                         SetCursor(hCur);\r
1798                         return TRUE;\r
1799                 }\r
1800         }\r
1801         if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))\r
1802                 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);\r
1803 \r
1804         HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));\r
1805         SetCursor(hCur);\r
1806         return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);\r
1807 }\r
1808 \r
1809 void CLogDlg::OnBnClickedHelp()\r
1810 {\r
1811         OnHelp();\r
1812 }\r
1813 \r
1814 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
1815 {\r
1816         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1817         *pResult = 0;\r
1818         //if (this->IsThreadRunning())\r
1819         if(m_LogList.m_bNoDispUpdates)\r
1820                 return;\r
1821         if (pNMLV->iItem >= 0)\r
1822         {\r
1823                 m_nSearchIndex = pNMLV->iItem;\r
1824                 if (pNMLV->iSubItem != 0)\r
1825                         return;\r
1826                 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount())&&(m_bStrict)&&(1/*m_bStrictStopped*/))\r
1827                 {\r
1828                         // remove the selected state\r
1829                         if (pNMLV->uChanged & LVIF_STATE)\r
1830                         {\r
1831                                 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);\r
1832                                 FillLogMessageCtrl();\r
1833                                 UpdateData(FALSE);\r
1834                                 UpdateLogInfoLabel();\r
1835                         }\r
1836                         return;\r
1837                 }\r
1838                 if (pNMLV->uChanged & LVIF_STATE)\r
1839                 {\r
1840                         FillLogMessageCtrl();\r
1841                         UpdateData(FALSE);\r
1842                 }\r
1843         }\r
1844         else\r
1845         {\r
1846                 FillLogMessageCtrl();\r
1847                 UpdateData(FALSE);\r
1848         }\r
1849         EnableOKButton();\r
1850         UpdateLogInfoLabel();\r
1851 }\r
1852 \r
1853 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)\r
1854 {\r
1855         ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);\r
1856         if (pEnLink->msg == WM_LBUTTONUP)\r
1857         {\r
1858                 CString url, msg;\r
1859                 GetDlgItemText(IDC_MSGVIEW, msg);\r
1860                 msg.Replace(_T("\r\n"), _T("\n"));\r
1861                 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);\r
1862                 if (!::PathIsURL(url))\r
1863                 {\r
1864                         url = m_ProjectProperties.GetBugIDUrl(url);\r
1865                         url = GetAbsoluteUrlFromRelativeUrl(url);\r
1866                 }\r
1867                 if (!url.IsEmpty())\r
1868                         ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);\r
1869         }\r
1870         *pResult = 0;\r
1871 }\r
1872 \r
1873 void CLogDlg::OnBnClickedStatbutton()\r
1874 {\r
1875 \r
1876         if (this->IsThreadRunning())\r
1877                 return;\r
1878         if (m_LogList.m_arShownList.IsEmpty())\r
1879                 return;         // nothing is shown, so no statistics.\r
1880         // the statistics dialog expects the log entries to be sorted by date\r
1881         SortByColumn(3, false);\r
1882         CPtrArray shownlist;\r
1883         m_LogList.RecalculateShownList(&shownlist);\r
1884         // create arrays which are aware of the current filter\r
1885         CStringArray m_arAuthorsFiltered;\r
1886         CDWordArray m_arDatesFiltered;\r
1887         CDWordArray m_arFileChangesFiltered;\r
1888         for (INT_PTR i=0; i<shownlist.GetCount(); ++i)\r
1889         {\r
1890                 GitRev* pLogEntry = reinterpret_cast<GitRev*>(shownlist.GetAt(i));\r
1891                 CString strAuthor = pLogEntry->m_AuthorName;\r
1892                 if ( strAuthor.IsEmpty() )\r
1893                 {\r
1894                         strAuthor.LoadString(IDS_STATGRAPH_EMPTYAUTHOR);\r
1895                 }\r
1896                 m_arAuthorsFiltered.Add(strAuthor);\r
1897                 m_arDatesFiltered.Add(pLogEntry->m_AuthorDate.GetTime());\r
1898                 m_arFileChangesFiltered.Add(pLogEntry->m_Files.GetCount());\r
1899         }\r
1900         CStatGraphDlg dlg;\r
1901         dlg.m_parAuthors = &m_arAuthorsFiltered;\r
1902         dlg.m_parDates = &m_arDatesFiltered;\r
1903         dlg.m_parFileChanges = &m_arFileChangesFiltered;\r
1904         dlg.m_path = m_path;\r
1905         dlg.DoModal();\r
1906         // restore the previous sorting\r
1907         SortByColumn(m_nSortColumn, m_bAscending);\r
1908         OnTimer(LOGFILTER_TIMER);\r
1909 \r
1910 }\r
1911 \r
1912 #if 0\r
1913 void CLogDlg::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
1914 {\r
1915 \r
1916         NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );\r
1917         // Take the default processing unless we set this to something else below.\r
1918         *pResult = CDRF_DODEFAULT;\r
1919 \r
1920         if (m_bNoDispUpdates)\r
1921                 return;\r
1922 \r
1923         switch (pLVCD->nmcd.dwDrawStage)\r
1924         {\r
1925         case CDDS_PREPAINT:\r
1926                 {\r
1927                         *pResult = CDRF_NOTIFYITEMDRAW;\r
1928                         return;\r
1929                 }\r
1930                 break;\r
1931         case CDDS_ITEMPREPAINT:\r
1932                 {\r
1933                         // This is the prepaint stage for an item. Here's where we set the\r
1934                         // item's text color. \r
1935                         \r
1936                         // Tell Windows to send draw notifications for each subitem.\r
1937                         *pResult = CDRF_NOTIFYSUBITEMDRAW;\r
1938 \r
1939                         COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);\r
1940 \r
1941                         if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
1942                         {\r
1943                                 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);\r
1944                                 if (data)\r
1945                                 {\r
1946 #if 0\r
1947                                         if (data->bCopiedSelf)\r
1948                                         {\r
1949                                                 // only change the background color if the item is not 'hot' (on vista with themes enabled)\r
1950                                                 if (!theme.IsAppThemed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))\r
1951                                                         pLVCD->clrTextBk = GetSysColor(COLOR_MENU);\r
1952                                         }\r
1953 \r
1954                                         if (data->bCopies)\r
1955                                                 crText = m_Colors.GetColor(CColors::Modified);\r
1956 #endif\r
1957 //                                      if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))\r
1958 //                                              crText = GetSysColor(COLOR_GRAYTEXT);\r
1959 //                                      if (data->Rev == m_wcRev)\r
1960 //                                      {\r
1961 //                                              SelectObject(pLVCD->nmcd.hdc, m_boldFont);\r
1962                                                 // We changed the font, so we're returning CDRF_NEWFONT. This\r
1963                                                 // tells the control to recalculate the extent of the text.\r
1964 //                                              *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;\r
1965 //                                      }\r
1966                                 }\r
1967                         }\r
1968                         if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
1969                         {\r
1970                                 if (m_bStrictStopped)\r
1971                                         crText = GetSysColor(COLOR_GRAYTEXT);\r
1972                         }\r
1973                         // Store the color back in the NMLVCUSTOMDRAW struct.\r
1974                         pLVCD->clrText = crText;\r
1975                         return;\r
1976                 }\r
1977                 break;\r
1978         case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:\r
1979                 {\r
1980                         if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))\r
1981                         {\r
1982                                 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);\r
1983                         }\r
1984                         if (pLVCD->iSubItem == 1)\r
1985                         {\r
1986                                 *pResult = CDRF_DODEFAULT;\r
1987 \r
1988                                 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
1989                                         return;\r
1990 \r
1991                                 int             nIcons = 0;\r
1992                                 int             iconwidth = ::GetSystemMetrics(SM_CXSMICON);\r
1993                                 int             iconheight = ::GetSystemMetrics(SM_CYSMICON);\r
1994 \r
1995                                 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));\r
1996 \r
1997                                 // Get the selected state of the\r
1998                                 // item being drawn.\r
1999                                 LVITEM   rItem;\r
2000                                 SecureZeroMemory(&rItem, sizeof(LVITEM));\r
2001                                 rItem.mask  = LVIF_STATE;\r
2002                                 rItem.iItem = pLVCD->nmcd.dwItemSpec;\r
2003                                 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;\r
2004                                 m_LogList.GetItem(&rItem);\r
2005 \r
2006                                 CRect rect;\r
2007                                 m_LogList.GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
2008 \r
2009                                 // Fill the background\r
2010                                 if (theme.IsAppThemed() && m_bVista)\r
2011                                 {\r
2012                                         theme.Open(m_hWnd, L"Explorer");\r
2013                                         int state = LISS_NORMAL;\r
2014                                         if (rItem.state & LVIS_SELECTED)\r
2015                                         {\r
2016                                                 if (::GetFocus() == m_LogList.m_hWnd)\r
2017                                                         state |= LISS_SELECTED;\r
2018                                                 else\r
2019                                                         state |= LISS_SELECTEDNOTFOCUS;\r
2020                                         }\r
2021                                         else\r
2022                                         {\r
2023 #if 0\r
2024                                                 if (pLogEntry->bCopiedSelf)\r
2025                                                 {\r
2026                                                         // unfortunately, the pLVCD->nmcd.uItemState does not contain valid\r
2027                                                         // information at this drawing stage. But we can check the whether the\r
2028                                                         // previous stage changed the background color of the item\r
2029                                                         if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))\r
2030                                                         {\r
2031                                                                 HBRUSH brush;\r
2032                                                                 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
2033                                                                 if (brush)\r
2034                                                                 {\r
2035                                                                         ::FillRect(pLVCD->nmcd.hdc, &rect, brush);\r
2036                                                                         ::DeleteObject(brush);\r
2037                                                                 }\r
2038                                                         }\r
2039                                                 }\r
2040 #endif\r
2041                                         }\r
2042 \r
2043                                         if (theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))\r
2044                                                 theme.DrawParentBackground(m_hWnd, pLVCD->nmcd.hdc, &rect);\r
2045 \r
2046                                         theme.DrawBackground(pLVCD->nmcd.hdc, LVP_LISTDETAIL, state, &rect, NULL);\r
2047                                 }\r
2048                                 else\r
2049                                 {\r
2050                                         HBRUSH brush;\r
2051                                         if (rItem.state & LVIS_SELECTED)\r
2052                                         {\r
2053                                                 if (::GetFocus() == m_LogList.m_hWnd)\r
2054                                                         brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));\r
2055                                                 else\r
2056                                                         brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));\r
2057                                         }\r
2058                                         else\r
2059                                         {\r
2060                                                 //if (pLogEntry->bCopiedSelf)\r
2061                                                 //      brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));\r
2062                                                 //else\r
2063                                                         brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));\r
2064                                         }\r
2065                                         if (brush == NULL)\r
2066                                                 return;\r
2067 \r
2068                                         ::FillRect(pLVCD->nmcd.hdc, &rect, brush);\r
2069                                         ::DeleteObject(brush);\r
2070                                 }\r
2071 \r
2072                                 // Draw the icon(s) into the compatible DC\r
2073                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)\r
2074                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2075                                 nIcons++;\r
2076 \r
2077                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)\r
2078                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2079                                 nIcons++;\r
2080 \r
2081                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)\r
2082                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2083                                 nIcons++;\r
2084 \r
2085                                 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)\r
2086                                         ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);\r
2087                                 nIcons++;\r
2088                                 *pResult = CDRF_SKIPDEFAULT;\r
2089                                 return;\r
2090                         }\r
2091                 }\r
2092                 break;\r
2093         }\r
2094         *pResult = CDRF_DODEFAULT;\r
2095 \r
2096 }\r
2097 #endif\r
2098 \r
2099 void CLogDlg::OnNMCustomdrawChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)\r
2100 {\r
2101 \r
2102         NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );\r
2103         // Take the default processing unless we set this to something else below.\r
2104         *pResult = CDRF_DODEFAULT;\r
2105 \r
2106 //      if (m_bNoDispUpdates)\r
2107 //              return;\r
2108 \r
2109         // First thing - check the draw stage. If it's the control's prepaint\r
2110         // stage, then tell Windows we want messages for every item.\r
2111 \r
2112         if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )\r
2113         {\r
2114                 *pResult = CDRF_NOTIFYITEMDRAW;\r
2115         }\r
2116         else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )\r
2117         {\r
2118                 // This is the prepaint stage for an item. Here's where we set the\r
2119                 // item's text color. Our return value will tell Windows to draw the\r
2120                 // item itself, but it will use the new color we set here.\r
2121 \r
2122                 // Tell Windows to paint the control itself.\r
2123                 *pResult = CDRF_DODEFAULT;\r
2124 \r
2125                 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);\r
2126                 bool bGrayed = false;\r
2127 #if 0\r
2128                 if ((m_cHidePaths.GetState() & 0x0003)==BST_INDETERMINATE)\r
2129                 {\r
2130                         if ((m_currentChangedArray)&&((m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)))\r
2131                         {\r
2132                                 //if ((*m_currentChangedArray)[(pLVCD->nmcd.dwItemSpec)]sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)\r
2133                                 {\r
2134                                         crText = GetSysColor(COLOR_GRAYTEXT);\r
2135                                         bGrayed = true;\r
2136                                 }\r
2137                         }\r
2138                         else if (m_currentChangedPathList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
2139                         {\r
2140                                 //if (m_currentChangedPathList[pLVCD->nmcd.dwItemSpec].GetGitPathString().Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)!=0)\r
2141                                 {\r
2142                                         crText = GetSysColor(COLOR_GRAYTEXT);\r
2143                                         bGrayed = true;\r
2144                                 }\r
2145                         }\r
2146                 }\r
2147 \r
2148 #endif\r
2149                 if ((!bGrayed)&&(m_currentChangedArray)&&(m_currentChangedArray->GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec))\r
2150                 {\r
2151                         DWORD action = ((*m_currentChangedArray)[pLVCD->nmcd.dwItemSpec]).m_Action;\r
2152                         if (action == CTGitPath::LOGACTIONS_MODIFIED)\r
2153                                 crText = m_Colors.GetColor(CColors::Modified);\r
2154                         if (action == CTGitPath::LOGACTIONS_REPLACED)\r
2155                                 crText = m_Colors.GetColor(CColors::Deleted);\r
2156                         if (action == CTGitPath::LOGACTIONS_ADDED)\r
2157                                 crText = m_Colors.GetColor(CColors::Added);\r
2158                         if (action == CTGitPath::LOGACTIONS_DELETED)\r
2159                                 crText = m_Colors.GetColor(CColors::Deleted);\r
2160                 }\r
2161 \r
2162                 // Store the color back in the NMLVCUSTOMDRAW struct.\r
2163                 pLVCD->clrText = crText;\r
2164         }\r
2165 }\r
2166 \r
2167 void CLogDlg::DoSizeV1(int delta)\r
2168 {\r
2169 \r
2170         RemoveAnchor(IDC_LOGLIST);\r
2171         RemoveAnchor(IDC_SPLITTERTOP);\r
2172         RemoveAnchor(IDC_MSGVIEW);\r
2173         RemoveAnchor(IDC_SPLITTERBOTTOM);\r
2174         RemoveAnchor(IDC_LOGMSG);\r
2175         CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);\r
2176         CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), -delta, CW_BOTTOMALIGN);\r
2177         AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);\r
2178         AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);\r
2179         AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);\r
2180         AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2181         AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2182         ArrangeLayout();\r
2183         AdjustMinSize();\r
2184         SetSplitterRange();\r
2185         m_LogList.Invalidate();\r
2186         GetDlgItem(IDC_MSGVIEW)->Invalidate();\r
2187 \r
2188 }\r
2189 \r
2190 void CLogDlg::DoSizeV2(int delta)\r
2191 {\r
2192 \r
2193         RemoveAnchor(IDC_LOGLIST);\r
2194         RemoveAnchor(IDC_SPLITTERTOP);\r
2195         RemoveAnchor(IDC_MSGVIEW);\r
2196         RemoveAnchor(IDC_SPLITTERBOTTOM);\r
2197         RemoveAnchor(IDC_LOGMSG);\r
2198         CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), delta, CW_TOPALIGN);\r
2199         CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);\r
2200         AddAnchor(IDC_LOGLIST, TOP_LEFT, TOP_RIGHT);\r
2201         AddAnchor(IDC_SPLITTERTOP, TOP_LEFT, TOP_RIGHT);\r
2202         AddAnchor(IDC_MSGVIEW, TOP_LEFT, BOTTOM_RIGHT);\r
2203         AddAnchor(IDC_SPLITTERBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2204         AddAnchor(IDC_LOGMSG, BOTTOM_LEFT, BOTTOM_RIGHT);\r
2205         ArrangeLayout();\r
2206         AdjustMinSize();\r
2207         SetSplitterRange();\r
2208         GetDlgItem(IDC_MSGVIEW)->Invalidate();\r
2209         m_ChangedFileListCtrl.Invalidate();\r
2210 \r
2211 }\r
2212 \r
2213 void CLogDlg::AdjustMinSize()\r
2214 {\r
2215         // adjust the minimum size of the dialog to prevent the resizing from\r
2216         // moving the list control too far down.\r
2217         CRect rcChgListView;\r
2218         m_ChangedFileListCtrl.GetClientRect(rcChgListView);\r
2219         CRect rcLogList;\r
2220         m_LogList.GetClientRect(rcLogList);\r
2221 \r
2222         SetMinTrackSize(CSize(m_DlgOrigRect.Width(), \r
2223                 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()\r
2224                 +rcChgListView.Height()+rcLogList.Height()+60));\r
2225 }\r
2226 \r
2227 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r
2228 {\r
2229         switch (message) {\r
2230         case WM_NOTIFY:\r
2231                 if (wParam == IDC_SPLITTERTOP)\r
2232                 { \r
2233                         SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;\r
2234                         DoSizeV1(pHdr->delta);\r
2235                 }\r
2236                 else if (wParam == IDC_SPLITTERBOTTOM)\r
2237                 { \r
2238                         SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;\r
2239                         DoSizeV2(pHdr->delta);\r
2240                 }\r
2241                 break;\r
2242         }\r
2243 \r
2244         return CResizableDialog::DefWindowProc(message, wParam, lParam);\r
2245 }\r
2246 \r
2247 void CLogDlg::SetSplitterRange()\r
2248 {\r
2249         if ((m_LogList)&&(m_ChangedFileListCtrl))\r
2250         {\r
2251                 CRect rcTop;\r
2252                 m_LogList.GetWindowRect(rcTop);\r
2253                 ScreenToClient(rcTop);\r
2254                 CRect rcMiddle;\r
2255                 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(rcMiddle);\r
2256                 ScreenToClient(rcMiddle);\r
2257                 m_wndSplitter1.SetRange(rcTop.top+30, rcMiddle.bottom-20);\r
2258                 CRect rcBottom;\r
2259                 m_ChangedFileListCtrl.GetWindowRect(rcBottom);\r
2260                 ScreenToClient(rcBottom);\r
2261                 m_wndSplitter2.SetRange(rcMiddle.top+30, rcBottom.bottom-20);\r
2262         }\r
2263 }\r
2264 \r
2265 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM /*wParam*/, LPARAM lParam)\r
2266 {\r
2267         RECT * rect = (LPRECT)lParam;\r
2268         CPoint point;\r
2269         CString temp;\r
2270         point = CPoint(rect->left, rect->bottom);\r
2271 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | (m_LogList.m_nSelectedFilter == x ? MF_CHECKED : MF_UNCHECKED))\r
2272         CMenu popup;\r
2273         if (popup.CreatePopupMenu())\r
2274         {\r
2275                 temp.LoadString(IDS_LOG_FILTER_ALL);\r
2276                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_ALL), LOGFILTER_ALL, temp);\r
2277 \r
2278                 popup.AppendMenu(MF_SEPARATOR, NULL);\r
2279                 \r
2280                 temp.LoadString(IDS_LOG_FILTER_MESSAGES);\r
2281                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);\r
2282                 temp.LoadString(IDS_LOG_FILTER_PATHS);\r
2283                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);\r
2284                 temp.LoadString(IDS_LOG_FILTER_AUTHORS);\r
2285                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);\r
2286                 temp.LoadString(IDS_LOG_FILTER_REVS);\r
2287                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);\r
2288                 temp.LoadString(IDS_LOG_FILTER_BUGIDS);\r
2289                 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);\r
2290                 \r
2291                 popup.AppendMenu(MF_SEPARATOR, NULL);\r
2292 \r
2293                 temp.LoadString(IDS_LOG_FILTER_REGEX);\r
2294                 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);\r
2295 \r
2296                 m_tooltips.Pop();\r
2297                 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
2298                 if (selection != 0)\r
2299                 {\r
2300 \r
2301                         if (selection == LOGFILTER_REGEX)\r
2302                         {\r
2303                                 m_bFilterWithRegex = !m_bFilterWithRegex;\r
2304                                 CRegDWORD b = CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);\r
2305                                 b = m_bFilterWithRegex;\r
2306                                 CheckRegexpTooltip();\r
2307                         }\r
2308                         else\r
2309                         {\r
2310                                 m_LogList.m_nSelectedFilter = selection;\r
2311                                 SetFilterCueText();\r
2312                         }\r
2313                         SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
2314                 }\r
2315         }\r
2316         return 0L;\r
2317 }\r
2318 \r
2319 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)\r
2320 {\r
2321 #if 0\r
2322         KillTimer(LOGFILTER_TIMER);\r
2323 \r
2324         m_sFilterText.Empty();\r
2325         UpdateData(FALSE);\r
2326         theApp.DoWaitCursor(1);\r
2327         CStoreSelection storeselection(this);\r
2328         FillLogMessageCtrl(false);\r
2329         InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
2330         m_arShownList.RemoveAll();\r
2331 \r
2332         // reset the time filter too\r
2333         m_timFrom = (__time64_t(m_tFrom));\r
2334         m_timTo = (__time64_t(m_tTo));\r
2335         m_DateFrom.SetTime(&m_timFrom);\r
2336         m_DateTo.SetTime(&m_timTo);\r
2337         m_DateFrom.SetRange(&m_timFrom, &m_timTo);\r
2338         m_DateTo.SetRange(&m_timFrom, &m_timTo);\r
2339 \r
2340         for (DWORD i=0; i<m_logEntries.size(); ++i)\r
2341         {\r
2342                 m_arShownList.Add(m_logEntries[i]);\r
2343         }\r
2344         InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
2345         m_LogList.DeleteAllItems();\r
2346         m_LogList.SetItemCountEx(ShownCountWithStopped());\r
2347         m_LogList.RedrawItems(0, ShownCountWithStopped());\r
2348         m_LogList.SetRedraw(false);\r
2349         ResizeAllListCtrlCols();\r
2350         m_LogList.SetRedraw(true);\r
2351         theApp.DoWaitCursor(-1);\r
2352         GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
2353         GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
2354         GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
2355         UpdateLogInfoLabel();\r
2356 #endif\r
2357         return 0L;      \r
2358 }\r
2359 \r
2360 \r
2361 void CLogDlg::SetFilterCueText()\r
2362 {\r
2363         CString temp;\r
2364         switch (m_LogList.m_nSelectedFilter)\r
2365         {\r
2366         case LOGFILTER_ALL:\r
2367                 temp.LoadString(IDS_LOG_FILTER_ALL);\r
2368                 break;\r
2369         case LOGFILTER_MESSAGES:\r
2370                 temp.LoadString(IDS_LOG_FILTER_MESSAGES);\r
2371                 break;\r
2372         case LOGFILTER_PATHS:\r
2373                 temp.LoadString(IDS_LOG_FILTER_PATHS);\r
2374                 break;\r
2375         case LOGFILTER_AUTHORS:\r
2376                 temp.LoadString(IDS_LOG_FILTER_AUTHORS);\r
2377                 break;\r
2378         case LOGFILTER_REVS:\r
2379                 temp.LoadString(IDS_LOG_FILTER_REVS);\r
2380                 break;\r
2381         }\r
2382         // to make the cue banner text appear more to the right of the edit control\r
2383         temp = _T("   ")+temp;\r
2384         m_cFilter.SetCueBanner(temp);\r
2385 }\r
2386 #if 0\r
2387 void CLogDlg::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
2388 {\r
2389         NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
2390 \r
2391         // Create a pointer to the item\r
2392         LV_ITEM* pItem = &(pDispInfo)->item;\r
2393 \r
2394         // Do the list need text information?\r
2395         if (!(pItem->mask & LVIF_TEXT))\r
2396                 return;\r
2397 \r
2398         // By default, clear text buffer.\r
2399         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2400 \r
2401         bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();\r
2402         \r
2403         *pResult = 0;\r
2404         if (m_bNoDispUpdates || m_bThreadRunning || bOutOfRange)\r
2405                 return;\r
2406 \r
2407         // Which item number?\r
2408         int itemid = pItem->iItem;\r
2409         GitRev * pLogEntry = NULL;\r
2410         if (itemid < m_arShownList.GetCount())\r
2411                 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));\r
2412     \r
2413         // Which column?\r
2414         switch (pItem->iSubItem)\r
2415         {\r
2416         case this->LOGLIST_GRAPH:       //Graphic\r
2417                 if (pLogEntry)\r
2418                 {\r
2419                 }\r
2420                 break;\r
2421         case this->LOGLIST_ACTION: //action -- no text in the column\r
2422                 break;\r
2423         case this->LOGLIST_MESSAGE: //Message\r
2424                 if (pLogEntry)\r
2425                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);\r
2426                 break;\r
2427         case this->LOGLIST_AUTHOR: //Author\r
2428                 if (pLogEntry)\r
2429                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);\r
2430                 break;\r
2431         case this->LOGLIST_DATE: //Date\r
2432                 if (pLogEntry)\r
2433                         lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);\r
2434                 break;\r
2435                 \r
2436         case 5:\r
2437 \r
2438                 break;\r
2439         default:\r
2440                 ASSERT(false);\r
2441         }\r
2442 }\r
2443 #endif\r
2444 void CLogDlg::OnLvnGetdispinfoChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)\r
2445 {\r
2446 \r
2447 #if 0\r
2448         NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);\r
2449 \r
2450         //Create a pointer to the item\r
2451         LV_ITEM* pItem= &(pDispInfo)->item;\r
2452 \r
2453         *pResult = 0;\r
2454         if ((m_bNoDispUpdates)||(m_bThreadRunning))\r
2455         {\r
2456                 if (pItem->mask & LVIF_TEXT)\r
2457                         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2458                 return;\r
2459         }\r
2460         if ((m_currentChangedArray!=NULL)&&(pItem->iItem >= m_currentChangedArray->GetCount()))\r
2461         {\r
2462                 if (pItem->mask & LVIF_TEXT)\r
2463                         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2464                 return;\r
2465         }\r
2466         if ((m_currentChangedArray==NULL)&&(pItem->iItem >= m_currentChangedPathList.GetCount()))\r
2467         {\r
2468                 if (pItem->mask & LVIF_TEXT)\r
2469                         lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2470                 return;\r
2471         }\r
2472         CTGitPath lcpath = NULL;\r
2473         if (m_currentChangedArray)\r
2474                 lcpath = (*m_currentChangedArray)[pItem->iItem];\r
2475         //Does the list need text information?\r
2476         if (pItem->mask & LVIF_TEXT)\r
2477         {\r
2478                 //Which column?\r
2479                 switch (pItem->iSubItem)\r
2480                 {\r
2481                 case this->FILELIST_ACTION:     //Action\r
2482 #if 0\r
2483                         if (lcpath)\r
2484                                 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->GetAction(), pItem->cchTextMax);\r
2485                         else\r
2486                                 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);                            \r
2487 #endif\r
2488                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetActionName(), pItem->cchTextMax);\r
2489 \r
2490                         break;\r
2491 \r
2492                 case this->FILELIST_ADD: //add\r
2493 #if 0\r
2494                         if (lcpath)\r
2495                                 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sPath, pItem->cchTextMax);\r
2496                         else\r
2497                                 lstrcpyn(pItem->pszText, (LPCTSTR)m_currentChangedPathList[pItem->iItem].GetGitPathString(), pItem->cchTextMax);\r
2498 #endif\r
2499                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatAdd, pItem->cchTextMax);\r
2500                         break;\r
2501 \r
2502                 case this->FILELIST_DEL: //del\r
2503 #if 0\r
2504                         if (lcpath)\r
2505                                 lstrcpyn(pItem->pszText, (LPCTSTR)lcpath->sCopyFromPath, pItem->cchTextMax);\r
2506                         else\r
2507                                 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2508 #endif\r
2509                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.m_StatDel, pItem->cchTextMax);\r
2510                         break;\r
2511                 case this->FILELIST_PATH: //path\r
2512 #if 0\r
2513                         if ((lcpath==NULL)||(lcpath->sCopyFromPath.IsEmpty()))\r
2514                                 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);\r
2515                         else\r
2516                                 _stprintf_s(pItem->pszText, pItem->cchTextMax, _T("%ld"), lcpath->lCopyFromRev);\r
2517 #endif\r
2518                         lstrcpyn(pItem->pszText, (LPCTSTR)lcpath.GetGitPathString(), pItem->cchTextMax);\r
2519                         break;\r
2520                 }\r
2521         }\r
2522 #endif\r
2523         *pResult = 0;\r
2524 }\r
2525 \r
2526 void CLogDlg::OnEnChangeSearchedit()\r
2527 {\r
2528 #if 0\r
2529         UpdateData();\r
2530         if (m_sFilterText.IsEmpty())\r
2531         {\r
2532                 CStoreSelection storeselection(this);\r
2533                 // clear the filter, i.e. make all entries appear\r
2534                 theApp.DoWaitCursor(1);\r
2535                 KillTimer(LOGFILTER_TIMER);\r
2536                 FillLogMessageCtrl(false);\r
2537                 InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
2538                 m_arShownList.RemoveAll();\r
2539                 for (DWORD i=0; i<m_logEntries.size(); ++i)\r
2540                 {\r
2541                         if (IsEntryInDateRange(i))\r
2542                                 m_arShownList.Add(m_logEntries[i]);\r
2543                 }\r
2544                 InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
2545                 m_LogList.DeleteAllItems();\r
2546                 m_LogList.SetItemCountEx(ShownCountWithStopped());\r
2547                 m_LogList.RedrawItems(0, ShownCountWithStopped());\r
2548                 m_LogList.SetRedraw(false);\r
2549                 ResizeAllListCtrlCols();\r
2550                 m_LogList.SetRedraw(true);\r
2551                 theApp.DoWaitCursor(-1);\r
2552                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
2553                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
2554                 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
2555                 DialogEnableWindow(IDC_STATBUTTON, !(((m_bThreadRunning)||(m_arShownList.IsEmpty()))));\r
2556                 return;\r
2557         }\r
2558         if (Validate(m_sFilterText))\r
2559                 SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
2560         else\r
2561                 KillTimer(LOGFILTER_TIMER);\r
2562 #endif\r
2563 }\r
2564 \r
2565 bool CLogDlg::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)\r
2566 {\r
2567         try\r
2568         {\r
2569                 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;\r
2570                 if (!bMatchCase)\r
2571                         type |= tr1::regex_constants::icase;\r
2572                 pat = tr1::wregex(regexp_str, type);\r
2573                 return true;\r
2574         }\r
2575         catch (exception) {}\r
2576         return false;\r
2577 }\r
2578 \r
2579 bool CLogDlg::Validate(LPCTSTR string)\r
2580 {\r
2581         if (!m_bFilterWithRegex)\r
2582                 return true;\r
2583         tr1::wregex pat;\r
2584         return ValidateRegexp(string, pat, false);\r
2585 }\r
2586 \r
2587 \r
2588 void CLogDlg::OnTimer(UINT_PTR nIDEvent)\r
2589 {\r
2590         if (nIDEvent == LOGFILTER_TIMER)\r
2591         {\r
2592                 if (this->IsThreadRunning())\r
2593                 {\r
2594                         // thread still running! So just restart the timer.\r
2595                         SetTimer(LOGFILTER_TIMER, 1000, NULL);\r
2596                         return;\r
2597                 }\r
2598                 CWnd * focusWnd = GetFocus();\r
2599                 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))\r
2600                         && (focusWnd != GetDlgItem(IDC_LOGLIST)));\r
2601                 if (m_sFilterText.IsEmpty())\r
2602                 {\r
2603                         DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));\r
2604                         // do not return here!\r
2605                         // we also need to run the filter if the filter text is empty:\r
2606                         // 1. to clear an existing filter\r
2607                         // 2. to rebuild the m_arShownList after sorting\r
2608                 }\r
2609                 theApp.DoWaitCursor(1);\r
2610                 CStoreSelection storeselection(this);\r
2611                 KillTimer(LOGFILTER_TIMER);\r
2612                 FillLogMessageCtrl(false);\r
2613 \r
2614                 // now start filter the log list\r
2615 //              InterlockedExchange(&m_bNoDispUpdates, TRUE);\r
2616 //              RecalculateShownList(&m_LogList.m_arShownList);\r
2617 //              InterlockedExchange(&m_bNoDispUpdates, FALSE);\r
2618 \r
2619 \r
2620 //              m_LogList.DeleteAllItems();\r
2621 //              m_LogList.SetItemCountEx(m_LogList.ShownCountWithStopped());\r
2622 //              m_LogList.RedrawItems(0, m_LogList.ShownCountWithStopped());\r
2623 //              m_LogList.SetRedraw(false);\r
2624 //              m_LogList.ResizeAllListCtrlCols();\r
2625 //              m_LogList.SetRedraw(true);\r
2626 //              m_LogList.Invalidate();\r
2627 //              if ( m_LogList.GetItemCount()==1 )\r
2628 //              {\r
2629 //                      m_LogList.SetSelectionMark(0);\r
2630 //                      m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);\r
2631 //              }\r
2632                 theApp.DoWaitCursor(-1);\r
2633                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);\r
2634                 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);\r
2635                 if (bSetFocusToFilterControl)\r
2636                         GetDlgItem(IDC_SEARCHEDIT)->SetFocus();\r
2637                 UpdateLogInfoLabel();\r
2638         } // if (nIDEvent == LOGFILTER_TIMER)\r
2639         DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));\r
2640         __super::OnTimer(nIDEvent);\r
2641 }\r
2642 \r
2643 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
2644 {\r
2645         CTime _time;\r
2646         m_DateTo.GetTime(_time);\r
2647         try\r
2648         {\r
2649                 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);\r
2650                 if (time.GetTime() != m_tTo)\r
2651                 {\r
2652                         m_tTo = (DWORD)time.GetTime();\r
2653                         SetTimer(LOGFILTER_TIMER, 10, NULL);\r
2654                 }\r
2655         }\r
2656         catch (CAtlException)\r
2657         {\r
2658         }\r
2659         \r
2660         *pResult = 0;\r
2661 }\r
2662 \r
2663 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
2664 {\r
2665         CTime _time;\r
2666         m_DateFrom.GetTime(_time);\r
2667         try\r
2668         {\r
2669                 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);\r
2670                 if (time.GetTime() != m_tFrom)\r
2671                 {\r
2672                         m_tFrom = (DWORD)time.GetTime();\r
2673                         SetTimer(LOGFILTER_TIMER, 10, NULL);\r
2674                 }\r
2675         }\r
2676         catch (CAtlException)\r
2677         {\r
2678         }\r
2679         \r
2680         *pResult = 0;\r
2681 }\r
2682 \r
2683 \r
2684 \r
2685 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool bRelativePaths /* = false */, bool bUseFilter /* = true */)\r
2686 {\r
2687         CTGitPathList pathList;\r
2688 #if 0\r
2689         \r
2690         if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))\r
2691         {\r
2692                 m_sRepositoryRoot = GetRepositoryRoot(m_path);\r
2693         }\r
2694         if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))\r
2695                 return pathList;\r
2696         \r
2697         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
2698         if (pos != NULL)\r
2699         {\r
2700                 while (pos)\r
2701                 {\r
2702                         int nextpos = m_LogList.GetNextSelectedItem(pos);\r
2703                         if (nextpos >= m_arShownList.GetCount())\r
2704                                 continue;\r
2705                         PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(nextpos));\r
2706                         LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;\r
2707                         for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)\r
2708                         {\r
2709                                 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);\r
2710                                 if (cpath == NULL)\r
2711                                         continue;\r
2712                                 CTGitPath path;\r
2713                                 if (!bRelativePaths)\r
2714                                         path.SetFromGit(m_sRepositoryRoot);\r
2715                                 path.AppendPathString(cpath->sPath);\r
2716                                 if ((!bUseFilter)||\r
2717                                         ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||\r
2718                                         (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))\r
2719                                         pathList.AddPath(path);\r
2720                                 \r
2721                         }\r
2722                 }\r
2723         }\r
2724         pathList.RemoveDuplicates();\r
2725 #endif\r
2726         return pathList;\r
2727 }\r
2728 \r
2729 void CLogDlg::SortByColumn(int nSortColumn, bool bAscending)\r
2730 {\r
2731 #if 0\r
2732         switch(nSortColumn)\r
2733         {\r
2734         case 0: // Revision\r
2735                 {\r
2736                         if(bAscending)\r
2737                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());\r
2738                         else\r
2739                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());\r
2740                 }\r
2741                 break;\r
2742         case 1: // action\r
2743                 {\r
2744                         if(bAscending)\r
2745                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());\r
2746                         else\r
2747                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());\r
2748                 }\r
2749                 break;\r
2750         case 2: // Author\r
2751                 {\r
2752                         if(bAscending)\r
2753                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());\r
2754                         else\r
2755                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());\r
2756                 }\r
2757                 break;\r
2758         case 3: // Date\r
2759                 {\r
2760                         if(bAscending)\r
2761                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());\r
2762                         else\r
2763                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());\r
2764                 }\r
2765                 break;\r
2766         case 4: // Message or bug id\r
2767                 if (m_bShowBugtraqColumn)\r
2768                 {\r
2769                         if(bAscending)\r
2770                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());\r
2771                         else\r
2772                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());\r
2773                         break;\r
2774                 }\r
2775                 // fall through here\r
2776         case 5: // Message\r
2777                 {\r
2778                         if(bAscending)\r
2779                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());\r
2780                         else\r
2781                                 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());\r
2782                 }\r
2783                 break;\r
2784         default:\r
2785                 ATLASSERT(0);\r
2786                 break;\r
2787         }\r
2788 #endif\r
2789 }\r
2790 \r
2791 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)\r
2792 {\r
2793         if (this->IsThreadRunning())\r
2794                 return;         //no sorting while the arrays are filled\r
2795         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
2796         const int nColumn = pNMLV->iSubItem;\r
2797         m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;\r
2798         m_nSortColumn = nColumn;\r
2799         SortByColumn(m_nSortColumn, m_bAscending);\r
2800         SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);\r
2801         SortShownListArray();\r
2802         m_LogList.Invalidate();\r
2803         UpdateLogInfoLabel();\r
2804         // the "next 100" button only makes sense if the log messages\r
2805         // are sorted by revision in descending order\r
2806         if ((m_nSortColumn)||(m_bAscending))\r
2807         {\r
2808                 DialogEnableWindow(IDC_NEXTHUNDRED, false);\r
2809         }\r
2810         else\r
2811         {\r
2812                 DialogEnableWindow(IDC_NEXTHUNDRED, true);\r
2813         }\r
2814         *pResult = 0;\r
2815 }\r
2816 \r
2817 void CLogDlg::SortShownListArray()\r
2818 {\r
2819         // make sure the shown list still matches the filter after sorting.\r
2820     OnTimer(LOGFILTER_TIMER);\r
2821     // clear the selection states\r
2822         POSITION pos = m_LogList.GetFirstSelectedItemPosition();\r
2823         while (pos)\r
2824         {\r
2825                 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);\r
2826         }    \r
2827         m_LogList.SetSelectionMark(-1);\r
2828 }\r
2829 \r
2830 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)\r
2831 {\r
2832         if (control == NULL)\r
2833                 return;\r
2834         // set the sort arrow\r
2835         CHeaderCtrl * pHeader = control->GetHeaderCtrl();\r
2836         HDITEM HeaderItem = {0};\r
2837         HeaderItem.mask = HDI_FORMAT;\r
2838         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
2839         {\r
2840                 pHeader->GetItem(i, &HeaderItem);\r
2841                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
2842                 pHeader->SetItem(i, &HeaderItem);\r
2843         }\r
2844         if (nColumn >= 0)\r
2845         {\r
2846                 pHeader->GetItem(nColumn, &HeaderItem);\r
2847                 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
2848                 pHeader->SetItem(nColumn, &HeaderItem);\r
2849         }\r
2850 }\r
2851 void CLogDlg::OnLvnColumnclickChangedFileList(NMHDR *pNMHDR, LRESULT *pResult)\r
2852 {\r
2853 #if 0\r
2854         if (this->IsThreadRunning())\r
2855                 return;         //no sorting while the arrays are filled\r
2856         if (m_currentChangedArray == NULL)\r
2857                 return;\r
2858         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
2859         const int nColumn = pNMLV->iSubItem;\r
2860         m_bAscendingPathList = nColumn == m_nSortColumnPathList ? !m_bAscendingPathList : TRUE;\r
2861         m_nSortColumnPathList = nColumn;\r
2862 //      qsort(m_currentChangedArray->GetData(), m_currentChangedArray->GetSize(), sizeof(LogChangedPath*), (GENERICCOMPAREFN)SortCompare);\r
2863 \r
2864         SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);\r
2865         m_ChangedFileListCtrl.Invalidate();\r
2866         *pResult = 0;\r
2867 #endif\r
2868 }\r
2869 \r
2870 int CLogDlg::m_nSortColumnPathList = 0;\r
2871 bool CLogDlg::m_bAscendingPathList = false;\r
2872 \r
2873 int CLogDlg::SortCompare(const void * pElem1, const void * pElem2)\r
2874 {\r
2875 #if 0\r
2876         LogChangedPath * cpath1 = *((LogChangedPath**)pElem1);\r
2877         LogChangedPath * cpath2 = *((LogChangedPath**)pElem2);\r
2878 \r
2879         if (m_bAscendingPathList)\r
2880                 std::swap (cpath1, cpath2);\r
2881 \r
2882         int cmp = 0;\r
2883         switch (m_nSortColumnPathList)\r
2884         {\r
2885         case 0: // action\r
2886                         cmp = cpath2->GetAction().Compare(cpath1->GetAction());\r
2887                         if (cmp)\r
2888                                 return cmp;\r
2889                         // fall through\r
2890         case 1: // path\r
2891                         cmp = cpath2->sPath.CompareNoCase(cpath1->sPath);\r
2892                         if (cmp)\r
2893                                 return cmp;\r
2894                         // fall through\r
2895         case 2: // copy from path\r
2896                         cmp = cpath2->sCopyFromPath.Compare(cpath1->sCopyFromPath);\r
2897                         if (cmp)\r
2898                                 return cmp;\r
2899                         // fall through\r
2900         case 3: // copy from revision\r
2901                         return cpath2->lCopyFromRev > cpath1->lCopyFromRev;\r
2902         }\r
2903 #endif\r
2904         return 0;\r
2905 }\r
2906 \r
2907 #if 0\r
2908 void CLogDlg::ResizeAllListCtrlCols()\r
2909 {\r
2910 \r
2911         const int nMinimumWidth = ICONITEMBORDER+16*4;\r
2912         int maxcol = ((CHeaderCtrl*)(m_LogList.GetDlgItem(0)))->GetItemCount()-1;\r
2913         int nItemCount = m_LogList.GetItemCount();\r
2914         TCHAR textbuf[MAX_PATH];\r
2915         CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(m_LogList.GetDlgItem(0));\r
2916         if (pHdrCtrl)\r
2917         {\r
2918                 for (int col = 0; col <= maxcol; col++)\r
2919                 {\r
2920                         HDITEM hdi = {0};\r
2921                         hdi.mask = HDI_TEXT;\r
2922                         hdi.pszText = textbuf;\r
2923                         hdi.cchTextMax = sizeof(textbuf);\r
2924                         pHdrCtrl->GetItem(col, &hdi);\r
2925                         int cx = m_LogList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin\r
2926                         for (int index = 0; index<nItemCount; ++index)\r
2927                         {\r
2928                                 // get the width of the string and add 14 pixels for the column separator and margins\r
2929                                 int linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;\r
2930                                 if (index < m_arShownList.GetCount())\r
2931                                 {\r
2932                                         GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));\r
2933                                         if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))\r
2934                                         {\r
2935                                                 // set the bold font and ask for the string width again\r
2936                                                 m_LogList.SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);\r
2937                                                 linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14;\r
2938                                                 // restore the system font\r
2939                                                 m_LogList.SendMessage(WM_SETFONT, NULL, NULL);\r
2940                                         }\r
2941                                 }\r
2942                                 if (index == 0)\r
2943                                 {\r
2944                                         // add the image size\r
2945                                         CImageList * pImgList = m_LogList.GetImageList(LVSIL_SMALL);\r
2946                                         if ((pImgList)&&(pImgList->GetImageCount()))\r
2947                                         {\r
2948                                                 IMAGEINFO imginfo;\r
2949                                                 pImgList->GetImageInfo(0, &imginfo);\r
2950                                                 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);\r
2951                                                 linewidth += 3; // 3 pixels between icon and text\r
2952                                         }\r
2953                                 }\r
2954                                 if (cx < linewidth)\r
2955                                         cx = linewidth;\r
2956                         }\r
2957                         // Adjust columns "Actions" containing icons\r
2958                         if (col == this->LOGLIST_ACTION)\r
2959                         {\r
2960                                 if (cx < nMinimumWidth)\r
2961                                 {\r
2962                                         cx = nMinimumWidth;\r
2963                                 }\r
2964                         }\r
2965                         \r
2966                         if (col == this->LOGLIST_MESSAGE)\r
2967                         {\r
2968                                 if (cx > LOGLIST_MESSAGE_MAX)\r
2969                                 {\r
2970                                         cx = LOGLIST_MESSAGE_MAX;\r
2971                                 }\r
2972 \r
2973                         }\r
2974                         // keep the bug id column small\r
2975                         if ((col == 4)&&(m_bShowBugtraqColumn))\r
2976                         {\r
2977                                 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)\r
2978                                 {\r
2979                                         cx = (int)(DWORD)m_regMaxBugIDColWidth;\r
2980                                 }\r
2981                         }\r
2982 \r
2983                         m_LogList.SetColumnWidth(col, cx);\r
2984                 }\r
2985         }\r
2986 \r
2987 }\r
2988 #endif\r
2989 \r
2990 void CLogDlg::OnBnClickedHidepaths()\r
2991 {\r
2992         FillLogMessageCtrl();\r
2993         m_ChangedFileListCtrl.Invalidate();\r
2994 }\r
2995 \r
2996 \r
2997 \r
2998 void CLogDlg::OnBnClickedCheckStoponcopy()\r
2999 {\r
3000 #if 0\r
3001         if (!GetDlgItem(IDC_GETALL)->IsWindowEnabled())\r
3002                 return;\r
3003 \r
3004         // ignore old fetch limits when switching\r
3005         // between copy-following and stop-on-copy\r
3006         // (otherwise stop-on-copy will limit what\r
3007         // we see immediately after switching to