mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 04:40:26 +00:00
Avoid converting UniversalId to a different type via string
This commit is contained in:
parent
7b5310b569
commit
39dd73263d
4 changed files with 11 additions and 3 deletions
|
@ -328,6 +328,12 @@ CSMWorld::UniversalId::UniversalId(Type type, ESM::RefId id)
|
||||||
throw std::logic_error("invalid RefId argument UniversalId type: " + std::to_string(type));
|
throw std::logic_error("invalid RefId argument UniversalId type: " + std::to_string(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSMWorld::UniversalId::UniversalId(Type type, const UniversalId& id)
|
||||||
|
: mType(type)
|
||||||
|
, mValue(id.mValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CSMWorld::UniversalId::UniversalId(Type type, int index)
|
CSMWorld::UniversalId::UniversalId(Type type, int index)
|
||||||
: mType(type)
|
: mType(type)
|
||||||
, mValue(index)
|
, mValue(index)
|
||||||
|
|
|
@ -158,6 +158,8 @@ namespace CSMWorld
|
||||||
UniversalId(Type type, int index);
|
UniversalId(Type type, int index);
|
||||||
///< Using a type for a non-index-argument UniversalId will throw an exception.
|
///< Using a type for a non-index-argument UniversalId will throw an exception.
|
||||||
|
|
||||||
|
UniversalId(Type type, const UniversalId& id);
|
||||||
|
|
||||||
Class getClass() const;
|
Class getClass() const;
|
||||||
|
|
||||||
ArgumentType getArgumentType() const;
|
ArgumentType getArgumentType() const;
|
||||||
|
|
|
@ -629,7 +629,7 @@ void CSVDoc::View::addSubView(const CSMWorld::UniversalId& id, const std::string
|
||||||
if (isReferenceable)
|
if (isReferenceable)
|
||||||
{
|
{
|
||||||
view = mSubViewFactory.makeSubView(
|
view = mSubViewFactory.makeSubView(
|
||||||
CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()), *mDocument);
|
CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id), *mDocument);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -694,10 +694,10 @@ void CSVWorld::Table::previewRecord()
|
||||||
|
|
||||||
if (selectedRows.size() == 1)
|
if (selectedRows.size() == 1)
|
||||||
{
|
{
|
||||||
std::string id = getUniversalId(selectedRows.begin()->row()).getId();
|
CSMWorld::UniversalId id = getUniversalId(selectedRows.begin()->row());
|
||||||
|
|
||||||
QModelIndex index
|
QModelIndex index
|
||||||
= mModel->getModelIndex(id, mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Modification));
|
= mModel->getModelIndex(id.getId(), mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Modification));
|
||||||
|
|
||||||
if (mModel->data(index) != CSMWorld::RecordBase::State_Deleted)
|
if (mModel->data(index) != CSMWorld::RecordBase::State_Deleted)
|
||||||
emit editRequest(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, id), "");
|
emit editRequest(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, id), "");
|
||||||
|
|
Loading…
Reference in a new issue