Minor formatting cleanup and comments.

test
cc9cii 10 years ago
parent 05210d7f21
commit 860754e460

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

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

@ -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
{
@ -492,7 +491,7 @@ QVariant CSMWorld::NpcRefIdAdapter::getData (const RefIdColumn *column, const Re
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);

@ -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…
Cancel
Save