added references table

pull/16/head
Marc Zinnschlag 12 years ago
parent 94ec05c2c6
commit 9a49125281

@ -24,7 +24,7 @@ opencs_units (model/world
opencs_units_noqt (model/world
universalid data record commands columnbase scriptcontext cell refidcollection
refidadapter refiddata refidadapterimp ref collectionbase
refidadapter refiddata refidadapterimp ref collectionbase refcollection
)
opencs_hdrs_noqt (model/world

@ -22,7 +22,7 @@ void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type
mModelIndex.insert (std::make_pair (type2, model));
}
CSMWorld::Data::Data()
CSMWorld::Data::Data() : mRefs (mCells)
{
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
@ -128,6 +128,8 @@ CSMWorld::Data::Data()
mCells.addColumn (new FlagColumn<Cell> ("Interior Sky", ESM::Cell::QuasiEx));
mCells.addColumn (new RegionColumn<Cell>);
mRefs.addColumn (new RecordStateColumn<CellRef>);
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill);
@ -142,6 +144,7 @@ CSMWorld::Data::Data()
addModel (new IdTable (&mCells), UniversalId::Type_Cells, UniversalId::Type_Cell);
addModel (new IdTable (&mReferenceables), UniversalId::Type_Referenceables,
UniversalId::Type_Referenceable);
addModel (new IdTable (&mRefs), UniversalId::Type_References, UniversalId::Type_Reference);
}
CSMWorld::Data::~Data()
@ -325,7 +328,11 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
case ESM::REC_REGN: mRegions.load (reader, base); break;
case ESM::REC_BSGN: mBirthsigns.load (reader, base); break;
case ESM::REC_SPEL: mSpells.load (reader, base); break;
case ESM::REC_CELL: mCells.load (reader, base); break;
case ESM::REC_CELL:
mCells.load (reader, base);
mRefs.load (reader, mCells.getSize()-1, base);
break;
case ESM::REC_ACTI: mReferenceables.load (reader, base, UniversalId::Type_Activator); break;
case ESM::REC_ALCH: mReferenceables.load (reader, base, UniversalId::Type_Potion); break;

@ -22,6 +22,7 @@
#include "universalid.hpp"
#include "cell.hpp"
#include "refidcollection.hpp"
#include "refcollection.hpp"
class QAbstractItemModel;
@ -42,6 +43,7 @@ namespace CSMWorld
IdCollection<ESM::Spell> mSpells;
IdCollection<Cell> mCells;
RefIdCollection mReferenceables;
RefCollection mRefs;
std::vector<QAbstractItemModel *> mModels;
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;

@ -0,0 +1,39 @@
#include "refcollection.hpp"
#include <sstream>
#include "ref.hpp"
#include "cell.hpp"
CSMWorld::RefCollection::RefCollection (Collection<Cell>& cells)
: mCells (cells), mNextId (0)
{}
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
{
Record<Cell> cell = mCells.getRecord (cellIndex);
Cell& cell2 = base ? cell.mBase : cell.mModified;
cell2.restore (reader, 0); /// \todo fix the index
CellRef ref;
while (cell2.getNextRef (reader, ref))
{
/// \todo handle deleted and moved references
std::ostringstream stream;
stream << "ref#" << mNextId++;
ref.load (reader, cell2, stream.str());
Record<CellRef> record2;
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2.mBase : record2.mModified) = ref;
appendRecord (record2);
}
mCells.setRecord (cellIndex, cell);
}

@ -0,0 +1,27 @@
#ifndef CSM_WOLRD_REFCOLLECTION_H
#define CSM_WOLRD_REFCOLLECTION_H
#include "collection.hpp"
#include "ref.hpp"
#include "record.hpp"
namespace CSMWorld
{
struct Cell;
/// \brief References in cells
class RefCollection : public Collection<CellRef>
{
Collection<Cell>& mCells;
int mNextId;
public:
RefCollection (Collection<Cell>& cells);
void load (ESM::ESMReader& reader, int cellIndex, bool base);
///< Load a sequence of references.
};
}
#endif

@ -31,6 +31,8 @@ namespace
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Cells, "Cells" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Referenceables,
"Referenceables" },
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_References,
"References" },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
};
@ -73,6 +75,7 @@ namespace
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Repair, "Repair" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Static, "Static" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Weapon, "Weapon" },
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Reference, "Reference" },
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
};

@ -79,8 +79,9 @@ namespace CSMWorld
Type_Probe,
Type_Repair,
Type_Static,
Type_Weapon
Type_Weapon,
Type_References,
Type_Reference
};
private:

@ -136,6 +136,9 @@ void CSVDoc::View::setupWorldMenu()
connect (referenceables, SIGNAL (triggered()), this, SLOT (addReferenceablesSubView()));
world->addAction (referenceables);
QAction *references = new QAction (tr ("References"), this);
connect (references, SIGNAL (triggered()), this, SLOT (addReferencesSubView()));
world->addAction (references);
}
void CSVDoc::View::setupUi()
@ -346,6 +349,11 @@ void CSVDoc::View::addReferenceablesSubView()
addSubView (CSMWorld::UniversalId::Type_Referenceables);
}
void CSVDoc::View::addReferencesSubView()
{
addSubView (CSMWorld::UniversalId::Type_References);
}
void CSVDoc::View::abortOperation (int type)
{
mDocument->abortOperation (type);

@ -140,6 +140,8 @@ namespace CSVDoc
void addReferenceablesSubView();
void addReferencesSubView();
void showUserSettings();
};
}

@ -28,6 +28,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
CSMWorld::UniversalId::Type_Spells,
CSMWorld::UniversalId::Type_Cells,
CSMWorld::UniversalId::Type_Referenceables,
CSMWorld::UniversalId::Type_References,
CSMWorld::UniversalId::Type_None // end marker
};

Loading…
Cancel
Save