|
|
|
@ -10,6 +10,16 @@
|
|
|
|
|
#include "idtable.hpp"
|
|
|
|
|
#include "columns.hpp"
|
|
|
|
|
|
|
|
|
|
void CSMWorld::Data::addModel (QAbstractTableModel *model, UniversalId::Type type1,
|
|
|
|
|
UniversalId::Type type2)
|
|
|
|
|
{
|
|
|
|
|
mModels.push_back (model);
|
|
|
|
|
mModelIndex.insert (std::make_pair (type1, model));
|
|
|
|
|
|
|
|
|
|
if (type2!=UniversalId::Type_None)
|
|
|
|
|
mModelIndex.insert (std::make_pair (type2, model));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::Data::Data()
|
|
|
|
|
{
|
|
|
|
|
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
|
|
|
@ -17,16 +27,13 @@ CSMWorld::Data::Data()
|
|
|
|
|
mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global));
|
|
|
|
|
mGlobals.addColumn (new FloatValueColumn<ESM::Global>);
|
|
|
|
|
|
|
|
|
|
mModels.insert (std::make_pair (
|
|
|
|
|
UniversalId (UniversalId::Type_Globals),
|
|
|
|
|
new IdTable (&mGlobals)
|
|
|
|
|
));
|
|
|
|
|
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::Data::~Data()
|
|
|
|
|
{
|
|
|
|
|
for (std::map<UniversalId, QAbstractTableModel *>::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter)
|
|
|
|
|
delete iter->second;
|
|
|
|
|
for (std::vector<QAbstractTableModel *>::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter)
|
|
|
|
|
delete *iter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CSMWorld::IdCollection<ESM::Global>& CSMWorld::Data::getGlobals() const
|
|
|
|
@ -41,9 +48,9 @@ CSMWorld::IdCollection<ESM::Global>& CSMWorld::Data::getGlobals()
|
|
|
|
|
|
|
|
|
|
QAbstractTableModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
|
|
|
|
{
|
|
|
|
|
std::map<UniversalId, QAbstractTableModel *>::iterator iter = mModels.find (id);
|
|
|
|
|
std::map<UniversalId::Type, QAbstractTableModel *>::iterator iter = mModelIndex.find (id.getType());
|
|
|
|
|
|
|
|
|
|
if (iter==mModels.end())
|
|
|
|
|
if (iter==mModelIndex.end())
|
|
|
|
|
throw std::logic_error ("No table model available for " + id.toString());
|
|
|
|
|
|
|
|
|
|
return iter->second;
|
|
|
|
|