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

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

180 lines
4.7 KiB
C++
Raw Normal View History

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