forked from mirror/openmw-tes3mp
moved new flag from setupData function to Document constructor
This commit is contained in:
parent
5f1d2f72f6
commit
8dc6ad5059
9 changed files with 31 additions and 25 deletions
|
@ -2220,9 +2220,9 @@ void CSMDoc::Document::createBase()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir)
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir)
|
||||||
: mSavePath (savePath), mContentFiles (files), mTools (mData), mResDir(resDir),
|
: mSavePath (savePath), mContentFiles (files), mNew (new_), mTools (mData), mResDir(resDir),
|
||||||
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||||
(savePath.filename().string() + ".project")),
|
(savePath.filename().string() + ".project")),
|
||||||
mSaving (*this, mProjectPath)
|
mSaving (*this, mProjectPath)
|
||||||
|
@ -2260,21 +2260,21 @@ CSMDoc::Document::~Document()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::setupData (bool new_)
|
void CSMDoc::Document::setupData()
|
||||||
{
|
{
|
||||||
if (new_ && mContentFiles.size()==1)
|
if (mNew && mContentFiles.size()==1)
|
||||||
createBase();
|
createBase();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<boost::filesystem::path>::const_iterator end = mContentFiles.end();
|
std::vector<boost::filesystem::path>::const_iterator end = mContentFiles.end();
|
||||||
|
|
||||||
if (new_)
|
if (mNew)
|
||||||
--end;
|
--end;
|
||||||
|
|
||||||
load (mContentFiles.begin(), end, !new_);
|
load (mContentFiles.begin(), end, !mNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_)
|
if (mNew)
|
||||||
{
|
{
|
||||||
mData.setDescription ("");
|
mData.setDescription ("");
|
||||||
mData.setAuthor ("");
|
mData.setAuthor ("");
|
||||||
|
@ -2317,6 +2317,11 @@ const std::vector<boost::filesystem::path>& CSMDoc::Document::getContentFiles()
|
||||||
return mContentFiles;
|
return mContentFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSMDoc::Document::isNew() const
|
||||||
|
{
|
||||||
|
return mNew;
|
||||||
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::save()
|
void CSMDoc::Document::save()
|
||||||
{
|
{
|
||||||
if (mSaving.isRunning())
|
if (mSaving.isRunning())
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
boost::filesystem::path mSavePath;
|
boost::filesystem::path mSavePath;
|
||||||
std::vector<boost::filesystem::path> mContentFiles;
|
std::vector<boost::filesystem::path> mContentFiles;
|
||||||
|
bool mNew;
|
||||||
CSMWorld::Data mData;
|
CSMWorld::Data mData;
|
||||||
CSMTools::Tools mTools;
|
CSMTools::Tools mTools;
|
||||||
boost::filesystem::path mProjectPath;
|
boost::filesystem::path mProjectPath;
|
||||||
|
@ -72,12 +73,12 @@ namespace CSMDoc
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document (const Files::ConfigurationManager& configuration,
|
Document (const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir);
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir);
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
void setupData (bool new_);
|
void setupData();
|
||||||
|
|
||||||
QUndoStack& getUndoStack();
|
QUndoStack& getUndoStack();
|
||||||
|
|
||||||
|
@ -89,6 +90,9 @@ namespace CSMDoc
|
||||||
///< \attention The last element in this collection is the file that is being edited,
|
///< \attention The last element in this collection is the file that is being edited,
|
||||||
/// but with its original path instead of the save path.
|
/// but with its original path instead of the save path.
|
||||||
|
|
||||||
|
bool isNew() const;
|
||||||
|
///< Is this a newly created content file?
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
CSMWorld::UniversalId verify();
|
CSMWorld::UniversalId verify();
|
||||||
|
|
|
@ -27,8 +27,8 @@ CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& con
|
||||||
this, SLOT (documentLoaded (Document *)));
|
this, SLOT (documentLoaded (Document *)));
|
||||||
connect (&mLoader, SIGNAL (documentNotLoaded (Document *, const std::string&)),
|
connect (&mLoader, SIGNAL (documentNotLoaded (Document *, const std::string&)),
|
||||||
this, SLOT (documentNotLoaded (Document *, const std::string&)));
|
this, SLOT (documentNotLoaded (Document *, const std::string&)));
|
||||||
connect (this, SIGNAL (loadRequest (CSMDoc::Document *, bool)),
|
connect (this, SIGNAL (loadRequest (CSMDoc::Document *)),
|
||||||
&mLoader, SLOT (loadDocument (CSMDoc::Document *, bool)));
|
&mLoader, SLOT (loadDocument (CSMDoc::Document *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::DocumentManager::~DocumentManager()
|
CSMDoc::DocumentManager::~DocumentManager()
|
||||||
|
@ -44,11 +44,11 @@ CSMDoc::DocumentManager::~DocumentManager()
|
||||||
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
||||||
bool new_)
|
bool new_)
|
||||||
{
|
{
|
||||||
Document *document = new Document (mConfiguration, files, savePath, mResDir);
|
Document *document = new Document (mConfiguration, files, new_, savePath, mResDir);
|
||||||
|
|
||||||
mDocuments.push_back (document);
|
mDocuments.push_back (document);
|
||||||
|
|
||||||
emit loadRequest (document, new_);
|
emit loadRequest (document);
|
||||||
|
|
||||||
mLoader.hasThingsToDo().wakeAll();
|
mLoader.hasThingsToDo().wakeAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
void documentAdded (CSMDoc::Document *document);
|
void documentAdded (CSMDoc::Document *document);
|
||||||
|
|
||||||
void loadRequest (CSMDoc::Document *document, bool _new);
|
void loadRequest (CSMDoc::Document *document);
|
||||||
|
|
||||||
void lastDocumentDeleted();
|
void lastDocumentDeleted();
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,12 @@ void CSMDoc::Loader::load()
|
||||||
std::vector<std::pair<Document *, bool> >::iterator iter = mDocuments.begin();
|
std::vector<std::pair<Document *, bool> >::iterator iter = mDocuments.begin();
|
||||||
|
|
||||||
Document *document = iter->first;
|
Document *document = iter->first;
|
||||||
bool new_ = iter->second;
|
|
||||||
|
|
||||||
mDocuments.erase (iter);
|
mDocuments.erase (iter);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
document->setupData (new_);
|
document->setupData();
|
||||||
emit documentLoaded (document);
|
emit documentLoaded (document);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
@ -46,9 +45,9 @@ void CSMDoc::Loader::load()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Loader::loadDocument (CSMDoc::Document *document, bool new_)
|
void CSMDoc::Loader::loadDocument (CSMDoc::Document *document)
|
||||||
{
|
{
|
||||||
mDocuments.push_back (std::make_pair (document, new_));
|
mDocuments.push_back (std::make_pair (document, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Loader::abortLoading (Document *document)
|
void CSMDoc::Loader::abortLoading (Document *document)
|
||||||
|
|
|
@ -31,10 +31,8 @@ namespace CSMDoc
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void loadDocument (CSMDoc::Document *document, bool new_);
|
void loadDocument (CSMDoc::Document *document);
|
||||||
///< The ownership of \a document is not transferred.
|
///< The ownership of \a document is not transferred.
|
||||||
/// \param new_ Do not load the last content file in the files list specified in
|
|
||||||
/// \a document and instead create it in an appropriate way.
|
|
||||||
|
|
||||||
void abortLoading (Document *document);
|
void abortLoading (Document *document);
|
||||||
///< Abort loading \a docuemnt (ignored if \a document has already finished being
|
///< Abort loading \a docuemnt (ignored if \a document has already finished being
|
||||||
|
|
|
@ -22,7 +22,7 @@ CSVDoc::Loader::~Loader()
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::Loader::add (CSMDoc::Document *document, bool new_)
|
void CSVDoc::Loader::add (CSMDoc::Document *document)
|
||||||
{
|
{
|
||||||
mDocuments.insert (std::make_pair (document, new LoadingDocument (document)));
|
mDocuments.insert (std::make_pair (document, new LoadingDocument (document)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace CSVDoc
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void add (CSMDoc::Document *document, bool new_);
|
void add (CSMDoc::Document *document);
|
||||||
|
|
||||||
void loadingStopped (CSMDoc::Document *document, bool completed,
|
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||||
const std::string& error);
|
const std::string& error);
|
||||||
|
|
|
@ -87,8 +87,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
||||||
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
||||||
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
||||||
|
|
||||||
connect (&mDocumentManager, SIGNAL (loadRequest (CSMDoc::Document *, bool)),
|
connect (&mDocumentManager, SIGNAL (loadRequest (CSMDoc::Document *)),
|
||||||
&mLoader, SLOT (add (CSMDoc::Document *, bool)));
|
&mLoader, SLOT (add (CSMDoc::Document *)));
|
||||||
|
|
||||||
connect (
|
connect (
|
||||||
&mDocumentManager, SIGNAL (loadingStopped (CSMDoc::Document *, bool, const std::string&)),
|
&mDocumentManager, SIGNAL (loadingStopped (CSMDoc::Document *, bool, const std::string&)),
|
||||||
|
|
Loading…
Reference in a new issue