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.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'view/sharedcache/ui/symboltable.cpp') diff --git a/view/sharedcache/ui/symboltable.cpp b/view/sharedcache/ui/symboltable.cpp index f4a062da..c96ce086 100644 --- a/view/sharedcache/ui/symboltable.cpp +++ b/view/sharedcache/ui/symboltable.cpp @@ -3,6 +3,8 @@ #include +#include "ui/fontsettings.h" + #include "binaryninjaapi.h" using namespace BinaryNinja; @@ -10,6 +12,8 @@ using namespace SharedCacheAPI; SymbolTableModel::SymbolTableModel(SymbolTableView* parent) : QAbstractTableModel(parent), m_parent(parent) { + // TODO: Need to implement updating this font if it is changed by the user + m_font = getMonospaceFont(parent); } int SymbolTableModel::rowCount(const QModelIndex& parent) const { @@ -24,20 +28,31 @@ int SymbolTableModel::columnCount(const QModelIndex& parent) const { } QVariant SymbolTableModel::data(const QModelIndex& index, int role) const { - if (!index.isValid() || role != Qt::DisplayRole) { + if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::FontRole)) { return QVariant(); } - auto symbol = symbolAt(index.row()); - auto symbolType = GetSymbolTypeAsString(symbol.type); - - switch (index.column()) { - case 0: // Address column - return QString("0x%1").arg(symbol.address, 0, 16); // Display address as hexadecimal - case 1: // Type column - return QString::fromUtf8(symbolType.c_str(), symbolType.size()); - case 2: // Name column - return QString::fromUtf8(symbol.name.c_str(), symbol.name.size()); + switch (role) + { + case Qt::DisplayRole: + { + auto symbol = symbolAt(index.row()); + auto symbolType = GetSymbolTypeAsString(symbol.type); + + switch (index.column()) + { + case 0: // Address column + return QString("0x%1").arg(symbol.address, 0, 16); // Display address as hexadecimal + case 1: // Type column + return QString::fromUtf8(symbolType.c_str(), symbolType.size()); + case 2: // Name column + return QString::fromUtf8(symbol.name.c_str(), symbol.name.size()); + default: + return QVariant(); + } + } + case Qt::FontRole: + return m_font; default: return QVariant(); } -- cgit v1.3.1