added creator to bottom box; more cleanup

pull/51/head
Marc Zinnschlag 12 years ago
parent 6c4bdc0101
commit ed83e2e70a

@ -7,6 +7,8 @@
#include <QStackedLayout>
#include <QLabel>
#include "creator.hpp"
void CSVWorld::TableBottomBox::updateStatus()
{
if (mShowStatusBar)
@ -37,7 +39,7 @@ void CSVWorld::TableBottomBox::updateStatus()
}
}
CSVWorld::TableBottomBox::TableBottomBox (QWidget *parent)
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory, QWidget *parent)
: QWidget (parent), mShowStatusBar (false)
{
for (int i=0; i<4; ++i)
@ -60,6 +62,13 @@ CSVWorld::TableBottomBox::TableBottomBox (QWidget *parent)
layout->addWidget (statusBar2);
setLayout (layout);
mCreator = creatorFactory.makeCreator();
}
CSVWorld::TableBottomBox::~TableBottomBox()
{
delete mCreator;
}
void CSVWorld::TableBottomBox::setStatusBar (bool show)
@ -75,6 +84,11 @@ void CSVWorld::TableBottomBox::setStatusBar (bool show)
}
}
bool CSVWorld::TableBottomBox::canCreateAndDelete() const
{
return mCreator;
}
void CSVWorld::TableBottomBox::selectionSizeChanged (int size)
{
if (mStatusCount[3]!=size)

@ -7,6 +7,9 @@ class QLabel;
namespace CSVWorld
{
class CreatorFactoryBase;
class Creator;
class TableBottomBox : public QWidget
{
Q_OBJECT
@ -14,17 +17,29 @@ namespace CSVWorld
bool mShowStatusBar;
QLabel *mStatus;
int mStatusCount[4];
Creator *mCreator;
private:
// not implemented
TableBottomBox (const TableBottomBox&);
TableBottomBox& operator= (const TableBottomBox&);
void updateStatus();
public:
TableBottomBox (QWidget *parent = 0);
TableBottomBox (const CreatorFactoryBase& creatorFactory, QWidget *parent = 0);
virtual ~TableBottomBox();
void setStatusBar (bool show);
bool canCreateAndDelete() const;
///< Is record creation and deletion supported?
///
/// \note The BotomBox does not partake in the deletion of records.
public slots:
void selectionSizeChanged (int size);

@ -18,14 +18,10 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
layout->setContentsMargins (QMargins (0, 0, 0, 0));
Creator *creator = creatorFactory.makeCreator();
bool createAndDelete = creator!=0;
delete creator;
layout->addWidget (mBottom = new TableBottomBox (creatorFactory, this), 0);
layout->addWidget (
mTable = new Table (id, document.getData(), document.getUndoStack(), createAndDelete), 2);
layout->addWidget (mBottom = new TableBottomBox (this), 0);
layout->insertWidget (0, mTable =
new Table (id, document.getData(), document.getUndoStack(), mBottom->canCreateAndDelete()), 2);
QWidget *widget = new QWidget;

Loading…
Cancel
Save