diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index e905cfef6..afddda454 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -50,6 +50,12 @@ std::string CSVWorld::GenericCreator::getId() const void CSVWorld::GenericCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const {} +void CSVWorld::GenericCreator::pushCommand (std::auto_ptr command, + const std::string& id) +{ + mUndoStack.push (command.release()); +} + CSMWorld::Data& CSVWorld::GenericCreator::getData() const { return mData; @@ -173,24 +179,23 @@ void CSVWorld::GenericCreator::create() { std::string id = getId(); + std::auto_ptr command; + if (mCloneMode) { - std::auto_ptr command (new CSMWorld::CloneCommand ( + command.reset (new CSMWorld::CloneCommand ( dynamic_cast (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); - - mUndoStack.push(command.release()); - } else { - std::auto_ptr command (new CSMWorld::CreateCommand ( - dynamic_cast (*mData.getTableModel (mListId)), id)); + command.reset (new CSMWorld::CreateCommand ( + dynamic_cast (*mData.getTableModel (mListId)), id)); - configureCreateCommand (*command); - - mUndoStack.push (command.release()); + configureCreateCommand (dynamic_cast (*command)); } + pushCommand (command, id); + emit done(); emit requestFocus(id); } diff --git a/apps/opencs/view/world/genericcreator.hpp b/apps/opencs/view/world/genericcreator.hpp index ea099248e..4cd2fce2f 100644 --- a/apps/opencs/view/world/genericcreator.hpp +++ b/apps/opencs/view/world/genericcreator.hpp @@ -1,16 +1,19 @@ #ifndef CSV_WORLD_GENERICCREATOR_H #define CSV_WORLD_GENERICCREATOR_H +#include + +#include "../../model/world/universalid.hpp" + +#include "creator.hpp" + class QString; class QPushButton; class QLineEdit; class QHBoxLayout; class QComboBox; class QLabel; - -#include "creator.hpp" - -#include "../../model/world/universalid.hpp" +class QUndoCommand; namespace CSMWorld { @@ -56,8 +59,12 @@ namespace CSVWorld virtual std::string getId() const; + /// \note This function is not called in case of a clone operation. virtual void configureCreateCommand (CSMWorld::CreateCommand& command) const; + virtual void pushCommand (std::auto_ptr command, + const std::string& id); + CSMWorld::Data& getData() const; const CSMWorld::UniversalId& getCollectionId() const;