mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 23:39:42 +00:00
Rework creator factories to accept Document as a parameter
This commit is contained in:
parent
d5bc561d17
commit
36271f25ec
10 changed files with 37 additions and 42 deletions
|
@ -15,8 +15,8 @@ void CSVWorld::Creator::setScope (unsigned int scope)
|
||||||
CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}
|
CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}
|
||||||
|
|
||||||
|
|
||||||
CSVWorld::Creator *CSVWorld::NullCreatorFactory::makeCreator (CSMWorld::Data& data,
|
CSVWorld::Creator *CSVWorld::NullCreatorFactory::makeCreator (CSMDoc::Document& document,
|
||||||
QUndoStack& undoStack, const CSMWorld::UniversalId& id) const
|
const CSMWorld::UniversalId& id) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,12 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "../../model/world/scope.hpp"
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
#include "../../model/world/scope.hpp"
|
namespace CSMDoc
|
||||||
|
|
||||||
class QUndoStack;
|
|
||||||
|
|
||||||
namespace CSMWorld
|
|
||||||
{
|
{
|
||||||
class Data;
|
class Document;
|
||||||
class UniversalId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
|
@ -59,8 +55,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual ~CreatorFactoryBase();
|
virtual ~CreatorFactoryBase();
|
||||||
|
|
||||||
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
virtual Creator *makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const = 0;
|
||||||
const CSMWorld::UniversalId& id) const = 0;
|
|
||||||
///< The ownership of the returned Creator is transferred to the caller.
|
///< 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
|
/// \note The function can return a 0-pointer, which means no UI for creating/deleting
|
||||||
|
@ -72,8 +67,7 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
virtual Creator *makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const;
|
||||||
const CSMWorld::UniversalId& id) const;
|
|
||||||
///< The ownership of the returned Creator is transferred to the caller.
|
///< The ownership of the returned Creator is transferred to the caller.
|
||||||
///
|
///
|
||||||
/// \note The function always returns 0.
|
/// \note The function always returns 0.
|
||||||
|
@ -84,8 +78,7 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
virtual Creator *makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const;
|
||||||
const CSMWorld::UniversalId& id) const;
|
|
||||||
///< The ownership of the returned Creator is transferred to the caller.
|
///< 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
|
/// \note The function can return a 0-pointer, which means no UI for creating/deleting
|
||||||
|
@ -93,10 +86,10 @@ namespace CSVWorld
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class CreatorT, unsigned int scope>
|
template<class CreatorT, unsigned int scope>
|
||||||
Creator *CreatorFactory<CreatorT, scope>::makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
Creator *CreatorFactory<CreatorT, scope>::makeCreator (CSMDoc::Document& document,
|
||||||
const CSMWorld::UniversalId& id) const
|
const CSMWorld::UniversalId& id) const
|
||||||
{
|
{
|
||||||
std::auto_ptr<CreatorT> creator (new CreatorT (data, undoStack, id));
|
std::auto_ptr<CreatorT> creator (new CreatorT (document.getData(), document.getUndoStack(), id));
|
||||||
|
|
||||||
creator->setScope (scope);
|
creator->setScope (scope);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <components/esm/loaddial.hpp>
|
#include <components/esm/loaddial.hpp>
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/world/columns.hpp"
|
#include "../../model/world/columns.hpp"
|
||||||
|
@ -22,14 +24,14 @@ CSVWorld::DialogueCreator::DialogueCreator (CSMWorld::Data& data, QUndoStack& un
|
||||||
: GenericCreator (data, undoStack, id, true), mType (type)
|
: GenericCreator (data, undoStack, id, true), mType (type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSVWorld::Creator *CSVWorld::TopicCreatorFactory::makeCreator (CSMWorld::Data& data,
|
CSVWorld::Creator *CSVWorld::TopicCreatorFactory::makeCreator (CSMDoc::Document& document,
|
||||||
QUndoStack& undoStack, const CSMWorld::UniversalId& id) const
|
const CSMWorld::UniversalId& id) const
|
||||||
{
|
{
|
||||||
return new DialogueCreator (data, undoStack, id, ESM::Dialogue::Topic);
|
return new DialogueCreator (document.getData(), document.getUndoStack(), id, ESM::Dialogue::Topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::Creator *CSVWorld::JournalCreatorFactory::makeCreator (CSMWorld::Data& data,
|
CSVWorld::Creator *CSVWorld::JournalCreatorFactory::makeCreator (CSMDoc::Document& document,
|
||||||
QUndoStack& undoStack, const CSMWorld::UniversalId& id) const
|
const CSMWorld::UniversalId& id) const
|
||||||
{
|
{
|
||||||
return new DialogueCreator (data, undoStack, id, ESM::Dialogue::Journal);
|
return new DialogueCreator (document.getData(), document.getUndoStack(), id, ESM::Dialogue::Journal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,7 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
virtual Creator *makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const;
|
||||||
const CSMWorld::UniversalId& id) const;
|
|
||||||
///< The ownership of the returned Creator is transferred to the caller.
|
///< The ownership of the returned Creator is transferred to the caller.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,8 +31,7 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
virtual Creator *makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const;
|
||||||
const CSMWorld::UniversalId& id) const;
|
|
||||||
///< The ownership of the returned Creator is transferred to the caller.
|
///< The ownership of the returned Creator is transferred to the caller.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -685,8 +685,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
mMainLayout->addWidget(mEditWidget);
|
mMainLayout->addWidget(mEditWidget);
|
||||||
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
mMainLayout->addWidget (mBottom =
|
mMainLayout->addWidget (mBottom = new TableBottomBox (creatorFactory, document, id, this));
|
||||||
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this));
|
|
||||||
|
|
||||||
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,12 @@ class QLineEdit;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QUndoStack;
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class CreateCommand;
|
class CreateCommand;
|
||||||
|
class Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
|
|
|
@ -33,9 +33,7 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
|
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
layout->addWidget (mBottom =
|
layout->addWidget (mBottom = new TableBottomBox (NullCreatorFactory(), document, id, this), 0);
|
||||||
new TableBottomBox (NullCreatorFactory(), document.getData(), document.getUndoStack(), id,
|
|
||||||
this), 0);
|
|
||||||
|
|
||||||
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,10 @@ void CSVWorld::TableBottomBox::updateStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory,
|
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory,
|
||||||
CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, QWidget *parent)
|
CSMDoc::Document& document,
|
||||||
|
const CSMWorld::UniversalId& id,
|
||||||
|
QWidget *parent)
|
||||||
: QWidget (parent), mShowStatusBar (false), mCreating (false)
|
: QWidget (parent), mShowStatusBar (false), mCreating (false)
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
|
@ -61,7 +63,7 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
|
||||||
|
|
||||||
setLayout (mLayout);
|
setLayout (mLayout);
|
||||||
|
|
||||||
mCreator = creatorFactory.makeCreator (data, undoStack, id);
|
mCreator = creatorFactory.makeCreator (document, id);
|
||||||
|
|
||||||
if (mCreator)
|
if (mCreator)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,10 +9,9 @@ class QStackedLayout;
|
||||||
class QStatusBar;
|
class QStatusBar;
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Data;
|
class Document;
|
||||||
class UniversalId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
|
@ -42,8 +41,10 @@ namespace CSVWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TableBottomBox (const CreatorFactoryBase& creatorFactory, CSMWorld::Data& data,
|
TableBottomBox (const CreatorFactoryBase& creatorFactory,
|
||||||
QUndoStack& undoStack, const CSMWorld::UniversalId& id, QWidget *parent = 0);
|
CSMDoc::Document& document,
|
||||||
|
const CSMWorld::UniversalId& id,
|
||||||
|
QWidget *parent = 0);
|
||||||
|
|
||||||
virtual ~TableBottomBox();
|
virtual ~TableBottomBox();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
layout->addWidget (mBottom =
|
layout->addWidget (mBottom =
|
||||||
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this), 0);
|
new TableBottomBox (creatorFactory, document, id, this), 0);
|
||||||
|
|
||||||
layout->insertWidget (0, mTable =
|
layout->insertWidget (0, mTable =
|
||||||
new Table (id, mBottom->canCreateAndDelete(), sorting, document), 2);
|
new Table (id, mBottom->canCreateAndDelete(), sorting, document), 2);
|
||||||
|
|
Loading…
Reference in a new issue