summaryrefslogtreecommitdiff
path: root/view/kernelcache/ui/symboltable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'view/kernelcache/ui/symboltable.cpp')
-rw-r--r--view/kernelcache/ui/symboltable.cpp40
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);
}