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

copying references.

This commit is contained in:
Marek Kochanowicz 2014-01-21 21:37:21 +01:00
parent bc0130f8d8
commit b3b51992ef
4 changed files with 24 additions and 4 deletions

View file

@ -4,7 +4,6 @@
#include <QAbstractItemModel>
#include <components/misc/stringops.hpp>
#include "idtable.hpp"
#include "idtable.hpp"
CSMWorld::ModifyCommand::ModifyCommand(QAbstractItemModel& model, const QModelIndex& index,
const QVariant& new_, QUndoCommand* parent)

View file

@ -5,6 +5,8 @@
#include "ref.hpp"
#include "cell.hpp"
#include "universalid.hpp"
#include "record.hpp"
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
{
@ -35,3 +37,16 @@ std::string CSMWorld::RefCollection::getNewId()
stream << "ref#" << mNextId++;
return stream.str();
}
void CSMWorld::RefCollection::cloneRecord(const std::string& origin,
const std::string& destination,
const CSMWorld::UniversalId::Type type,
const CSMWorld::UniversalId::ArgumentType argumentType)
{
Record<CSMWorld::CellRef> originRecord = getRecord(origin);
Record<CSMWorld::CellRef> *copy = dynamic_cast<Record<CSMWorld::CellRef>* >(originRecord.clone());
copy->mState = CSMWorld::RecordBase::State_ModifiedOnly;
copy->get().mId = getNewId();
insertRecord(*copy, getAppendIndex(destination, type));
delete copy;
}

View file

@ -8,6 +8,7 @@
namespace CSMWorld
{
struct Cell;
struct UniversalId;
/// \brief References in cells
class RefCollection : public Collection<CellRef>
@ -25,6 +26,11 @@ namespace CSMWorld
///< Load a sequence of references.
std::string getNewId();
void cloneRecord(const std::string& origin,
const std::string& destination,
const CSMWorld::UniversalId::Type type,
const CSMWorld::UniversalId::ArgumentType argumentType);
};
}