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

Implement "model" view in rwviewer

This commit is contained in:
Daniel Evans 2014-09-21 16:13:01 +01:00
parent 78334aa51b
commit 33afc649c5
4 changed files with 55 additions and 22 deletions

View File

@ -1,42 +1,47 @@
#include "ObjectViewer.hpp"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <models/ObjectListModel.hpp>
#include "ViewerWidget.hpp"
#include <QDebug>
ObjectViewer::ObjectViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f)
{
mainLayout = new QHBoxLayout;
objectList = new QTableView;
QHBoxLayout* layout = new QHBoxLayout;
layout->addWidget(objectList);
QVBoxLayout* infoLayout = new QVBoxLayout;
layout->addItem(infoLayout);
mainLayout->addWidget(objectList);
previewWidget = viewer;
previewWidget->setMinimumSize(250,250);
QGridLayout* dataGrid = new QGridLayout;
dataGrid->addWidget(previewWidget, 0, 0, 1, 2);
infoLayout = new QGridLayout;
previewID = new QLabel;
previewModel = new QLabel;
previewClass = new QLabel;
dataGrid->addWidget(new QLabel("ID"), 1, 0);
dataGrid->addWidget(previewID, 1, 1);
dataGrid->addWidget(new QLabel("Type"), 2, 0);
dataGrid->addWidget(previewClass, 2, 1);
dataGrid->addWidget(new QLabel("Model"), 3, 0);
dataGrid->addWidget(previewModel, 3, 1);
infoLayout->addWidget(new QLabel("ID"), 1, 0);
infoLayout->addWidget(previewID, 1, 1);
infoLayout->addWidget(new QLabel("Type"), 2, 0);
infoLayout->addWidget(previewClass, 2, 1);
infoLayout->addWidget(new QLabel("Model"), 3, 0);
infoLayout->addWidget(previewModel, 3, 1);
infoLayout->addItem(dataGrid);
//infoLayout->addStretch(100);
infoLayout->addStretch(100);
mainLayout->addLayout(infoLayout);
this->setLayout(layout);
this->setLayout(mainLayout);
setViewerWidget(previewWidget);
}
void ObjectViewer::setViewerWidget(ViewerWidget* widget)
{
static size_t c = 0;
//widgetLayout->removeWidget(previewWidget);
previewWidget = widget;
infoLayout->addWidget(previewWidget, 0, 0, 1, 2);
}
static std::map<ObjectInformation::ObjectClass, QString> gDataType =

View File

@ -6,6 +6,8 @@
#include <QGLWidget>
#include <QTableView>
#include <QLabel>
#include <QGridLayout>
#include <QHBoxLayout>
class ViewerWidget;
@ -16,11 +18,12 @@ class ObjectViewer : public QWidget
QTableView* objectList;
GameWorld* _world;
QHBoxLayout* mainLayout;
QGridLayout* infoLayout;
ViewerWidget* previewWidget;
QLabel* previewID;
QLabel* previewModel;
QLabel* previewClass;
public:
ObjectViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
@ -30,6 +33,8 @@ public:
return _world;
}
void setViewerWidget( ViewerWidget* widget );
public slots:
void showItem(qint16 item);

View File

@ -49,7 +49,6 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
viewSwitcher = new QStackedWidget;
viewSwitcher->addWidget(objectViewer);
viewSwitcher->addWidget(new QLabel("Model Viewer Not Implemented Yet"));
QMenu* view = mb->addMenu("&View");
QAction* objectAction = view->addAction("&Object");
@ -67,6 +66,13 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
QMenu* anim = mb->addMenu("&Animation");
anim->addAction("Load &Animations", this, SLOT(openAnimations()));
modelLayout = new QVBoxLayout;
QWidget* span = new QWidget;
span->setLayout(modelLayout);
viewSwitcher->addWidget(span);
this->setCentralWidget(viewSwitcher);
updateRecentGames();
@ -171,7 +177,19 @@ void ViewerWindow::switchWidget()
{
QAction* r = qobject_cast< QAction* >(sender());
if(r) {
viewSwitcher->setCurrentIndex(r->data().toInt() );
int index = r->data().toInt();
if( index == 0 )
{
modelLayout->removeWidget( viewerWidget );
objectViewer->setViewerWidget( viewerWidget );
}
else if( index == 1 )
{
modelLayout->addWidget( viewerWidget );
}
viewSwitcher->setCurrentIndex( index );
}
}

View File

@ -5,6 +5,7 @@
#include <engine/GameWorld.hpp>
#include <QGLContext>
#include <QStackedWidget>
#include <QVBoxLayout>
class ObjectViewer;
class ViewerWidget;
@ -17,7 +18,11 @@ class ViewerWindow : public QMainWindow
/** Contains the OGL context */
ViewerWidget* viewerWidget;
ObjectViewer* objectViewer;
QVBoxLayout* modelLayout;
QStackedWidget* viewSwitcher;
QGLContext* context;