openrw/rwviewer/widgets/ModelFramesWidget.cpp

54 lines
1.7 KiB
C++
Raw Normal View History

2014-02-12 06:42:07 +00:00
#include "ModelFramesWidget.hpp"
2017-01-03 14:18:06 +00:00
#include <data/Clump.hpp>
2014-06-10 20:26:04 +01:00
#include <glm/gtx/string_cast.hpp>
2017-01-03 14:18:06 +00:00
void ModelFramesWidget::updateInfoBox(Clump* model, ModelFrame* f) {
2016-09-09 21:13:21 +01:00
if (f == nullptr) {
_frameLabel->setText("");
} else {
auto labText = QString("Name: %1\nTranslation: %2")
2016-09-09 21:13:21 +01:00
.arg(QString::fromStdString(f->getName()))
.arg(QString::fromStdString(
glm::to_string(f->getDefaultTranslation())));
_frameLabel->setText(labText);
}
2014-06-10 20:26:04 +01:00
}
2016-09-09 21:13:21 +01:00
void ModelFramesWidget::selectedModelChanged(const QModelIndex& n,
const QModelIndex&) {
updateInfoBox(gmodel, (ModelFrame*)n.internalPointer());
selectedFrameChanged((ModelFrame*)n.internalPointer());
2014-06-10 20:26:04 +01:00
}
2014-02-12 06:42:07 +00:00
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
2016-09-09 21:13:21 +01:00
: QWidget(parent, flags), gmodel(nullptr), framemodel(nullptr) {
setWindowTitle("Frames");
2014-06-10 20:26:04 +01:00
2016-09-09 21:13:21 +01:00
_layout = new QVBoxLayout;
tree = new QTreeView(this);
_layout->addWidget(tree);
_frameLabel = new QLabel(this);
_layout->addWidget(_frameLabel);
2014-06-10 20:26:04 +01:00
2016-09-09 21:13:21 +01:00
setLayout(_layout);
2014-02-12 06:42:07 +00:00
}
2017-01-08 19:46:00 +00:00
void ModelFramesWidget::setModel(Clump* model) {
2016-09-09 21:13:21 +01:00
if (framemodel) {
delete framemodel;
framemodel = nullptr;
tree->setModel(nullptr);
}
gmodel = model;
if (model != nullptr) {
2017-01-08 19:46:00 +00:00
framemodel = new DFFFramesTreeModel(model, this);
2016-09-09 21:13:21 +01:00
tree->setModel(framemodel);
tree->setDisabled(false);
connect(tree->selectionModel(),
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(selectedModelChanged(QModelIndex, QModelIndex)));
} else {
tree->setDisabled(true);
}
2014-02-12 06:42:07 +00:00
}