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"
|
|
|
|
|
2012-12-30 13:01:52 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2012-11-26 11:29:22 +00:00
|
|
|
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>);
|
|
|
|
|
2012-12-30 13:01:52 +00:00
|
|
|
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
2012-11-26 11:29:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSMWorld::Data::~Data()
|
|
|
|
{
|
2012-12-30 13:01:52 +00:00
|
|
|
for (std::vector<QAbstractTableModel *>::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter)
|
|
|
|
delete *iter;
|
2012-11-26 11:29:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2012-12-30 13:01:52 +00:00
|
|
|
std::map<UniversalId::Type, QAbstractTableModel *>::iterator iter = mModelIndex.find (id.getType());
|
2012-11-26 11:29:22 +00:00
|
|
|
|
2012-12-30 13:01:52 +00:00
|
|
|
if (iter==mModelIndex.end())
|
2012-11-26 11:29:22 +00:00
|
|
|
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();
|
2013-02-07 10:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
|
|
|
{
|
|
|
|
std::cout << "pretending to load " << path.string() << std::endl;
|
2012-11-26 11:29:22 +00:00
|
|
|
}
|