mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Implement an override-value when cloning, use when cloning info records
This commit is contained in:
parent
3045d20a97
commit
7196ad7455
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include "columnbase.hpp"
|
#include "columnbase.hpp"
|
||||||
#include "collectionbase.hpp"
|
#include "collectionbase.hpp"
|
||||||
#include "info.hpp"
|
|
||||||
#include "land.hpp"
|
#include "land.hpp"
|
||||||
#include "landtexture.hpp"
|
#include "landtexture.hpp"
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
@ -265,13 +264,6 @@ namespace CSMWorld
|
|||||||
CSMWorld::CellRef* ptr = (CSMWorld::CellRef*) ©.mModified;
|
CSMWorld::CellRef* ptr = (CSMWorld::CellRef*) ©.mModified;
|
||||||
ptr->mRefNum.mIndex = 0;
|
ptr->mRefNum.mIndex = 0;
|
||||||
}
|
}
|
||||||
if (type == UniversalId::Type_TopicInfo || type == UniversalId::Type_JournalInfo)
|
|
||||||
{
|
|
||||||
CSMWorld::Info* ptr = (CSMWorld::Info*) ©.mModified;
|
|
||||||
std::vector<std::string> splitStringContainer;
|
|
||||||
Misc::StringUtils::split(destination, splitStringContainer, "#");
|
|
||||||
if (!splitStringContainer.empty()) ptr->mTopicId = splitStringContainer[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
int index = getAppendIndex(destination, type);
|
int index = getAppendIndex(destination, type);
|
||||||
insertRecord(copy, getAppendIndex(destination, type));
|
insertRecord(copy, getAppendIndex(destination, type));
|
||||||
|
@ -397,6 +397,10 @@ void CSMWorld::CloneCommand::redo()
|
|||||||
{
|
{
|
||||||
mModel.cloneRecord (mIdOrigin, mId, mType);
|
mModel.cloneRecord (mIdOrigin, mId, mType);
|
||||||
applyModifications();
|
applyModifications();
|
||||||
|
for (auto& value : mOverrideValues)
|
||||||
|
{
|
||||||
|
mModel.setData(mModel.getModelIndex (mId, value.first), value.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::CloneCommand::undo()
|
void CSMWorld::CloneCommand::undo()
|
||||||
@ -404,6 +408,11 @@ void CSMWorld::CloneCommand::undo()
|
|||||||
mModel.removeRow (mModel.getModelIndex (mId, 0).row());
|
mModel.removeRow (mModel.getModelIndex (mId, 0).row());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMWorld::CloneCommand::setOverrideValue(int column, QVariant value)
|
||||||
|
{
|
||||||
|
mOverrideValues.emplace_back(std::make_pair(column, value));
|
||||||
|
}
|
||||||
|
|
||||||
CSMWorld::CreatePathgridCommand::CreatePathgridCommand(IdTable& model, const std::string& id, QUndoCommand *parent)
|
CSMWorld::CreatePathgridCommand::CreatePathgridCommand(IdTable& model, const std::string& id, QUndoCommand *parent)
|
||||||
: CreateCommand(model, id, parent)
|
: CreateCommand(model, id, parent)
|
||||||
{
|
{
|
||||||
|
@ -183,6 +183,7 @@ namespace CSMWorld
|
|||||||
class CloneCommand : public CreateCommand
|
class CloneCommand : public CreateCommand
|
||||||
{
|
{
|
||||||
std::string mIdOrigin;
|
std::string mIdOrigin;
|
||||||
|
std::vector<std::pair<int, QVariant>> mOverrideValues;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -194,6 +195,8 @@ namespace CSMWorld
|
|||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
|
|
||||||
|
void setOverrideValue(int column, QVariant value);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RevertCommand : public QUndoCommand
|
class RevertCommand : public QUndoCommand
|
||||||
|
@ -40,10 +40,14 @@ void CSVWorld::InfoCreator::configureCreateCommand (CSMWorld::CreateCommand& com
|
|||||||
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Rank), -1);
|
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Rank), -1);
|
||||||
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Gender), -1);
|
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Gender), -1);
|
||||||
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_PcRank), -1);
|
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_PcRank), -1);
|
||||||
|
CSMWorld::CloneCommand* cloneCommand = dynamic_cast<CSMWorld::CloneCommand*> (&command);
|
||||||
|
if (cloneCommand) cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Topic), mTopic->text());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text());
|
command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text());
|
||||||
|
CSMWorld::CloneCommand* cloneCommand = dynamic_cast<CSMWorld::CloneCommand*> (&command);
|
||||||
|
if (cloneCommand) cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user