1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-27 14:17:45 +00:00
novus/parts/exl/exlpart.cpp

47 lines
1.3 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "exlpart.h"
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QVBoxLayout>
#include <physis.hpp>
EXLPart::EXLPart(GameData *data, QWidget *parent)
: QWidget(parent)
, data(data)
{
auto layout = new QVBoxLayout();
m_tableWidget = new QTableWidget();
layout->addWidget(m_tableWidget);
setLayout(layout);
}
void EXLPart::load(physis_Buffer file)
{
auto exl = physis_gamedata_read_excel_list(file);
if (exl.entry_count > 0) {
m_tableWidget->clear();
2023-10-12 21:43:42 -04:00
m_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_tableWidget->setColumnCount(2);
m_tableWidget->setRowCount(exl.entry_count);
m_tableWidget->setHorizontalHeaderLabels({QStringLiteral("Key"), QStringLiteral("Value")});
for (int i = 0; i < exl.entry_count; i++) {
auto keyItem = new QTableWidgetItem(QLatin1String(exl.entry_keys[i]));
auto valueItem = new QTableWidgetItem(QString::number(exl.entry_values[i]));
m_tableWidget->setItem(i, 0, keyItem);
m_tableWidget->setItem(i, 1, valueItem);
}
m_tableWidget->resizeColumnsToContents();
}
}
2023-10-12 23:45:25 -04:00
#include "moc_exlpart.cpp"