1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-09 20:32:43 +01:00
openrw/rwviewer/widgets/ModelFramesWidget.cpp

54 lines
1.7 KiB
C++
Raw Normal View History

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