diff options
| author | Josh Ferrell <josh@vector35.com> | 2026-01-26 14:23:12 -0500 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2026-02-06 17:53:45 -0500 |
| commit | 70bbb18a9444824a8ec2b9a7ff57fc848e017b6e (patch) | |
| tree | fe87c0976b75a7557986d1ac6bcc2409a839624c /view/kernelcache/ui/symboltable.cpp | |
| parent | 9b7604d13e8bd98c6998facb9326926ed96281b5 (diff) | |
Add regex and case sensitivity options to FilterEdit
Diffstat (limited to 'view/kernelcache/ui/symboltable.cpp')
| -rw-r--r-- | view/kernelcache/ui/symboltable.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/view/kernelcache/ui/symboltable.cpp b/view/kernelcache/ui/symboltable.cpp index 90d0d18b..c3c45b8a 100644 --- a/view/kernelcache/ui/symboltable.cpp +++ b/view/kernelcache/ui/symboltable.cpp @@ -128,7 +128,7 @@ void SymbolTableModel::sort(int column, Qt::SortOrder order) void SymbolTableModel::updateSymbols(std::vector<CacheSymbol>&& symbols) { m_preparedSymbols = symbols; - setFilter(m_filter); + setFilter(m_filter, m_filterOptions); } @@ -138,20 +138,42 @@ const CacheSymbol& SymbolTableModel::symbolAt(int row) const } -void SymbolTableModel::setFilter(std::string text) +void SymbolTableModel::setFilter(const std::string& text, FilterOptions options) { - beginResetModel(); - m_filter = text; + m_filterOptions = options; m_modelSymbols = {}; + bool caseSensitive = options.testFlag(CaseSensitiveOption); + beginResetModel(); // Skip filtering if no filter applied. if (!m_filter.empty()) { m_modelSymbols.reserve(m_preparedSymbols.size()); for (const auto& symbol : m_preparedSymbols) - if (((std::string_view)symbol.name).find(m_filter) != std::string::npos) + { + const std::string& symbolName = symbol.name; + bool match; + if (caseSensitive) + { + match = (symbolName.find(m_filter) != std::string::npos); + } + else + { + auto it = std::search( + symbolName.begin(), symbolName.end(), + m_filter.begin(), m_filter.end(), + [](char c1, char c2) { return std::tolower(c1) == std::tolower(c2); } + ); + + match = (it != symbolName.end()); + } + + if (match) + { m_modelSymbols.push_back(symbol); + } + } m_modelSymbols.shrink_to_fit(); } else @@ -163,6 +185,8 @@ void SymbolTableModel::setFilter(std::string text) } + + SymbolTableView::SymbolTableView(QWidget* parent) : QTableView(parent), m_model(new SymbolTableModel(this)) { @@ -215,6 +239,8 @@ void SymbolTableView::populateSymbols(BinaryView &view) } } -void SymbolTableView::setFilter(const std::string& filter) { - m_model->setFilter(filter); + +void SymbolTableView::setFilter(const std::string& filter, FilterOptions options) +{ + m_model->setFilter(filter, options); } |
