mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 21:19:57 +00:00
Added code to delete nestedRows
This commit is contained in:
parent
88c5288eaf
commit
c45061614b
9 changed files with 30 additions and 9 deletions
|
@ -47,3 +47,8 @@ int CSMWorld::CollectionBase::getNestedRowsCount(int row, int column) const
|
|||
assert(false); //TODO, make pure abstract
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CSMWorld::CollectionBase::removeNestedRows(int row, int column, int subRow)
|
||||
{
|
||||
assert(false); //todo, make pure abstract
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ namespace CSMWorld
|
|||
|
||||
virtual void removeRows (int index, int count) = 0;
|
||||
|
||||
virtual void removeNestedRows(int row, int column, int subRow);
|
||||
|
||||
virtual void appendBlankRecord (const std::string& id,
|
||||
UniversalId::Type type = UniversalId::Type_None) = 0;
|
||||
///< \param type Will be ignored, unless the collection supports multiple record types
|
||||
|
|
|
@ -126,7 +126,13 @@ Qt::ItemFlags CSMWorld::IdTable::flags (const QModelIndex & index) const
|
|||
bool CSMWorld::IdTable::removeRows (int row, int count, const QModelIndex& parent)
|
||||
{
|
||||
if (parent.isValid())
|
||||
return false;
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
mIdCollection->removeNestedRows(parent.row(), parent.column(), row+i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
beginRemoveRows (parent, row, row+count-1);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace CSMWorld
|
|||
|
||||
virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const = 0;
|
||||
|
||||
virtual void removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, unsigned rowToRemove) const = 0;
|
||||
virtual void removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, int rowToRemove) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column, co
|
|||
return NameRefIdAdapter<ESM::Container>::getData (column, data, index);
|
||||
}
|
||||
|
||||
void CSMWorld::ContainerRefIdAdapter::removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, unsigned rowToRemove) const
|
||||
void CSMWorld::ContainerRefIdAdapter::removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, int rowToRemove) const
|
||||
{
|
||||
assert(column==mContent);
|
||||
|
||||
|
@ -227,8 +227,6 @@ void CSMWorld::ContainerRefIdAdapter::removeNestedRow (const RefIdColumn *column
|
|||
list.erase (list.begin () + rowToRemove);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSMWorld::ContainerRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index,
|
||||
const QVariant& value) const
|
||||
{
|
||||
|
|
|
@ -633,9 +633,8 @@ namespace CSMWorld
|
|||
virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const;
|
||||
|
||||
virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const;
|
||||
|
||||
|
||||
virtual void removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, unsigned rowToRemove) const;
|
||||
virtual void removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, int rowToRemove) const;
|
||||
};
|
||||
|
||||
struct CreatureColumns : public ActorColumns
|
||||
|
|
|
@ -463,6 +463,15 @@ void CSMWorld::RefIdCollection::removeRows (int index, int count)
|
|||
mData.erase (index, count);
|
||||
}
|
||||
|
||||
void CSMWorld::RefIdCollection::removeNestedRows(int row, int column, int subRow)
|
||||
{
|
||||
RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row);
|
||||
|
||||
const RefIdAdapter& adaptor = findAdaptor (localIndex.second);
|
||||
|
||||
dynamic_cast<const CSMWorld::NestedRefIdAdapter&>(adaptor).removeNestedRow(&mColumns.at (column), mData, localIndex.first, subRow);
|
||||
}
|
||||
|
||||
void CSMWorld::RefIdCollection::appendBlankRecord (const std::string& id, UniversalId::Type type)
|
||||
{
|
||||
mData.appendRecord (type, id, false);
|
||||
|
|
|
@ -76,6 +76,8 @@ namespace CSMWorld
|
|||
virtual void setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn);
|
||||
|
||||
virtual void removeRows (int index, int count);
|
||||
|
||||
virtual void removeNestedRows(int row, int column, int subRow);
|
||||
|
||||
virtual void cloneRecord(const std::string& origin,
|
||||
const std::string& destination,
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace CSMWorld
|
|||
virtual void load (int index, ESM::ESMReader& reader, bool base) = 0;
|
||||
|
||||
virtual void erase (int index, int count) = 0;
|
||||
|
||||
|
||||
virtual std::string getId (int index) const = 0;
|
||||
|
||||
virtual void save (int index, ESM::ESMWriter& writer) const = 0;
|
||||
|
@ -134,7 +134,7 @@ namespace CSMWorld
|
|||
throw std::runtime_error ("invalid RefIdDataContainer index");
|
||||
|
||||
mContainer.erase (mContainer.begin()+index, mContainer.begin()+index+count);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename RecordT>
|
||||
std::string RefIdDataContainer<RecordT>::getId (int index) const
|
||||
|
|
Loading…
Reference in a new issue