1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 08:53:50 +00:00

rewrote command generation in GenericCreator

This commit is contained in:
Marc Zinnschlag 2014-09-16 13:28:11 +02:00
parent 90b45e09f7
commit 70275350de
2 changed files with 25 additions and 13 deletions

View file

@ -50,6 +50,12 @@ std::string CSVWorld::GenericCreator::getId() const
void CSVWorld::GenericCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const {} void CSVWorld::GenericCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const {}
void CSVWorld::GenericCreator::pushCommand (std::auto_ptr<QUndoCommand> command,
const std::string& id)
{
mUndoStack.push (command.release());
}
CSMWorld::Data& CSVWorld::GenericCreator::getData() const CSMWorld::Data& CSVWorld::GenericCreator::getData() const
{ {
return mData; return mData;
@ -173,24 +179,23 @@ void CSVWorld::GenericCreator::create()
{ {
std::string id = getId(); std::string id = getId();
std::auto_ptr<QUndoCommand> command;
if (mCloneMode) if (mCloneMode)
{ {
std::auto_ptr<CSMWorld::CloneCommand> command (new CSMWorld::CloneCommand ( command.reset (new CSMWorld::CloneCommand (
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType));
mUndoStack.push(command.release());
} }
else else
{ {
std::auto_ptr<CSMWorld::CreateCommand> command (new CSMWorld::CreateCommand ( command.reset (new CSMWorld::CreateCommand (
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id)); dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id));
configureCreateCommand (*command); configureCreateCommand (dynamic_cast<CSMWorld::CreateCommand&> (*command));
mUndoStack.push (command.release());
} }
pushCommand (command, id);
emit done(); emit done();
emit requestFocus(id); emit requestFocus(id);
} }

View file

@ -1,16 +1,19 @@
#ifndef CSV_WORLD_GENERICCREATOR_H #ifndef CSV_WORLD_GENERICCREATOR_H
#define CSV_WORLD_GENERICCREATOR_H #define CSV_WORLD_GENERICCREATOR_H
#include <memory>
#include "../../model/world/universalid.hpp"
#include "creator.hpp"
class QString; class QString;
class QPushButton; class QPushButton;
class QLineEdit; class QLineEdit;
class QHBoxLayout; class QHBoxLayout;
class QComboBox; class QComboBox;
class QLabel; class QLabel;
class QUndoCommand;
#include "creator.hpp"
#include "../../model/world/universalid.hpp"
namespace CSMWorld namespace CSMWorld
{ {
@ -56,8 +59,12 @@ namespace CSVWorld
virtual std::string getId() const; 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 configureCreateCommand (CSMWorld::CreateCommand& command) const;
virtual void pushCommand (std::auto_ptr<QUndoCommand> command,
const std::string& id);
CSMWorld::Data& getData() const; CSMWorld::Data& getData() const;
const CSMWorld::UniversalId& getCollectionId() const; const CSMWorld::UniversalId& getCollectionId() const;