From c87d9ff38d67d698f60d0f438b45b99c546a869a Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 23 Jan 2014 16:17:04 +0100 Subject: [PATCH] Disable reference creator widget when in the clone mode. --- apps/opencs/view/world/genericcreator.hpp | 6 ++++-- apps/opencs/view/world/referencecreator.cpp | 21 +++++++++++++++++++-- apps/opencs/view/world/referencecreator.hpp | 5 +++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/opencs/view/world/genericcreator.hpp b/apps/opencs/view/world/genericcreator.hpp index e4813594b2..4870ba46c4 100644 --- a/apps/opencs/view/world/genericcreator.hpp +++ b/apps/opencs/view/world/genericcreator.hpp @@ -29,11 +29,13 @@ namespace CSVWorld std::string mErrors; QHBoxLayout *mLayout; bool mLocked; - bool mCloneMode; std::string mClonedId; CSMWorld::UniversalId::Type mClonedType; CSMWorld::UniversalId::ArgumentType mArgumentType; - + + protected: + bool mCloneMode; + protected: void update(); diff --git a/apps/opencs/view/world/referencecreator.cpp b/apps/opencs/view/world/referencecreator.cpp index 06b3eb76dd..6991ecf36d 100644 --- a/apps/opencs/view/world/referencecreator.cpp +++ b/apps/opencs/view/world/referencecreator.cpp @@ -49,8 +49,13 @@ std::string CSVWorld::ReferenceCreator::getErrors() const { std::string errors = GenericCreator::getErrors(); + if (mCloneMode) + { + return errors; + } + std::string cell = mCell->text().toUtf8().constData(); - + if (cell.empty()) { if (!errors.empty()) @@ -72,4 +77,16 @@ std::string CSVWorld::ReferenceCreator::getErrors() const void CSVWorld::ReferenceCreator::cellChanged() { update(); -} \ No newline at end of file +} + +void CSVWorld::ReferenceCreator::toggleWidgets(bool active) +{ + CSVWorld::GenericCreator::toggleWidgets(active); + mCell->setEnabled(active); +} + +void CSVWorld::ReferenceCreator::cloneMode(const std::string& originid, const CSMWorld::UniversalId::Type type, const CSMWorld::UniversalId::ArgumentType argumentType) +{ + CSVWorld::GenericCreator::cloneMode(originid, type, argumentType); + cellChanged(); //otherwise ok button will remain disabled +} diff --git a/apps/opencs/view/world/referencecreator.hpp b/apps/opencs/view/world/referencecreator.hpp index 27f81564fd..2f0897026d 100644 --- a/apps/opencs/view/world/referencecreator.hpp +++ b/apps/opencs/view/world/referencecreator.hpp @@ -25,7 +25,12 @@ namespace CSVWorld ReferenceCreator (CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id); + virtual void cloneMode(const std::string& originid, + const CSMWorld::UniversalId::Type type, + const CSMWorld::UniversalId::ArgumentType argumentType); + virtual void reset(); + virtual void toggleWidgets(bool active = true); virtual std::string getErrors() const; ///< Return formatted error descriptions for the current state of the creator. if an empty