1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 19:23:52 +00:00
openmw/apps/opencs/model/doc/documentmanager.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

116 lines
3.6 KiB
C++
Raw Normal View History

2012-11-22 12:30:02 +00:00
#ifndef CSM_DOC_DOCUMENTMGR_H
#define CSM_DOC_DOCUMENTMGR_H
2012-11-21 16:31:18 +00:00
#include <QObject>
2014-04-24 13:09:25 +00:00
#include <QThread>
2022-10-19 17:02:00 +00:00
#include <filesystem>
#include <string>
#include <vector>
#include <components/files/multidircollection.hpp>
#include <components/to_utf8/to_utf8.hpp>
2014-07-04 10:46:57 +00:00
2014-04-24 13:09:25 +00:00
#include "loader.hpp"
namespace Files
{
2015-03-13 21:09:19 +00:00
struct ConfigurationManager;
}
2012-11-21 16:31:18 +00:00
namespace CSMDoc
{
class Document;
class DocumentManager : public QObject
2012-11-21 16:31:18 +00:00
{
Q_OBJECT
2012-11-21 16:31:18 +00:00
std::vector<Document*> mDocuments;
const Files::ConfigurationManager& mConfiguration;
QThread mLoaderThread;
Loader mLoader;
ToUTF8::FromType mEncoding;
std::vector<std::string> mBlacklistedScripts;
std::filesystem::path mResDir;
2012-11-21 16:31:18 +00:00
bool mFsStrict;
Files::PathContainer mDataPaths;
std::vector<std::string> mArchives;
DocumentManager(const DocumentManager&);
DocumentManager& operator=(const DocumentManager&);
2022-09-22 18:26:05 +00:00
public:
DocumentManager(const Files::ConfigurationManager& configuration);
2012-11-21 16:31:18 +00:00
~DocumentManager();
void addDocument(
const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath, bool new_);
///< \param new_ Do not load the last content file in \a files and instead create in an
/// appropriate way.
2012-11-21 16:31:18 +00:00
/// Create a new document. The ownership of the created document is transferred to
/// the calling function. The DocumentManager does not manage it. Loading has not
/// taken place at the point when the document is returned.
///
/// \param new_ Do not load the last content file in \a files and instead create in an
/// appropriate way.
Document* makeDocument(
const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath, bool new_);
void setResourceDir(const std::filesystem::path& parResDir);
void setEncoding(ToUTF8::FromType encoding);
void setBlacklistedScripts(const std::vector<std::string>& scriptIds);
/// Sets the file data that gets passed to newly created documents.
void setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
2014-07-04 10:46:57 +00:00
bool isEmpty();
2014-04-24 13:09:25 +00:00
private slots:
void documentLoaded(Document* document);
///< The ownership of \a document is not transferred.
void documentNotLoaded(Document* document, const std::string& error);
///< Document load has been interrupted either because of a call to abortLoading
/// or a problem during loading). In the former case error will be an empty string.
public slots:
void removeDocument(CSMDoc::Document* document);
///< Emits the lastDocumentDeleted signal, if applicable.
/// Hand over document to *this. The ownership is transferred. The DocumentManager
/// will initiate the load procedure, if necessary
void insertDocument(CSMDoc::Document* document);
signals:
void documentAdded(CSMDoc::Document* document);
2014-04-24 13:09:25 +00:00
void documentAboutToBeRemoved(CSMDoc::Document* document);
void loadRequest(CSMDoc::Document* document);
void lastDocumentDeleted();
2014-04-29 12:17:25 +00:00
void loadingStopped(CSMDoc::Document* document, bool completed, const std::string& error);
2014-05-03 11:01:29 +00:00
2014-06-26 09:41:21 +00:00
void nextStage(CSMDoc::Document* document, const std::string& name, int totalRecords);
2014-05-03 13:33:35 +00:00
2014-06-26 09:41:21 +00:00
void nextRecord(CSMDoc::Document* document, int records);
2014-05-03 14:44:50 +00:00
void cancelLoading(CSMDoc::Document* document);
void loadMessage(CSMDoc::Document* document, const std::string& message);
2012-11-21 16:31:18 +00:00
};
}
#endif