1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 06:53:53 +00:00

added creator to bottom box; more cleanup

This commit is contained in:
Marc Zinnschlag 2013-07-26 12:51:45 +02:00
parent 6c4bdc0101
commit ed83e2e70a
3 changed files with 34 additions and 9 deletions

View file

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

View file

@ -7,6 +7,9 @@ class QLabel;
namespace CSVWorld namespace CSVWorld
{ {
class CreatorFactoryBase;
class Creator;
class TableBottomBox : public QWidget class TableBottomBox : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -14,17 +17,29 @@ namespace CSVWorld
bool mShowStatusBar; bool mShowStatusBar;
QLabel *mStatus; QLabel *mStatus;
int mStatusCount[4]; int mStatusCount[4];
Creator *mCreator;
private: private:
// not implemented
TableBottomBox (const TableBottomBox&);
TableBottomBox& operator= (const TableBottomBox&);
void updateStatus(); void updateStatus();
public: public:
TableBottomBox (QWidget *parent = 0); TableBottomBox (const CreatorFactoryBase& creatorFactory, QWidget *parent = 0);
virtual ~TableBottomBox();
void setStatusBar (bool show); 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: public slots:
void selectionSizeChanged (int size); void selectionSizeChanged (int size);

View file

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