#ifndef CSM_WOLRD_DATA_H #define CSM_WOLRD_DATA_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cell.hpp" #include "idcollection.hpp" #include "infocollection.hpp" #include "land.hpp" #include "landtexture.hpp" #include "metadata.hpp" #include "nestedidcollection.hpp" #include "nestedinfocollection.hpp" #include "pathgrid.hpp" #include "refcollection.hpp" #include "refidcollection.hpp" #include "resourcesmanager.hpp" #include "universalid.hpp" #ifndef Q_MOC_RUN #include "subcellcollection.hpp" #endif class QAbstractItemModel; class QModelIndex; namespace Resource { class ResourceSystem; } namespace VFS { class Manager; } namespace ESM { class ESMReader; } namespace CSMDoc { class Messages; } namespace CSMWorld { class ActorAdapter; class CollectionBase; class Resources; class Data : public QObject { Q_OBJECT ToUTF8::Utf8Encoder mEncoder; IdCollection mGlobals; IdCollection mGmsts; IdCollection mSkills; IdCollection mClasses; NestedIdCollection mFactions; NestedIdCollection mRaces; IdCollection mSounds; IdCollection mScripts; NestedIdCollection mRegions; NestedIdCollection mBirthsigns; NestedIdCollection mSpells; IdCollection mTopics; IdCollection mJournals; NestedIdCollection mEnchantments; IdCollection mBodyParts; IdCollection mMagicEffects; IdCollection mDebugProfiles; IdCollection mSoundGens; IdCollection mStartScripts; NestedInfoCollection mTopicInfos; InfoCollection mJournalInfos; NestedIdCollection mCells; SubCellCollection mPathgrids; IdCollection mLandTextures; IdCollection mLand; RefIdCollection mReferenceables; RefCollection mRefs; IdCollection mFilters; Collection mMetaData; std::unique_ptr mActorAdapter; std::vector mModels; std::map mModelIndex; ESM::ESMReader* mReader; const ESM::Dialogue* mDialogue; // last loaded dialogue bool mBase; bool mProject; std::map> mRefLoadCache; int mReaderIndex; bool mFsStrict; Files::PathContainer mDataPaths; std::vector mArchives; std::unique_ptr mVFS; ResourcesManager mResourcesManager; std::shared_ptr mResourceSystem; std::vector> mReaders; // not implemented Data(const Data&); Data& operator=(const Data&); void addModel(QAbstractItemModel* model, UniversalId::Type type, bool update = true); static void appendIds(std::vector& ids, const CollectionBase& collection, bool listDeleted); ///< Append all IDs from collection to \a ids. static int count(RecordBase::State state, const CollectionBase& collection); void loadFallbackEntries(); public: Data(ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, const std::vector& archives, const std::filesystem::path& resDir); ~Data() override; const VFS::Manager* getVFS() const; std::shared_ptr getResourceSystem(); std::shared_ptr getResourceSystem() const; const IdCollection& getGlobals() const; IdCollection& getGlobals(); const IdCollection& getGmsts() const; IdCollection& getGmsts(); const IdCollection& getSkills() const; IdCollection& getSkills(); const IdCollection& getClasses() const; IdCollection& getClasses(); const IdCollection& getFactions() const; IdCollection& getFactions(); const IdCollection& getRaces() const; IdCollection& getRaces(); const IdCollection& getSounds() const; IdCollection& getSounds(); const IdCollection& getScripts() const; IdCollection& getScripts(); const IdCollection& getRegions() const; IdCollection& getRegions(); const IdCollection& getBirthsigns() const; IdCollection& getBirthsigns(); const IdCollection& getSpells() const; IdCollection& getSpells(); const IdCollection& getTopics() const; IdCollection& getTopics(); const IdCollection& getJournals() const; IdCollection& getJournals(); const InfoCollection& getTopicInfos() const; InfoCollection& getTopicInfos(); const InfoCollection& getJournalInfos() const; InfoCollection& getJournalInfos(); const IdCollection& getCells() const; IdCollection& getCells(); const RefIdCollection& getReferenceables() const; RefIdCollection& getReferenceables(); const RefCollection& getReferences() const; RefCollection& getReferences(); const IdCollection& getFilters() const; IdCollection& getFilters(); const IdCollection& getEnchantments() const; IdCollection& getEnchantments(); const IdCollection& getBodyParts() const; IdCollection& getBodyParts(); const IdCollection& getDebugProfiles() const; IdCollection& getDebugProfiles(); const IdCollection& getLand() const; IdCollection& getLand(); const IdCollection& getLandTextures() const; IdCollection& getLandTextures(); const IdCollection& getSoundGens() const; IdCollection& getSoundGens(); const IdCollection& getMagicEffects() const; IdCollection& getMagicEffects(); const SubCellCollection& getPathgrids() const; SubCellCollection& getPathgrids(); const IdCollection& getStartScripts() const; IdCollection& getStartScripts(); /// Throws an exception, if \a id does not match a resources list. const Resources& getResources(const UniversalId& id) const; const MetaData& getMetaData() const; void setMetaData(const MetaData& metaData); QAbstractItemModel* getTableModel(const UniversalId& id); ///< 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. const ActorAdapter* getActorAdapter() const; ActorAdapter* getActorAdapter(); void merge(); ///< Merge modified into base. int getTotalRecords(const std::vector& files); // for better loading bar int startLoading(const std::filesystem::path& path, bool base, bool project); ///< Begin merging content of a file into base or modified. /// /// \param project load project file instead of content file /// ///< \return estimated number of records bool continueLoading(CSMDoc::Messages& messages); ///< \return Finished? bool hasId(const std::string& id) const; std::vector getIds(bool listDeleted = true) const; ///< Return a sorted collection of all IDs that are not internal to the editor. /// /// \param listDeleted include deleted record in the list int count(RecordBase::State state) const; ///< Return number of top-level records with the given \a state. signals: void idListChanged(); void assetTablesChanged(); public slots: void assetsChanged(); private slots: void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); void rowsChanged(const QModelIndex& parent, int start, int end); }; } #endif