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 <vector>
|
2012-11-23 13:05:49 +00:00
|
|
|
#include <string>
|
2012-11-21 16:31:18 +00:00
|
|
|
|
2013-02-04 12:46:54 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
|
2014-04-21 07:02:58 +00:00
|
|
|
#include <QObject>
|
2014-04-24 13:09:25 +00:00
|
|
|
#include <QThread>
|
|
|
|
|
2014-05-12 08:32:57 +00:00
|
|
|
#include <components/to_utf8/to_utf8.hpp>
|
2016-01-06 11:58:36 +00:00
|
|
|
#include <components/fallback/fallback.hpp>
|
2017-08-22 02:31:19 +00:00
|
|
|
#include <components/files/multidircollection.hpp>
|
2014-07-04 10:46:57 +00:00
|
|
|
|
2014-04-24 13:09:25 +00:00
|
|
|
#include "loader.hpp"
|
2014-04-21 07:02:58 +00:00
|
|
|
|
2015-03-19 16:49:41 +00:00
|
|
|
namespace VFS
|
|
|
|
{
|
|
|
|
class Manager;
|
|
|
|
}
|
|
|
|
|
2013-09-27 13:24:58 +00:00
|
|
|
namespace Files
|
|
|
|
{
|
2015-03-13 21:09:19 +00:00
|
|
|
struct ConfigurationManager;
|
2013-09-27 13:24:58 +00:00
|
|
|
}
|
|
|
|
|
2012-11-21 16:31:18 +00:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
|
2014-04-21 07:02:58 +00:00
|
|
|
class DocumentManager : public QObject
|
2012-11-21 16:31:18 +00:00
|
|
|
{
|
2014-04-21 07:02:58 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-11-21 16:31:18 +00:00
|
|
|
std::vector<Document *> mDocuments;
|
2013-09-27 13:24:58 +00:00
|
|
|
const Files::ConfigurationManager& mConfiguration;
|
2014-04-24 13:09:25 +00:00
|
|
|
QThread mLoaderThread;
|
|
|
|
Loader mLoader;
|
2014-05-12 08:32:57 +00:00
|
|
|
ToUTF8::FromType mEncoding;
|
2014-07-21 10:15:21 +00:00
|
|
|
std::vector<std::string> mBlacklistedScripts;
|
2017-08-22 02:31:19 +00:00
|
|
|
|
|
|
|
boost::filesystem::path mResDir;
|
|
|
|
Fallback::Map mFallbackMap;
|
|
|
|
|
|
|
|
bool mFsStrict;
|
|
|
|
Files::PathContainer mDataPaths;
|
|
|
|
std::vector<std::string> mArchives;
|
2012-11-21 16:31:18 +00:00
|
|
|
|
|
|
|
DocumentManager (const DocumentManager&);
|
|
|
|
DocumentManager& operator= (const DocumentManager&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-09-27 13:24:58 +00:00
|
|
|
DocumentManager (const Files::ConfigurationManager& configuration);
|
2012-11-21 16:31:18 +00:00
|
|
|
|
|
|
|
~DocumentManager();
|
|
|
|
|
2014-04-21 07:02:58 +00:00
|
|
|
void addDocument (const std::vector< boost::filesystem::path >& files,
|
|
|
|
const boost::filesystem::path& savePath, bool new_);
|
|
|
|
///< \param new_ Do not load the last content file in \a files and instead create in an
|
2013-02-04 12:46:54 +00:00
|
|
|
/// appropriate way.
|
2012-11-21 16:31:18 +00:00
|
|
|
|
2015-08-16 13:24:48 +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< boost::filesystem::path >& files,
|
|
|
|
const boost::filesystem::path& savePath, bool new_);
|
|
|
|
|
2015-03-13 21:09:19 +00:00
|
|
|
void setResourceDir (const boost::filesystem::path& parResDir);
|
2014-04-21 07:02:58 +00:00
|
|
|
|
2016-01-06 11:58:36 +00:00
|
|
|
void setFallbackMap (const std::map<std::string, std::string>& fallbackMap);
|
|
|
|
|
2014-05-12 08:32:57 +00:00
|
|
|
void setEncoding (ToUTF8::FromType encoding);
|
|
|
|
|
2014-07-21 10:15:21 +00:00
|
|
|
void setBlacklistedScripts (const std::vector<std::string>& scriptIds);
|
|
|
|
|
2017-08-22 02:31:19 +00:00
|
|
|
/// 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
|
|
|
|
2015-05-29 22:37:58 +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.
|
|
|
|
|
2014-05-06 07:39:39 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void removeDocument (CSMDoc::Document *document);
|
|
|
|
///< Emits the lastDocumentDeleted signal, if applicable.
|
|
|
|
|
2015-08-16 13:24:48 +00:00
|
|
|
/// Hand over document to *this. The ownership is transferred. The DocumentManager
|
|
|
|
/// will initiate the load procedure, if necessary
|
|
|
|
void insertDocument (CSMDoc::Document *document);
|
|
|
|
|
2014-04-21 07:02:58 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void documentAdded (CSMDoc::Document *document);
|
2014-04-24 13:09:25 +00:00
|
|
|
|
2015-08-06 10:52:10 +00:00
|
|
|
void documentAboutToBeRemoved (CSMDoc::Document *document);
|
|
|
|
|
2014-04-29 12:27:44 +00:00
|
|
|
void loadRequest (CSMDoc::Document *document);
|
2014-04-26 11:11:27 +00:00
|
|
|
|
|
|
|
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);
|
2014-05-10 11:18:40 +00:00
|
|
|
|
|
|
|
void loadMessage (CSMDoc::Document *document, const std::string& message);
|
2012-11-21 16:31:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-19 16:49:41 +00:00
|
|
|
#endif
|