From 1b32a95b3a88567b349e1d3a57dea2fea9f42961 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Wed, 2 Apr 2025 20:03:51 -0400 Subject: Styling for data in shared cache view. --- view/sharedcache/ui/symboltable.h | 133 ++++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 62 deletions(-) (limited to 'view/sharedcache/ui/symboltable.h') diff --git a/view/sharedcache/ui/symboltable.h b/view/sharedcache/ui/symboltable.h index 53c71874..2fc5c892 100644 --- a/view/sharedcache/ui/symboltable.h +++ b/view/sharedcache/ui/symboltable.h @@ -8,79 +8,88 @@ #include #include "filter.h" + class SymbolTableView; -class SymbolTableModel : public QAbstractTableModel { - Q_OBJECT - SymbolTableView* m_parent; - std::string m_filter; - std::vector m_preparedSymbols {}; - // the symbols we actually use. - std::vector m_modelSymbols {}; +class SymbolTableModel : public QAbstractTableModel +{ +Q_OBJECT + SymbolTableView* m_parent; + QFont m_font; + std::string m_filter; + std::vector m_preparedSymbols{}; + // These are the symbols we actually use + std::vector m_modelSymbols{}; public: - explicit SymbolTableModel(SymbolTableView* parent); - - int rowCount(const QModelIndex& parent = QModelIndex()) const override; - int columnCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - - void updateSymbols(std::vector&& symbols); - - void setFilter(std::string text); - - const SharedCacheAPI::CacheSymbol& symbolAt(int row) const; + 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 updateSymbols(std::vector&& symbols); + void setFilter(std::string text); + const SharedCacheAPI::CacheSymbol& symbolAt(int row) const; }; class SymbolTableView : public QTableView, public FilterTarget { - Q_OBJECT - friend class SymbolTableModel; +Q_OBJECT + friend class SymbolTableModel; - SymbolTableModel* m_model; + SymbolTableModel* m_model; public: - SymbolTableView(QWidget* parent); - virtual ~SymbolTableView() override; - - void scrollToFirstItem() override { - if (model()->rowCount() > 0) { - scrollTo(model()->index(0, 0)); - } - } - - // Call this to populate the symbols from the given view. - void populateSymbols(BinaryNinja::BinaryView& view); - - void scrollToCurrentItem() override { - QModelIndex currentIndex = selectionModel()->currentIndex(); - if (currentIndex.isValid()) { - scrollTo(currentIndex); - } - } - - void selectFirstItem() override { - if (model()->rowCount() > 0) { - QModelIndex firstIndex = model()->index(0, 0); - selectionModel()->select(firstIndex, QItemSelectionModel::ClearAndSelect); - } - } - - void activateFirstItem() override { - if (model()->rowCount() > 0) { - QModelIndex firstIndex = model()->index(0, 0); - setCurrentIndex(firstIndex); - emit activated(firstIndex); - } - } - - SharedCacheAPI::CacheSymbol getSymbolAtRow(int row) const - { - return m_model->symbolAt(row); - } - - void setFilter(const std::string& filter) override; + explicit SymbolTableView(QWidget* parent); + + ~SymbolTableView() override; + + void scrollToFirstItem() override + { + if (model()->rowCount() > 0) + { + scrollTo(model()->index(0, 0)); + } + } + + // Call this to populate the symbols from the given view. + void populateSymbols(BinaryNinja::BinaryView& view); + + void scrollToCurrentItem() override + { + QModelIndex currentIndex = selectionModel()->currentIndex(); + if (currentIndex.isValid()) + { + scrollTo(currentIndex); + } + } + + void selectFirstItem() override + { + if (model()->rowCount() > 0) + { + QModelIndex firstIndex = model()->index(0, 0); + selectionModel()->select(firstIndex, QItemSelectionModel::ClearAndSelect); + } + } + + void activateFirstItem() override + { + if (model()->rowCount() > 0) + { + QModelIndex firstIndex = model()->index(0, 0); + setCurrentIndex(firstIndex); + emit activated(firstIndex); + } + } + + SharedCacheAPI::CacheSymbol getSymbolAtRow(int row) const + { + return m_model->symbolAt(row); + } + + void setFilter(const std::string& filter) override; }; \ No newline at end of file -- cgit v1.3.1