1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-23 12:53:52 +00:00
openmw/apps/opencs/view/world/previewsubview.cpp

79 lines
2.5 KiB
C++
Raw Normal View History

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
#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"
2022-09-22 18:26:05 +00:00
CSVWorld::PreviewSubView::PreviewSubView(const CSMWorld::UniversalId& id, CSMDoc::Document& document)
: SubView(id)
, mTitle(id.toString().c_str())
2014-03-16 11:44:01 +00:00
{
2022-09-22 18:26:05 +00:00
QHBoxLayout* layout = new QHBoxLayout;
2014-03-16 11:44:01 +00:00
2022-09-22 18:26:05 +00:00
if (document.getData().getReferenceables().searchId(id.getId()) == -1)
2014-03-16 11:44:01 +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
2022-09-22 18:26:05 +00:00
referenceableIdChanged(referenceableId);
2022-09-22 18:26:05 +00:00
mScene = new CSVRender::PreviewWidget(document.getData(), id.getId(), false, this);
2014-03-16 11:44:01 +00:00
}
else
2022-09-22 18:26:05 +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);
2022-09-22 18:26:05 +00:00
CSVWidget::SceneToolbar* toolbar = new CSVWidget::SceneToolbar(48 + 6, this);
2014-03-16 11:44:01 +00:00
2022-09-22 18:26:05 +00:00
CSVWidget::SceneToolMode* lightingTool = mScene->makeLightingSelector(toolbar);
toolbar->addTool(lightingTool);
2014-03-23 14:14:26 +00:00
2022-09-22 18:26:05 +00:00
layout->addWidget(toolbar, 0);
2014-03-16 11:44:01 +00:00
2022-09-22 18:26:05 +00:00
layout->addWidget(mScene, 1);
2014-03-16 11:44:01 +00:00
2022-09-22 18:26:05 +00:00
QWidget* widget = new QWidget;
2014-03-16 11:44:01 +00:00
2022-09-22 18:26:05 +00:00
widget->setLayout(layout);
2014-03-16 11:44:01 +00:00
2022-09-22 18:26:05 +00:00
setWidget(widget);
2014-03-16 11:44:01 +00:00
2022-09-22 18:26:05 +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
}
2022-09-22 18:26:05 +00:00
void CSVWorld::PreviewSubView::setEditLock(bool locked) {}
2014-03-16 11:44:01 +00:00
std::string CSVWorld::PreviewSubView::getTitle() const
{
return mTitle;
}
2022-09-22 18:26:05 +00:00
void CSVWorld::PreviewSubView::referenceableIdChanged(const std::string& id)
{
if (id.empty())
mTitle = "Preview: Reference to <nothing>";
else
mTitle = "Preview: Reference to " + id;
2022-09-22 18:26:05 +00:00
setWindowTitle(QString::fromUtf8(mTitle.c_str()));
emit updateTitle();
}