Simplify and relocate nested column definitions.

test
cc9cii 10 years ago
parent 8dab2f9b14
commit 4b9c9bf095

@ -3,7 +3,7 @@
#include "columns.hpp" #include "columns.hpp"
CSMWorld::ColumnBase::ColumnBase (int columnId, Display displayType, int flags) CSMWorld::ColumnBase::ColumnBase (int columnId, Display displayType, int flags)
: mColumnId (columnId), mDisplayType (displayType), mFlags (flags) : mColumnId (columnId), mDisplayType (displayType), mFlags (flags)
{} {}
CSMWorld::ColumnBase::~ColumnBase() {} CSMWorld::ColumnBase::~ColumnBase() {}
@ -39,8 +39,7 @@ const CSMWorld::ColumnBase& CSMWorld::NestableColumn::nestedColumn(int subColumn
CSMWorld::NestableColumn::NestableColumn(int columnId, CSMWorld::ColumnBase::Display displayType, CSMWorld::NestableColumn::NestableColumn(int columnId, CSMWorld::ColumnBase::Display displayType,
int flag) int flag)
: CSMWorld::ColumnBase(columnId, displayType, flag) : CSMWorld::ColumnBase(columnId, displayType, flag)
{ {}
}
CSMWorld::NestableColumn::~NestableColumn() CSMWorld::NestableColumn::~NestableColumn()
{ {
@ -54,3 +53,13 @@ bool CSMWorld::NestableColumn::hasChildren() const
{ {
return !mNestedColumns.empty(); return !mNestedColumns.empty();
} }
CSMWorld::NestedChildColumn::NestedChildColumn (int id,
CSMWorld::ColumnBase::Display display, bool isEditable)
: NestableColumn (id, display, CSMWorld::ColumnBase::Flag_Dialogue) , mIsEditable(isEditable)
{}
bool CSMWorld::NestedChildColumn::isEditable () const
{
return mIsEditable;
}

@ -165,6 +165,33 @@ namespace CSMWorld
throw std::logic_error ("Column " + getTitle() + " is not editable"); throw std::logic_error ("Column " + getTitle() + " is not editable");
} }
}; };
template<typename ESXRecordT>
struct NestedParentColumn : public Column<ESXRecordT>
{
NestedParentColumn (int id) : Column<ESXRecordT> (id, Display_NestedHeader, Flag_Dialogue)
{}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
return true; // required by IdTree::hasChildren()
}
virtual bool isEditable() const
{
return true;
}
};
struct NestedChildColumn : public NestableColumn
{
NestedChildColumn (int id, Display display, bool isEditable = true);
virtual bool isEditable() const;
private:
bool mIsEditable;
};
} }
#endif #endif

@ -2264,55 +2264,6 @@ namespace CSMWorld
return true; return true;
} }
}; };
template<typename ESXRecordT>
struct NestedParentColumn : public Column<ESXRecordT>
{
NestedParentColumn (Columns::ColumnId id)
: Column<ESXRecordT> (id, ColumnBase::Display_NestedHeader, ColumnBase::Flag_Dialogue)
{}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
return true; // required by IdTree::hasChildren()
}
virtual bool isEditable() const
{
return true;
}
};
struct NestedStringColumn : public NestableColumn
{
bool mIsEditable;
NestedStringColumn (Columns::ColumnId id, bool isEditable = true)
: NestableColumn (id, ColumnBase::Display_String, ColumnBase::Flag_Dialogue)
, mIsEditable(isEditable)
{}
virtual bool isEditable() const
{
return mIsEditable;
}
};
struct NestedIntegerColumn : public NestableColumn
{
bool mIsEditable;
NestedIntegerColumn (Columns::ColumnId id, bool isEditable = true)
: NestableColumn (id, ColumnBase::Display_Integer, ColumnBase::Flag_Dialogue)
, mIsEditable(isEditable)
{}
virtual bool isEditable() const
{
return mIsEditable;
}
};
} }
#endif #endif

@ -114,9 +114,9 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mFactions.addColumn (reactions); mFactions.addColumn (reactions);
mFactions.addAdapter (std::make_pair(reactions, new FactionReactionsAdapter<ESM::Faction> ())); mFactions.addAdapter (std::make_pair(reactions, new FactionReactionsAdapter<ESM::Faction> ()));
mFactions.getNestableColumn(mFactions.getColumns()-1)->addColumn( mFactions.getNestableColumn(mFactions.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_Faction)); new NestedChildColumn (Columns::ColumnId_Faction, ColumnBase::Display_String));
mFactions.getNestableColumn(mFactions.getColumns()-1)->addColumn( mFactions.getNestableColumn(mFactions.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_FactionReaction)); 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>);
@ -135,7 +135,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mRaces.addColumn (raceSpells); mRaces.addColumn (raceSpells);
mRaces.addAdapter (std::make_pair(raceSpells, new SpellListAdapter<ESM::Race> ())); mRaces.addAdapter (std::make_pair(raceSpells, new SpellListAdapter<ESM::Race> ()));
mRaces.getNestableColumn(mRaces.getColumns()-1)->addColumn( mRaces.getNestableColumn(mRaces.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_SpellId)); 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>);
@ -162,9 +162,9 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mRegions.addColumn (soundList); mRegions.addColumn (soundList);
mRegions.addAdapter (std::make_pair(soundList, new RegionSoundListAdapter<ESM::Region> ())); mRegions.addAdapter (std::make_pair(soundList, new RegionSoundListAdapter<ESM::Region> ()));
mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn( mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_SoundName)); new NestedChildColumn (Columns::ColumnId_SoundName, ColumnBase::Display_String));
mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn( mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_SoundChance)); 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>);
@ -178,7 +178,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mBirthsigns.addColumn (birthSpells); mBirthsigns.addColumn (birthSpells);
mBirthsigns.addAdapter (std::make_pair(birthSpells, new SpellListAdapter<ESM::BirthSign> ())); mBirthsigns.addAdapter (std::make_pair(birthSpells, new SpellListAdapter<ESM::BirthSign> ()));
mBirthsigns.getNestableColumn(mBirthsigns.getColumns()-1)->addColumn( mBirthsigns.getNestableColumn(mBirthsigns.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_SpellId)); 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>);
@ -195,21 +195,21 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mSpells.addColumn (spellEffect); mSpells.addColumn (spellEffect);
mSpells.addAdapter (std::make_pair(spellEffect, new EffectsListAdapter<ESM::Spell> ())); mSpells.addAdapter (std::make_pair(spellEffect, new EffectsListAdapter<ESM::Spell> ()));
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_EffectId/*, false*/)); // false means no edit new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/)); // false means no edit
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_Skill)); new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String));
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_Attribute)); // reuse attribute new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_String)); // reuse attribute
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_EffectRange)); new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_Integer));
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_EffectArea)); new NestedChildColumn (Columns::ColumnId_EffectArea, ColumnBase::Display_String));
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_Duration)); // reuse from light new NestedChildColumn (Columns::ColumnId_Duration, ColumnBase::Display_Integer)); // reuse from light
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_MinRange)); // reuse from sound new NestedChildColumn (Columns::ColumnId_MinRange, ColumnBase::Display_Integer)); // reuse from sound
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn( mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_MaxRange)); // 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>);
@ -269,21 +269,21 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mEnchantments.addColumn (enchantmentEffect); mEnchantments.addColumn (enchantmentEffect);
mEnchantments.addAdapter (std::make_pair(enchantmentEffect, new EffectsListAdapter<ESM::Enchantment> ())); mEnchantments.addAdapter (std::make_pair(enchantmentEffect, new EffectsListAdapter<ESM::Enchantment> ()));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_EffectId/*, false*/)); new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_Skill)); new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_Attribute)); // reuse attribute new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_String)); // reuse attribute
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_EffectRange)); new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_Integer));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedStringColumn (Columns::ColumnId_EffectArea)); new NestedChildColumn (Columns::ColumnId_EffectArea, ColumnBase::Display_String));
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_Duration)); // reuse from light new NestedChildColumn (Columns::ColumnId_Duration, ColumnBase::Display_Integer)); // reuse from light
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_MinRange)); // reuse from sound new NestedChildColumn (Columns::ColumnId_MinRange, ColumnBase::Display_Integer)); // reuse from sound
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn( mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_MaxRange)); // 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>);
@ -339,24 +339,24 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
// 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(mPathgrids.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_PathgridIndex, false)); new NestedChildColumn (Columns::ColumnId_PathgridIndex, ColumnBase::Display_Integer, false));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_PathgridPosX)); new NestedChildColumn (Columns::ColumnId_PathgridPosX, ColumnBase::Display_Integer));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_PathgridPosY)); new NestedChildColumn (Columns::ColumnId_PathgridPosY, ColumnBase::Display_Integer));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_PathgridPosZ)); new NestedChildColumn (Columns::ColumnId_PathgridPosZ, ColumnBase::Display_Integer));
NestedParentColumn<Pathgrid> *edgeList = NestedParentColumn<Pathgrid> *edgeList =
new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridEdges); new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridEdges);
mPathgrids.addColumn (edgeList); mPathgrids.addColumn (edgeList);
mPathgrids.addAdapter (std::make_pair(edgeList, new PathgridEdgeListAdapter<Pathgrid> ())); mPathgrids.addAdapter (std::make_pair(edgeList, new PathgridEdgeListAdapter<Pathgrid> ()));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_PathgridEdgeIndex, false)); new NestedChildColumn (Columns::ColumnId_PathgridEdgeIndex, ColumnBase::Display_Integer, false));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_PathgridEdge0)); new NestedChildColumn (Columns::ColumnId_PathgridEdge0, ColumnBase::Display_Integer));
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn( mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
new NestedIntegerColumn (Columns::ColumnId_PathgridEdge1)); new NestedChildColumn (Columns::ColumnId_PathgridEdge1, ColumnBase::Display_Integer));
mStartScripts.addColumn (new StringIdColumn<ESM::StartScript>); mStartScripts.addColumn (new StringIdColumn<ESM::StartScript>);
mStartScripts.addColumn (new RecordStateColumn<ESM::StartScript>); mStartScripts.addColumn (new RecordStateColumn<ESM::StartScript>);

Loading…
Cancel
Save