summaryrefslogtreecommitdiff
path: root/view/kernelcache/ui/symboltable.h
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2025-07-06 15:05:01 -0400
committerkat <kat@vector35.com>2025-07-07 07:37:23 -0400
commit768f7c78465fb93936e5ca50a0ca712664fe54e7 (patch)
tree78c73e0022d6006882e365a257595a5b55a37432 /view/kernelcache/ui/symboltable.h
parent8f3e251c42169fb4fe8db9403d900571434d88ff (diff)
KernelCache rewrite
Diffstat (limited to 'view/kernelcache/ui/symboltable.h')
-rw-r--r--view/kernelcache/ui/symboltable.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/view/kernelcache/ui/symboltable.h b/view/kernelcache/ui/symboltable.h
new file mode 100644
index 00000000..866390c7
--- /dev/null
+++ b/view/kernelcache/ui/symboltable.h
@@ -0,0 +1,102 @@
+#pragma once
+
+#include <kernelcacheapi.h>
+#include "viewframe.h"
+
+#include <QTableView>
+#include <QStandardItemModel>
+#include "filter.h"
+
+#ifndef BINARYNINJA_KCSYMBOLTABLE_H
+#define BINARYNINJA_KCSYMBOLTABLE_H
+
+class SymbolTableView;
+
+
+class SymbolTableModel : public QAbstractTableModel
+{
+Q_OBJECT
+ SymbolTableView* m_parent;
+ QFont m_font;
+ std::string m_filter;
+ std::vector<KernelCacheAPI::CacheSymbol> m_preparedSymbols{};
+ // These are the symbols we actually use
+ std::vector<KernelCacheAPI::CacheSymbol> m_modelSymbols{};
+
+public:
+ explicit SymbolTableModel(SymbolTableView* parent);
+
+ int rowCount(const QModelIndex& parent) const override;
+ int columnCount(const QModelIndex& parent) const override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+ void sort(int column, Qt::SortOrder order) override;
+ void updateSymbols(std::vector<KernelCacheAPI::CacheSymbol>&& symbols);
+ void setFilter(std::string text);
+ const KernelCacheAPI::CacheSymbol& symbolAt(int row) const;
+
+};
+
+
+class SymbolTableView : public QTableView, public FilterTarget
+{
+Q_OBJECT
+ friend class SymbolTableModel;
+
+ SymbolTableModel* m_model;
+
+public:
+ explicit SymbolTableView(QWidget* parent);
+ ~SymbolTableView() override;
+
+ // Call this to populate the symbols from the given view.
+ void populateSymbols(BinaryNinja::BinaryView& view);
+
+ void scrollToFirstItem() override
+ {
+ if (model()->rowCount() > 0) {
+ QModelIndex top = indexAt(rect().topLeft());
+ if (top.isValid())
+ scrollTo(top);
+ }
+ }
+
+ void scrollToCurrentItem() override
+ {
+ QModelIndex currentIndex = selectionModel()->currentIndex();
+ if (currentIndex.isValid())
+ scrollTo(currentIndex);
+ }
+
+ void selectFirstItem() override
+ {
+ if (model()->rowCount() > 0) {
+ QModelIndex top = indexAt(rect().topLeft());
+ if (top.isValid()) {
+ selectionModel()->select(top, QItemSelectionModel::ClearAndSelect);
+ setCurrentIndex(top);
+ }
+ }
+ }
+
+ void activateFirstItem() override
+ {
+ if (model()->rowCount() > 0) {
+ QModelIndex topLeft = indexAt(rect().topLeft());
+ if (topLeft.isValid()) {
+ setCurrentIndex(topLeft);
+ emit activated(topLeft);
+ }
+ }
+ }
+
+ KernelCacheAPI::CacheSymbol getSymbolAtRow(int row) const
+ {
+ return m_model->symbolAt(row);
+ }
+
+ void setFilter(const std::string& filter) override;
+};
+
+
+#endif // BINARYNINJA_KCSYMBOLTABLE_H