diff options
| author | Alexander Taylor <alex@vector35.com> | 2025-04-16 10:21:22 -0400 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2025-04-16 10:21:22 -0400 |
| commit | ca696ab4a79902d0448135f6fca3769f0576e39d (patch) | |
| tree | 3aabbba81e4968c03289c5d10eea5340f15597ce /view/kernelcache/ui/kctriage.h | |
| parent | 77c3bf786be64267cb7f45d9d0f118fcbf6d8aea (diff) | |
Add loaded column for kernel cache view.
Required adding an API to determine if an image is loaded.
Diffstat (limited to 'view/kernelcache/ui/kctriage.h')
| -rw-r--r-- | view/kernelcache/ui/kctriage.h | 65 |
1 files changed, 64 insertions, 1 deletions
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 <QHeaderView> +#include <QItemDelegate> +#include <QPainter> #include <QSortFilterProxyModel> #include <QStandardItemModel> #include <QStyledItemDelegate> @@ -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<uint64_t>& addresses); + void setImageLoaded(const uint64_t imageHeaderAddr); QWidget* initImageTable(); void initSymbolTable(); }; |
