2012-11-22 13:30:02 +01:00
|
|
|
#ifndef CSM_DOC_DOCUMENT_H
|
|
|
|
#define CSM_DOC_DOCUMENT_H
|
2012-11-21 17:31:18 +01:00
|
|
|
|
2012-11-22 23:42:17 +01:00
|
|
|
#include <QObject>
|
2012-11-22 15:54:31 +01:00
|
|
|
#include <QUndoStack>
|
|
|
|
|
2022-10-19 19:02:00 +02:00
|
|
|
#include <filesystem>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <apps/opencs/model/world/universalid.hpp>
|
|
|
|
|
2017-08-21 22:31:19 -04:00
|
|
|
#include <components/files/multidircollection.hpp>
|
2014-05-12 10:32:57 +02:00
|
|
|
#include <components/to_utf8/to_utf8.hpp>
|
|
|
|
|
2012-11-26 12:29:22 +01:00
|
|
|
#include "../world/data.hpp"
|
2015-05-30 15:40:23 +03:00
|
|
|
#include "../world/idcompletionmanager.hpp"
|
2012-11-26 12:29:22 +01:00
|
|
|
|
2012-12-08 11:59:13 +01:00
|
|
|
#include "../tools/tools.hpp"
|
|
|
|
|
2014-07-21 12:15:21 +02:00
|
|
|
#include "blacklist.hpp"
|
2015-03-14 12:00:24 +01:00
|
|
|
#include "operationholder.hpp"
|
2014-09-02 10:21:17 +02:00
|
|
|
#include "runner.hpp"
|
2013-09-15 12:48:57 +02:00
|
|
|
#include "saving.hpp"
|
2012-12-08 14:44:03 +01:00
|
|
|
|
2022-10-09 10:39:43 +00:00
|
|
|
class QTextDocument;
|
2012-12-11 15:35:47 +01:00
|
|
|
|
2022-10-09 10:39:43 +00:00
|
|
|
namespace CSMTools
|
2015-03-20 00:39:24 +01:00
|
|
|
{
|
2022-10-09 10:39:43 +00:00
|
|
|
class ReportModel;
|
|
|
|
class Search;
|
2015-03-20 00:39:24 +01:00
|
|
|
}
|
|
|
|
|
2013-02-17 20:03:39 +01:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct GameSetting;
|
2013-02-23 12:51:45 +01:00
|
|
|
struct Global;
|
2014-09-27 12:38:42 +02:00
|
|
|
struct MagicEffect;
|
2013-02-17 20:03:39 +01:00
|
|
|
}
|
|
|
|
|
2013-09-27 15:24:58 +02:00
|
|
|
namespace Files
|
|
|
|
{
|
2015-03-14 08:09:19 +11:00
|
|
|
struct ConfigurationManager;
|
2013-09-27 15:24:58 +02:00
|
|
|
}
|
|
|
|
|
2012-11-21 17:31:18 +01:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
2022-10-09 10:39:43 +00:00
|
|
|
struct Message;
|
2012-11-22 23:42:17 +01:00
|
|
|
class Document : public QObject
|
2012-11-21 17:31:18 +01:00
|
|
|
{
|
2012-11-22 23:42:17 +01:00
|
|
|
Q_OBJECT
|
2012-11-22 15:54:31 +01:00
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
private:
|
2022-06-08 23:25:50 +02:00
|
|
|
std::filesystem::path mSavePath;
|
2015-05-30 15:40:23 +03:00
|
|
|
std::vector<std::filesystem::path> mContentFiles;
|
2014-04-29 14:27:44 +02:00
|
|
|
bool mNew;
|
2015-05-30 15:40:23 +03:00
|
|
|
CSMWorld::Data mData;
|
2012-12-08 11:59:13 +01:00
|
|
|
CSMTools::Tools mTools;
|
2015-05-30 15:40:23 +03:00
|
|
|
std::filesystem::path mProjectPath;
|
|
|
|
Saving mSavingOperation;
|
|
|
|
OperationHolder mSaving;
|
|
|
|
std::filesystem::path mResDir;
|
2014-07-21 12:15:21 +02:00
|
|
|
Blacklist mBlacklist;
|
2014-09-02 10:21:17 +02:00
|
|
|
Runner mRunner;
|
2015-08-23 12:37:45 +02:00
|
|
|
bool mDirty;
|
2012-11-22 15:54:31 +01:00
|
|
|
|
2012-12-08 23:27:59 +01:00
|
|
|
CSMWorld::IdCompletionManager mIdCompletionManager;
|
|
|
|
|
2012-11-22 13:30:02 +01:00
|
|
|
// It is important that the undo stack is declared last, because on desctruction it fires a signal, that is
|
|
|
|
// connected to a slot, that is using other member variables. Unfortunately this connection is cut only in the
|
2012-11-21 17:31:18 +01:00
|
|
|
// QObject destructor, which is way too late.
|
|
|
|
QUndoStack mUndoStack;
|
|
|
|
|
2013-02-04 13:46:54 +01:00
|
|
|
// not implemented
|
2013-10-21 18:24:16 +02:00
|
|
|
Document(const Document&);
|
2013-02-04 13:46:54 +01:00
|
|
|
Document& operator=(const Document&);
|
|
|
|
|
2013-06-23 15:19:08 -04:00
|
|
|
void createBase();
|
2013-06-22 21:01:27 -04:00
|
|
|
|
2013-02-17 20:03:39 +01:00
|
|
|
void addGmsts();
|
|
|
|
|
2013-02-23 12:51:45 +01:00
|
|
|
void addOptionalGmsts();
|
|
|
|
|
2014-09-27 12:38:42 +02:00
|
|
|
void addOptionalGlobals();
|
|
|
|
|
2013-02-17 20:03:39 +01:00
|
|
|
void addOptionalMagicEffects();
|
|
|
|
|
2013-02-23 12:51:45 +01:00
|
|
|
void addOptionalGmst(const ESM::GameSetting& gmst);
|
|
|
|
|
2014-09-27 12:38:42 +02:00
|
|
|
void addOptionalGlobal(const ESM::Global& global);
|
|
|
|
|
2012-11-21 17:31:18 +01:00
|
|
|
void addOptionalMagicEffect(const ESM::MagicEffect& effect);
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
public:
|
2017-08-21 22:31:19 -04:00
|
|
|
Document(const Files::ConfigurationManager& configuration, std::vector<std::filesystem::path> files, bool new_,
|
2022-06-08 23:25:50 +02:00
|
|
|
const std::filesystem::path& savePath, const std::filesystem::path& resDir, ToUTF8::FromType encoding,
|
2023-05-31 23:11:03 +02:00
|
|
|
const std::vector<std::string>& blacklistedScripts, const Files::PathContainer& dataPaths,
|
2017-08-21 22:31:19 -04:00
|
|
|
const std::vector<std::string>& archives);
|
2013-09-10 16:45:01 +02:00
|
|
|
|
2023-05-29 13:37:19 +02:00
|
|
|
~Document() override = default;
|
2012-11-22 15:54:31 +01:00
|
|
|
|
|
|
|
QUndoStack& getUndoStack();
|
2012-11-22 23:42:17 +01:00
|
|
|
|
|
|
|
int getState() const;
|
|
|
|
|
2022-06-08 23:25:50 +02:00
|
|
|
const std::filesystem::path& getResourceDir() const;
|
2018-12-21 16:17:09 +04:00
|
|
|
|
2022-06-08 23:25:50 +02:00
|
|
|
const std::filesystem::path& getSavePath() const;
|
2012-11-23 14:05:49 +01:00
|
|
|
|
2022-06-08 23:25:50 +02:00
|
|
|
const std::filesystem::path& getProjectPath() const;
|
2014-05-03 12:07:05 +02:00
|
|
|
|
2022-06-08 23:25:50 +02:00
|
|
|
const std::vector<std::filesystem::path>& getContentFiles() const;
|
2013-09-23 12:16:56 +02:00
|
|
|
///< \attention The last element in this collection is the file that is being edited,
|
|
|
|
/// but with its original path instead of the save path.
|
|
|
|
|
2014-04-29 14:27:44 +02:00
|
|
|
bool isNew() const;
|
|
|
|
///< Is this a newly created content file?
|
|
|
|
|
2012-11-23 00:36:01 +01:00
|
|
|
void save();
|
|
|
|
|
2015-06-25 12:03:40 +02:00
|
|
|
CSMWorld::UniversalId verify(const CSMWorld::UniversalId& reportId = CSMWorld::UniversalId());
|
2012-11-23 13:15:45 +01:00
|
|
|
|
2015-03-17 12:30:47 +01:00
|
|
|
CSMWorld::UniversalId newSearch();
|
2015-03-27 16:33:54 +01:00
|
|
|
|
|
|
|
void runSearch(const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);
|
2015-08-13 12:03:20 +02:00
|
|
|
|
2017-04-28 17:30:26 +02:00
|
|
|
void runMerge(std::unique_ptr<CSMDoc::Document> target);
|
2015-08-13 12:03:20 +02:00
|
|
|
|
2012-11-23 12:20:35 +01:00
|
|
|
void abortOperation(int type);
|
2012-11-23 00:36:01 +01:00
|
|
|
|
2012-11-26 12:29:22 +01:00
|
|
|
const CSMWorld::Data& getData() const;
|
|
|
|
|
|
|
|
CSMWorld::Data& getData();
|
|
|
|
|
2012-12-11 15:35:47 +01:00
|
|
|
CSMTools::ReportModel* getReport(const CSMWorld::UniversalId& id);
|
|
|
|
///< The ownership of the returned report is not transferred.
|
|
|
|
|
2014-07-21 12:15:21 +02:00
|
|
|
bool isBlacklisted(const CSMWorld::UniversalId& id) const;
|
|
|
|
|
2014-09-02 10:21:17 +02:00
|
|
|
void startRunning(const std::string& profile, const std::string& startupInstruction = "");
|
|
|
|
|
|
|
|
void stopRunning();
|
|
|
|
|
2014-09-05 13:49:34 +02:00
|
|
|
QTextDocument* getRunLog();
|
|
|
|
|
2015-05-30 15:40:23 +03:00
|
|
|
CSMWorld::IdCompletionManager& getIdCompletionManager();
|
|
|
|
|
2015-08-23 12:37:45 +02:00
|
|
|
void flagAsDirty();
|
|
|
|
|
2012-11-22 23:42:17 +01:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void stateChanged(int state, CSMDoc::Document* document);
|
|
|
|
|
2012-11-23 12:20:35 +01:00
|
|
|
void progress(int current, int max, int type, int threads, CSMDoc::Document* document);
|
2012-11-23 10:25:34 +01:00
|
|
|
|
2015-08-16 15:24:48 +02:00
|
|
|
/// \attention When this signal is emitted, *this hands over the ownership of the
|
|
|
|
/// document. This signal must be handled to avoid a leak.
|
|
|
|
void mergeDone(CSMDoc::Document* document);
|
|
|
|
|
2018-06-13 15:48:24 +02:00
|
|
|
void operationDone(int type, bool failed);
|
|
|
|
|
2012-11-22 23:42:17 +01:00
|
|
|
private slots:
|
|
|
|
|
|
|
|
void modificationStateChanged(bool clean);
|
2012-11-23 00:36:01 +01:00
|
|
|
|
2015-06-20 17:56:42 +02:00
|
|
|
void reportMessage(const CSMDoc::Message& message, int type);
|
2013-09-27 13:54:51 +02:00
|
|
|
|
2018-06-13 15:48:24 +02:00
|
|
|
void operationDone2(int type, bool failed);
|
2012-12-08 11:59:13 +01:00
|
|
|
|
2014-09-02 11:56:35 +02:00
|
|
|
void runStateChanged();
|
|
|
|
|
2012-12-08 11:59:13 +01:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void progress(int current, int max, int type);
|
2012-11-21 17:31:18 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-03-12 06:28:13 -05:00
|
|
|
#endif
|