From 23a31f4a55f1523c9af44b606155fb831bc1a848 Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:02:46 +0100 Subject: [PATCH] StyledItemDelegateHTML as standard member --- include/QtHelpers/TreeViewMemoryFields.h | 4 ++-- include/Views/ViewThreads.h | 4 ++-- include/Views/ViewVirtualTable.h | 4 ++-- src/QtHelpers/TreeViewMemoryFields.cpp | 4 +--- src/Views/ViewThreads.cpp | 6 ++---- src/Views/ViewVirtualTable.cpp | 6 ++---- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/QtHelpers/TreeViewMemoryFields.h b/include/QtHelpers/TreeViewMemoryFields.h index 7b0210d6..ef0825b0 100644 --- a/include/QtHelpers/TreeViewMemoryFields.h +++ b/include/QtHelpers/TreeViewMemoryFields.h @@ -1,5 +1,6 @@ #pragma once +#include "QtHelpers/StyledItemDelegateHTML.h" #include #include #include @@ -14,7 +15,6 @@ namespace S2Plugin { class ViewToolbar; struct MemoryField; - class StyledItemDelegateHTML; struct ColumnFilter { @@ -75,7 +75,7 @@ namespace S2Plugin private: ViewToolbar* mToolbar; QStandardItemModel* mModel; - std::unique_ptr mHTMLDelegate; + StyledItemDelegateHTML mHTMLDelegate; std::array mSavedColumnWidths = {0}; bool mEnableChangeHighlighting = true; }; diff --git a/include/Views/ViewThreads.h b/include/Views/ViewThreads.h index 96c36fb5..32ddcfe4 100644 --- a/include/Views/ViewThreads.h +++ b/include/Views/ViewThreads.h @@ -1,5 +1,6 @@ #pragma once +#include "QtHelpers/StyledItemDelegateHTML.h" #include #include #include @@ -9,7 +10,6 @@ namespace S2Plugin { class ViewToolbar; - class StyledItemDelegateHTML; class ViewThreads : public QWidget { @@ -28,7 +28,7 @@ namespace S2Plugin private: ViewToolbar* mToolbar; - std::unique_ptr mHTMLDelegate; + StyledItemDelegateHTML mHTMLDelegate; QVBoxLayout* mMainLayout; QTableWidget* mMainTable; diff --git a/include/Views/ViewVirtualTable.h b/include/Views/ViewVirtualTable.h index 8016051b..d2f5258a 100644 --- a/include/Views/ViewVirtualTable.h +++ b/include/Views/ViewVirtualTable.h @@ -1,5 +1,6 @@ #pragma once +#include "QtHelpers/StyledItemDelegateHTML.h" #include #include #include @@ -11,7 +12,6 @@ namespace S2Plugin { class ItemModelVirtualTable; class SortFilterProxyModelVirtualTable; - class StyledItemDelegateHTML; class ItemModelGatherVirtualData; class SortFilterProxyModelGatherVirtualData; @@ -56,7 +56,7 @@ namespace S2Plugin QTableView* mDataTable; std::unique_ptr mModel; std::unique_ptr mSortFilterProxy; - std::unique_ptr mHTMLDelegate; + StyledItemDelegateHTML mHTMLDelegate; // LOOKUP QLineEdit* mLookupAddressLineEdit; diff --git a/src/QtHelpers/TreeViewMemoryFields.cpp b/src/QtHelpers/TreeViewMemoryFields.cpp index 078616a4..3070026c 100644 --- a/src/QtHelpers/TreeViewMemoryFields.cpp +++ b/src/QtHelpers/TreeViewMemoryFields.cpp @@ -11,7 +11,6 @@ #include "Data/TextureDB.h" #include "QtHelpers/DialogEditSimpleValue.h" #include "QtHelpers/DialogEditState.h" -#include "QtHelpers/StyledItemDelegateHTML.h" #include "Spelunky2.h" #include "Views/ViewCharacterDB.h" #include "Views/ViewEntity.h" @@ -37,8 +36,7 @@ S2Plugin::TreeViewMemoryFields::TreeViewMemoryFields(ViewToolbar* toolbar, QWidget* parent) : QTreeView(parent), mToolbar(toolbar) { - mHTMLDelegate = std::make_unique(); - setItemDelegate(mHTMLDelegate.get()); + setItemDelegate(&mHTMLDelegate); setAlternatingRowColors(true); mModel = new QStandardItemModel(this); setModel(mModel); diff --git a/src/Views/ViewThreads.cpp b/src/Views/ViewThreads.cpp index 311e5057..6873a418 100644 --- a/src/Views/ViewThreads.cpp +++ b/src/Views/ViewThreads.cpp @@ -1,7 +1,6 @@ #include "Views/ViewThreads.h" #include "Configuration.h" #include "Data/State.h" -#include "QtHelpers/StyledItemDelegateHTML.h" #include "Spelunky2.h" #include "Views/ViewToolbar.h" #include "pluginmain.h" @@ -47,9 +46,8 @@ void S2Plugin::ViewThreads::initializeUI() mMainTable->horizontalHeader()->setStretchLastSection(true); mMainTable->setSelectionBehavior(QAbstractItemView::SelectRows); mMainTable->setSelectionMode(QAbstractItemView::SingleSelection); - mHTMLDelegate = std::make_unique(); - mMainTable->setItemDelegate(mHTMLDelegate.get()); - mHTMLDelegate->setCenterVertically(true); + mMainTable->setItemDelegate(&mHTMLDelegate); + mHTMLDelegate.setCenterVertically(true); QObject::connect(mMainTable, &QTableWidget::cellClicked, this, &ViewThreads::cellClicked); mMainLayout->addWidget(mMainTable); diff --git a/src/Views/ViewVirtualTable.cpp b/src/Views/ViewVirtualTable.cpp index 4bd7b982..666073f8 100644 --- a/src/Views/ViewVirtualTable.cpp +++ b/src/Views/ViewVirtualTable.cpp @@ -2,7 +2,6 @@ #include "Data/VirtualTableLookup.h" #include "QtHelpers/ItemModelGatherVirtualData.h" #include "QtHelpers/ItemModelVirtualTable.h" -#include "QtHelpers/StyledItemDelegateHTML.h" #include "QtHelpers/TableWidgetItemNumeric.h" #include "Spelunky2.h" #include "Views/ViewToolbar.h" @@ -19,7 +18,6 @@ S2Plugin::ViewVirtualTable::ViewVirtualTable(QWidget* parent) : QWidget(parent) { - mHTMLDelegate = std::make_unique(); mModel = std::make_unique(this); mSortFilterProxy = std::make_unique(this); mGatherModel = std::make_unique(this); @@ -104,7 +102,7 @@ void S2Plugin::ViewVirtualTable::initializeUI() mDataTable->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); mDataTable->verticalHeader()->setDefaultSectionSize(19); mDataTable->verticalHeader()->setVisible(false); - mDataTable->setItemDelegate(mHTMLDelegate.get()); + mDataTable->setItemDelegate(&mHTMLDelegate); mDataTable->setColumnWidth(gsColTableOffset, 100); mDataTable->setColumnWidth(gsColCodeAddress, 125); mDataTable->setColumnWidth(gsColTableAddress, 125); @@ -192,7 +190,7 @@ void S2Plugin::ViewVirtualTable::initializeUI() mGatherTable->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); mGatherTable->verticalHeader()->setDefaultSectionSize(19); mGatherTable->verticalHeader()->setVisible(false); - mGatherTable->setItemDelegate(mHTMLDelegate.get()); + mGatherTable->setItemDelegate(&mHTMLDelegate); mGatherTable->setColumnWidth(gsColGatherID, 50); mGatherTable->setColumnWidth(gsColGatherName, 200); mGatherTable->setColumnWidth(gsColGatherVirtualTableOffset, 125);