2013-07-26 10:34:30 +00:00
|
|
|
#ifndef CSV_WORLD_CREATOR_H
|
|
|
|
#define CSV_WORLD_CREATOR_H
|
|
|
|
|
2013-07-26 16:22:31 +00:00
|
|
|
#include <QWidget>
|
2014-01-19 10:44:47 +00:00
|
|
|
#include "../../model/world/universalid.hpp"
|
2013-07-26 16:22:31 +00:00
|
|
|
|
2013-07-27 11:28:12 +00:00
|
|
|
class QUndoStack;
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class Data;
|
2013-07-28 11:43:16 +00:00
|
|
|
class UniversalId;
|
2013-07-27 11:28:12 +00:00
|
|
|
}
|
|
|
|
|
2013-07-26 10:34:30 +00:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
|
|
|
/// \brief Record creator UI base class
|
2013-07-26 16:22:31 +00:00
|
|
|
class Creator : public QWidget
|
2013-07-26 10:34:30 +00:00
|
|
|
{
|
2013-07-26 19:09:23 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-07-26 10:34:30 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~Creator();
|
2013-07-26 19:09:23 +00:00
|
|
|
|
|
|
|
virtual void reset() = 0;
|
2014-01-27 18:40:05 +00:00
|
|
|
|
2014-01-27 12:13:39 +00:00
|
|
|
virtual void cloneMode(const std::string& originId,
|
2014-01-27 12:08:14 +00:00
|
|
|
const CSMWorld::UniversalId::Type type) = 0;
|
2013-07-26 19:09:23 +00:00
|
|
|
|
2013-07-28 12:51:47 +00:00
|
|
|
virtual void setEditLock (bool locked) = 0;
|
2014-01-27 18:40:05 +00:00
|
|
|
|
2014-01-23 15:00:44 +00:00
|
|
|
virtual void toggleWidgets(bool active = true) = 0;
|
2013-07-28 12:51:47 +00:00
|
|
|
|
2013-07-26 19:09:23 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void done();
|
2013-07-29 13:00:41 +00:00
|
|
|
|
|
|
|
void requestFocus (const std::string& id);
|
|
|
|
///< Request owner of this creator to focus the just created \a id. The owner may
|
|
|
|
/// ignore this request.
|
2013-07-26 10:34:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Base class for Creator factory
|
|
|
|
class CreatorFactoryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~CreatorFactoryBase();
|
|
|
|
|
2013-07-28 11:43:16 +00:00
|
|
|
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
|
|
|
const CSMWorld::UniversalId& id) const = 0;
|
2013-07-26 10:34:30 +00:00
|
|
|
///< The ownership of the returned Creator is transferred to the caller.
|
|
|
|
///
|
|
|
|
/// \note The function can return a 0-pointer, which means no UI for creating/deleting
|
|
|
|
/// records should be provided.
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Creator factory that does not produces any creator
|
|
|
|
class NullCreatorFactory : public CreatorFactoryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-07-28 11:43:16 +00:00
|
|
|
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
|
|
|
const CSMWorld::UniversalId& id) const;
|
2013-07-26 10:34:30 +00:00
|
|
|
///< The ownership of the returned Creator is transferred to the caller.
|
|
|
|
///
|
|
|
|
/// \note The function always returns 0.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class CreatorT>
|
|
|
|
class CreatorFactory : public CreatorFactoryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-07-28 11:43:16 +00:00
|
|
|
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
|
|
|
const CSMWorld::UniversalId& id) const;
|
2013-07-26 10:34:30 +00:00
|
|
|
///< The ownership of the returned Creator is transferred to the caller.
|
|
|
|
///
|
|
|
|
/// \note The function can return a 0-pointer, which means no UI for creating/deleting
|
|
|
|
/// records should be provided.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class CreatorT>
|
2013-07-28 11:43:16 +00:00
|
|
|
Creator *CreatorFactory<CreatorT>::makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
|
|
|
const CSMWorld::UniversalId& id) const
|
2013-07-26 10:34:30 +00:00
|
|
|
{
|
2013-07-28 11:43:16 +00:00
|
|
|
return new CreatorT (data, undoStack, id);
|
2013-07-26 10:34:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|