SIEdit/app/siview/siview.cpp

55 lines
1.2 KiB
C++
Raw Normal View History

#include "siview.h"
#include <QFileDialog>
#include <QPushButton>
#include <QSplitter>
#include <QTreeView>
#include <QVBoxLayout>
using namespace si;
2022-07-18 03:27:00 -04:00
SIViewDialog::SIViewDialog(Info *riff, QWidget *parent) :
QWidget(parent, Qt::Window),
root_(riff),
last_set_data_(nullptr)
{
auto layout = new QVBoxLayout(this);
auto splitter = new QSplitter();
splitter->setChildrenCollapsible(false);
layout->addWidget(splitter);
auto tree = new QTreeView();
2022-07-11 04:48:50 -04:00
chunk_model_.SetCore(riff);
tree->setModel(&chunk_model_);
tree->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tree->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &SIViewDialog::SelectionChanged);
splitter->addWidget(tree);
config_stack_ = new QStackedWidget();
splitter->addWidget(config_stack_);
2022-07-18 03:27:00 -04:00
panel_ = new InfoPanel();
config_stack_->addWidget(panel_);
2022-07-18 03:27:00 -04:00
splitter->setSizes({99999, 99999});
2022-07-30 12:03:21 -04:00
SetSubtitle(QString());
}
void SIViewDialog::SetSubtitle(const QString &s)
{
QString t;
if (s.isEmpty()) {
t = tr("View SI File");
} else {
t = tr("View SI File: %1").arg(s);
}
setWindowTitle(t);
}
void SIViewDialog::SelectionChanged(const QModelIndex &index)
{
2022-07-18 03:27:00 -04:00
panel_->SetData(static_cast<Info*>(index.internalPointer()));
}