2012-12-30 14:01:52 +01:00
|
|
|
#ifndef CSM_WOLRD_DATA_H
|
|
|
|
#define CSM_WOLRD_DATA_H
|
2012-11-26 12:29:22 +01:00
|
|
|
|
|
|
|
#include <map>
|
2012-12-30 14:01:52 +01:00
|
|
|
#include <vector>
|
2012-11-26 12:29:22 +01:00
|
|
|
|
2013-02-07 11:33:08 +01:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
|
2013-09-19 12:11:27 +02:00
|
|
|
#include <QObject>
|
|
|
|
#include <QModelIndex>
|
|
|
|
|
2012-11-26 12:29:22 +01:00
|
|
|
#include <components/esm/loadglob.hpp>
|
2013-02-08 09:58:19 +01:00
|
|
|
#include <components/esm/loadgmst.hpp>
|
2013-03-21 14:31:32 +01:00
|
|
|
#include <components/esm/loadskil.hpp>
|
2013-03-25 13:22:06 +01:00
|
|
|
#include <components/esm/loadclas.hpp>
|
2013-04-02 12:00:45 +02:00
|
|
|
#include <components/esm/loadfact.hpp>
|
2013-04-04 14:34:39 +02:00
|
|
|
#include <components/esm/loadrace.hpp>
|
2013-04-06 21:21:10 +02:00
|
|
|
#include <components/esm/loadsoun.hpp>
|
2013-04-07 15:17:35 +02:00
|
|
|
#include <components/esm/loadscpt.hpp>
|
2013-04-07 16:32:06 +02:00
|
|
|
#include <components/esm/loadregn.hpp>
|
2013-04-07 20:26:39 +02:00
|
|
|
#include <components/esm/loadbsgn.hpp>
|
2013-04-09 11:40:36 +02:00
|
|
|
#include <components/esm/loadspel.hpp>
|
2013-10-20 17:13:31 +02:00
|
|
|
#include <components/esm/loaddial.hpp>
|
2012-11-26 12:29:22 +01:00
|
|
|
|
2013-07-22 21:18:47 +02:00
|
|
|
#include "../filter/filter.hpp"
|
|
|
|
|
2012-11-26 12:29:22 +01:00
|
|
|
#include "idcollection.hpp"
|
|
|
|
#include "universalid.hpp"
|
2013-04-14 17:04:55 +02:00
|
|
|
#include "cell.hpp"
|
2013-05-07 11:23:18 +02:00
|
|
|
#include "refidcollection.hpp"
|
2013-07-06 17:03:18 +02:00
|
|
|
#include "refcollection.hpp"
|
2013-10-29 13:18:22 +01:00
|
|
|
#include "infocollection.hpp"
|
2012-11-26 12:29:22 +01:00
|
|
|
|
2013-03-21 10:07:25 +01:00
|
|
|
class QAbstractItemModel;
|
2012-11-26 12:29:22 +01:00
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
2013-09-19 12:11:27 +02:00
|
|
|
class Data : public QObject
|
2012-11-26 12:29:22 +01:00
|
|
|
{
|
2013-09-19 12:11:27 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-11-26 12:29:22 +01:00
|
|
|
IdCollection<ESM::Global> mGlobals;
|
2013-02-08 09:58:19 +01:00
|
|
|
IdCollection<ESM::GameSetting> mGmsts;
|
2013-03-21 14:31:32 +01:00
|
|
|
IdCollection<ESM::Skill> mSkills;
|
2013-03-25 13:22:06 +01:00
|
|
|
IdCollection<ESM::Class> mClasses;
|
2013-04-02 12:00:45 +02:00
|
|
|
IdCollection<ESM::Faction> mFactions;
|
2013-04-04 14:34:39 +02:00
|
|
|
IdCollection<ESM::Race> mRaces;
|
2013-04-06 21:21:10 +02:00
|
|
|
IdCollection<ESM::Sound> mSounds;
|
2013-04-07 15:17:35 +02:00
|
|
|
IdCollection<ESM::Script> mScripts;
|
2013-04-07 16:32:06 +02:00
|
|
|
IdCollection<ESM::Region> mRegions;
|
2013-04-07 20:26:39 +02:00
|
|
|
IdCollection<ESM::BirthSign> mBirthsigns;
|
2013-04-09 11:40:36 +02:00
|
|
|
IdCollection<ESM::Spell> mSpells;
|
2013-10-20 17:13:31 +02:00
|
|
|
IdCollection<ESM::Dialogue> mTopics;
|
|
|
|
IdCollection<ESM::Dialogue> mJournals;
|
2013-10-29 13:18:22 +01:00
|
|
|
InfoCollection mTopicInfos;
|
|
|
|
InfoCollection mJournalInfos;
|
2013-04-14 17:04:55 +02:00
|
|
|
IdCollection<Cell> mCells;
|
2013-05-07 11:23:18 +02:00
|
|
|
RefIdCollection mReferenceables;
|
2013-07-06 17:03:18 +02:00
|
|
|
RefCollection mRefs;
|
2013-07-22 21:18:47 +02:00
|
|
|
IdCollection<CSMFilter::Filter> mFilters;
|
2013-03-21 10:07:25 +01:00
|
|
|
std::vector<QAbstractItemModel *> mModels;
|
|
|
|
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
2013-09-24 17:17:01 +02:00
|
|
|
std::string mAuthor;
|
|
|
|
std::string mDescription;
|
2012-11-26 12:29:22 +01:00
|
|
|
|
|
|
|
// not implemented
|
|
|
|
Data (const Data&);
|
|
|
|
Data& operator= (const Data&);
|
|
|
|
|
2013-03-21 10:07:25 +01:00
|
|
|
void addModel (QAbstractItemModel *model, UniversalId::Type type1,
|
2013-09-19 12:11:27 +02:00
|
|
|
UniversalId::Type type2 = UniversalId::Type_None, bool update = true);
|
|
|
|
|
2013-09-19 13:42:19 +02:00
|
|
|
static void appendIds (std::vector<std::string>& ids, const CollectionBase& collection,
|
|
|
|
bool listDeleted);
|
2013-09-19 12:11:27 +02:00
|
|
|
///< Append all IDs from collection to \a ids.
|
2012-12-30 14:01:52 +01:00
|
|
|
|
2013-09-24 17:08:24 +02:00
|
|
|
static int count (RecordBase::State state, const CollectionBase& collection);
|
|
|
|
|
2012-11-26 12:29:22 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
Data();
|
|
|
|
|
2013-09-19 12:11:27 +02:00
|
|
|
virtual ~Data();
|
2012-11-26 12:29:22 +01:00
|
|
|
|
|
|
|
const IdCollection<ESM::Global>& getGlobals() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Global>& getGlobals();
|
|
|
|
|
2013-02-17 20:03:39 +01:00
|
|
|
const IdCollection<ESM::GameSetting>& getGmsts() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::GameSetting>& getGmsts();
|
|
|
|
|
2013-03-24 15:10:03 +01:00
|
|
|
const IdCollection<ESM::Skill>& getSkills() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Skill>& getSkills();
|
|
|
|
|
2013-04-04 10:10:26 +02:00
|
|
|
const IdCollection<ESM::Class>& getClasses() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Class>& getClasses();
|
|
|
|
|
2013-04-02 12:00:45 +02:00
|
|
|
const IdCollection<ESM::Faction>& getFactions() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Faction>& getFactions();
|
|
|
|
|
2013-04-04 14:34:39 +02:00
|
|
|
const IdCollection<ESM::Race>& getRaces() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Race>& getRaces();
|
|
|
|
|
2013-04-06 21:21:10 +02:00
|
|
|
const IdCollection<ESM::Sound>& getSounds() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Sound>& getSounds();
|
|
|
|
|
2013-04-07 15:17:35 +02:00
|
|
|
const IdCollection<ESM::Script>& getScripts() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Script>& getScripts();
|
|
|
|
|
2013-04-07 16:32:06 +02:00
|
|
|
const IdCollection<ESM::Region>& getRegions() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Region>& getRegions();
|
|
|
|
|
2013-04-07 20:26:39 +02:00
|
|
|
const IdCollection<ESM::BirthSign>& getBirthsigns() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::BirthSign>& getBirthsigns();
|
|
|
|
|
2013-04-09 11:40:36 +02:00
|
|
|
const IdCollection<ESM::Spell>& getSpells() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Spell>& getSpells();
|
|
|
|
|
2013-10-21 14:26:54 +02:00
|
|
|
const IdCollection<ESM::Dialogue>& getTopics() const;
|
2013-10-20 17:13:31 +02:00
|
|
|
|
2013-10-21 14:26:54 +02:00
|
|
|
IdCollection<ESM::Dialogue>& getTopics();
|
2013-10-20 17:13:31 +02:00
|
|
|
|
|
|
|
const IdCollection<ESM::Dialogue>& getJournals() const;
|
|
|
|
|
|
|
|
IdCollection<ESM::Dialogue>& getJournals();
|
|
|
|
|
2013-10-29 13:18:22 +01:00
|
|
|
const InfoCollection& getTopicInfos() const;
|
|
|
|
|
|
|
|
InfoCollection& getTopicInfos();
|
|
|
|
|
|
|
|
const InfoCollection& getJournalInfos() const;
|
|
|
|
|
|
|
|
InfoCollection& getJournalInfos();
|
|
|
|
|
2013-04-14 17:04:55 +02:00
|
|
|
const IdCollection<Cell>& getCells() const;
|
|
|
|
|
|
|
|
IdCollection<Cell>& getCells();
|
|
|
|
|
2013-05-07 11:23:18 +02:00
|
|
|
const RefIdCollection& getReferenceables() const;
|
|
|
|
|
|
|
|
RefIdCollection& getReferenceables();
|
|
|
|
|
2013-07-30 12:53:03 +02:00
|
|
|
const RefCollection& getReferences() const;
|
|
|
|
|
|
|
|
RefCollection& getReferences();
|
|
|
|
|
2013-08-24 17:40:00 +02:00
|
|
|
const IdCollection<CSMFilter::Filter>& getFilters() const;
|
|
|
|
|
|
|
|
IdCollection<CSMFilter::Filter>& getFilters();
|
|
|
|
|
2013-03-21 10:07:25 +01:00
|
|
|
QAbstractItemModel *getTableModel (const UniversalId& id);
|
2012-12-30 14:01:52 +01:00
|
|
|
///< If no table model is available for \a id, an exception is thrown.
|
|
|
|
///
|
|
|
|
/// \note The returned table may either be the model for the ID itself or the model that
|
|
|
|
/// contains the record specified by the ID.
|
2012-12-03 13:56:02 +01:00
|
|
|
|
|
|
|
void merge();
|
|
|
|
///< Merge modified into base.
|
2013-02-07 11:33:08 +01:00
|
|
|
|
2013-09-27 15:04:30 +02:00
|
|
|
void loadFile (const boost::filesystem::path& path, bool base, bool project);
|
2013-02-07 11:33:08 +01:00
|
|
|
///< Merging content of a file into base or modified.
|
2013-09-27 15:04:30 +02:00
|
|
|
///
|
|
|
|
/// \param project load project file instead of content file
|
2013-07-28 15:27:15 +02:00
|
|
|
|
|
|
|
bool hasId (const std::string& id) const;
|
2013-09-19 12:11:27 +02:00
|
|
|
|
2013-09-19 13:42:19 +02:00
|
|
|
std::vector<std::string> getIds (bool listDeleted = true) const;
|
2013-09-19 12:11:27 +02:00
|
|
|
///< Return a sorted collection of all IDs that are not internal to the editor.
|
|
|
|
///
|
2013-09-19 13:42:19 +02:00
|
|
|
/// \param listDeleted include deleted record in the list
|
2013-09-19 12:11:27 +02:00
|
|
|
|
2013-09-24 17:08:24 +02:00
|
|
|
int count (RecordBase::State state) const;
|
|
|
|
///< Return number of top-level records with the given \a state.
|
|
|
|
|
2013-09-24 17:17:01 +02:00
|
|
|
void setDescription (const std::string& description);
|
|
|
|
|
|
|
|
std::string getDescription() const;
|
|
|
|
|
|
|
|
void setAuthor (const std::string& author);
|
|
|
|
|
|
|
|
std::string getAuthor() const;
|
|
|
|
|
2013-09-19 12:11:27 +02:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void idListChanged();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
|
|
|
|
|
|
|
void rowsChanged (const QModelIndex& parent, int start, int end);
|
2012-11-26 12:29:22 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|