summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Wiens <github@psifertex.com>2025-11-10 12:51:31 -0500
committerGlenn Smith <glenn@vector35.com>2025-11-10 20:48:22 -0500
commit0418561000622602146864421599964744262557 (patch)
tree5e4be390ca03aa9b661bef7ea177b75275ff79a3
parentdb7506ab8288cdbf0a47c40e654c7e8d1a6d0757 (diff)
Revert various table view changes
They were not tested in time and we will address their bugs after the release
-rw-r--r--ui/memorymap.h6
-rw-r--r--ui/searchresult.h3
-rw-r--r--ui/stringsview.h13
-rw-r--r--ui/tableviewbase.h169
-rw-r--r--ui/tagtypelist.h3
5 files changed, 6 insertions, 188 deletions
diff --git a/ui/memorymap.h b/ui/memorymap.h
index 34753b40..44bd0195 100644
--- a/ui/memorymap.h
+++ b/ui/memorymap.h
@@ -17,7 +17,6 @@
#include "uitypes.h"
#include "fontsettings.h"
#include "viewframe.h"
-#include "tableviewbase.h"
/*!
@@ -173,13 +172,14 @@ class BINARYNINJAUIAPI SegmentWidget : public QWidget
Q_OBJECT
BinaryViewRef m_data;
- TableViewBase* m_table;
+ QTableView* m_table;
SegmentModel* m_model;
QSortFilterProxyModel* m_proxyModel;
std::mutex m_updateMutex;
//void updateInfo();
void showContextMenu(const QPoint& point);
+ QMenu* createHeaderContextMenu(const QPoint& p);
void restoreDefaults();
void addMemoryRegion(SegmentRef segment);
@@ -251,7 +251,7 @@ class BINARYNINJAUIAPI SectionWidget : public QWidget
Q_OBJECT
BinaryViewRef m_data;
- TableViewBase* m_table;
+ QTableView* m_table;
SectionModel* m_model;
QSortFilterProxyModel* m_proxyModel;
std::mutex m_updateMutex;
diff --git a/ui/searchresult.h b/ui/searchresult.h
index a4f6d6a0..13fa77f9 100644
--- a/ui/searchresult.h
+++ b/ui/searchresult.h
@@ -1,6 +1,5 @@
#pragma once
-#include <tableviewbase.h>
#include <QtCore/QAbstractItemModel>
#include <QtCore/QItemSelectionModel>
#include <QtCore/QSortFilterProxyModel>
@@ -174,7 +173,7 @@ class SearchResultWidget;
/*!
\ingroup searchresult
*/
-class BINARYNINJAUIAPI SearchResultTable : public TableViewBase
+class BINARYNINJAUIAPI SearchResultTable : public QTableView
{
Q_OBJECT
diff --git a/ui/stringsview.h b/ui/stringsview.h
index e745d28d..4be86d60 100644
--- a/ui/stringsview.h
+++ b/ui/stringsview.h
@@ -9,7 +9,6 @@
#include "render.h"
#include "filter.h"
#include "uicontext.h"
-#include "tableviewbase.h"
#define STRINGS_LIST_UPDATE_INTERVAL 250
@@ -167,7 +166,7 @@ class StringsViewSidebarWidget;
\ingroup stringsview
*/
-class BINARYNINJAUIAPI StringsView : public TableViewBase, public View, public FilterTarget
+class BINARYNINJAUIAPI StringsView : public QTableView, public View, public FilterTarget
{
Q_OBJECT
@@ -184,14 +183,6 @@ class BINARYNINJAUIAPI StringsView : public TableViewBase, public View, public F
uint64_t m_currentlySelectedDataAddress;
std::optional<BinaryNinja::DerivedString> m_derivedString;
- QPointer<QHeaderView> m_horizontalHeader;
- QPointer<QHeaderView> m_verticalHeader;
- QTimer m_headerSaveDebounce;
-
- void restoreHeaderState() const;
- void saveHeaderState() const;
- void scheduleSaveHeaderState();
-
public:
StringsView(BinaryViewRef data, StringsContainer* container);
@@ -223,7 +214,6 @@ class BINARYNINJAUIAPI StringsView : public TableViewBase, public View, public F
void toggleIncludeOnlyReferenced() const { m_list->toggleIncludeOnlyReferenced(); };
void toggleIncludeOnlyFromCurrentFunction() const { m_list->toggleIncludeOnlyFromCurrentFunction(); };
- void resetColumnLayout() const;
void resetFilterOptions();
void copyText();
@@ -236,7 +226,6 @@ class BINARYNINJAUIAPI StringsView : public TableViewBase, public View, public F
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual bool event(QEvent* event) override;
- int defaultSectionWidth(int logicalIndex, int charWidth) const override;
private Q_SLOTS:
void goToString(const QModelIndex& idx);
diff --git a/ui/tableviewbase.h b/ui/tableviewbase.h
deleted file mode 100644
index 7080f741..00000000
--- a/ui/tableviewbase.h
+++ /dev/null
@@ -1,169 +0,0 @@
-//
-// Created by Alexander Khosrowshahi on 8/22/25.
-//
-
-#pragma once
-
-#include <QtWidgets/QTableView>
-#include <QtWidgets/QHeaderView>
-#include <QtCore/QTimer>
-#include <QMenu>
-
-/// Base class for table views in Binary Ninja views
-/// - Moveable, resizeable columns with saved state
-/// - QSettings save to Tables/<viewName>/<Suffix>
-/// - Reset columns context menu action
-class BINARYNINJAUIAPI TableViewBase: public QTableView {
- Q_OBJECT
-
-public:
- explicit TableViewBase(QWidget* parent = nullptr, const QString& viewName = {}): QTableView(parent), m_viewName(viewName) {
- auto* hh = horizontalHeader();
- hh->setStretchLastSection(true);
- hh->setSectionResizeMode(QHeaderView::Interactive);
- hh->setSectionsMovable(true);
- hh->setSectionsClickable(true);
- hh->setSortIndicatorShown(true);
- hh->setSortIndicator(0, Qt::AscendingOrder);
- hh->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(hh, &QHeaderView::customContextMenuRequested, this,
- [this, hh](const QPoint& p) {
- QMenu menu(hh);
- QAction* reset = menu.addAction(tr("Reset Column Layout"));
- connect(reset, &QAction::triggered, this, &TableViewBase::resetColumnLayout);
- populateHeaderContextMenu(&menu, p);
- menu.exec(hh->viewport()->mapToGlobal(p));
- });
-
- m_headerSaveDebounce.setSingleShot(true);
- m_headerSaveDebounce.setInterval(150);
-
- connect(&m_headerSaveDebounce, &QTimer::timeout, this, &TableViewBase::saveHeaderState);
- connect(hh, &QHeaderView::sectionResized, this, &TableViewBase::scheduleSaveHeaderState);
- connect(hh, &QHeaderView::sectionMoved, this, &TableViewBase::scheduleSaveHeaderState);
-
- setShowGrid(false);
- setSortingEnabled(true);
-
- QMetaObject::invokeMethod(this, "restoreHeaderState", Qt::QueuedConnection);
- }
-
-
- void setModel(QAbstractItemModel* m) override
- {
- QTableView::setModel(m);
- if (!m) return;
- connect(m, &QAbstractItemModel::modelReset, this, &TableViewBase::restoreHeaderState);
- connect(m, &QAbstractItemModel::columnsInserted, this, &TableViewBase::restoreHeaderState);
- connect(m, &QAbstractItemModel::columnsRemoved, this, &TableViewBase::restoreHeaderState);
-
- // Grab default header state
- QTimer::singleShot(0, this, [this]{
- captureDefaultHeaderState();
- });
-
- QMetaObject::invokeMethod(this, "restoreHeaderState", Qt::QueuedConnection);
- }
-
- // Save after debounce for repeated move/drag
- void scheduleSaveHeaderState() { m_headerSaveDebounce.start(); }
-
-Q_SIGNALS:
- // For owners/derived classes to add their own menu items
- void populateHeaderContextMenu(QMenu*, const QPoint&);
-
-protected:
- QString viewName() const {
- if (!m_viewName.isEmpty()) return m_viewName;
- if (!objectName().isEmpty()) return objectName();
- return metaObject()->className();
- }
-
- QString settingsKey(const QString& suffix) const {
- return QStringLiteral("tables/%1/%2").arg(viewName(), suffix);
- }
-
- void saveHeaderState() const {
- auto* hh = horizontalHeader();
- if (!hh) return;
- QSettings s;
- s.setValue(settingsKey("horizontalHeaderState"), hh->saveState());
- }
-
- void restoreHeaderState() const
- {
- auto* hh = horizontalHeader();
- if (!hh) return;
- QSettings s;
- const QByteArray st = s.value(settingsKey("horizontalHeaderState")).toByteArray();
- if (!st.isEmpty()) hh->restoreState(st);
-
- const QByteArray def = s.value(settingsKey("horizontalHeaderDefaultState")).toByteArray();
- if (!def.isEmpty()) hh->restoreState(def);
- }
-
- virtual int defaultSectionWidth(const int logicalIndex, const int charWidth) const
- {
- QString headerText;
- if (model()) {
- headerText = model()->headerData(logicalIndex, Qt::Horizontal, Qt::DisplayRole).toString();
- }
- constexpr int minChars = 8;
- const int headerChars = qMax(minChars, headerText.size() + 2);
- return headerChars * charWidth;
- }
-
- /// Grabs default header states on startup to save
- /// Kind of a hacky fix, but many of our tables have manually set widths,
- /// so compensating for them is a hassle.
- void captureDefaultHeaderState() const
- {
- auto* hh = horizontalHeader();
- if (!hh) return;
-
- QSettings s;
- const auto key = settingsKey("horizontalHeaderDefaultState");
- if (!s.contains(key)) {
- s.setValue(key, hh->saveState());
- s.sync();
- }
- }
-
-
- void resetColumnLayout() const
- {
- auto* hh = horizontalHeader();
- if (!hh || !model()) return;
-
- {
- QSettings s;
- s.remove(settingsKey("horizontalHeaderState"));
- }
-
- QSettings s;
- const QByteArray def = s.value(settingsKey("horizontalHeaderDefaultState")).
- toByteArray();
- if (!def.isEmpty() && hh->restoreState(def))
- {
- return;
- }
-
- // If no default or set user layout, use size hints
- for (int c = 0; c < model()->columnCount(); ++c)
- {
- constexpr int extra = 12;
- int w = sizeHintForColumn(c);
- QVariant head = model()->headerData(c, Qt::Horizontal, Qt::SizeHintRole);
- int headerW = hh->sectionSizeHint(c);
- if (head.canConvert<QSize>())
- headerW = std::max(headerW, head.toSize().width());
- hh->resizeSection(c, std::max(w, headerW) + extra);
- }
- }
-
-
-private:
- QString m_viewName;
- QTimer m_headerSaveDebounce;
-
-};
diff --git a/ui/tagtypelist.h b/ui/tagtypelist.h
index ee6793c3..62950405 100644
--- a/ui/tagtypelist.h
+++ b/ui/tagtypelist.h
@@ -8,7 +8,6 @@
#include <QtWidgets/QComboBox>
#include "binaryninjaapi.h"
#include "viewframe.h"
-#include "tableviewbase.h"
#define TAGS_UPDATE_CHECK_INTERVAL 200
@@ -89,7 +88,7 @@ class BINARYNINJAUIAPI TagTypeItemDelegate : public QItemDelegate
\ingroup tagtypelist
*/
-class BINARYNINJAUIAPI TagTypeList : public TableViewBase, public BinaryNinja::BinaryDataNotification
+class BINARYNINJAUIAPI TagTypeList : public QTableView, public BinaryNinja::BinaryDataNotification
{
Q_OBJECT