mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
replaced return value of DocumentManager::addDocument with a signal
This commit is contained in:
parent
86bd2f48dc
commit
e324450118
@ -5,11 +5,11 @@ opencs_units (. editor)
|
|||||||
set (CMAKE_BUILD_TYPE DEBUG)
|
set (CMAKE_BUILD_TYPE DEBUG)
|
||||||
|
|
||||||
opencs_units (model/doc
|
opencs_units (model/doc
|
||||||
document operation saving
|
document operation saving documentmanager
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (model/doc
|
opencs_units_noqt (model/doc
|
||||||
documentmanager stage savingstate savingstages
|
stage savingstate savingstages
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_hdrs_noqt (model/doc
|
opencs_hdrs_noqt (model/doc
|
||||||
|
@ -37,6 +37,9 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
|
|||||||
mNewGame.setLocalData (mLocal);
|
mNewGame.setLocalData (mLocal);
|
||||||
mFileDialog.setLocalData (mLocal);
|
mFileDialog.setLocalData (mLocal);
|
||||||
|
|
||||||
|
connect (&mDocumentManager, SIGNAL (documentAdded (CSMDoc::Document *)),
|
||||||
|
this, SLOT (documentAdded (CSMDoc::Document *)));
|
||||||
|
|
||||||
connect (&mViewManager, SIGNAL (newGameRequest ()), this, SLOT (createGame ()));
|
connect (&mViewManager, SIGNAL (newGameRequest ()), this, SLOT (createGame ()));
|
||||||
connect (&mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ()));
|
connect (&mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ()));
|
||||||
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
||||||
@ -150,9 +153,8 @@ void CS::Editor::openFiles (const boost::filesystem::path &savePath)
|
|||||||
foreach (const QString &path, mFileDialog.selectedFilePaths())
|
foreach (const QString &path, mFileDialog.selectedFilePaths())
|
||||||
files.push_back(path.toUtf8().constData());
|
files.push_back(path.toUtf8().constData());
|
||||||
|
|
||||||
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, false);
|
mDocumentManager.addDocument (files, savePath, false);
|
||||||
|
|
||||||
mViewManager.addView (document);
|
|
||||||
mFileDialog.hide();
|
mFileDialog.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +168,8 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
|
|||||||
|
|
||||||
files.push_back(mFileDialog.filename().toUtf8().constData());
|
files.push_back(mFileDialog.filename().toUtf8().constData());
|
||||||
|
|
||||||
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, true);
|
mDocumentManager.addDocument (files, savePath, true);
|
||||||
|
|
||||||
mViewManager.addView (document);
|
|
||||||
mFileDialog.hide();
|
mFileDialog.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,9 +179,7 @@ void CS::Editor::createNewGame (const boost::filesystem::path& file)
|
|||||||
|
|
||||||
files.push_back (file);
|
files.push_back (file);
|
||||||
|
|
||||||
CSMDoc::Document *document = mDocumentManager.addDocument (files, file, true);
|
mDocumentManager.addDocument (files, file, true);
|
||||||
|
|
||||||
mViewManager.addView (document);
|
|
||||||
|
|
||||||
mNewGame.hide();
|
mNewGame.hide();
|
||||||
}
|
}
|
||||||
@ -287,3 +286,8 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
|
|||||||
|
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CS::Editor::documentAdded (CSMDoc::Document *document)
|
||||||
|
{
|
||||||
|
mViewManager.addView (document);
|
||||||
|
}
|
@ -85,6 +85,8 @@ namespace CS
|
|||||||
|
|
||||||
void showSettings();
|
void showSettings();
|
||||||
|
|
||||||
|
void documentAdded (CSMDoc::Document *document);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString mIpcServerName;
|
QString mIpcServerName;
|
||||||
|
@ -27,14 +27,14 @@ CSMDoc::DocumentManager::~DocumentManager()
|
|||||||
delete *iter;
|
delete *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document *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, new_);
|
Document *document = new Document (mConfiguration, files, savePath, mResDir, new_);
|
||||||
|
|
||||||
mDocuments.push_back (document);
|
mDocuments.push_back (document);
|
||||||
|
|
||||||
return document;
|
emit documentAdded (document);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSMDoc::DocumentManager::removeDocument (Document *document)
|
bool CSMDoc::DocumentManager::removeDocument (Document *document)
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
namespace Files
|
namespace Files
|
||||||
{
|
{
|
||||||
class ConfigurationManager;
|
class ConfigurationManager;
|
||||||
@ -15,8 +17,10 @@ namespace CSMDoc
|
|||||||
{
|
{
|
||||||
class Document;
|
class Document;
|
||||||
|
|
||||||
class DocumentManager
|
class DocumentManager : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
std::vector<Document *> mDocuments;
|
std::vector<Document *> mDocuments;
|
||||||
const Files::ConfigurationManager& mConfiguration;
|
const Files::ConfigurationManager& mConfiguration;
|
||||||
|
|
||||||
@ -29,20 +33,23 @@ namespace CSMDoc
|
|||||||
|
|
||||||
~DocumentManager();
|
~DocumentManager();
|
||||||
|
|
||||||
Document *addDocument (const std::vector< boost::filesystem::path >& files,
|
void addDocument (const std::vector< boost::filesystem::path >& files,
|
||||||
const boost::filesystem::path& savePath,
|
const boost::filesystem::path& savePath, bool new_);
|
||||||
bool new_);
|
///< \param new_ Do not load the last content file in \a files and instead create in an
|
||||||
///< The ownership of the returned document is not transferred to the caller.
|
|
||||||
///
|
|
||||||
/// \param new_ Do not load the last content file in \a files and instead create in an
|
|
||||||
/// appropriate way.
|
/// appropriate way.
|
||||||
|
|
||||||
bool removeDocument (Document *document);
|
bool removeDocument (Document *document);
|
||||||
///< \return last document removed?
|
///< \return last document removed?
|
||||||
|
|
||||||
void setResourceDir (const boost::filesystem::path& parResDir);
|
void setResourceDir (const boost::filesystem::path& parResDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::filesystem::path mResDir;
|
boost::filesystem::path mResDir;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void documentAdded (CSMDoc::Document *document);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user