OSDN Git Service

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