From ca696ab4a79902d0448135f6fca3769f0576e39d Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Wed, 16 Apr 2025 10:21:22 -0400 Subject: Add loaded column for kernel cache view. Required adding an API to determine if an image is loaded. --- view/kernelcache/ui/kctriage.h | 65 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'view/kernelcache/ui/kctriage.h') diff --git a/view/kernelcache/ui/kctriage.h b/view/kernelcache/ui/kctriage.h index 7d8bdfc1..d606875a 100644 --- a/view/kernelcache/ui/kctriage.h +++ b/view/kernelcache/ui/kctriage.h @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -53,6 +55,65 @@ public: }; +class LoadedDelegate : public QItemDelegate +{ +Q_OBJECT + +public: + explicit LoadedDelegate(QObject* parent = nullptr) : QItemDelegate(parent) {} + + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override + { + if (!index.isValid()) + return; + + painter->save(); + + // Highlight if the item is selected + if (option.state & QStyle::State_Selected) + painter->fillRect(option.rect, option.palette.highlight()); + + // "1" is the indicator that its loaded. + if (index.data(Qt::DisplayRole).toString() == "1") + { + QPixmap loadedIcon; + pixmapForBWMaskIcon(":/icons/images/check.png", &loadedIcon, SidebarHeaderTextColor); + if (!loadedIcon.isNull()) + { + QSize pixmapSize(20, 20); + QPixmap scaledPixmap = loadedIcon.scaled(pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); + + // Calculate the rectangle for centering the pixmap + int x = option.rect.x() + (option.rect.width() - scaledPixmap.width()) / 2; // Center horizontally + int y = option.rect.y() + (option.rect.height() - scaledPixmap.height()) / 2; // Center vertically + QRect iconRect(x, y, scaledPixmap.width(), scaledPixmap.height()); + + // Draw the pixmap + painter->drawPixmap(iconRect, scaledPixmap); + } + } + + painter->restore(); + } + + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const override + { + Q_UNUSED(option); + Q_UNUSED(index); + return {50, 24}; + } + + void setEditorData(QWidget *editor, const QModelIndex &index) const override + { + Q_UNUSED(editor); + Q_UNUSED(index); + } +}; + + + class FilterableTableView : public QTableView, public FilterTarget { Q_OBJECT @@ -134,7 +195,7 @@ class SymbolTableProxyModel : public QSortFilterProxyModel Q_OBJECT public: - SymbolTableProxyModel(QObject* parent = nullptr) : QSortFilterProxyModel(parent), m_timer(new QTimer(this)) + explicit SymbolTableProxyModel(QObject* parent = nullptr) : QSortFilterProxyModel(parent), m_timer(new QTimer(this)) { m_timer->setSingleShot(true); connect(m_timer, &QTimer::timeout, this, &SymbolTableProxyModel::delayedFilterChanged); @@ -308,6 +369,8 @@ public: uint64_t getCurrentOffset() override; private: + void loadImagesWithAddr(const std::vector& addresses); + void setImageLoaded(const uint64_t imageHeaderAddr); QWidget* initImageTable(); void initSymbolTable(); }; -- cgit v1.3.1