From ed83e2e70a794157254c0cbdbe05411562f45ca7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 26 Jul 2013 12:51:45 +0200 Subject: [PATCH] added creator to bottom box; more cleanup --- apps/opencs/view/world/tablebottombox.cpp | 16 +++++++++++++++- apps/opencs/view/world/tablebottombox.hpp | 17 ++++++++++++++++- apps/opencs/view/world/tablesubview.cpp | 10 +++------- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/apps/opencs/view/world/tablebottombox.cpp b/apps/opencs/view/world/tablebottombox.cpp index c8ddb662c..dbd518c60 100644 --- a/apps/opencs/view/world/tablebottombox.cpp +++ b/apps/opencs/view/world/tablebottombox.cpp @@ -7,6 +7,8 @@ #include #include +#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) diff --git a/apps/opencs/view/world/tablebottombox.hpp b/apps/opencs/view/world/tablebottombox.hpp index 2663da855..0f25f787b 100644 --- a/apps/opencs/view/world/tablebottombox.hpp +++ b/apps/opencs/view/world/tablebottombox.hpp @@ -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); diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index f236a079a..2173c0a48 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -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;