From 124a70906f06849ba42e0e804d41505cab2cda75 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 28 Jul 2013 14:51:47 +0200 Subject: [PATCH] added creator edit lock --- apps/opencs/view/world/creator.hpp | 2 ++ apps/opencs/view/world/genericcreator.cpp | 21 +++++++++++++++------ apps/opencs/view/world/genericcreator.hpp | 3 +++ apps/opencs/view/world/tablebottombox.cpp | 6 ++++++ apps/opencs/view/world/tablebottombox.hpp | 2 ++ apps/opencs/view/world/tablesubview.cpp | 1 + 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/world/creator.hpp b/apps/opencs/view/world/creator.hpp index 564a5584e0..a5c1991c39 100644 --- a/apps/opencs/view/world/creator.hpp +++ b/apps/opencs/view/world/creator.hpp @@ -24,6 +24,8 @@ namespace CSVWorld virtual void reset() = 0; + virtual void setEditLock (bool locked) = 0; + signals: void done(); diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index f30ada0923..cdfd715160 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -18,12 +18,12 @@ void CSVWorld::GenericCreator::update() mCreate->setToolTip (QString::fromUtf8 (mErrors.c_str())); - mCreate->setEnabled (mErrors.empty()); + mCreate->setEnabled (mErrors.empty() && !mLocked); } CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id) -: mData (data), mUndoStack (undoStack), mListId (id) +: mData (data), mUndoStack (undoStack), mListId (id), mLocked (false) { QHBoxLayout *layout = new QHBoxLayout; layout->setContentsMargins (0, 0, 0, 0); @@ -46,6 +46,12 @@ CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undo connect (mId, SIGNAL (textChanged (const QString&)), this, SLOT (textChanged (const QString&))); } +void CSVWorld::GenericCreator::setEditLock (bool locked) +{ + mLocked = locked; + update(); +} + void CSVWorld::GenericCreator::reset() { mId->setText (""); @@ -77,9 +83,12 @@ void CSVWorld::GenericCreator::textChanged (const QString& text) void CSVWorld::GenericCreator::create() { - mUndoStack.push (new CSMWorld::CreateCommand ( - dynamic_cast (*mData.getTableModel (mListId)), - mId->text().toUtf8().constData())); + if (!mLocked) + { + mUndoStack.push (new CSMWorld::CreateCommand ( + dynamic_cast (*mData.getTableModel (mListId)), + mId->text().toUtf8().constData())); - emit done(); + emit done(); + } } \ No newline at end of file diff --git a/apps/opencs/view/world/genericcreator.hpp b/apps/opencs/view/world/genericcreator.hpp index a89b4c31f2..b9ea58ad5c 100644 --- a/apps/opencs/view/world/genericcreator.hpp +++ b/apps/opencs/view/world/genericcreator.hpp @@ -20,6 +20,7 @@ namespace CSVWorld QPushButton *mCreate; QLineEdit *mId; std::string mErrors; + bool mLocked; private: @@ -30,6 +31,8 @@ namespace CSVWorld GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id); + virtual void setEditLock (bool locked); + virtual void reset(); virtual std::string getErrors() const; diff --git a/apps/opencs/view/world/tablebottombox.cpp b/apps/opencs/view/world/tablebottombox.cpp index b6d0e7807c..6a5dc83c1e 100644 --- a/apps/opencs/view/world/tablebottombox.cpp +++ b/apps/opencs/view/world/tablebottombox.cpp @@ -68,6 +68,12 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto connect (mCreator, SIGNAL (done()), this, SLOT (createRequestDone())); } +void CSVWorld::TableBottomBox::setEditLock (bool locked) +{ + if (mCreator) + mCreator->setEditLock (locked); +} + CSVWorld::TableBottomBox::~TableBottomBox() { delete mCreator; diff --git a/apps/opencs/view/world/tablebottombox.hpp b/apps/opencs/view/world/tablebottombox.hpp index 62c552c93a..21e68f51a3 100644 --- a/apps/opencs/view/world/tablebottombox.hpp +++ b/apps/opencs/view/world/tablebottombox.hpp @@ -46,6 +46,8 @@ namespace CSVWorld virtual ~TableBottomBox(); + void setEditLock (bool locked); + void setStatusBar (bool show); bool canCreateAndDelete() const; diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 8a828c9bd2..fb1a255cb6 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -46,6 +46,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D void CSVWorld::TableSubView::setEditLock (bool locked) { mTable->setEditLock (locked); + mBottom->setEditLock (locked); } void CSVWorld::TableSubView::editRequest (int row)