2014-03-16 11:44:01 +00:00
|
|
|
#include "previewsubview.hpp"
|
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <apps/opencs/model/world/data.hpp>
|
|
|
|
#include <apps/opencs/model/world/record.hpp>
|
|
|
|
#include <apps/opencs/model/world/ref.hpp>
|
|
|
|
#include <apps/opencs/model/world/refcollection.hpp>
|
|
|
|
#include <apps/opencs/model/world/refidcollection.hpp>
|
|
|
|
#include <apps/opencs/view/doc/subview.hpp>
|
|
|
|
|
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
|
|
|
|
2022-08-19 17:19:42 +00:00
|
|
|
#include "../../model/doc/document.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;
|
|
|
|
|
|
|
|
if (document.getData().getReferenceables().searchId(id.getId()) == -1)
|
|
|
|
{
|
2022-10-06 17:39:46 +00:00
|
|
|
std::string referenceableId = document.getData().getReferences().getRecord(ESM::RefId::stringRefId(id.getId())).get().mRefID.getRefIdString();
|
2014-03-16 11:44:01 +00:00
|
|
|
|
2014-03-21 11:52:46 +00:00
|
|
|
referenceableIdChanged(referenceableId);
|
2014-03-16 12:22:32 +00:00
|
|
|
|
2015-03-25 23:55:58 +00:00
|
|
|
mScene = 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
|
|
|
|
2022-01-11 09:34:19 +00:00
|
|
|
mScene->setExterior(true);
|
|
|
|
|
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);
|
|
|
|
|
2022-08-23 02:28:58 +00: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 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
|
|
|
}
|