35 lines
No EOL
1.2 KiB
C++
35 lines
No EOL
1.2 KiB
C++
#include "MainWindow.h"
|
|
|
|
#include <QTableView>
|
|
#include <QHeaderView>
|
|
|
|
#include "ArtDetailWindow.h"
|
|
#include "ArtModel.h"
|
|
|
|
MainWindow::MainWindow(const QString& definitionDirectory, const QString& assetDirectory) {
|
|
setWindowTitle("Redai");
|
|
setMinimumSize(1280, 720);
|
|
|
|
auto model = new ArtModel(definitionDirectory, assetDirectory);
|
|
|
|
auto pieceListView = new QTableView();
|
|
pieceListView->setModel(model);
|
|
pieceListView->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
|
|
pieceListView->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
QHeaderView *verticalHeader = pieceListView->verticalHeader();
|
|
verticalHeader->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
|
|
QHeaderView *horizontalHeader = pieceListView->horizontalHeader();
|
|
horizontalHeader->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
|
|
connect(pieceListView, &QListView::clicked, this, [assetDirectory](QModelIndex index) {
|
|
const QString filename = index.data(Qt::UserRole + 1).toString();
|
|
const QJsonObject object = index.data(Qt::UserRole).toJsonObject();
|
|
|
|
auto window = new ArtDetailWindow(filename, assetDirectory);
|
|
window->show();
|
|
});
|
|
|
|
setCentralWidget(pieceListView);
|
|
} |