mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 09:23:53 +00:00
create new records with basic data in the same step without updates inbetween (Fixes #3207)
This commit is contained in:
parent
ebaeabc962
commit
7d8bd56e11
3 changed files with 20 additions and 4 deletions
|
@ -68,9 +68,6 @@ void CSMWorld::ModifyCommand::undo()
|
|||
|
||||
void CSMWorld::CreateCommand::applyModifications()
|
||||
{
|
||||
for (std::map<int, QVariant>::const_iterator iter (mValues.begin()); iter!=mValues.end(); ++iter)
|
||||
mModel.setData (mModel.getModelIndex (mId, iter->first), iter->second);
|
||||
|
||||
if (!mNestedValues.empty())
|
||||
{
|
||||
CSMWorld::IdTree *tree = dynamic_cast<CSMWorld::IdTree *>(&mModel);
|
||||
|
@ -114,7 +111,7 @@ void CSMWorld::CreateCommand::setType (UniversalId::Type type)
|
|||
|
||||
void CSMWorld::CreateCommand::redo()
|
||||
{
|
||||
mModel.addRecord (mId, mType);
|
||||
mModel.addRecordWithData (mId, mValues, mType);
|
||||
applyModifications();
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,21 @@ void CSMWorld::IdTable::addRecord (const std::string& id, UniversalId::Type type
|
|||
endInsertRows();
|
||||
}
|
||||
|
||||
void CSMWorld::IdTable::addRecordWithData (const std::string& id,
|
||||
const std::map<int, QVariant>& data, UniversalId::Type type)
|
||||
{
|
||||
int index = mIdCollection->getAppendIndex (id, type);
|
||||
|
||||
beginInsertRows (QModelIndex(), index, index);
|
||||
|
||||
mIdCollection->appendBlankRecord (id, type);
|
||||
|
||||
for (std::map<int, QVariant>::const_iterator iter (data.begin()); iter!=data.end(); ++iter)
|
||||
mIdCollection->setData (index, iter->first, iter->second);
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void CSMWorld::IdTable::cloneRecord(const std::string& origin,
|
||||
const std::string& destination,
|
||||
CSMWorld::UniversalId::Type type)
|
||||
|
|
|
@ -53,6 +53,10 @@ namespace CSMWorld
|
|||
void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
|
||||
///< \param type Will be ignored, unless the collection supports multiple record types
|
||||
|
||||
void addRecordWithData (const std::string& id, const std::map<int, QVariant>& data,
|
||||
UniversalId::Type type = UniversalId::Type_None);
|
||||
///< \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);
|
||||
|
|
Loading…
Reference in a new issue