|
13 | 13 | #include <qmdihost.h> |
14 | 14 |
|
15 | 15 | #include "AnsiToHTML.hpp" |
16 | | -#include "GenericItems.h" |
17 | 16 | #include "ProjectBuildConfig.h" |
18 | 17 | #include "ProjectManagerPlg.h" |
19 | 18 | #include "ProjectSearch.h" |
20 | 19 | #include "ui_ProjectSearchGUI.h" |
21 | 20 |
|
| 21 | +bool FilenameMatches(const QString &fileName, const QString &goodList, const QString &badList) { |
| 22 | + if (!badList.isEmpty()) { |
| 23 | + auto list = badList.split(";"); |
| 24 | + for (const auto &rule : std::as_const(list)) { |
| 25 | + if (rule.length() < 3) { |
| 26 | + continue; |
| 27 | + } |
| 28 | + auto clean_rule = rule.trimmed(); |
| 29 | + if (clean_rule.isEmpty()) { |
| 30 | + continue; |
| 31 | + } |
| 32 | + auto options = QRegularExpression::UnanchoredWildcardConversion; |
| 33 | + auto pattern = QRegularExpression::wildcardToRegularExpression(rule, options); |
| 34 | + auto regex = QRegularExpression(pattern); |
| 35 | + auto matches = regex.match(fileName).hasMatch(); |
| 36 | + if (matches) { |
| 37 | + return false; |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + bool filterMatchFound = true; |
| 43 | + if (!goodList.isEmpty()) { |
| 44 | + filterMatchFound = false; |
| 45 | + auto list = goodList.split(";"); |
| 46 | + for (const auto &rule : std::as_const(list)) { |
| 47 | + auto clean_rule = rule.trimmed(); |
| 48 | + if (clean_rule.isEmpty()) { |
| 49 | + continue; |
| 50 | + } |
| 51 | + auto options = QRegularExpression::UnanchoredWildcardConversion; |
| 52 | + auto pattern = QRegularExpression::wildcardToRegularExpression(rule, options); |
| 53 | + auto regex = QRegularExpression(pattern); |
| 54 | + auto matches = regex.match(fileName).hasMatch(); |
| 55 | + if (matches) { |
| 56 | + filterMatchFound = true; |
| 57 | + break; |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + return filterMatchFound; |
| 62 | +} |
| 63 | + |
22 | 64 | void searchTextFile(std::ifstream &file, const std::string &searchString, |
23 | 65 | std::function<void(const std::string &, size_t)> callback) { |
24 | 66 | auto line = std::string(); |
|
0 commit comments