copying references.

actorid
Marek Kochanowicz 11 years ago
parent bc0130f8d8
commit b3b51992ef

@ -200,9 +200,9 @@ namespace CSMWorld
template<typename ESXRecordT, typename IdAccessorT>
void Collection<ESXRecordT, IdAccessorT>::cloneRecord(const std::string& origin,
const std::string& destination,
const UniversalId::Type type,
const UniversalId::ArgumentType argumentType)
const std::string& destination,
const UniversalId::Type type,
const UniversalId::ArgumentType argumentType)
{
Record<ESXRecordT> copy = getRecord(origin);
if (argumentType == UniversalId::ArgumentType_Id)

@ -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)

@ -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)
{
@ -34,4 +36,17 @@ std::string CSMWorld::RefCollection::getNewId()
std::ostringstream stream;
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;
}

@ -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);
};
}

Loading…
Cancel
Save