From 96895a80c14936efbb804cb8d17d28ea428d2247 Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Sun, 15 Oct 2023 12:41:10 -0400 Subject: [PATCH] Debugger: Try to rationally size bp,tl and sf columns --- pcsx2-qt/Debugger/CpuWidget.cpp | 18 +++++++++++++++--- pcsx2-qt/Debugger/Models/BreakpointModel.h | 13 +++++++++++++ pcsx2-qt/Debugger/Models/StackModel.h | 11 +++++++++++ pcsx2-qt/Debugger/Models/ThreadModel.h | 11 +++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/pcsx2-qt/Debugger/CpuWidget.cpp b/pcsx2-qt/Debugger/CpuWidget.cpp index ecb0c336c6..0a036629a5 100644 --- a/pcsx2-qt/Debugger/CpuWidget.cpp +++ b/pcsx2-qt/Debugger/CpuWidget.cpp @@ -61,23 +61,35 @@ CpuWidget::CpuWidget(QWidget* parent, DebugInterface& cpu) connect(m_ui.breakpointList, &QTableView::customContextMenuRequested, this, &CpuWidget::onBPListContextMenu); connect(m_ui.breakpointList, &QTableView::doubleClicked, this, &CpuWidget::onBPListDoubleClicked); - m_ui.breakpointList->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); m_ui.breakpointList->setModel(&m_bpModel); + for (std::size_t i = 0; auto mode : BreakpointModel::HeaderResizeModes) + { + m_ui.breakpointList->horizontalHeader()->setSectionResizeMode(i, mode); + i++; + } connect(m_ui.threadList, &QTableView::customContextMenuRequested, this, &CpuWidget::onThreadListContextMenu); connect(m_ui.threadList, &QTableView::doubleClicked, this, &CpuWidget::onThreadListDoubleClick); - m_ui.threadList->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); m_threadProxyModel.setSourceModel(&m_threadModel); m_ui.threadList->setModel(&m_threadProxyModel); m_ui.threadList->setSortingEnabled(true); m_ui.threadList->sortByColumn(ThreadModel::ThreadColumns::ID, Qt::SortOrder::AscendingOrder); + for (std::size_t i = 0; auto mode : ThreadModel::HeaderResizeModes) + { + m_ui.threadList->horizontalHeader()->setSectionResizeMode(i, mode); + i++; + } connect(m_ui.stackList, &QTableView::customContextMenuRequested, this, &CpuWidget::onStackListContextMenu); connect(m_ui.stackList, &QTableView::doubleClicked, this, &CpuWidget::onStackListDoubleClick); - m_ui.stackList->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); m_ui.stackList->setModel(&m_stackModel); + for (std::size_t i = 0; auto mode : StackModel::HeaderResizeModes) + { + m_ui.stackList->horizontalHeader()->setSectionResizeMode(i, mode); + i++; + } connect(m_ui.tabWidgetRegFunc, &QTabWidget::currentChanged, [this](int i) {if(i == 1){updateFunctionList(true);} }); connect(m_ui.listFunctions, &QListWidget::customContextMenuRequested, this, &CpuWidget::onFuncListContextMenu); diff --git a/pcsx2-qt/Debugger/Models/BreakpointModel.h b/pcsx2-qt/Debugger/Models/BreakpointModel.h index 2285d17c5e..d551c7a75f 100644 --- a/pcsx2-qt/Debugger/Models/BreakpointModel.h +++ b/pcsx2-qt/Debugger/Models/BreakpointModel.h @@ -16,6 +16,8 @@ #pragma once #include +#include + #include "DebugTools/DebugInterface.h" #include "DebugTools/Breakpoints.h" @@ -44,6 +46,17 @@ public: ExportRole = Qt::UserRole + 1, }; + static constexpr QHeaderView::ResizeMode HeaderResizeModes[BreakpointColumns::COLUMN_COUNT] = + { + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::Stretch, + QHeaderView::ResizeMode::Stretch, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + }; + explicit BreakpointModel(DebugInterface& cpu, QObject* parent = nullptr); int rowCount(const QModelIndex& parent = QModelIndex()) const override; diff --git a/pcsx2-qt/Debugger/Models/StackModel.h b/pcsx2-qt/Debugger/Models/StackModel.h index df8bb535d0..ad022b01d5 100644 --- a/pcsx2-qt/Debugger/Models/StackModel.h +++ b/pcsx2-qt/Debugger/Models/StackModel.h @@ -16,6 +16,7 @@ #pragma once #include +#include #include "DebugTools/DebugInterface.h" #include "DebugTools/MipsStackWalk.h" @@ -36,6 +37,16 @@ public: COLUMN_COUNT }; + static constexpr QHeaderView::ResizeMode HeaderResizeModes[StackColumns::COLUMN_COUNT] = + { + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::Stretch, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + }; + explicit StackModel(DebugInterface& cpu, QObject* parent = nullptr); int rowCount(const QModelIndex& parent = QModelIndex()) const override; diff --git a/pcsx2-qt/Debugger/Models/ThreadModel.h b/pcsx2-qt/Debugger/Models/ThreadModel.h index 4fabaee0b7..a4b27a67e0 100644 --- a/pcsx2-qt/Debugger/Models/ThreadModel.h +++ b/pcsx2-qt/Debugger/Models/ThreadModel.h @@ -16,6 +16,7 @@ #pragma once #include +#include #include "DebugTools/DebugInterface.h" #include "DebugTools/BiosDebugData.h" @@ -38,6 +39,16 @@ public: COLUMN_COUNT }; + static constexpr QHeaderView::ResizeMode HeaderResizeModes[ThreadColumns::COLUMN_COUNT] = + { + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::ResizeToContents, + QHeaderView::ResizeMode::Stretch, + QHeaderView::ResizeMode::Stretch, + }; + explicit ThreadModel(DebugInterface& cpu, QObject* parent = nullptr); int rowCount(const QModelIndex& parent = QModelIndex()) const override;