1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

clang-format files in rwviewer/widgets

This commit is contained in:
Daniel Evans 2016-09-09 21:13:21 +01:00
parent 4ca99c380a
commit 46628d98d9
2 changed files with 68 additions and 72 deletions

View File

@ -2,68 +2,65 @@
#include <data/Model.hpp> #include <data/Model.hpp>
#include <glm/gtx/string_cast.hpp> #include <glm/gtx/string_cast.hpp>
void ModelFramesWidget::updateInfoBox(Model* model, ModelFrame *f) void ModelFramesWidget::updateInfoBox(Model* model, ModelFrame* f) {
{ if (f == nullptr) {
if( f == nullptr ) { _frameLabel->setText("");
_frameLabel->setText(""); } else {
} auto labText = QString("Name: %1\nTranslation: %2\nTextures:%3")
else { .arg(QString::fromStdString(f->getName()))
auto labText = QString("Name: %1\nTranslation: %2\nTextures:%3") .arg(QString::fromStdString(
.arg(QString::fromStdString(f->getName())) glm::to_string(f->getDefaultTranslation())));
.arg(QString::fromStdString(glm::to_string(f->getDefaultTranslation()))); QString geomString;
QString geomString; for (size_t gi : f->getGeometries()) {
for(size_t gi : f->getGeometries()) { auto& g = model->geometries[gi];
auto& g = model->geometries[gi]; // for(Model::SubGeometry& sg : g->subgeom)
//for(Model::SubGeometry& sg : g->subgeom) for (Model::Material& m : g->materials) {
for(Model::Material& m : g->materials) { for (Model::Texture& t : m.textures) {
for(Model::Texture& t : m.textures) { geomString += QString("\n %1 (%2)")
geomString += QString("\n %1 (%2)") .arg(t.name.c_str())
.arg(t.name.c_str()) .arg(t.alphaName.c_str());
.arg(t.alphaName.c_str()); }
} }
} }
} labText = labText.arg(geomString);
labText = labText.arg(geomString); _frameLabel->setText(labText);
_frameLabel->setText(labText); }
}
} }
void ModelFramesWidget::selectedModelChanged(const QModelIndex & n, const QModelIndex &) void ModelFramesWidget::selectedModelChanged(const QModelIndex& n,
{ const QModelIndex&) {
updateInfoBox( gmodel, (ModelFrame*) n.internalPointer() ); updateInfoBox(gmodel, (ModelFrame*)n.internalPointer());
selectedFrameChanged( (ModelFrame*) n.internalPointer() ); selectedFrameChanged((ModelFrame*)n.internalPointer());
} }
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags) ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
: QWidget(parent, flags), gmodel(nullptr), framemodel(nullptr) : QWidget(parent, flags), gmodel(nullptr), framemodel(nullptr) {
{ setWindowTitle("Frames");
setWindowTitle("Frames");
_layout = new QVBoxLayout; _layout = new QVBoxLayout;
tree = new QTreeView(this); tree = new QTreeView(this);
_layout->addWidget(tree); _layout->addWidget(tree);
_frameLabel = new QLabel(this); _frameLabel = new QLabel(this);
_layout->addWidget(_frameLabel); _layout->addWidget(_frameLabel);
setLayout(_layout); setLayout(_layout);
} }
void ModelFramesWidget::setModel(Model *model, Skeleton* skeleton) void ModelFramesWidget::setModel(Model* model, Skeleton* skeleton) {
{ if (framemodel) {
if(framemodel) { delete framemodel;
delete framemodel; framemodel = nullptr;
framemodel = nullptr; tree->setModel(nullptr);
tree->setModel(nullptr); }
} gmodel = model;
gmodel = model; if (model != nullptr) {
if(model != nullptr) { framemodel = new DFFFramesTreeModel(model, skeleton, this);
framemodel = new DFFFramesTreeModel(model, skeleton, this); tree->setModel(framemodel);
tree->setModel(framemodel); tree->setDisabled(false);
tree->setDisabled(false); connect(tree->selectionModel(),
connect(tree->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(selectedModelChanged(QModelIndex,QModelIndex))); SLOT(selectedModelChanged(QModelIndex, QModelIndex)));
} } else {
else { tree->setDisabled(true);
tree->setDisabled(true); }
}
} }

View File

@ -2,40 +2,39 @@
#ifndef _MODELFRAMESWIDGET_HPP_ #ifndef _MODELFRAMESWIDGET_HPP_
#define _MODELFRAMESWIDGET_HPP_ #define _MODELFRAMESWIDGET_HPP_
#include <QDockWidget> #include <QDockWidget>
#include <QTreeView>
#include "models/DFFFramesTreeModel.hpp"
#include <rw/types.hpp>
#include <QVBoxLayout>
#include <QLabel> #include <QLabel>
#include <QTreeView>
#include <QVBoxLayout>
#include <rw/types.hpp>
#include "models/DFFFramesTreeModel.hpp"
class ModelFrame; class ModelFrame;
class ModelFramesWidget : public QWidget class ModelFramesWidget : public QWidget {
{ Q_OBJECT
Q_OBJECT
Model* gmodel; Model* gmodel;
DFFFramesTreeModel* framemodel; DFFFramesTreeModel* framemodel;
QTreeView* tree; QTreeView* tree;
QVBoxLayout* _layout; QVBoxLayout* _layout;
QLabel* _frameLabel; QLabel* _frameLabel;
private slots: private slots:
void updateInfoBox(Model* model, ModelFrame* f); void updateInfoBox(Model* model, ModelFrame* f);
void selectedModelChanged(const QModelIndex&, const QModelIndex&);
void selectedModelChanged(const QModelIndex&,const QModelIndex&);
public: public:
ModelFramesWidget(QWidget* parent = 0, Qt::WindowFlags flags = 0); ModelFramesWidget(QWidget* parent = 0, Qt::WindowFlags flags = 0);
public slots: public slots:
void setModel(Model *model, Skeleton* skeleton); void setModel(Model* model, Skeleton* skeleton);
signals: signals:
void selectedFrameChanged(ModelFrame* frame); void selectedFrameChanged(ModelFrame* frame);
}; };
#endif #endif