mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 13:23:50 +00:00
copying references.
This commit is contained in:
parent
bc0130f8d8
commit
b3b51992ef
4 changed files with 24 additions and 4 deletions
|
@ -200,9 +200,9 @@ namespace CSMWorld
|
||||||
|
|
||||||
template<typename ESXRecordT, typename IdAccessorT>
|
template<typename ESXRecordT, typename IdAccessorT>
|
||||||
void Collection<ESXRecordT, IdAccessorT>::cloneRecord(const std::string& origin,
|
void Collection<ESXRecordT, IdAccessorT>::cloneRecord(const std::string& origin,
|
||||||
const std::string& destination,
|
const std::string& destination,
|
||||||
const UniversalId::Type type,
|
const UniversalId::Type type,
|
||||||
const UniversalId::ArgumentType argumentType)
|
const UniversalId::ArgumentType argumentType)
|
||||||
{
|
{
|
||||||
Record<ESXRecordT> copy = getRecord(origin);
|
Record<ESXRecordT> copy = getRecord(origin);
|
||||||
if (argumentType == UniversalId::ArgumentType_Id)
|
if (argumentType == UniversalId::ArgumentType_Id)
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
#include "idtable.hpp"
|
#include "idtable.hpp"
|
||||||
#include "idtable.hpp"
|
|
||||||
|
|
||||||
CSMWorld::ModifyCommand::ModifyCommand(QAbstractItemModel& model, const QModelIndex& index,
|
CSMWorld::ModifyCommand::ModifyCommand(QAbstractItemModel& model, const QModelIndex& index,
|
||||||
const QVariant& new_, QUndoCommand* parent)
|
const QVariant& new_, QUndoCommand* parent)
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
#include "cell.hpp"
|
#include "cell.hpp"
|
||||||
|
#include "universalid.hpp"
|
||||||
|
#include "record.hpp"
|
||||||
|
|
||||||
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
|
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
|
||||||
{
|
{
|
||||||
|
@ -35,3 +37,16 @@ std::string CSMWorld::RefCollection::getNewId()
|
||||||
stream << "ref#" << mNextId++;
|
stream << "ref#" << mNextId++;
|
||||||
return stream.str();
|
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
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
struct Cell;
|
struct Cell;
|
||||||
|
struct UniversalId;
|
||||||
|
|
||||||
/// \brief References in cells
|
/// \brief References in cells
|
||||||
class RefCollection : public Collection<CellRef>
|
class RefCollection : public Collection<CellRef>
|
||||||
|
@ -25,6 +26,11 @@ namespace CSMWorld
|
||||||
///< Load a sequence of references.
|
///< Load a sequence of references.
|
||||||
|
|
||||||
std::string getNewId();
|
std::string getNewId();
|
||||||
|
|
||||||
|
void cloneRecord(const std::string& origin,
|
||||||
|
const std::string& destination,
|
||||||
|
const CSMWorld::UniversalId::Type type,
|
||||||
|
const CSMWorld::UniversalId::ArgumentType argumentType);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue