OpenMW
apps/opencs/model/doc/document.hpp
Go to the documentation of this file.
00001 #ifndef CSM_DOC_DOCUMENT_H
00002 #define CSM_DOC_DOCUMENT_H
00003 
00004 #include <string>
00005 
00006 #include <boost/filesystem/path.hpp>
00007 
00008 #include <QUndoStack>
00009 #include <QObject>
00010 #include <QTimer>
00011 
00012 #include "../world/data.hpp"
00013 
00014 #include "../tools/tools.hpp"
00015 
00016 #include "state.hpp"
00017 #include "saving.hpp"
00018 
00019 class QAbstractItemModel;
00020 
00021 namespace ESM
00022 {
00023     struct GameSetting;
00024     struct Global;
00025 }
00026 
00027 namespace Files
00028 {
00029     class ConfigurationManager;
00030 }
00031 
00032 namespace CSMDoc
00033 {
00034     class Document : public QObject
00035     {
00036             Q_OBJECT
00037 
00038         private:
00039 
00040             boost::filesystem::path mSavePath;
00041             std::vector<boost::filesystem::path> mContentFiles;
00042             CSMWorld::Data mData;
00043             CSMTools::Tools mTools;
00044             boost::filesystem::path mProjectPath;
00045             Saving mSaving;
00046             boost::filesystem::path mResDir;
00047 
00048             // 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
00049             // using other member variables.  Unfortunately this connection is cut only in the QObject destructor, which is way too late.
00050             QUndoStack mUndoStack;
00051 
00052             // not implemented
00053             Document (const Document&);
00054             Document& operator= (const Document&);
00055 
00056             void load (const std::vector<boost::filesystem::path>::const_iterator& begin,
00057                 const std::vector<boost::filesystem::path>::const_iterator& end, bool lastAsModified);
00059 
00060             void createBase();
00061 
00062             void addGmsts();
00063 
00064             void addOptionalGmsts();
00065 
00066             void addOptionalGlobals();
00067 
00068             void addOptionalGmst (const ESM::GameSetting& gmst);
00069 
00070             void addOptionalGlobal (const ESM::Global& global);
00071 
00072         public:
00073 
00074             Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, bool new_);
00075 
00076             ~Document();
00077 
00078             QUndoStack& getUndoStack();
00079 
00080             int getState() const;
00081 
00082             const boost::filesystem::path& getSavePath() const;
00083 
00084             const std::vector<boost::filesystem::path>& getContentFiles() const;
00087 
00088             void save();
00089 
00090             CSMWorld::UniversalId verify();
00091 
00092             void abortOperation (int type);
00093 
00094             const CSMWorld::Data& getData() const;
00095 
00096             CSMWorld::Data& getData();
00097 
00098             CSMTools::ReportModel *getReport (const CSMWorld::UniversalId& id);
00100 
00101         signals:
00102 
00103             void stateChanged (int state, CSMDoc::Document *document);
00104 
00105             void progress (int current, int max, int type, int threads, CSMDoc::Document *document);
00106 
00107         private slots:
00108 
00109             void modificationStateChanged (bool clean);
00110 
00111             void reportMessage (const QString& message, int type);
00112 
00113             void operationDone (int type);
00114 
00115         public slots:
00116 
00117             void progress (int current, int max, int type);
00118     };
00119 }
00120 
00121 #endif
00122