mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
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,
|
||||
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)
|
||||
: mSavePath (savePath), mContentFiles (files), mTools (mData), mResDir(resDir),
|
||||
: mSavePath (savePath), mContentFiles (files), mNew (new_), mTools (mData), mResDir(resDir),
|
||||
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||
(savePath.filename().string() + ".project")),
|
||||
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();
|
||||
else
|
||||
{
|
||||
std::vector<boost::filesystem::path>::const_iterator end = mContentFiles.end();
|
||||
|
||||
if (new_)
|
||||
if (mNew)
|
||||
--end;
|
||||
|
||||
load (mContentFiles.begin(), end, !new_);
|
||||
load (mContentFiles.begin(), end, !mNew);
|
||||
}
|
||||
|
||||
if (new_)
|
||||
if (mNew)
|
||||
{
|
||||
mData.setDescription ("");
|
||||
mData.setAuthor ("");
|
||||
|
@ -2317,6 +2317,11 @@ const std::vector<boost::filesystem::path>& CSMDoc::Document::getContentFiles()
|
|||
return mContentFiles;
|
||||
}
|
||||
|
||||
bool CSMDoc::Document::isNew() const
|
||||
{
|
||||
return mNew;
|
||||
}
|
||||
|
||||
void CSMDoc::Document::save()
|
||||
{
|
||||
if (mSaving.isRunning())
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace CSMDoc
|
|||
|
||||
boost::filesystem::path mSavePath;
|
||||
std::vector<boost::filesystem::path> mContentFiles;
|
||||
bool mNew;
|
||||
CSMWorld::Data mData;
|
||||
CSMTools::Tools mTools;
|
||||
boost::filesystem::path mProjectPath;
|
||||
|
@ -72,12 +73,12 @@ namespace CSMDoc
|
|||
public:
|
||||
|
||||
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);
|
||||
|
||||
~Document();
|
||||
|
||||
void setupData (bool new_);
|
||||
void setupData();
|
||||
|
||||
QUndoStack& getUndoStack();
|
||||
|
||||
|
@ -89,6 +90,9 @@ namespace CSMDoc
|
|||
///< \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();
|
||||
|
|
|
@ -27,8 +27,8 @@ CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& con
|
|||
this, SLOT (documentLoaded (Document *)));
|
||||
connect (&mLoader, SIGNAL (documentNotLoaded (Document *, const std::string&)),
|
||||
this, SLOT (documentNotLoaded (Document *, const std::string&)));
|
||||
connect (this, SIGNAL (loadRequest (CSMDoc::Document *, bool)),
|
||||
&mLoader, SLOT (loadDocument (CSMDoc::Document *, bool)));
|
||||
connect (this, SIGNAL (loadRequest (CSMDoc::Document *)),
|
||||
&mLoader, SLOT (loadDocument (CSMDoc::Document *)));
|
||||
}
|
||||
|
||||
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,
|
||||
bool new_)
|
||||
{
|
||||
Document *document = new Document (mConfiguration, files, savePath, mResDir);
|
||||
Document *document = new Document (mConfiguration, files, new_, savePath, mResDir);
|
||||
|
||||
mDocuments.push_back (document);
|
||||
|
||||
emit loadRequest (document, new_);
|
||||
emit loadRequest (document);
|
||||
|
||||
mLoader.hasThingsToDo().wakeAll();
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace CSMDoc
|
|||
|
||||
void documentAdded (CSMDoc::Document *document);
|
||||
|
||||
void loadRequest (CSMDoc::Document *document, bool _new);
|
||||
void loadRequest (CSMDoc::Document *document);
|
||||
|
||||
void lastDocumentDeleted();
|
||||
|
||||
|
|
|
@ -31,13 +31,12 @@ void CSMDoc::Loader::load()
|
|||
std::vector<std::pair<Document *, bool> >::iterator iter = mDocuments.begin();
|
||||
|
||||
Document *document = iter->first;
|
||||
bool new_ = iter->second;
|
||||
|
||||
mDocuments.erase (iter);
|
||||
|
||||
try
|
||||
{
|
||||
document->setupData (new_);
|
||||
document->setupData();
|
||||
emit documentLoaded (document);
|
||||
}
|
||||
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)
|
||||
|
|
|
@ -31,10 +31,8 @@ namespace CSMDoc
|
|||
|
||||
public slots:
|
||||
|
||||
void loadDocument (CSMDoc::Document *document, bool new_);
|
||||
void loadDocument (CSMDoc::Document *document);
|
||||
///< 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);
|
||||
///< Abort loading \a docuemnt (ignored if \a document has already finished being
|
||||
|
|
|
@ -22,7 +22,7 @@ CSVDoc::Loader::~Loader()
|
|||
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)));
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace CSVDoc
|
|||
|
||||
public slots:
|
||||
|
||||
void add (CSMDoc::Document *document, bool new_);
|
||||
void add (CSMDoc::Document *document);
|
||||
|
||||
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||
const std::string& error);
|
||||
|
|
|
@ -87,8 +87,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
||||
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
||||
|
||||
connect (&mDocumentManager, SIGNAL (loadRequest (CSMDoc::Document *, bool)),
|
||||
&mLoader, SLOT (add (CSMDoc::Document *, bool)));
|
||||
connect (&mDocumentManager, SIGNAL (loadRequest (CSMDoc::Document *)),
|
||||
&mLoader, SLOT (add (CSMDoc::Document *)));
|
||||
|
||||
connect (
|
||||
&mDocumentManager, SIGNAL (loadingStopped (CSMDoc::Document *, bool, const std::string&)),
|
||||
|
|
Loading…
Reference in a new issue