replaced return value of DocumentManager::addDocument with a signal

deque
Marc Zinnschlag 11 years ago
parent 86bd2f48dc
commit e324450118

@ -5,11 +5,11 @@ opencs_units (. editor)
set (CMAKE_BUILD_TYPE DEBUG)
opencs_units (model/doc
document operation saving
document operation saving documentmanager
)
opencs_units_noqt (model/doc
documentmanager stage savingstate savingstages
stage savingstate savingstages
)
opencs_hdrs_noqt (model/doc

@ -37,6 +37,9 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
mNewGame.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 (newAddonRequest ()), this, SLOT (createAddon ()));
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())
files.push_back(path.toUtf8().constData());
CSMDoc::Document *document = mDocumentManager.addDocument (files, savePath, false);
mDocumentManager.addDocument (files, savePath, false);
mViewManager.addView (document);
mFileDialog.hide();
}
@ -166,9 +168,8 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
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();
}
@ -178,9 +179,7 @@ void CS::Editor::createNewGame (const boost::filesystem::path& file)
files.push_back (file);
CSMDoc::Document *document = mDocumentManager.addDocument (files, file, true);
mViewManager.addView (document);
mDocumentManager.addDocument (files, file, true);
mNewGame.hide();
}
@ -287,3 +286,8 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
return factory;
}
void CS::Editor::documentAdded (CSMDoc::Document *document)
{
mViewManager.addView (document);
}

@ -85,6 +85,8 @@ namespace CS
void showSettings();
void documentAdded (CSMDoc::Document *document);
private:
QString mIpcServerName;

@ -27,14 +27,14 @@ CSMDoc::DocumentManager::~DocumentManager()
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_)
{
Document *document = new Document (mConfiguration, files, savePath, mResDir, new_);
mDocuments.push_back (document);
return document;
emit documentAdded (document);
}
bool CSMDoc::DocumentManager::removeDocument (Document *document)

@ -6,6 +6,8 @@
#include <boost/filesystem/path.hpp>
#include <QObject>
namespace Files
{
class ConfigurationManager;
@ -15,8 +17,10 @@ namespace CSMDoc
{
class Document;
class DocumentManager
class DocumentManager : public QObject
{
Q_OBJECT
std::vector<Document *> mDocuments;
const Files::ConfigurationManager& mConfiguration;
@ -29,20 +33,23 @@ namespace CSMDoc
~DocumentManager();
Document *addDocument (const std::vector< boost::filesystem::path >& files,
const boost::filesystem::path& savePath,
bool new_);
///< 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
void addDocument (const std::vector< boost::filesystem::path >& files,
const boost::filesystem::path& savePath, bool new_);
///< \param new_ Do not load the last content file in \a files and instead create in an
/// appropriate way.
bool removeDocument (Document *document);
///< \return last document removed?
void setResourceDir (const boost::filesystem::path& parResDir);
private:
private:
boost::filesystem::path mResDir;
signals:
void documentAdded (CSMDoc::Document *document);
};
}

Loading…
Cancel
Save