Add support for Ctrl+A in BrowseRefsDlg and RepositoryBrowser
[TortoiseGit.git] / src / TortoiseProc / LogDlgFilter.cpp
blob435f5831c23038ccd4eb981ff7289da79ebb82cf
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2018-2020 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "LogDlgFilter.h"
21 #include "LogDlg.h"
23 bool CLogDlgFilter::operator()(GitRevLoglist* pRev, CGitLogListBase* loglist, const MAP_HASH_NAME& hashMapRefs) const
25 if (!IsFilterActive())
26 return CalculateFinalResult(true);
28 // we need to perform expensive string / pattern matching
29 scratch.clear();
30 if (GetSelectedFilters() & (LOGFILTER_SUBJECT | LOGFILTER_MESSAGES))
32 scratch += pRev->GetSubject();
33 scratch += L'\n';
35 if (GetSelectedFilters() & LOGFILTER_MESSAGES)
37 scratch += pRev->GetBody();
38 scratch += L'\n';
40 if (GetSelectedFilters() & LOGFILTER_BUGID)
42 scratch += loglist->m_ProjectProperties.FindBugID(pRev->GetSubjectBody());
43 scratch += L'\n';
45 if (GetSelectedFilters() & LOGFILTER_AUTHORS)
47 scratch += pRev->GetAuthorName();
48 scratch += L'\n';
49 scratch += pRev->GetCommitterName();
50 scratch += L'\n';
52 if (GetSelectedFilters() & LOGFILTER_EMAILS)
54 scratch += pRev->GetAuthorEmail();
55 scratch += L'\n';
56 scratch += pRev->GetCommitterEmail();
57 scratch += L'\n';
59 if (GetSelectedFilters() & LOGFILTER_REVS)
61 scratch += pRev->m_CommitHash.ToString();
62 scratch += L'\n';
64 if (GetSelectedFilters() & LOGFILTER_NOTES)
66 scratch += pRev->m_Notes;
67 scratch += L'\n';
69 if (GetSelectedFilters() & (LOGFILTER_REFNAME | LOGFILTER_ANNOTATEDTAG))
71 auto refList = hashMapRefs.find(pRev->m_CommitHash);
72 if (refList != hashMapRefs.cend())
74 if (GetSelectedFilters() & LOGFILTER_REFNAME)
76 for (const auto& ref : (*refList).second)
78 scratch += ref;
79 scratch += L'\n';
82 if (GetSelectedFilters() & LOGFILTER_ANNOTATEDTAG)
84 scratch += loglist->GetTagInfo((*refList).second);
85 scratch += L'\n';
89 if (GetSelectedFilters() & LOGFILTER_PATHS)
91 /* Because changed files list is loaded on demand when gui show, files will empty when files have not fetched.
92 we can add it back by using one-way diff(with outnumber changed and rename detect.
93 here just need changed filename list. one-way is much quicker.
95 if (pRev->m_IsDiffFiles || loglist->IsCached(pRev))
97 auto pathList = pRev->GetFiles(loglist);
98 for (int i = 0; i < pathList.GetCount(); ++i)
100 scratch += pathList[i].GetGitPathString();
101 scratch += L'|';
102 scratch += pathList[i].GetGitOldPathString();
103 scratch += L'\n';
106 else
108 if (!pRev->m_IsSimpleListReady)
109 pRev->SafeGetSimpleList(&g_Git);
111 for (size_t i = 0; i < pRev->m_SimpleFileList.size(); ++i)
113 scratch += pRev->m_SimpleFileList[i];
114 scratch += L'\n';
119 return CalculateFinalResult(Match(scratch));