summaryrefslogtreecommitdiff
path: root/view/sharedcache/ui/dsctriage.h
diff options
context:
space:
mode:
authorAlexander Taylor <alex@vector35.com>2025-04-09 12:47:00 -0400
committerAlexander Taylor <alex@vector35.com>2025-04-09 17:16:23 -0400
commite3772366504d6d05b4809013cb4f4149ca64c4d4 (patch)
treee3fcb0818bfede1a5f8fff0b1edd59422b517b67 /view/sharedcache/ui/dsctriage.h
parentf78345462ebc25e0241d838f04104e5c6bfae863 (diff)
Shared cache and kernel cache UI cleanup.
One day, these will share more code, but today is not quite that day.
Diffstat (limited to 'view/sharedcache/ui/dsctriage.h')
-rw-r--r--view/sharedcache/ui/dsctriage.h128
1 files changed, 67 insertions, 61 deletions
diff --git a/view/sharedcache/ui/dsctriage.h b/view/sharedcache/ui/dsctriage.h
index b1e98f6d..a16457e3 100644
--- a/view/sharedcache/ui/dsctriage.h
+++ b/view/sharedcache/ui/dsctriage.h
@@ -1,7 +1,3 @@
-//
-// Created by kat on 8/15/24.
-//
-
#include <binaryninjaapi.h>
#include <QItemDelegate>
#include <QStyledItemDelegate>
@@ -19,6 +15,7 @@
#ifndef BINARYNINJA_DSCTRIAGE_H
#define BINARYNINJA_DSCTRIAGE_H
+
class AddressColorDelegate : public QStyledItemDelegate
{
@@ -37,6 +34,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
@@ -119,6 +175,7 @@ signals:
void filterTextChanged(const QString& text);
};
+
class DSCTriageView : public QWidget, public View, public UIContextNotification
{
BinaryViewRef m_data;
@@ -148,6 +205,12 @@ public:
void OnAfterOpenFile(UIContext* context, FileContext* file, ViewFrame* frame) override;
void RefreshData();
void setImageLoaded(uint64_t imageHeaderAddr);
+
+private:
+ void loadImagesWithAddr(const std::vector<uint64_t>& addresses, bool includeDependencies = false);
+ QWidget* initImageTable();
+ void initSymbolTable();
+ void initCacheInfoTables();
};
@@ -160,61 +223,4 @@ public:
static void Register();
};
-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);
- }
-};
-
#endif // BINARYNINJA_DSCTRIAGE_H