create new records with basic data in the same step without updates inbetween (Fixes #3207)

move
Marc Zinnschlag 9 years ago
parent ebaeabc962
commit 7d8bd56e11

@ -68,9 +68,6 @@ void CSMWorld::ModifyCommand::undo()
void CSMWorld::CreateCommand::applyModifications() 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()) if (!mNestedValues.empty())
{ {
CSMWorld::IdTree *tree = dynamic_cast<CSMWorld::IdTree *>(&mModel); CSMWorld::IdTree *tree = dynamic_cast<CSMWorld::IdTree *>(&mModel);
@ -114,7 +111,7 @@ void CSMWorld::CreateCommand::setType (UniversalId::Type type)
void CSMWorld::CreateCommand::redo() void CSMWorld::CreateCommand::redo()
{ {
mModel.addRecord (mId, mType); mModel.addRecordWithData (mId, mValues, mType);
applyModifications(); applyModifications();
} }

@ -149,6 +149,21 @@ void CSMWorld::IdTable::addRecord (const std::string& id, UniversalId::Type type
endInsertRows(); 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, void CSMWorld::IdTable::cloneRecord(const std::string& origin,
const std::string& destination, const std::string& destination,
CSMWorld::UniversalId::Type type) CSMWorld::UniversalId::Type type)

@ -53,6 +53,10 @@ 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 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, void cloneRecord(const std::string& origin,
const std::string& destination, const std::string& destination,
UniversalId::Type type = UniversalId::Type_None); UniversalId::Type type = UniversalId::Type_None);

Loading…
Cancel
Save