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