mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 21:45:32 +00:00
Minor formatting cleanup and comments.
This commit is contained in:
parent
05210d7f21
commit
860754e460
6 changed files with 15 additions and 138 deletions
|
@ -177,129 +177,6 @@ namespace CSMWorld
|
|||
|
||||
};
|
||||
|
||||
/*
|
||||
template <typename ESXRecordT>
|
||||
class MagicEffectsHelper : public CastableHelper<ESXRecordT>
|
||||
{
|
||||
public:
|
||||
|
||||
MagicEffectsHelper(CSMWorld::UniversalId::Type type)
|
||||
: CastableHelper<ESXRecordT>(type) {}
|
||||
|
||||
virtual void setNestedTable(RefIdData& data,
|
||||
int index,
|
||||
const NestedTableWrapperBase& nestedTable)
|
||||
{
|
||||
CastableHelper<ESXRecordT>::getRecord(data, index).get().mEffects =
|
||||
(static_cast<const NestedTableWrapper<ESM::EffectList>&>(nestedTable)).mNestedTable;
|
||||
}
|
||||
|
||||
virtual NestedTableWrapperBase* nestedTable(const RefIdData& data,
|
||||
int index) const
|
||||
{
|
||||
return new NestedTableWrapper<ESM::EffectList>(CastableHelper<ESXRecordT>::getRecord(data, index).get().mEffects);
|
||||
}
|
||||
|
||||
virtual QVariant getNestedData(const CSMWorld::RefIdData& data,
|
||||
int index,
|
||||
int subRowIndex,
|
||||
int subColIndex) const
|
||||
{
|
||||
const ESM::EffectList& content = CastableHelper<ESXRecordT>::getRecord(data, index).get().mEffects;
|
||||
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0:
|
||||
return content.at(subRowIndex).mEffectID;
|
||||
|
||||
case 1:
|
||||
return content.at(subRowIndex).mRange;
|
||||
|
||||
case 2:
|
||||
return content.at(subRowIndex).mDuration;
|
||||
|
||||
case 3:
|
||||
return content.at(subRowIndex).mArea;
|
||||
|
||||
case 4:
|
||||
return content.at(subRowIndex).mMagMin;
|
||||
|
||||
case 5:
|
||||
return content.at(subRowIndex).mMagMax;
|
||||
|
||||
case 6:
|
||||
return (int)content.at(rubRowIndex).mSkill;
|
||||
|
||||
case 7:
|
||||
return (int)content.at(subRowIndex).mAttribute;
|
||||
|
||||
default:
|
||||
throw std::logic_error("Trying to access non-existing column in the nested table!");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void removeNestedRow (RefIdData& data, int index, int rowToRemove) const
|
||||
{
|
||||
ESM::EffectList& list = CastableHelper<ESXRecordT>::getRecord(data, index).get().mEffects;
|
||||
|
||||
list.erase (list.begin () + rowToRemove);
|
||||
}
|
||||
|
||||
void setNestedData (RefIdData& data,
|
||||
int index,
|
||||
const QVariant& value,
|
||||
int subRowIndex,
|
||||
int subColIndex) const
|
||||
{
|
||||
switch(subColIndex)
|
||||
{
|
||||
case 0:
|
||||
CastableHelper<ESXRecordT>::getRecord(data, index).get().mEffects.at(subRowIndex).mEffectID = value.toInt();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::logic_error("Trying to access non-existing column in the nested table!");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void addNestedRow (RefIdData& data, int index, int position) const
|
||||
{
|
||||
std::vector<ESM::Transport::Dest>& list = CastableHelper<ESXRecordT>::getRecord(data, index).get().mTransport.mList;
|
||||
|
||||
ESM::Position newPos;
|
||||
for (unsigned i = 0; i < 3; ++i)
|
||||
{
|
||||
newPos.pos[i] = 0;
|
||||
newPos.rot[i] = 0;
|
||||
}
|
||||
|
||||
ESM::Transport::Dest newRow;
|
||||
newRow.mPos = newPos;
|
||||
newRow.mCellName = "";
|
||||
|
||||
if (position >= (int)list.size())
|
||||
{
|
||||
list.push_back(newRow);
|
||||
return;
|
||||
}
|
||||
|
||||
list.insert(list.begin()+position, newRow);
|
||||
}
|
||||
|
||||
virtual int getNestedColumnsCount(const RefIdData& data) const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
|
||||
virtual int getNestedRowsCount(const RefIdData& data,
|
||||
int index) const
|
||||
{
|
||||
return CastableHelper<ESXRecordT>::getRecord(data, index).get().mTransport.mList.size();
|
||||
}
|
||||
|
||||
};
|
||||
*/
|
||||
template <typename ESXRecordT>
|
||||
class DestinationsHelper : public CastableHelper<ESXRecordT>
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ QVariant CSMWorld::NestedTableProxyModel::headerData(int section,
|
|||
}
|
||||
|
||||
|
||||
bool CSMWorld::NestedTableProxyModel::setData ( const QModelIndex & index, const QVariant & value, int role)
|
||||
bool CSMWorld::NestedTableProxyModel::setData (const QModelIndex & index, const QVariant & value, int role)
|
||||
{
|
||||
return mMainModel->setData(mapToSource(index), value, role);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace CSMWorld
|
|||
IdTree* mMainModel;
|
||||
std::string mId;
|
||||
|
||||
public:
|
||||
public:
|
||||
NestedTableProxyModel(const QModelIndex& parent,
|
||||
ColumnBase::Display displayType,
|
||||
IdTree* parentModel);
|
||||
|
@ -51,9 +51,9 @@ namespace CSMWorld
|
|||
|
||||
virtual QModelIndex parent(const QModelIndex& index) const;
|
||||
|
||||
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const;
|
||||
virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const;
|
||||
|
||||
virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
|
||||
virtual bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
|
||||
|
||||
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
/*! \brief
|
||||
* Adapters acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels of model.
|
||||
* Please notice that nested adaptor uses helper classes for actually performing any actions. Different record types require different helpers (needs to be created in the subclass and then fetched via member function).
|
||||
*
|
||||
* Important point: don't forget to make sure that getData on the nestedColumn returns true (otherwise code will not treat the index pointing to the column as having childs!
|
||||
*/
|
||||
|
||||
|
@ -44,7 +45,7 @@ namespace CSMWorld
|
|||
|
||||
virtual std::string getId (const RecordBase& record) const = 0;
|
||||
|
||||
virtual void setId(RecordBase& record, const std::string& id) = 0;
|
||||
virtual void setId(RecordBase& record, const std::string& id) = 0; // FIXME: used by RefIdCollection::cloneRecord()
|
||||
};
|
||||
|
||||
class NestedRefIdAdapterBase
|
||||
|
@ -75,7 +76,7 @@ namespace CSMWorld
|
|||
|
||||
class NestedRefIdAdapter : public NestedRefIdAdapterBase
|
||||
{
|
||||
std::vector<std::pair <const RefIdColumn*, HelperBase*> > mAssociatedColumns; //basicly, i wanted map, but with pointer key
|
||||
std::vector<std::pair <const RefIdColumn*, HelperBase*> > mAssociatedColumns; //basically, i wanted a map, but with pointer key
|
||||
|
||||
public:
|
||||
NestedRefIdAdapter();
|
||||
|
|
|
@ -186,11 +186,11 @@ CSMWorld::ContainerRefIdAdapter::ContainerRefIdAdapter (const NameColumns& colum
|
|||
std::vector<std::pair <const RefIdColumn*, HelperBase*> > assoCol;
|
||||
|
||||
assoCol.push_back(std::make_pair(content, new InventoryHelper<ESM::Container>(UniversalId::Type_Container)));
|
||||
|
||||
|
||||
setAssocColumns(assoCol);
|
||||
}
|
||||
|
||||
QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column,
|
||||
QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column,
|
||||
const RefIdData& data,
|
||||
int index) const
|
||||
{
|
||||
|
@ -207,12 +207,11 @@ QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column,
|
|||
return (record.get().mFlags & ESM::Container::Respawn)!=0;
|
||||
|
||||
if (column==mContent)
|
||||
return true;
|
||||
return true; // required by IdTree::hasChildren()
|
||||
|
||||
return NameRefIdAdapter<ESM::Container>::getData (column, data, index);
|
||||
}
|
||||
|
||||
|
||||
void CSMWorld::ContainerRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index,
|
||||
const QVariant& value) const
|
||||
{
|
||||
|
@ -490,16 +489,16 @@ QVariant CSMWorld::NpcRefIdAdapter::getData (const RefIdColumn *column, const Re
|
|||
|
||||
if (column==mColumns.mHead)
|
||||
return QString::fromUtf8 (record.get().mHead.c_str());
|
||||
|
||||
|
||||
if (column==mColumns.mDestinations)
|
||||
return true;
|
||||
return true; // required by IdTree::hasChildren()
|
||||
|
||||
std::map<const RefIdColumn *, unsigned int>::const_iterator iter =
|
||||
mColumns.mFlags.find (column);
|
||||
|
||||
if (iter!=mColumns.mFlags.end())
|
||||
return (record.get().mFlags & iter->second)!=0;
|
||||
|
||||
|
||||
return ActorRefIdAdapter<ESM::NPC>::getData (column, data, index);
|
||||
}
|
||||
|
||||
|
|
|
@ -536,10 +536,10 @@ namespace CSMWorld
|
|||
return record.get().mAiData.mAlarm;
|
||||
|
||||
if (column==mActors.mInventory)
|
||||
return true;
|
||||
return true; // required by IdTree::hasChildren()
|
||||
|
||||
if (column==mActors.mSpells)
|
||||
return true;
|
||||
return true; // required by IdTree::hasChildren()
|
||||
|
||||
std::map<const RefIdColumn *, unsigned int>::const_iterator iter =
|
||||
mActors.mServices.find (column);
|
||||
|
|
Loading…
Reference in a new issue