Skip to content

Commit

Permalink
get rid of some of the initializeUI functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed May 2, 2024
1 parent 840f44b commit 4826b44
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 84 deletions.
2 changes: 0 additions & 2 deletions include/Views/ViewJournalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ namespace S2Plugin
private:
uintptr_t mPageAddress;
TreeViewMemoryFields* mMainTreeView;

void initializeUI();
};
} // namespace S2Plugin
2 changes: 0 additions & 2 deletions include/Views/ViewLevelGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,5 @@ namespace S2Plugin

// TAB LEVEL
std::unordered_map<std::string, WidgetSpelunkyRooms*> mRoomsWidgets; // field_name -> widget*

void initializeUI();
};
} // namespace S2Plugin
1 change: 0 additions & 1 deletion include/Views/ViewLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace S2Plugin
QTableView* mSamplesTableView;
ItemModelLoggerSamples* mSamplesTableModel;

void initializeUI();
void startLogging();
};
} // namespace S2Plugin
2 changes: 0 additions & 2 deletions include/Views/ViewStdMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@ namespace S2Plugin
uint8_t mMapValueAlignment;

TreeViewMemoryFields* mMainTreeView;

void initializeRefreshLayout();
};
} // namespace S2Plugin
2 changes: 0 additions & 2 deletions include/Views/ViewStdVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,5 @@ namespace S2Plugin
size_t mVectorTypeSize;

TreeViewMemoryFields* mMainTreeView;

void initializeRefreshLayout();
};
} // namespace S2Plugin
2 changes: 0 additions & 2 deletions include/Views/ViewThreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ namespace S2Plugin

private:
QTableWidget* mMainTable;

void initializeUI();
};
} // namespace S2Plugin
30 changes: 14 additions & 16 deletions src/Views/ViewEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@
#include <string>
#include <vector>

enum TABS
{
FIELDS = 0,
MEMORY = 1,
LEVEL = 2,
CPP = 3,
};

S2Plugin::ViewEntity::ViewEntity(size_t entityOffset, QWidget* parent) : QWidget(parent), mEntityPtr(entityOffset)
{
initializeUI();
setWindowIcon(getCavemanIcon());

setWindowTitle(QString::asprintf("Entity %s 0x%016llX", Entity{mEntityPtr}.entityTypeName().c_str(), entityOffset));
mMainTreeView->setVisible(true);

mMainTreeView->setColumnWidth(gsColField, 175);
mMainTreeView->setColumnWidth(gsColValueHex, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddress, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddressDelta, 75);
mMainTreeView->setColumnWidth(gsColType, 100);
initializeUI();
updateMemoryViewOffsetAndSize();

mSpelunkyLevel->paintFloor(QColor(160, 160, 160));
Expand All @@ -49,14 +50,6 @@ S2Plugin::ViewEntity::ViewEntity(size_t entityOffset, QWidget* parent) : QWidget
mInterpretAsComboBox->setCurrentText(QString::fromStdString(entityClassName));
}

enum TABS
{
FIELDS = 0,
MEMORY = 1,
LEVEL = 2,
CPP = 3,
};

void S2Plugin::ViewEntity::initializeUI()
{
auto mainLayout = new QVBoxLayout(this);
Expand Down Expand Up @@ -120,6 +113,11 @@ void S2Plugin::ViewEntity::initializeUI()
// TAB FIELDS
mMainTreeView = new TreeViewMemoryFields(this);
mMainTreeView->setColumnWidth(gsColValue, 250);
mMainTreeView->setColumnWidth(gsColField, 175);
mMainTreeView->setColumnWidth(gsColValueHex, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddress, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddressDelta, 75);
mMainTreeView->setColumnWidth(gsColType, 100);
mMainTreeView->setVisible(false);
mMainTreeView->activeColumns.disable(gsColComparisonValue).disable(gsColComparisonValueHex);
mMainTreeView->updateTableHeader();
Expand Down
15 changes: 5 additions & 10 deletions src/Views/ViewJournalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,9 @@

S2Plugin::ViewJournalPage::ViewJournalPage(uintptr_t address, QWidget* parent) : QWidget(parent), mPageAddress(address)
{
initializeUI();
setWindowIcon(getCavemanIcon());
setWindowTitle("JournalPage");

mMainTreeView->setColumnWidth(gsColField, 125);
mMainTreeView->setColumnWidth(gsColValueHex, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddress, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddressDelta, 75);
mMainTreeView->setColumnWidth(gsColType, 100);
}

void S2Plugin::ViewJournalPage::initializeUI()
{
auto mainLayout = new QVBoxLayout(this);
auto refreshLayout = new QHBoxLayout();
mainLayout->addLayout(refreshLayout);
Expand Down Expand Up @@ -67,6 +57,11 @@ void S2Plugin::ViewJournalPage::initializeUI()
mainLayout->addWidget(mMainTreeView);

mMainTreeView->setColumnWidth(gsColValue, 250);
mMainTreeView->setColumnWidth(gsColField, 125);
mMainTreeView->setColumnWidth(gsColValueHex, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddress, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddressDelta, 75);
mMainTreeView->setColumnWidth(gsColType, 100);
mMainTreeView->updateTableHeader();

mainLayout->setMargin(5);
Expand Down
16 changes: 6 additions & 10 deletions src/Views/ViewLevelGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,9 @@

S2Plugin::ViewLevelGen::ViewLevelGen(uintptr_t address, QWidget* parent) : QWidget(parent), mLevelGenPtr(address)
{
initializeUI();
setWindowIcon(getCavemanIcon());
setWindowTitle("LevelGen");
mMainTreeView->updateTree(0, 0, true);
mMainTreeView->setColumnWidth(gsColField, 125);
mMainTreeView->setColumnWidth(gsColValueHex, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddress, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddressDelta, 75);
mMainTreeView->setColumnWidth(gsColType, 100);
}

void S2Plugin::ViewLevelGen::initializeUI()
{
auto mainLayout = new QVBoxLayout(this);
auto refreshLayout = new QHBoxLayout();
mainLayout->addLayout(refreshLayout);
Expand Down Expand Up @@ -65,6 +55,11 @@ void S2Plugin::ViewLevelGen::initializeUI()
tabData->layout()->addWidget(mMainTreeView);

mMainTreeView->setColumnWidth(gsColValue, 250);
mMainTreeView->setColumnWidth(gsColField, 125);
mMainTreeView->setColumnWidth(gsColValueHex, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddress, 125);
mMainTreeView->setColumnWidth(gsColMemoryAddressDelta, 75);
mMainTreeView->setColumnWidth(gsColType, 100);
mMainTreeView->activeColumns.disable(gsColComparisonValue).disable(gsColComparisonValueHex);
mMainTreeView->updateTableHeader();
QObject::connect(mMainTreeView, &TreeViewMemoryFields::levelGenRoomsPointerClicked, this, &ViewLevelGen::levelGenRoomsPointerClicked);
Expand Down Expand Up @@ -97,6 +92,7 @@ void S2Plugin::ViewLevelGen::initializeUI()
mainLayout->setMargin(5);
mMainTreeView->setVisible(true);
autoRefresh->toggleAutoRefresh(true);
mMainTreeView->updateTree(0, 0, true); // just initial refresh so we don't the all fields marked as just changed (red)
}

void S2Plugin::ViewLevelGen::refreshLevelGen()
Expand Down
24 changes: 10 additions & 14 deletions src/Views/ViewLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,9 @@ S2Plugin::ViewLogger::ViewLogger(QWidget* parent) : QWidget(parent)
{
mLogger = new Logger(this);

initializeUI();
setWindowIcon(getCavemanIcon());
setWindowTitle("Logger");
}

QSize S2Plugin::ViewLogger::sizeHint() const
{
return QSize(650, 450);
}

QSize S2Plugin::ViewLogger::minimumSizeHint() const
{
return QSize(150, 150);
}

void S2Plugin::ViewLogger::initializeUI()
{
auto mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(5);

Expand Down Expand Up @@ -123,6 +109,16 @@ void S2Plugin::ViewLogger::initializeUI()
mainLayout->addWidget(mSamplingWidget);
}

QSize S2Plugin::ViewLogger::sizeHint() const
{
return QSize(650, 450);
}

QSize S2Plugin::ViewLogger::minimumSizeHint() const
{
return QSize(150, 150);
}

void S2Plugin::ViewLogger::startLogging()
{
if (mLogger->fieldCount() > 0)
Expand Down
10 changes: 2 additions & 8 deletions src/Views/ViewStdMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,15 @@ S2Plugin::ViewStdMap::ViewStdMap(const std::string& keytypeName, const std::stri
mMapKeyAlignment = config->getAlingment(keytypeName);
mMapValueAlignment = config->getAlingment(valuetypeName);

initializeRefreshLayout();
setWindowIcon(getCavemanIcon());

if (mMapValueTypeSize == 0)
setWindowTitle(QString("std::set<%1>").arg(QString::fromStdString(keytypeName)));
else
setWindowTitle(QString("std::map<%1, %2>").arg(QString::fromStdString(keytypeName), QString::fromStdString(valuetypeName)));

refreshMapContents();
}

void S2Plugin::ViewStdMap::initializeRefreshLayout()
{
auto mainLayout = new QVBoxLayout(this);

auto refreshLayout = new QHBoxLayout(this);
auto refreshLayout = new QHBoxLayout();
mainLayout->addLayout(refreshLayout);

auto refreshMapButton = new QPushButton("Refresh map", this);
Expand All @@ -54,6 +47,7 @@ void S2Plugin::ViewStdMap::initializeRefreshLayout()
mainLayout->addWidget(mMainTreeView);
mainLayout->setMargin(5);
autoRefresh->toggleAutoRefresh(true);
refreshMapContents();
}

void S2Plugin::ViewStdMap::refreshMapContents()
Expand Down
8 changes: 1 addition & 7 deletions src/Views/ViewStdVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@ S2Plugin::ViewStdVector::ViewStdVector(const std::string& vectorType, uintptr_t
{
mVectorTypeSize = Configuration::get()->getTypeSize(mVectorType);

initializeRefreshLayout();
setWindowIcon(getCavemanIcon());
setWindowTitle(QString("std::vector<%1>").arg(QString::fromStdString(vectorType)));

refreshVectorContents();
}

void S2Plugin::ViewStdVector::initializeRefreshLayout()
{
auto mainLayout = new QVBoxLayout(this);

auto refreshLayout = new QHBoxLayout();
mainLayout->addLayout(refreshLayout);

Expand All @@ -42,6 +35,7 @@ void S2Plugin::ViewStdVector::initializeRefreshLayout()
mainLayout->addWidget(mMainTreeView);
mainLayout->setMargin(5);
autoRefresh->toggleAutoRefresh(true);
refreshVectorContents();
}

void S2Plugin::ViewStdVector::refreshVectorContents()
Expand Down
9 changes: 2 additions & 7 deletions src/Views/ViewThreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,11 @@ static const uint32_t gsRoleMemoryAddress = Qt::UserRole + 1;

S2Plugin::ViewThreads::ViewThreads(QWidget* parent) : QWidget(parent)
{
initializeUI();
setWindowIcon(getCavemanIcon());
setWindowTitle("Threads");
refreshThreads();
}

void S2Plugin::ViewThreads::initializeUI()
{
auto mainLayout = new QVBoxLayout(this);

auto horLayout = new QHBoxLayout(this);
auto horLayout = new QHBoxLayout();
auto refreshButton = new QPushButton("Refresh", this);
horLayout->addWidget(refreshButton);
QObject::connect(refreshButton, &QPushButton::clicked, this, &ViewThreads::refreshThreads);
Expand All @@ -55,6 +49,7 @@ void S2Plugin::ViewThreads::initializeUI()
QObject::connect(mMainTable, &QTableWidget::cellClicked, this, &ViewThreads::cellClicked);

mainLayout->addWidget(mMainTable);
refreshThreads();
}

void S2Plugin::ViewThreads::refreshThreads()
Expand Down
2 changes: 1 addition & 1 deletion src/Views/ViewVirtualTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ S2Plugin::ViewVirtualTable::ViewVirtualTable(QWidget* parent) : QWidget(parent)
mGatherSortFilterProxy = new SortFilterProxyModelGatherVirtualData(this);
mGatherSortFilterProxy->sort(gsColGatherID);

initializeUI();
setWindowIcon(getCavemanIcon());
setWindowTitle("Virtual Table");
initializeUI();
}

enum TABS
Expand Down

0 comments on commit 4826b44

Please sign in to comment.