forked from teamnwah/openmw-tes3coop
giving Documents direct access to ConfigurationManager
This commit is contained in:
parent
e7c48cbe58
commit
6143ec33e0
5 changed files with 41 additions and 24 deletions
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
|
|
||||||
CS::Editor::Editor()
|
CS::Editor::Editor()
|
||||||
: mDocumentManager (mCfgMgr.getUserPath() / "projects"), mViewManager (mDocumentManager)
|
: mDocumentManager (mCfgMgr), mViewManager (mDocumentManager)
|
||||||
{
|
{
|
||||||
mIpcServerName = "org.openmw.OpenCS";
|
mIpcServerName = "org.openmw.OpenCS";
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#ifndef Q_MOC_RUN
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
void CSMDoc::Document::load (const std::vector<boost::filesystem::path>::const_iterator& begin,
|
void CSMDoc::Document::load (const std::vector<boost::filesystem::path>::const_iterator& begin,
|
||||||
const std::vector<boost::filesystem::path>::const_iterator& end, bool lastAsModified)
|
const std::vector<boost::filesystem::path>::const_iterator& end, bool lastAsModified)
|
||||||
{
|
{
|
||||||
|
@ -2142,10 +2146,13 @@ void CSMDoc::Document::createBase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document::Document (const std::vector<boost::filesystem::path>& files,
|
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
||||||
const boost::filesystem::path& savePath, bool new_,
|
const std::vector<boost::filesystem::path>& files,
|
||||||
const boost::filesystem::path& projectPath)
|
const boost::filesystem::path& savePath, bool new_)
|
||||||
: mSavePath (savePath), mContentFiles (files), mTools (mData), mSaving (*this, projectPath)
|
: mSavePath (savePath), mContentFiles (files), mTools (mData),
|
||||||
|
mProjectPath ((configuration.getUserPath() / "projects") /
|
||||||
|
(savePath.filename().string() + ".project")),
|
||||||
|
mSaving (*this, mProjectPath)
|
||||||
{
|
{
|
||||||
if (files.empty())
|
if (files.empty())
|
||||||
throw std::runtime_error ("Empty content file sequence");
|
throw std::runtime_error ("Empty content file sequence");
|
||||||
|
@ -2170,9 +2177,9 @@ CSMDoc::Document::Document (const std::vector<boost::filesystem::path>& files,
|
||||||
/// \todo un-outcomment the else, once loading an existing content file works properly again.
|
/// \todo un-outcomment the else, once loading an existing content file works properly again.
|
||||||
// else
|
// else
|
||||||
{
|
{
|
||||||
if (boost::filesystem::exists (projectPath))
|
if (boost::filesystem::exists (mProjectPath))
|
||||||
{
|
{
|
||||||
getData().loadFile (projectPath, false, true);
|
getData().loadFile (mProjectPath, false, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,11 @@ namespace ESM
|
||||||
struct Global;
|
struct Global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Files
|
||||||
|
{
|
||||||
|
class ConfigurationManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Document : public QObject
|
class Document : public QObject
|
||||||
|
@ -36,6 +41,7 @@ namespace CSMDoc
|
||||||
std::vector<boost::filesystem::path> mContentFiles;
|
std::vector<boost::filesystem::path> mContentFiles;
|
||||||
CSMWorld::Data mData;
|
CSMWorld::Data mData;
|
||||||
CSMTools::Tools mTools;
|
CSMTools::Tools mTools;
|
||||||
|
boost::filesystem::path mProjectPath;
|
||||||
Saving mSaving;
|
Saving mSaving;
|
||||||
|
|
||||||
// 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
|
// 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
|
||||||
|
@ -64,11 +70,9 @@ namespace CSMDoc
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document (const std::vector<boost::filesystem::path>& files,
|
Document (const Files::ConfigurationManager& configuration,
|
||||||
const boost::filesystem::path& savePath, bool new_,
|
const std::vector<boost::filesystem::path>& files,
|
||||||
const boost::filesystem::path& projectPath);
|
const boost::filesystem::path& savePath, bool new_);
|
||||||
///< \param projectPath Location of file that can be used to store additional data for
|
|
||||||
/// this project.
|
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,19 @@
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#ifndef Q_MOC_RUN
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::DocumentManager::DocumentManager (const boost::filesystem::path& projectPath)
|
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
||||||
: mProjectPath (projectPath)
|
: mConfiguration (configuration)
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory (mProjectPath))
|
boost::filesystem::path projectPath = configuration.getUserPath() / "projects";
|
||||||
boost::filesystem::create_directories (mProjectPath);
|
|
||||||
|
if (!boost::filesystem::is_directory (projectPath))
|
||||||
|
boost::filesystem::create_directories (projectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::DocumentManager::~DocumentManager()
|
CSMDoc::DocumentManager::~DocumentManager()
|
||||||
|
@ -24,11 +30,7 @@ CSMDoc::DocumentManager::~DocumentManager()
|
||||||
CSMDoc::Document *CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
CSMDoc::Document *CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
||||||
bool new_)
|
bool new_)
|
||||||
{
|
{
|
||||||
boost::filesystem::path projectFile (mProjectPath);
|
Document *document = new Document (mConfiguration, files, savePath, new_);
|
||||||
|
|
||||||
projectFile /= savePath.filename().string() + ".project";
|
|
||||||
|
|
||||||
Document *document = new Document (files, savePath, new_, projectFile);
|
|
||||||
|
|
||||||
mDocuments.push_back (document);
|
mDocuments.push_back (document);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
namespace Files
|
||||||
|
{
|
||||||
|
class ConfigurationManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Document;
|
class Document;
|
||||||
|
@ -13,15 +18,14 @@ namespace CSMDoc
|
||||||
class DocumentManager
|
class DocumentManager
|
||||||
{
|
{
|
||||||
std::vector<Document *> mDocuments;
|
std::vector<Document *> mDocuments;
|
||||||
boost::filesystem::path mProjectPath;
|
const Files::ConfigurationManager& mConfiguration;
|
||||||
|
|
||||||
DocumentManager (const DocumentManager&);
|
DocumentManager (const DocumentManager&);
|
||||||
DocumentManager& operator= (const DocumentManager&);
|
DocumentManager& operator= (const DocumentManager&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DocumentManager (const boost::filesystem::path& projectPath);
|
DocumentManager (const Files::ConfigurationManager& configuration);
|
||||||
///< \param projectPath Directory where additional per-project data will be stored.
|
|
||||||
|
|
||||||
~DocumentManager();
|
~DocumentManager();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue