mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 11:53:52 +00:00
Working on commands
This commit is contained in:
parent
b3e45c55bc
commit
0ea2bb7c4c
5 changed files with 53 additions and 0 deletions
|
@ -25,6 +25,27 @@ void CSMWorld::ModifyCommand::undo()
|
||||||
mModel.setData (mIndex, mOld);
|
mModel.setData (mIndex, mOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSMWorld::CloneCommand::CloneCommand (CSMWorld::IdTable& model,
|
||||||
|
const std::string& idOrigin,
|
||||||
|
const std::string& IdDestination,
|
||||||
|
CSMWorld::UniversalId::Type type,
|
||||||
|
QUndoCommand* parent) :
|
||||||
|
QUndoCommand(parent),
|
||||||
|
mModel(model),
|
||||||
|
mIdOrigin(idOrigin),
|
||||||
|
mIdDestination(IdDestination),
|
||||||
|
mType(type)
|
||||||
|
{
|
||||||
|
setText (("Clone record " + idOrigin + " to the " + IdDestination).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CSMWorld::CloneCommand::redo()
|
||||||
|
{
|
||||||
|
mModel.cloneRecord(mIdOrigin, mIdDestination, mType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CSMWorld::CreateCommand::CreateCommand (IdTable& model, const std::string& id, QUndoCommand *parent)
|
CSMWorld::CreateCommand::CreateCommand (IdTable& model, const std::string& id, QUndoCommand *parent)
|
||||||
: QUndoCommand (parent), mModel (model), mId (id), mType (UniversalId::Type_None)
|
: QUndoCommand (parent), mModel (model), mId (id), mType (UniversalId::Type_None)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,26 @@ namespace CSMWorld
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CloneCommand : public QUndoCommand
|
||||||
|
{
|
||||||
|
IdTable& mModel;
|
||||||
|
std::string mIdOrigin;
|
||||||
|
std::string mIdDestination;
|
||||||
|
UniversalId::Type mType;
|
||||||
|
std::map<int, QVariant> mValues;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
CloneCommand (IdTable& model, const std::string& idOrigin,
|
||||||
|
const std::string& IdDestination,
|
||||||
|
UniversalId::Type type,
|
||||||
|
QUndoCommand* parent = 0);
|
||||||
|
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
// virtual void undo();
|
||||||
|
};
|
||||||
|
|
||||||
class CreateCommand : public QUndoCommand
|
class CreateCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
IdTable& mModel;
|
IdTable& mModel;
|
||||||
|
|
|
@ -124,6 +124,14 @@ void CSMWorld::IdTable::addRecord (const std::string& id, UniversalId::Type type
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMWorld::IdTable::cloneRecord(const std::string& origin,
|
||||||
|
const std::string& destination,
|
||||||
|
CSMWorld::UniversalId::Type type)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QModelIndex CSMWorld::IdTable::getModelIndex (const std::string& id, int column) const
|
QModelIndex CSMWorld::IdTable::getModelIndex (const std::string& id, int column) const
|
||||||
{
|
{
|
||||||
return index (mIdCollection->getIndex (id), column);
|
return index (mIdCollection->getIndex (id), column);
|
||||||
|
|
|
@ -63,6 +63,8 @@ namespace CSMWorld
|
||||||
void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
|
void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
|
||||||
///< \param type Will be ignored, unless the collection supports multiple record types
|
///< \param type Will be ignored, unless the collection supports multiple record types
|
||||||
|
|
||||||
|
void cloneRecord(const std::string& origin, const std::string& destination, UniversalId::Type type = UniversalId::Type_None);
|
||||||
|
|
||||||
QModelIndex getModelIndex (const std::string& id, int column) const;
|
QModelIndex getModelIndex (const std::string& id, int column) const;
|
||||||
|
|
||||||
void setRecord (const std::string& id, const RecordBase& record);
|
void setRecord (const std::string& id, const RecordBase& record);
|
||||||
|
|
|
@ -125,6 +125,8 @@ void CSVWorld::GenericCreator::create()
|
||||||
if (mCloneMode)
|
if (mCloneMode)
|
||||||
{
|
{
|
||||||
std::string id = getId();
|
std::string id = getId();
|
||||||
|
std::auto_ptr<CSMWorld::CloneCommand> command (new CSMWorld::CloneCommand (
|
||||||
|
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType));
|
||||||
} else {
|
} else {
|
||||||
std::string id = getId();
|
std::string id = getId();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue