mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-22 03:57:45 +00:00
Add support for multiple excel sheet pages
This commit is contained in:
parent
e3e71c10ad
commit
e30ea1b31b
1 changed files with 31 additions and 28 deletions
|
@ -12,37 +12,39 @@
|
||||||
MainWindow::MainWindow(GameData& data) : data(data) {
|
MainWindow::MainWindow(GameData& data) : data(data) {
|
||||||
setWindowTitle("Novus");
|
setWindowTitle("Novus");
|
||||||
|
|
||||||
QWidget* dummyWidget = new QWidget();
|
auto dummyWidget = new QWidget();
|
||||||
setCentralWidget(dummyWidget);
|
setCentralWidget(dummyWidget);
|
||||||
|
|
||||||
QHBoxLayout* layout = new QHBoxLayout();
|
auto layout = new QHBoxLayout();
|
||||||
dummyWidget->setLayout(layout);
|
dummyWidget->setLayout(layout);
|
||||||
|
|
||||||
QListWidget* listWidget = new QListWidget();
|
auto listWidget = new QListWidget();
|
||||||
for(auto name : data.getAllSheetNames()) {
|
for(auto name : data.getAllSheetNames()) {
|
||||||
listWidget->addItem(name.c_str());
|
listWidget->addItem(name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QTableWidget* tableWidget = new QTableWidget();
|
auto* pageTabWidget = new QTabWidget();
|
||||||
|
|
||||||
|
connect(listWidget, &QListWidget::itemClicked, this, [&data, pageTabWidget](QListWidgetItem* item) {
|
||||||
|
pageTabWidget->clear();
|
||||||
|
|
||||||
connect(listWidget, &QListWidget::itemClicked, this, [&data, tableWidget](QListWidgetItem* item) {
|
|
||||||
auto name = item->text().toStdString();
|
auto name = item->text().toStdString();
|
||||||
auto nameLowercase = item->text().toLower().toStdString();
|
auto nameLowercase = item->text().toLower().toStdString();
|
||||||
|
|
||||||
auto exh = *data.readExcelSheet(name);
|
auto exh = *data.readExcelSheet(name);
|
||||||
for(auto column : exh.columnDefinitions) {
|
for (auto column: exh.columnDefinitions) {
|
||||||
fmt::print("type = {}, offset = {}\n", column.type, column.offset);
|
fmt::print("type = {}, offset = {}\n", column.type, column.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto page : exh.pages) {
|
||||||
|
QTableWidget* tableWidget = new QTableWidget();
|
||||||
|
|
||||||
tableWidget->setColumnCount(exh.columnDefinitions.size());
|
tableWidget->setColumnCount(exh.columnDefinitions.size());
|
||||||
tableWidget->setRowCount(exh.header.rowCount);
|
tableWidget->setRowCount(exh.header.rowCount);
|
||||||
|
|
||||||
for(auto page : exh.pages) {
|
|
||||||
if(page.startId == 0) {
|
|
||||||
fmt::print("page, row count = {}, start id = {}\n", page.rowCount, page.startId);
|
fmt::print("page, row count = {}, start id = {}\n", page.rowCount, page.startId);
|
||||||
|
|
||||||
std::string path;
|
std::string path;
|
||||||
if(exh.language[0] == Language::None) {
|
if (exh.language[0] == Language::None) {
|
||||||
path = getEXDFilename(exh, nameLowercase, "", page);
|
path = getEXDFilename(exh, nameLowercase, "", page);
|
||||||
} else {
|
} else {
|
||||||
path = getEXDFilename(exh, nameLowercase, getLanguageCode(Language::English), page);
|
path = getEXDFilename(exh, nameLowercase, getLanguageCode(Language::English), page);
|
||||||
|
@ -61,10 +63,11 @@ MainWindow::MainWindow(GameData& data) : data(data) {
|
||||||
tableWidget->setHorizontalHeaderItem(j, headerItem);
|
tableWidget->setHorizontalHeaderItem(j, headerItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
pageTabWidget->addTab(tableWidget, QString("Page %1").arg(page.startId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
layout->addWidget(listWidget);
|
layout->addWidget(listWidget);
|
||||||
layout->addWidget(tableWidget);
|
layout->addWidget(pageTabWidget);
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue