This repository has been archived on 2023-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
frostbite/CuttownTest/infoPanel.cpp
Rose eda2b5b1d5
(Used Razzy's credentials by accident the first time) Fix includes
remove/change Windows-specific code so TestApp can compile on other platforms
2023-10-23 17:55:23 +13:00

47 lines
1.1 KiB
C++

#include "infoPanel.h"
#include "gameData.h"
#include <QtWidgets>
InfoPanel::InfoPanel(QWidget* parent, GameData& gameData) : gameData(gameData)
{
widget = new QTableWidget(1, 2, parent);
widget->setHorizontalHeaderLabels(QStringList() << "Property" << "Value");
widget->setCornerButtonEnabled(false);
widget->verticalHeader()->hide();
widget->setAlternatingRowColors(true);
populateGamedata();
}
void InfoPanel::populateGamedata()
{
widget->clearContents();
widget->setRowCount(0);
widget->setSortingEnabled(false);
addRow("Root Dir", gameData.getRootDir());
addRow("GOB Name", gameData.getGobName());
widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
widget->resizeColumnsToContents();
widget->resizeRowsToContents();
}
void InfoPanel::addRow(const char* name, QString val)
{
int row = widget->rowCount();
widget->insertRow(row);
widget->setItem(row, 0, new QTableWidgetItem(name));
widget->setItem(row, 1, new QTableWidgetItem(val));
}
InfoPanel::~InfoPanel()
{
delete widget;
widget = nullptr;
}
QWidget* InfoPanel::getWidget()
{
return widget;
}