2014-03-16 11:44:01 +00:00
|
|
|
|
|
|
|
#include "previewsubview.hpp"
|
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
2014-03-23 14:14:26 +00:00
|
|
|
#include "../render/previewwidget.hpp"
|
2014-03-16 11:44:01 +00:00
|
|
|
|
2014-07-08 10:39:12 +00:00
|
|
|
#include "../widget/scenetoolbar.hpp"
|
|
|
|
#include "../widget/scenetoolmode.hpp"
|
2014-03-16 11:44:01 +00:00
|
|
|
|
|
|
|
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
2014-10-27 07:57:18 +00:00
|
|
|
: SubView (id), mTitle (id.toString().c_str())
|
2014-03-16 11:44:01 +00:00
|
|
|
{
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
|
|
|
|
|
|
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
|
|
|
|
|
|
if (document.getData().getReferenceables().searchId (id.getId())==-1)
|
|
|
|
{
|
|
|
|
std::string referenceableId =
|
|
|
|
document.getData().getReferences().getRecord (id.getId()).get().mRefID;
|
|
|
|
|
2014-03-21 11:52:46 +00:00
|
|
|
referenceableIdChanged (referenceableId);
|
2014-03-16 12:22:32 +00:00
|
|
|
|
2014-03-16 11:44:01 +00:00
|
|
|
mScene =
|
2015-03-25 23:55:58 +00:00
|
|
|
new CSVRender::PreviewWidget (document.getData(), id.getId(), false, this);
|
2014-03-16 11:44:01 +00:00
|
|
|
}
|
|
|
|
else
|
2015-03-25 23:55:58 +00:00
|
|
|
mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), true, this);
|
2014-03-16 11:44:01 +00:00
|
|
|
|
2014-07-08 10:39:12 +00:00
|
|
|
CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this);
|
2014-03-16 11:44:01 +00:00
|
|
|
|
2015-03-28 19:15:17 +00:00
|
|
|
CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
|
|
|
|
toolbar->addTool (lightingTool);
|
2014-03-23 14:14:26 +00:00
|
|
|
|
2014-03-16 11:44:01 +00:00
|
|
|
layout->addWidget (toolbar, 0);
|
|
|
|
|
|
|
|
layout->addWidget (mScene, 1);
|
|
|
|
|
|
|
|
QWidget *widget = new QWidget;
|
|
|
|
|
|
|
|
widget->setLayout (layout);
|
|
|
|
|
|
|
|
setWidget (widget);
|
|
|
|
|
|
|
|
connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
|
2014-03-21 11:52:46 +00:00
|
|
|
connect (mScene, SIGNAL (referenceableIdChanged (const std::string&)),
|
|
|
|
this, SLOT (referenceableIdChanged (const std::string&)));
|
2014-07-14 09:19:59 +00:00
|
|
|
connect (mScene, SIGNAL (focusToolbarRequest()), toolbar, SLOT (setFocus()));
|
2014-07-14 11:49:55 +00:00
|
|
|
connect (toolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus()));
|
2014-03-16 11:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
|
|
|
|
|
2014-10-27 07:57:18 +00:00
|
|
|
std::string CSVWorld::PreviewSubView::getTitle() const
|
|
|
|
{
|
|
|
|
return mTitle;
|
|
|
|
}
|
|
|
|
|
2014-03-21 11:52:46 +00:00
|
|
|
void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id)
|
|
|
|
{
|
|
|
|
if (id.empty())
|
2014-10-27 07:57:18 +00:00
|
|
|
mTitle = "Preview: Reference to <nothing>";
|
2014-03-21 11:52:46 +00:00
|
|
|
else
|
2014-10-27 07:57:18 +00:00
|
|
|
mTitle = "Preview: Reference to " + id;
|
|
|
|
|
|
|
|
setWindowTitle (QString::fromUtf8 (mTitle.c_str()));
|
|
|
|
|
|
|
|
emit updateTitle();
|
2015-03-19 22:27:14 +00:00
|
|
|
}
|