2012-11-26 11:29:22 +00:00
|
|
|
|
|
|
|
#include "data.hpp"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
|
|
|
#include <components/esm/loadglob.hpp>
|
|
|
|
|
|
|
|
#include "idtable.hpp"
|
|
|
|
#include "columns.hpp"
|
|
|
|
|
|
|
|
CSMWorld::Data::Data()
|
|
|
|
{
|
2012-11-29 17:56:28 +00:00
|
|
|
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
2012-12-01 12:42:12 +00:00
|
|
|
mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
|
2012-12-13 12:35:08 +00:00
|
|
|
mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global));
|
2012-11-26 11:29:22 +00:00
|
|
|
mGlobals.addColumn (new FloatValueColumn<ESM::Global>);
|
|
|
|
|
|
|
|
mModels.insert (std::make_pair (
|
|
|
|
UniversalId (UniversalId::Type_Globals),
|
|
|
|
new IdTable (&mGlobals)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
CSMWorld::Data::~Data()
|
|
|
|
{
|
|
|
|
for (std::map<UniversalId, QAbstractTableModel *>::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter)
|
|
|
|
delete iter->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSMWorld::IdCollection<ESM::Global>& CSMWorld::Data::getGlobals() const
|
|
|
|
{
|
|
|
|
return mGlobals;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSMWorld::IdCollection<ESM::Global>& CSMWorld::Data::getGlobals()
|
|
|
|
{
|
|
|
|
return mGlobals;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAbstractTableModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
|
|
|
{
|
|
|
|
std::map<UniversalId, QAbstractTableModel *>::iterator iter = mModels.find (id);
|
|
|
|
|
|
|
|
if (iter==mModels.end())
|
|
|
|
throw std::logic_error ("No table model available for " + id.toString());
|
|
|
|
|
|
|
|
return iter->second;
|
2012-12-03 12:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSMWorld::Data::merge()
|
|
|
|
{
|
|
|
|
mGlobals.merge();
|
2012-11-26 11:29:22 +00:00
|
|
|
}
|