|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
#include "data.hpp"
|
|
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
|
|
|
|
|
@ -15,13 +16,31 @@
|
|
|
|
|
#include "columns.hpp"
|
|
|
|
|
|
|
|
|
|
void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type1,
|
|
|
|
|
UniversalId::Type type2)
|
|
|
|
|
UniversalId::Type type2, bool update)
|
|
|
|
|
{
|
|
|
|
|
mModels.push_back (model);
|
|
|
|
|
mModelIndex.insert (std::make_pair (type1, model));
|
|
|
|
|
|
|
|
|
|
if (type2!=UniversalId::Type_None)
|
|
|
|
|
mModelIndex.insert (std::make_pair (type2, model));
|
|
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
|
{
|
|
|
|
|
connect (model, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
|
|
|
|
this, SLOT (dataChanged (const QModelIndex&, const QModelIndex&)));
|
|
|
|
|
connect (model, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
|
|
|
|
this, SLOT (rowsChanged (const QModelIndex&, int, int)));
|
|
|
|
|
connect (model, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
|
|
|
|
this, SLOT (rowsChanged (const QModelIndex&, int, int)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::Data::appendIds (std::vector<std::string>& ids, const CollectionBase& collection,
|
|
|
|
|
bool listDeleted)
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> ids2 = collection.getIds (listDeleted);
|
|
|
|
|
|
|
|
|
|
ids.insert (ids.end(), ids2.begin(), ids2.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::Data::Data() : mRefs (mCells)
|
|
|
|
@ -155,7 +174,7 @@ CSMWorld::Data::Data() : mRefs (mCells)
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill, false);
|
|
|
|
|
addModel (new IdTable (&mClasses), UniversalId::Type_Classes, UniversalId::Type_Class);
|
|
|
|
|
addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction);
|
|
|
|
|
addModel (new IdTable (&mRaces), UniversalId::Type_Races, UniversalId::Type_Race);
|
|
|
|
@ -167,8 +186,8 @@ CSMWorld::Data::Data() : mRefs (mCells)
|
|
|
|
|
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);
|
|
|
|
|
addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter);
|
|
|
|
|
addModel (new IdTable (&mRefs), UniversalId::Type_References, UniversalId::Type_Reference, false);
|
|
|
|
|
addModel (new IdTable (&mFilters), UniversalId::Type_Filters, UniversalId::Type_Filter, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::Data::~Data()
|
|
|
|
@ -341,7 +360,7 @@ QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
|
|
|
|
{
|
|
|
|
|
RegionMap *table = 0;
|
|
|
|
|
addModel (table = new RegionMap (*this), UniversalId::Type_RegionMap,
|
|
|
|
|
UniversalId::Type_None);
|
|
|
|
|
UniversalId::Type_None, false);
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
throw std::logic_error ("No table model available for " + id.toString());
|
|
|
|
@ -440,3 +459,36 @@ bool CSMWorld::Data::hasId (const std::string& id) const
|
|
|
|
|
getCells().searchId (id)!=-1 ||
|
|
|
|
|
getReferenceables().searchId (id)!=-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> CSMWorld::Data::getIds (bool listDeleted) const
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> ids;
|
|
|
|
|
|
|
|
|
|
appendIds (ids, mGlobals, listDeleted);
|
|
|
|
|
appendIds (ids, mGmsts, listDeleted);
|
|
|
|
|
appendIds (ids, mClasses, listDeleted);
|
|
|
|
|
appendIds (ids, mFactions, listDeleted);
|
|
|
|
|
appendIds (ids, mRaces, listDeleted);
|
|
|
|
|
appendIds (ids, mSounds, listDeleted);
|
|
|
|
|
appendIds (ids, mScripts, listDeleted);
|
|
|
|
|
appendIds (ids, mRegions, listDeleted);
|
|
|
|
|
appendIds (ids, mBirthsigns, listDeleted);
|
|
|
|
|
appendIds (ids, mSpells, listDeleted);
|
|
|
|
|
appendIds (ids, mCells, listDeleted);
|
|
|
|
|
appendIds (ids, mReferenceables, listDeleted);
|
|
|
|
|
|
|
|
|
|
std::sort (ids.begin(), ids.end());
|
|
|
|
|
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
|
|
|
|
{
|
|
|
|
|
if (topLeft.column()<=0)
|
|
|
|
|
emit idListChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end)
|
|
|
|
|
{
|
|
|
|
|
emit idListChanged();
|
|
|
|
|
}
|