handling down a reference to Data and the undo stack to the creators

pull/51/head
Marc Zinnschlag 12 years ago
parent fee748d4b5
commit f93af52486

@ -6,7 +6,8 @@ CSVWorld::Creator:: ~Creator() {}
CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}
CSVWorld::Creator *CSVWorld::NullCreatorFactory::makeCreator() const
CSVWorld::Creator *CSVWorld::NullCreatorFactory::makeCreator (CSMWorld::Data& data,
QUndoStack& undoStack) const
{
return 0;
}

@ -3,6 +3,13 @@
#include <QWidget>
class QUndoStack;
namespace CSMWorld
{
class Data;
}
namespace CSVWorld
{
/// \brief Record creator UI base class
@ -28,7 +35,7 @@ namespace CSVWorld
virtual ~CreatorFactoryBase();
virtual Creator *makeCreator() const = 0;
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack) const = 0;
///< 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
@ -40,7 +47,7 @@ namespace CSVWorld
{
public:
virtual Creator *makeCreator() const;
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack) const;
///< The ownership of the returned Creator is transferred to the caller.
///
/// \note The function always returns 0.
@ -51,7 +58,7 @@ namespace CSVWorld
{
public:
virtual Creator *makeCreator() const;
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStac) const;
///< 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
@ -59,9 +66,9 @@ namespace CSVWorld
};
template<class CreatorT>
Creator *CreatorFactory<CreatorT>::makeCreator() const
Creator *CreatorFactory<CreatorT>::makeCreator (CSMWorld::Data& data, QUndoStack& undoStack) const
{
return new CreatorT;
return new CreatorT (data, undoStack);
}
}

@ -5,7 +5,7 @@
#include <QPushButton>
#include <QLineEdit>
CSVWorld::GenericCreator::GenericCreator()
CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack)
{
QHBoxLayout *layout = new QHBoxLayout;

@ -11,7 +11,7 @@ namespace CSVWorld
public:
GenericCreator();
GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack);
virtual void reset();
};

@ -39,7 +39,8 @@ void CSVWorld::TableBottomBox::updateStatus()
}
}
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory, QWidget *parent)
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory,
CSMWorld::Data& data, QUndoStack& undoStack, QWidget *parent)
: QWidget (parent), mShowStatusBar (false), mCreating (false)
{
for (int i=0; i<4; ++i)
@ -59,7 +60,7 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
setLayout (mLayout);
mCreator = creatorFactory.makeCreator();
mCreator = creatorFactory.makeCreator (data, undoStack);
mLayout->addWidget (mCreator);

@ -6,6 +6,12 @@
class QLabel;
class QStackedLayout;
class QStatusBar;
class QUndoStack;
namespace CSMWorld
{
class Data;
}
namespace CSVWorld
{
@ -34,7 +40,8 @@ namespace CSVWorld
public:
TableBottomBox (const CreatorFactoryBase& creatorFactory, QWidget *parent = 0);
TableBottomBox (const CreatorFactoryBase& creatorFactory, CSMWorld::Data& data,
QUndoStack& undoStack, QWidget *parent = 0);
virtual ~TableBottomBox();

@ -13,12 +13,12 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
const CreatorFactoryBase& creatorFactory)
: SubView (id)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins (QMargins (0, 0, 0, 0));
layout->addWidget (mBottom = new TableBottomBox (creatorFactory, this), 0);
layout->addWidget (mBottom =
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), this), 0);
layout->insertWidget (0, mTable =
new Table (id, document.getData(), document.getUndoStack(), mBottom->canCreateAndDelete()), 2);

Loading…
Cancel
Save