Renamed some stuff.

test
cc9cii 10 years ago
parent 41b368a759
commit ef84e553be

@ -25,7 +25,7 @@ opencs_units (model/world
opencs_units_noqt (model/world opencs_units_noqt (model/world
universalid record commands columnbase scriptcontext cell refidcollection universalid record commands columnbase scriptcontext cell refidcollection
refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope
pathgrid landtexture land nestedtablewrapper nestedadapters nestedcollection idadapterimp pathgrid landtexture land nestedtablewrapper nestedadapters nestedcollection nestedcoladapterimp
) )
opencs_hdrs_noqt (model/world opencs_hdrs_noqt (model/world

@ -18,7 +18,7 @@
#include "columns.hpp" #include "columns.hpp"
#include "resourcesmanager.hpp" #include "resourcesmanager.hpp"
#include "resourcetable.hpp" #include "resourcetable.hpp"
#include "idadapterimp.hpp" #include "nestedcoladapterimp.hpp"
void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type, bool update) void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type, bool update)
{ {
@ -64,6 +64,8 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), : mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
mResourcesManager (resourcesManager), mReader (0), mDialogue (0), mReaderIndex(0) mResourcesManager (resourcesManager), mReader (0), mDialogue (0), mReaderIndex(0)
{ {
int index = 0;
mGlobals.addColumn (new StringIdColumn<ESM::Global>); mGlobals.addColumn (new StringIdColumn<ESM::Global>);
mGlobals.addColumn (new RecordStateColumn<ESM::Global>); mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global)); mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global));
@ -109,14 +111,13 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
for (int i=0; i<7; ++i) for (int i=0; i<7; ++i)
mFactions.addColumn (new SkillsColumn<ESM::Faction> (i)); mFactions.addColumn (new SkillsColumn<ESM::Faction> (i));
// Faction Reactions // Faction Reactions
NestedParentColumn<ESM::Faction> *reactions = mFactions.addColumn (new NestedParentColumn<ESM::Faction> (Columns::ColumnId_FactionReactions));
new NestedParentColumn<ESM::Faction> (Columns::ColumnId_FactionReactions); index = mFactions.getColumns()-1;
mFactions.addColumn (reactions); mFactions.addAdapter (std::make_pair(&mFactions.getColumn(index), new FactionReactionsAdapter ()));
mFactions.addAdapter (std::make_pair(reactions, new FactionReactionsAdapter ())); mFactions.getNestableColumn(index)->addColumn(
mFactions.getNestableColumn(mFactions.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_Faction, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_Faction, ColumnBase::Display_String)); mFactions.getNestableColumn(index)->addColumn(
mFactions.getNestableColumn(mFactions.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_FactionReaction, ColumnBase::Display_Integer));
new NestedChildColumn (Columns::ColumnId_FactionReaction, ColumnBase::Display_Integer));
mRaces.addColumn (new StringIdColumn<ESM::Race>); mRaces.addColumn (new StringIdColumn<ESM::Race>);
mRaces.addColumn (new RecordStateColumn<ESM::Race>); mRaces.addColumn (new RecordStateColumn<ESM::Race>);
@ -130,12 +131,11 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mRaces.addColumn (new WeightHeightColumn<ESM::Race> (false, true)); mRaces.addColumn (new WeightHeightColumn<ESM::Race> (false, true));
mRaces.addColumn (new WeightHeightColumn<ESM::Race> (false, false)); mRaces.addColumn (new WeightHeightColumn<ESM::Race> (false, false));
// Race spells // Race spells
NestedParentColumn<ESM::Race> *raceSpells = mRaces.addColumn (new NestedParentColumn<ESM::Race> (Columns::ColumnId_SpellList));
new NestedParentColumn<ESM::Race> (Columns::ColumnId_SpellList); index = mRaces.getColumns()-1;
mRaces.addColumn (raceSpells); mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new SpellListAdapter<ESM::Race> ()));
mRaces.addAdapter (std::make_pair(raceSpells, new SpellListAdapter<ESM::Race> ())); mRaces.getNestableColumn(index)->addColumn(
mRaces.getNestableColumn(mRaces.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String));
mSounds.addColumn (new StringIdColumn<ESM::Sound>); mSounds.addColumn (new StringIdColumn<ESM::Sound>);
mSounds.addColumn (new RecordStateColumn<ESM::Sound>); mSounds.addColumn (new RecordStateColumn<ESM::Sound>);
@ -157,14 +157,13 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mRegions.addColumn (new MapColourColumn<ESM::Region>); mRegions.addColumn (new MapColourColumn<ESM::Region>);
mRegions.addColumn (new SleepListColumn<ESM::Region>); mRegions.addColumn (new SleepListColumn<ESM::Region>);
// Region Sounds // Region Sounds
NestedParentColumn<ESM::Region> *soundList = mRegions.addColumn (new NestedParentColumn<ESM::Region> (Columns::ColumnId_RegionSounds));
new NestedParentColumn<ESM::Region> (Columns::ColumnId_RegionSounds); index = mRegions.getColumns()-1;
mRegions.addColumn (soundList); mRegions.addAdapter (std::make_pair(&mRegions.getColumn(index), new RegionSoundListAdapter ()));
mRegions.addAdapter (std::make_pair(soundList, new RegionSoundListAdapter ())); mRegions.getNestableColumn(index)->addColumn(
mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_SoundName, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_SoundName, ColumnBase::Display_String)); mRegions.getNestableColumn(index)->addColumn(
mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_SoundChance, ColumnBase::Display_Integer));
new NestedChildColumn (Columns::ColumnId_SoundChance, ColumnBase::Display_Integer));
mBirthsigns.addColumn (new StringIdColumn<ESM::BirthSign>); mBirthsigns.addColumn (new StringIdColumn<ESM::BirthSign>);
mBirthsigns.addColumn (new RecordStateColumn<ESM::BirthSign>); mBirthsigns.addColumn (new RecordStateColumn<ESM::BirthSign>);
@ -173,12 +172,12 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mBirthsigns.addColumn (new TextureColumn<ESM::BirthSign>); mBirthsigns.addColumn (new TextureColumn<ESM::BirthSign>);
mBirthsigns.addColumn (new DescriptionColumn<ESM::BirthSign>); mBirthsigns.addColumn (new DescriptionColumn<ESM::BirthSign>);
// Birthsign spells // Birthsign spells
NestedParentColumn<ESM::BirthSign> *birthSpells = mBirthsigns.addColumn (new NestedParentColumn<ESM::BirthSign> (Columns::ColumnId_SpellList));
new NestedParentColumn<ESM::BirthSign> (Columns::ColumnId_SpellList); index = mBirthsigns.getColumns()-1;
mBirthsigns.addColumn (birthSpells); mBirthsigns.addAdapter (std::make_pair(&mBirthsigns.getColumn(index),
mBirthsigns.addAdapter (std::make_pair(birthSpells, new SpellListAdapter<ESM::BirthSign> ())); new SpellListAdapter<ESM::BirthSign> ()));
mBirthsigns.getNestableColumn(mBirthsigns.getColumns()-1)->addColumn( mBirthsigns.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String)); new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String));
mSpells.addColumn (new StringIdColumn<ESM::Spell>); mSpells.addColumn (new StringIdColumn<ESM::Spell>);
mSpells.addColumn (new RecordStateColumn<ESM::Spell>); mSpells.addColumn (new RecordStateColumn<ESM::Spell>);
@ -190,26 +189,25 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mSpells.addColumn (new FlagColumn<ESM::Spell> (Columns::ColumnId_StarterSpell, 0x2)); mSpells.addColumn (new FlagColumn<ESM::Spell> (Columns::ColumnId_StarterSpell, 0x2));
mSpells.addColumn (new FlagColumn<ESM::Spell> (Columns::ColumnId_AlwaysSucceeds, 0x4)); mSpells.addColumn (new FlagColumn<ESM::Spell> (Columns::ColumnId_AlwaysSucceeds, 0x4));
// Spell effects // Spell effects
NestedParentColumn<ESM::Spell> *spellEffect = mSpells.addColumn (new NestedParentColumn<ESM::Spell> (Columns::ColumnId_EffectList));
new NestedParentColumn<ESM::Spell> (Columns::ColumnId_EffectList); index = mSpells.getColumns()-1;
mSpells.addColumn (spellEffect); mSpells.addAdapter (std::make_pair(&mSpells.getColumn(index), new EffectsListAdapter<ESM::Spell> ()));
mSpells.addAdapter (std::make_pair(spellEffect, new EffectsListAdapter<ESM::Spell> ())); mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/)); // false means no edit
new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/)); // false means no edit mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String)); mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_String)); // reuse attribute
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_String)); // reuse attribute mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_Integer));
new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_Integer)); mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_EffectArea, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_EffectArea, ColumnBase::Display_String)); mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_Duration, ColumnBase::Display_Integer)); // reuse from light
new NestedChildColumn (Columns::ColumnId_Duration, ColumnBase::Display_Integer)); // reuse from light mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_MinRange, ColumnBase::Display_Integer)); // reuse from sound
new NestedChildColumn (Columns::ColumnId_MinRange, ColumnBase::Display_Integer)); // reuse from sound mSpells.getNestableColumn(index)->addColumn(
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( new NestedChildColumn (Columns::ColumnId_MaxRange, ColumnBase::Display_Integer)); // reuse from sound
new NestedChildColumn (Columns::ColumnId_MaxRange, ColumnBase::Display_Integer)); // reuse from sound
mTopics.addColumn (new StringIdColumn<ESM::Dialogue>); mTopics.addColumn (new StringIdColumn<ESM::Dialogue>);
mTopics.addColumn (new RecordStateColumn<ESM::Dialogue>); mTopics.addColumn (new RecordStateColumn<ESM::Dialogue>);
@ -264,26 +262,26 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mEnchantments.addColumn (new ChargesColumn2<ESM::Enchantment>); mEnchantments.addColumn (new ChargesColumn2<ESM::Enchantment>);
mEnchantments.addColumn (new AutoCalcColumn<ESM::Enchantment>); mEnchantments.addColumn (new AutoCalcColumn<ESM::Enchantment>);
// Enchantment effects // Enchantment effects
NestedParentColumn<ESM::Enchantment> *enchantmentEffect = mEnchantments.addColumn (new NestedParentColumn<ESM::Enchantment> (Columns::ColumnId_EffectList));
new NestedParentColumn<ESM::Enchantment> (Columns::ColumnId_EffectList); index = mEnchantments.getColumns()-1;
mEnchantments.addColumn (enchantmentEffect); mEnchantments.addAdapter (std::make_pair(&mEnchantments.getColumn(index),
mEnchantments.addAdapter (std::make_pair(enchantmentEffect, new EffectsListAdapter<ESM::Enchantment> ())); new EffectsListAdapter<ESM::Enchantment> ()));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/)); new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String)); new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_String)); // reuse attribute new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_String)); // reuse attribute
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_Integer)); new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_Integer));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectArea, ColumnBase::Display_String)); new NestedChildColumn (Columns::ColumnId_EffectArea, ColumnBase::Display_String));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Duration, ColumnBase::Display_Integer)); // reuse from light new NestedChildColumn (Columns::ColumnId_Duration, ColumnBase::Display_Integer)); // reuse from light
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_MinRange, ColumnBase::Display_Integer)); // reuse from sound new NestedChildColumn (Columns::ColumnId_MinRange, ColumnBase::Display_Integer)); // reuse from sound
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_MaxRange, ColumnBase::Display_Integer)); // reuse from sound new NestedChildColumn (Columns::ColumnId_MaxRange, ColumnBase::Display_Integer)); // reuse from sound
mBodyParts.addColumn (new StringIdColumn<ESM::BodyPart>); mBodyParts.addColumn (new StringIdColumn<ESM::BodyPart>);
mBodyParts.addColumn (new RecordStateColumn<ESM::BodyPart>); mBodyParts.addColumn (new RecordStateColumn<ESM::BodyPart>);
@ -331,31 +329,29 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mPathgrids.addColumn (new FixedRecordTypeColumn<Pathgrid> (UniversalId::Type_Pathgrid)); mPathgrids.addColumn (new FixedRecordTypeColumn<Pathgrid> (UniversalId::Type_Pathgrid));
// new object deleted in dtor of Collection<T,A> // new object deleted in dtor of Collection<T,A>
NestedParentColumn<Pathgrid> *pointList = mPathgrids.addColumn (new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridPoints));
new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridPoints); index = mPathgrids.getColumns()-1;
mPathgrids.addColumn (pointList); // new object deleted in dtor of NestedCollection<T,A>
// new object deleted in dtor of SubCellCollection<T,A> mPathgrids.addAdapter (std::make_pair(&mPathgrids.getColumn(index), new PathgridPointListAdapter ()));
mPathgrids.addAdapter (std::make_pair(pointList, new PathgridPointListAdapter ()));
// new objects deleted in dtor of NestableColumn // new objects deleted in dtor of NestableColumn
// WARNING: The order of the columns below are assumed in PathgridPointListAdapter // WARNING: The order of the columns below are assumed in PathgridPointListAdapter
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_PathgridIndex, ColumnBase::Display_Integer, false)); new NestedChildColumn (Columns::ColumnId_PathgridIndex, ColumnBase::Display_Integer, false));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_PathgridPosX, ColumnBase::Display_Integer)); new NestedChildColumn (Columns::ColumnId_PathgridPosX, ColumnBase::Display_Integer));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_PathgridPosY, ColumnBase::Display_Integer)); new NestedChildColumn (Columns::ColumnId_PathgridPosY, ColumnBase::Display_Integer));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_PathgridPosZ, ColumnBase::Display_Integer)); new NestedChildColumn (Columns::ColumnId_PathgridPosZ, ColumnBase::Display_Integer));
NestedParentColumn<Pathgrid> *edgeList = mPathgrids.addColumn (new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridEdges));
new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridEdges); index = mPathgrids.getColumns()-1;
mPathgrids.addColumn (edgeList); mPathgrids.addAdapter (std::make_pair(&mPathgrids.getColumn(index), new PathgridEdgeListAdapter ()));
mPathgrids.addAdapter (std::make_pair(edgeList, new PathgridEdgeListAdapter ())); mPathgrids.getNestableColumn(index)->addColumn(
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
new NestedChildColumn (Columns::ColumnId_PathgridEdgeIndex, ColumnBase::Display_Integer, false)); new NestedChildColumn (Columns::ColumnId_PathgridEdgeIndex, ColumnBase::Display_Integer, false));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_PathgridEdge0, ColumnBase::Display_Integer)); new NestedChildColumn (Columns::ColumnId_PathgridEdge0, ColumnBase::Display_Integer));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_PathgridEdge1, ColumnBase::Display_Integer)); new NestedChildColumn (Columns::ColumnId_PathgridEdge1, ColumnBase::Display_Integer));
mStartScripts.addColumn (new StringIdColumn<ESM::StartScript>); mStartScripts.addColumn (new StringIdColumn<ESM::StartScript>);

@ -1,4 +1,4 @@
#include "idadapterimp.hpp" #include "nestedcoladapterimp.hpp"
#include <components/esm/loadregn.hpp> #include <components/esm/loadregn.hpp>
#include <components/esm/loadfact.hpp> #include <components/esm/loadfact.hpp>

@ -1,5 +1,5 @@
#ifndef CSM_WOLRD_IDADAPTERIMP_H #ifndef CSM_WOLRD_NESTEDCOLADAPTERIMP_H
#define CSM_WOLRD_IDADAPTERIMP_H #define CSM_WOLRD_NESTEDCOLADAPTERIMP_H
#include <QVariant> #include <QVariant>
@ -9,7 +9,7 @@
#include <components/esm/loadskil.hpp> // for converting skill names #include <components/esm/loadskil.hpp> // for converting skill names
#include <components/esm/attr.hpp> // for converting attributes #include <components/esm/attr.hpp> // for converting attributes
#include "idadapter.hpp" #include "nestedcolumnadapter.hpp"
#include "nestedtablewrapper.hpp" #include "nestedtablewrapper.hpp"
namespace ESM namespace ESM
@ -37,7 +37,7 @@ namespace CSMWorld
} }
}; };
class PathgridPointListAdapter : public NestedIdAdapter<Pathgrid> class PathgridPointListAdapter : public NestedColumnAdapter<Pathgrid>
{ {
public: public:
PathgridPointListAdapter (); PathgridPointListAdapter ();
@ -62,7 +62,7 @@ namespace CSMWorld
virtual int getNestedRowsCount(const Record<Pathgrid>& record) const; virtual int getNestedRowsCount(const Record<Pathgrid>& record) const;
}; };
class PathgridEdgeListAdapter : public NestedIdAdapter<Pathgrid> class PathgridEdgeListAdapter : public NestedColumnAdapter<Pathgrid>
{ {
public: public:
PathgridEdgeListAdapter (); PathgridEdgeListAdapter ();
@ -87,7 +87,7 @@ namespace CSMWorld
virtual int getNestedRowsCount(const Record<Pathgrid>& record) const; virtual int getNestedRowsCount(const Record<Pathgrid>& record) const;
}; };
class FactionReactionsAdapter : public NestedIdAdapter<ESM::Faction> class FactionReactionsAdapter : public NestedColumnAdapter<ESM::Faction>
{ {
public: public:
FactionReactionsAdapter (); FactionReactionsAdapter ();
@ -112,7 +112,7 @@ namespace CSMWorld
virtual int getNestedRowsCount(const Record<ESM::Faction>& record) const; virtual int getNestedRowsCount(const Record<ESM::Faction>& record) const;
}; };
class RegionSoundListAdapter : public NestedIdAdapter<ESM::Region> class RegionSoundListAdapter : public NestedColumnAdapter<ESM::Region>
{ {
public: public:
RegionSoundListAdapter (); RegionSoundListAdapter ();
@ -138,7 +138,7 @@ namespace CSMWorld
}; };
template<typename ESXRecordT> template<typename ESXRecordT>
class SpellListAdapter : public NestedIdAdapter<ESXRecordT> class SpellListAdapter : public NestedColumnAdapter<ESXRecordT>
{ {
public: public:
SpellListAdapter () {} SpellListAdapter () {}
@ -234,7 +234,7 @@ namespace CSMWorld
}; };
template<typename ESXRecordT> template<typename ESXRecordT>
class EffectsListAdapter : public NestedIdAdapter<ESXRecordT> class EffectsListAdapter : public NestedColumnAdapter<ESXRecordT>
{ {
public: public:
EffectsListAdapter () {} EffectsListAdapter () {}
@ -476,4 +476,4 @@ namespace CSMWorld
}; };
} }
#endif // CSM_WOLRD_IDADAPTERIMP_H #endif // CSM_WOLRD_NESTEDCOLADAPTERIMP_H

@ -1,7 +1,5 @@
#ifndef CSM_WOLRD_IDADAPTER_H #ifndef CSM_WOLRD_NESTEDCOLUMNADAPTER_H
#define CSM_WOLRD_IDADAPTER_H #define CSM_WOLRD_NESTEDCOLUMNADAPTER_H
#include "record.hpp"
class QVariant; class QVariant;
@ -9,14 +7,17 @@ namespace CSMWorld
{ {
struct NestedTableWrapperBase; struct NestedTableWrapperBase;
template <typename ESXRecordT>
struct Record;
template<typename ESXRecordT> template<typename ESXRecordT>
class NestedIdAdapter class NestedColumnAdapter
{ {
public: public:
NestedIdAdapter() {} NestedColumnAdapter() {}
virtual ~NestedIdAdapter() {} virtual ~NestedColumnAdapter() {}
virtual void addNestedRow(Record<ESXRecordT>& record, int position) const = 0; virtual void addNestedRow(Record<ESXRecordT>& record, int position) const = 0;
@ -36,4 +37,4 @@ namespace CSMWorld
}; };
} }
#endif // CSM_WOLRD_IDADAPTER_H #endif // CSM_WOLRD_NESTEDCOLUMNADAPTER_H

@ -5,7 +5,7 @@
#include <stdexcept> #include <stdexcept>
#include "nestedcollection.hpp" #include "nestedcollection.hpp"
#include "idadapterimp.hpp" #include "nestedcoladapterimp.hpp"
namespace ESM namespace ESM
{ {
@ -23,9 +23,9 @@ namespace CSMWorld
template<typename ESXRecordT, typename IdAccessorT = IdAccessor<ESXRecordT> > template<typename ESXRecordT, typename IdAccessorT = IdAccessor<ESXRecordT> >
class NestedIdCollection : public IdCollection<ESXRecordT, IdAccessorT>, public NestedCollection class NestedIdCollection : public IdCollection<ESXRecordT, IdAccessorT>, public NestedCollection
{ {
std::map<const ColumnBase*, NestedIdAdapter<ESXRecordT>* > mAdapters; std::map<const ColumnBase*, NestedColumnAdapter<ESXRecordT>* > mAdapters;
const NestedIdAdapter<ESXRecordT>& getAdapter(const ColumnBase &column) const; const NestedColumnAdapter<ESXRecordT>& getAdapter(const ColumnBase &column) const;
public: public:
@ -51,7 +51,7 @@ namespace CSMWorld
// this method is inherited from NestedCollection, not from Collection<ESXRecordT> // this method is inherited from NestedCollection, not from Collection<ESXRecordT>
virtual NestableColumn *getNestableColumn(int column); virtual NestableColumn *getNestableColumn(int column);
void addAdapter(std::pair<const ColumnBase*, NestedIdAdapter<ESXRecordT>* > adapter); void addAdapter(std::pair<const ColumnBase*, NestedColumnAdapter<ESXRecordT>* > adapter);
}; };
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
@ -61,21 +61,24 @@ namespace CSMWorld
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
NestedIdCollection<ESXRecordT, IdAccessorT>::~NestedIdCollection() NestedIdCollection<ESXRecordT, IdAccessorT>::~NestedIdCollection()
{ {
for (typename std::map<const ColumnBase *, NestedIdAdapter<ESXRecordT>* >::iterator iter (mAdapters.begin()); for (typename std::map<const ColumnBase *, NestedColumnAdapter<ESXRecordT>* >::iterator
iter!=mAdapters.end(); ++iter) iter (mAdapters.begin()); iter!=mAdapters.end(); ++iter)
{
delete (*iter).second; delete (*iter).second;
}
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
void NestedIdCollection<ESXRecordT, IdAccessorT>::addAdapter(std::pair<const ColumnBase*, NestedIdAdapter<ESXRecordT>* > adapter) void NestedIdCollection<ESXRecordT, IdAccessorT>::addAdapter(std::pair<const ColumnBase*,
NestedColumnAdapter<ESXRecordT>* > adapter)
{ {
mAdapters.insert(adapter); mAdapters.insert(adapter);
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
const NestedIdAdapter<ESXRecordT>& NestedIdCollection<ESXRecordT, IdAccessorT>::getAdapter(const ColumnBase &column) const const NestedColumnAdapter<ESXRecordT>& NestedIdCollection<ESXRecordT, IdAccessorT>::getAdapter(const ColumnBase &column) const
{ {
typename std::map<const ColumnBase *, NestedIdAdapter<ESXRecordT>* >::const_iterator iter = typename std::map<const ColumnBase *, NestedColumnAdapter<ESXRecordT>* >::const_iterator iter =
mAdapters.find (&column); mAdapters.find (&column);
if (iter==mAdapters.end()) if (iter==mAdapters.end())

Loading…
Cancel
Save