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
|
|
|
|
2012-11-23 13:05:49 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-11-30 19:44:12 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2013-02-04 12:46:54 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
|
2012-11-22 14:54:31 +00:00
|
|
|
#include <QUndoStack>
|
2012-11-22 22:42:17 +00:00
|
|
|
#include <QObject>
|
2012-11-22 23:36:01 +00:00
|
|
|
#include <QTimer>
|
2012-11-22 14:54:31 +00:00
|
|
|
|
2014-05-12 08:32:57 +00:00
|
|
|
#include <components/to_utf8/to_utf8.hpp>
|
|
|
|
|
2012-11-26 11:29:22 +00:00
|
|
|
#include "../world/data.hpp"
|
|
|
|
|
2012-12-08 10:59:13 +00:00
|
|
|
#include "../tools/tools.hpp"
|
|
|
|
|
2012-12-08 13:44:03 +00:00
|
|
|
#include "state.hpp"
|
2013-09-15 10:48:57 +00:00
|
|
|
#include "saving.hpp"
|
2014-07-21 10:15:21 +00:00
|
|
|
#include "blacklist.hpp"
|
2014-09-02 08:21:17 +00:00
|
|
|
#include "runner.hpp"
|
2015-03-14 11:00:24 +00:00
|
|
|
#include "operationholder.hpp"
|
2012-12-08 13:44:03 +00:00
|
|
|
|
2012-12-11 14:35:47 +00:00
|
|
|
class QAbstractItemModel;
|
|
|
|
|
2013-02-17 19:03:39 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct GameSetting;
|
2013-02-23 11:51:45 +00:00
|
|
|
struct Global;
|
2014-09-27 10:38:42 +00:00
|
|
|
struct MagicEffect;
|
2013-02-17 19:03:39 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-07-04 10:46:57 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class ResourcesManager;
|
|
|
|
}
|
|
|
|
|
2014-11-30 19:44:12 +00:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
|
|
|
class PhysicsSystem;
|
|
|
|
}
|
|
|
|
|
2012-11-21 16:31:18 +00:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
2012-11-22 22:42:17 +00:00
|
|
|
class Document : public QObject
|
2012-11-21 16:31:18 +00:00
|
|
|
{
|
2012-11-22 22:42:17 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-11-26 11:29:22 +00:00
|
|
|
private:
|
|
|
|
|
2013-09-10 14:45:01 +00:00
|
|
|
boost::filesystem::path mSavePath;
|
2013-09-23 10:16:56 +00:00
|
|
|
std::vector<boost::filesystem::path> mContentFiles;
|
2014-04-29 12:27:44 +00:00
|
|
|
bool mNew;
|
2012-11-26 11:29:22 +00:00
|
|
|
CSMWorld::Data mData;
|
2012-12-08 10:59:13 +00:00
|
|
|
CSMTools::Tools mTools;
|
2013-09-27 13:24:58 +00:00
|
|
|
boost::filesystem::path mProjectPath;
|
2015-03-14 11:00:24 +00:00
|
|
|
Saving mSavingOperation;
|
|
|
|
OperationHolder mSaving;
|
2013-10-21 16:15:26 +00:00
|
|
|
boost::filesystem::path mResDir;
|
2014-07-21 10:15:21 +00:00
|
|
|
Blacklist mBlacklist;
|
2014-09-02 08:21:17 +00:00
|
|
|
Runner mRunner;
|
2014-11-30 19:44:12 +00:00
|
|
|
boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
|
2012-11-22 14:54:31 +00:00
|
|
|
|
2012-12-08 22:27:59 +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 QObject destructor, which is way too late.
|
|
|
|
QUndoStack mUndoStack;
|
|
|
|
|
2012-11-22 12:30:02 +00:00
|
|
|
// not implemented
|
2013-10-21 16:24:16 +00:00
|
|
|
Document (const Document&);
|
2012-11-21 16:31:18 +00:00
|
|
|
Document& operator= (const Document&);
|
|
|
|
|
2013-02-04 12:46:54 +00:00
|
|
|
void createBase();
|
|
|
|
|
2013-06-23 19:19:08 +00:00
|
|
|
void addGmsts();
|
2013-06-23 01:01:27 +00:00
|
|
|
|
2013-02-17 19:03:39 +00:00
|
|
|
void addOptionalGmsts();
|
|
|
|
|
2013-02-23 11:51:45 +00:00
|
|
|
void addOptionalGlobals();
|
|
|
|
|
2014-09-27 10:38:42 +00:00
|
|
|
void addOptionalMagicEffects();
|
|
|
|
|
2013-02-17 19:03:39 +00:00
|
|
|
void addOptionalGmst (const ESM::GameSetting& gmst);
|
|
|
|
|
2013-02-23 11:51:45 +00:00
|
|
|
void addOptionalGlobal (const ESM::Global& global);
|
|
|
|
|
2014-09-27 10:38:42 +00:00
|
|
|
void addOptionalMagicEffect (const ESM::MagicEffect& effect);
|
|
|
|
|
2012-11-21 16:31:18 +00:00
|
|
|
public:
|
|
|
|
|
2014-02-14 14:12:34 +00:00
|
|
|
Document (const Files::ConfigurationManager& configuration,
|
2014-04-29 12:27:44 +00:00
|
|
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
2014-05-12 08:32:57 +00:00
|
|
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
2014-07-21 10:15:21 +00:00
|
|
|
ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager,
|
|
|
|
const std::vector<std::string>& blacklistedScripts);
|
2013-09-10 14:45:01 +00:00
|
|
|
|
2013-03-12 11:28:13 +00:00
|
|
|
~Document();
|
2012-11-22 14:54:31 +00:00
|
|
|
|
|
|
|
QUndoStack& getUndoStack();
|
2012-11-22 22:42:17 +00:00
|
|
|
|
|
|
|
int getState() const;
|
|
|
|
|
2013-09-10 14:45:01 +00:00
|
|
|
const boost::filesystem::path& getSavePath() const;
|
2012-11-23 13:05:49 +00:00
|
|
|
|
2014-05-03 10:07:05 +00:00
|
|
|
const boost::filesystem::path& getProjectPath() const;
|
|
|
|
|
2013-09-23 10:16:56 +00:00
|
|
|
const std::vector<boost::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.
|
|
|
|
|
2014-04-29 12:27:44 +00:00
|
|
|
bool isNew() const;
|
|
|
|
///< Is this a newly created content file?
|
|
|
|
|
2012-11-22 23:36:01 +00:00
|
|
|
void save();
|
|
|
|
|
2012-12-11 14:35:47 +00:00
|
|
|
CSMWorld::UniversalId verify();
|
2012-11-23 12:15:45 +00:00
|
|
|
|
2015-03-17 11:30:47 +00:00
|
|
|
CSMWorld::UniversalId newSearch();
|
2015-03-27 15:33:54 +00:00
|
|
|
|
|
|
|
void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search);
|
2015-03-17 11:30:47 +00:00
|
|
|
|
2012-11-23 11:20:35 +00:00
|
|
|
void abortOperation (int type);
|
2012-11-22 23:36:01 +00:00
|
|
|
|
2012-11-26 11:29:22 +00:00
|
|
|
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.
|
|
|
|
|
2014-07-21 10:15:21 +00:00
|
|
|
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();
|
|
|
|
|
2014-11-30 19:44:12 +00:00
|
|
|
boost::shared_ptr<CSVWorld::PhysicsSystem> getPhysics();
|
|
|
|
|
2012-11-22 22:42:17 +00:00
|
|
|
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
|
|
|
|
2012-11-22 22:42:17 +00:00
|
|
|
private slots:
|
|
|
|
|
|
|
|
void modificationStateChanged (bool clean);
|
2012-11-22 23:36:01 +00:00
|
|
|
|
2014-05-08 10:42:29 +00:00
|
|
|
void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
2014-12-07 19:53:09 +00:00
|
|
|
const std::string& hint, int type);
|
2013-09-27 11:54:51 +00:00
|
|
|
|
2014-09-03 17:14:27 +00:00
|
|
|
void operationDone (int type, bool failed);
|
2012-12-08 10:59:13 +00:00
|
|
|
|
2014-09-02 09:56:35 +00:00
|
|
|
void runStateChanged();
|
|
|
|
|
2012-12-08 10:59:13 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void progress (int current, int max, int type);
|
2012-11-21 16:31:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-03-12 11:28:13 +00:00
|
|
|
#endif
|
2013-10-21 16:15:26 +00:00
|
|
|
|