1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 05:15:36 +00:00

added scope configuration to creators

This commit is contained in:
Marc Zinnschlag 2014-08-07 09:32:49 +02:00
parent 0be1e3d12f
commit 35803bc9b6
4 changed files with 29 additions and 8 deletions

View file

@ -56,7 +56,7 @@ CSVFilter::FilterCreator::FilterCreator (CSMWorld::Data& data, QUndoStack& undoS
/// \todo re-enable for OpenMW 1.1
// mScope->addItem ("Content");
connect (mScope, SIGNAL (currentIndexChanged (int)), this, SLOT (setScope (int)));
connect (mScope, SIGNAL (currentIndexChanged (int)), this, SLOT (setScope2 (int)));
insertAtBeginning (mScope, false);
@ -71,7 +71,7 @@ void CSVFilter::FilterCreator::reset()
GenericCreator::reset();
}
void CSVFilter::FilterCreator::setScope (int index)
void CSVFilter::FilterCreator::setScope2 (int index)
{
update();
}

View file

@ -36,7 +36,7 @@ namespace CSVFilter
private slots:
void setScope (int index);
void setScope2 (int index);
};
}

View file

@ -1,7 +1,16 @@
#include "creator.hpp"
CSVWorld::Creator:: ~Creator() {}
#include <stdexcept>
CSVWorld::Creator::~Creator() {}
void CSVWorld::Creator::setScope (unsigned int scope)
{
if (scope!=CSMWorld::Scope_Content)
throw std::logic_error ("Invalid scope in creator");
}
CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}

View file

@ -1,9 +1,14 @@
#ifndef CSV_WORLD_CREATOR_H
#define CSV_WORLD_CREATOR_H
#include <memory>
#include <QWidget>
#include "../../model/world/universalid.hpp"
#include "../../model/world/scope.hpp"
class QUndoStack;
namespace CSMWorld
@ -32,6 +37,9 @@ namespace CSVWorld
virtual void toggleWidgets(bool active = true) = 0;
/// Default implementation: Throw an exception if scope!=Scope_Content.
virtual void setScope (unsigned int scope);
signals:
void done();
@ -68,7 +76,7 @@ namespace CSVWorld
/// \note The function always returns 0.
};
template<class CreatorT>
template<class CreatorT, unsigned int scope = CSMWorld::Scope_Content>
class CreatorFactory : public CreatorFactoryBase
{
public:
@ -81,11 +89,15 @@ namespace CSVWorld
/// records should be provided.
};
template<class CreatorT>
Creator *CreatorFactory<CreatorT>::makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
template<class CreatorT, unsigned int scope>
Creator *CreatorFactory<CreatorT, scope>::makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
const CSMWorld::UniversalId& id) const
{
return new CreatorT (data, undoStack, id);
std::auto_ptr<CreatorT> creator (new CreatorT (data, undoStack, id));
creator->setScope (scope);
return creator.release();
}
}