mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 10:23:56 +00:00
handling down a reference to Data and the undo stack to the creators
This commit is contained in:
parent
fee748d4b5
commit
f93af52486
7 changed files with 29 additions and 13 deletions
|
@ -6,7 +6,8 @@ CSVWorld::Creator:: ~Creator() {}
|
||||||
CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}
|
CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}
|
||||||
|
|
||||||
|
|
||||||
CSVWorld::Creator *CSVWorld::NullCreatorFactory::makeCreator() const
|
CSVWorld::Creator *CSVWorld::NullCreatorFactory::makeCreator (CSMWorld::Data& data,
|
||||||
|
QUndoStack& undoStack) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -3,6 +3,13 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QUndoStack;
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
class Data;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
/// \brief Record creator UI base class
|
/// \brief Record creator UI base class
|
||||||
|
@ -28,7 +35,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual ~CreatorFactoryBase();
|
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.
|
///< 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
|
||||||
|
@ -40,7 +47,7 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
public:
|
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.
|
///< The ownership of the returned Creator is transferred to the caller.
|
||||||
///
|
///
|
||||||
/// \note The function always returns 0.
|
/// \note The function always returns 0.
|
||||||
|
@ -51,7 +58,7 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
public:
|
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.
|
///< 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
|
||||||
|
@ -59,9 +66,9 @@ namespace CSVWorld
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class CreatorT>
|
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 <QPushButton>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
CSVWorld::GenericCreator::GenericCreator()
|
CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack)
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GenericCreator();
|
GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack);
|
||||||
|
|
||||||
virtual void reset();
|
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)
|
: QWidget (parent), mShowStatusBar (false), mCreating (false)
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
|
@ -59,7 +60,7 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
|
||||||
|
|
||||||
setLayout (mLayout);
|
setLayout (mLayout);
|
||||||
|
|
||||||
mCreator = creatorFactory.makeCreator();
|
mCreator = creatorFactory.makeCreator (data, undoStack);
|
||||||
|
|
||||||
mLayout->addWidget (mCreator);
|
mLayout->addWidget (mCreator);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QStackedLayout;
|
class QStackedLayout;
|
||||||
class QStatusBar;
|
class QStatusBar;
|
||||||
|
class QUndoStack;
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
class Data;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
|
@ -34,7 +40,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TableBottomBox (const CreatorFactoryBase& creatorFactory, QWidget *parent = 0);
|
TableBottomBox (const CreatorFactoryBase& creatorFactory, CSMWorld::Data& data,
|
||||||
|
QUndoStack& undoStack, QWidget *parent = 0);
|
||||||
|
|
||||||
virtual ~TableBottomBox();
|
virtual ~TableBottomBox();
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
const CreatorFactoryBase& creatorFactory)
|
const CreatorFactoryBase& creatorFactory)
|
||||||
: SubView (id)
|
: SubView (id)
|
||||||
{
|
{
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
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 =
|
layout->insertWidget (0, mTable =
|
||||||
new Table (id, document.getData(), document.getUndoStack(), mBottom->canCreateAndDelete()), 2);
|
new Table (id, document.getData(), document.getUndoStack(), mBottom->canCreateAndDelete()), 2);
|
||||||
|
|
Loading…
Reference in a new issue