Skip to content

Commit

Permalink
StyledItemDelegateHTML as standard member
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Mar 27, 2024
1 parent 839fa0a commit 23a31f4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions include/QtHelpers/TreeViewMemoryFields.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "QtHelpers/StyledItemDelegateHTML.h"
#include <QStandardItemModel>
#include <QTreeView>
#include <array>
Expand All @@ -14,7 +15,6 @@ namespace S2Plugin
{
class ViewToolbar;
struct MemoryField;
class StyledItemDelegateHTML;

struct ColumnFilter
{
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace S2Plugin
private:
ViewToolbar* mToolbar;
QStandardItemModel* mModel;
std::unique_ptr<StyledItemDelegateHTML> mHTMLDelegate;
StyledItemDelegateHTML mHTMLDelegate;
std::array<uint32_t, 9> mSavedColumnWidths = {0};
bool mEnableChangeHighlighting = true;
};
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewThreads.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "QtHelpers/StyledItemDelegateHTML.h"
#include <QTableWidget>
#include <QVBoxLayout>
#include <QWidget>
Expand All @@ -9,7 +10,6 @@
namespace S2Plugin
{
class ViewToolbar;
class StyledItemDelegateHTML;

class ViewThreads : public QWidget
{
Expand All @@ -28,7 +28,7 @@ namespace S2Plugin

private:
ViewToolbar* mToolbar;
std::unique_ptr<StyledItemDelegateHTML> mHTMLDelegate;
StyledItemDelegateHTML mHTMLDelegate;

QVBoxLayout* mMainLayout;
QTableWidget* mMainTable;
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewVirtualTable.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "QtHelpers/StyledItemDelegateHTML.h"
#include <QCheckBox>
#include <QLabel>
#include <QTableView>
Expand All @@ -11,7 +12,6 @@ namespace S2Plugin
{
class ItemModelVirtualTable;
class SortFilterProxyModelVirtualTable;
class StyledItemDelegateHTML;
class ItemModelGatherVirtualData;
class SortFilterProxyModelGatherVirtualData;

Expand Down Expand Up @@ -56,7 +56,7 @@ namespace S2Plugin
QTableView* mDataTable;
std::unique_ptr<ItemModelVirtualTable> mModel;
std::unique_ptr<SortFilterProxyModelVirtualTable> mSortFilterProxy;
std::unique_ptr<StyledItemDelegateHTML> mHTMLDelegate;
StyledItemDelegateHTML mHTMLDelegate;

// LOOKUP
QLineEdit* mLookupAddressLineEdit;
Expand Down
4 changes: 1 addition & 3 deletions src/QtHelpers/TreeViewMemoryFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -37,8 +36,7 @@

S2Plugin::TreeViewMemoryFields::TreeViewMemoryFields(ViewToolbar* toolbar, QWidget* parent) : QTreeView(parent), mToolbar(toolbar)
{
mHTMLDelegate = std::make_unique<StyledItemDelegateHTML>();
setItemDelegate(mHTMLDelegate.get());
setItemDelegate(&mHTMLDelegate);
setAlternatingRowColors(true);
mModel = new QStandardItemModel(this);
setModel(mModel);
Expand Down
6 changes: 2 additions & 4 deletions src/Views/ViewThreads.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -47,9 +46,8 @@ void S2Plugin::ViewThreads::initializeUI()
mMainTable->horizontalHeader()->setStretchLastSection(true);
mMainTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mMainTable->setSelectionMode(QAbstractItemView::SingleSelection);
mHTMLDelegate = std::make_unique<StyledItemDelegateHTML>();
mMainTable->setItemDelegate(mHTMLDelegate.get());
mHTMLDelegate->setCenterVertically(true);
mMainTable->setItemDelegate(&mHTMLDelegate);
mHTMLDelegate.setCenterVertically(true);
QObject::connect(mMainTable, &QTableWidget::cellClicked, this, &ViewThreads::cellClicked);

mMainLayout->addWidget(mMainTable);
Expand Down
6 changes: 2 additions & 4 deletions src/Views/ViewVirtualTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -19,7 +18,6 @@

S2Plugin::ViewVirtualTable::ViewVirtualTable(QWidget* parent) : QWidget(parent)
{
mHTMLDelegate = std::make_unique<StyledItemDelegateHTML>();
mModel = std::make_unique<ItemModelVirtualTable>(this);
mSortFilterProxy = std::make_unique<SortFilterProxyModelVirtualTable>(this);
mGatherModel = std::make_unique<ItemModelGatherVirtualData>(this);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 23a31f4

Please sign in to comment.