moved edit mode handling from SceneSubView to WorldspaceWidget

sceneinput
Marc Zinnschlag 9 years ago
parent 5d9863aec1
commit 9bf27c7e37

@ -42,7 +42,7 @@ namespace
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
: SceneWidget (document.getData().getResourceSystem(), parent), mSceneElements(0), mRun(0), mDocument(document),
mInteractionMask (0)
mInteractionMask (0), mEditMode (0), mLocked (false)
{
setAcceptDrops(true);
@ -199,11 +199,14 @@ CSVWidget::SceneToolRun *CSVRender::WorldspaceWidget::makeRunTool (
CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeEditModeSelector (
CSVWidget::SceneToolbar *parent)
{
CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Edit Mode");
mEditMode = new CSVWidget::SceneToolMode (parent, "Edit Mode");
addEditModeSelectorButtons (tool);
addEditModeSelectorButtons (mEditMode);
return tool;
connect (mEditMode, SIGNAL (modeChanged (const std::string&)),
this, SLOT (editModeChanged (const std::string&)));
return mEditMode;
}
CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType (
@ -279,6 +282,13 @@ void CSVRender::WorldspaceWidget::updateUserSetting (const QString& name, const
{
if (!value.isEmpty() && storeMappingSetting (name, value.first()))
return;
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).updateUserSetting (name, value);
}
void CSVRender::WorldspaceWidget::setEditLock (bool locked)
{
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).setEditLock (locked);
}
void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
@ -468,6 +478,11 @@ void CSVRender::WorldspaceWidget::debugProfileAboutToBeRemoved (const QModelInde
}
}
void CSVRender::WorldspaceWidget::editModeChanged (const std::string& id)
{
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).setEditLock (mLocked);
}
void CSVRender::WorldspaceWidget::elementSelectionChanged()
{
setVisibilityMask (getVisibilityMask());

@ -36,6 +36,8 @@ namespace CSVRender
CSMDoc::Document& mDocument;
unsigned int mInteractionMask;
std::map<std::pair<Qt::MouseButton, bool>, std::string> mButtonMapping;
CSVWidget::SceneToolMode *mEditMode;
bool mLocked;
public:
@ -100,6 +102,8 @@ namespace CSVRender
virtual void updateUserSetting (const QString& name, const QStringList& value);
virtual void setEditLock (bool locked);
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);
@ -158,6 +162,7 @@ namespace CSVRender
void debugProfileAboutToBeRemoved (const QModelIndex& parent, int start, int end);
void editModeChanged (const std::string& id);
protected slots:

@ -27,8 +27,7 @@
#include "creator.hpp"
CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
: SubView (id), mScene(NULL), mLayout(new QHBoxLayout), mDocument(document), mToolbar(NULL),
mEditMode (0), mLocked (false)
: SubView (id), mScene(NULL), mLayout(new QHBoxLayout), mDocument(document), mToolbar(NULL)
{
QVBoxLayout *layout = new QVBoxLayout;
@ -123,16 +122,14 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp
CSVWidget::SceneToolRun *runTool = widget->makeRunTool (toolbar);
toolbar->addTool (runTool);
mEditMode = widget->makeEditModeSelector (toolbar);
toolbar->addTool (mEditMode);
toolbar->addTool (widget->makeEditModeSelector (toolbar));
return toolbar;
}
void CSVWorld::SceneSubView::setEditLock (bool locked)
{
mLocked = locked;
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).setEditLock (locked);
mScene->setEditLock (locked);
}
void CSVWorld::SceneSubView::setStatusBar (bool show)
@ -153,7 +150,6 @@ std::string CSVWorld::SceneSubView::getTitle() const
void CSVWorld::SceneSubView::updateUserSetting (const QString& name, const QStringList& value)
{
mScene->updateUserSetting (name, value);
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).updateUserSetting (name, value);
CSVDoc::SubView::updateUserSetting (name, value);
}
@ -259,12 +255,4 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW
mScene->selectDefaultNavigationMode();
setFocusProxy (mScene);
connect (mEditMode, SIGNAL (modeChanged (const std::string&)),
this, SLOT (editModeChanged (const std::string&)));
}
void CSVWorld::SceneSubView::editModeChanged (const std::string& id)
{
dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent()).setEditLock (mLocked);
}

@ -46,8 +46,6 @@ namespace CSVWorld
CSMDoc::Document& mDocument;
CSVWidget::SceneToolbar* mToolbar;
std::string mTitle;
CSVWidget::SceneToolMode *mEditMode;
bool mLocked;
public:
@ -86,8 +84,6 @@ namespace CSVWorld
void cellSelectionChanged (const CSMWorld::UniversalId& id);
void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
void editModeChanged (const std::string& id);
};
}

Loading…
Cancel
Save