mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
added basic loading GUI
This commit is contained in:
parent
ddb0496dca
commit
5f1d2f72f6
9 changed files with 111 additions and 7 deletions
|
@ -44,7 +44,7 @@ opencs_units_noqt (model/tools
|
||||||
|
|
||||||
opencs_units (view/doc
|
opencs_units (view/doc
|
||||||
viewmanager view operations operation subview startup filedialog newgame
|
viewmanager view operations operation subview startup filedialog newgame
|
||||||
filewidget adjusterwidget
|
filewidget adjusterwidget loader
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 (Document *, bool)),
|
connect (this, SIGNAL (loadRequest (CSMDoc::Document *, bool)),
|
||||||
&mLoader, SLOT (loadDocument (Document *, bool)));
|
&mLoader, SLOT (loadDocument (CSMDoc::Document *, bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::DocumentManager::~DocumentManager()
|
CSMDoc::DocumentManager::~DocumentManager()
|
||||||
|
@ -75,10 +75,11 @@ void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& par
|
||||||
void CSMDoc::DocumentManager::documentLoaded (Document *document)
|
void CSMDoc::DocumentManager::documentLoaded (Document *document)
|
||||||
{
|
{
|
||||||
emit documentAdded (document);
|
emit documentAdded (document);
|
||||||
|
emit loadingStopped (document, true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::DocumentManager::documentNotLoaded (Document *document, const std::string& error)
|
void CSMDoc::DocumentManager::documentNotLoaded (Document *document, const std::string& error)
|
||||||
{
|
{
|
||||||
|
// emit loadingStopped (document, false, error);
|
||||||
removeDocument (document);
|
removeDocument (document);
|
||||||
/// \todo report error
|
|
||||||
}
|
}
|
|
@ -65,9 +65,12 @@ namespace CSMDoc
|
||||||
|
|
||||||
void documentAdded (CSMDoc::Document *document);
|
void documentAdded (CSMDoc::Document *document);
|
||||||
|
|
||||||
void loadRequest (Document *document, bool _new);
|
void loadRequest (CSMDoc::Document *document, bool _new);
|
||||||
|
|
||||||
void lastDocumentDeleted();
|
void lastDocumentDeleted();
|
||||||
|
|
||||||
|
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||||
|
const std::string& error);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ void CSMDoc::Loader::load()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Loader::loadDocument (Document *document, bool new_)
|
void CSMDoc::Loader::loadDocument (CSMDoc::Document *document, bool new_)
|
||||||
{
|
{
|
||||||
mDocuments.push_back (std::make_pair (document, new_));
|
mDocuments.push_back (std::make_pair (document, new_));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void loadDocument (Document *document, bool new_);
|
void loadDocument (CSMDoc::Document *document, bool new_);
|
||||||
///< 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
|
/// \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.
|
/// \a document and instead create it in an appropriate way.
|
||||||
|
|
44
apps/opencs/view/doc/loader.cpp
Normal file
44
apps/opencs/view/doc/loader.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
#include "loader.hpp"
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
|
||||||
|
CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
||||||
|
{
|
||||||
|
setWindowTitle (("Loading " + document->getSavePath().filename().string()).c_str());
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSVDoc::Loader::Loader()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVDoc::Loader::~Loader()
|
||||||
|
{
|
||||||
|
for (std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter (mDocuments.begin());
|
||||||
|
iter!=mDocuments.end(); ++iter)
|
||||||
|
delete iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVDoc::Loader::add (CSMDoc::Document *document, bool new_)
|
||||||
|
{
|
||||||
|
mDocuments.insert (std::make_pair (document, new LoadingDocument (document)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVDoc::Loader::loadingStopped (CSMDoc::Document *document, bool completed,
|
||||||
|
const std::string& error)
|
||||||
|
{
|
||||||
|
if (completed || error.empty())
|
||||||
|
{
|
||||||
|
for (std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter (mDocuments.begin());
|
||||||
|
iter!=mDocuments.end(); ++iter)
|
||||||
|
if (iter->first==document)
|
||||||
|
{
|
||||||
|
delete iter->second;
|
||||||
|
mDocuments.erase (iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
apps/opencs/view/doc/loader.hpp
Normal file
46
apps/opencs/view/doc/loader.hpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef CSV_DOC_LOADER_H
|
||||||
|
#define CSV_DOC_LOADER_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace CSMDoc
|
||||||
|
{
|
||||||
|
class Document;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVDoc
|
||||||
|
{
|
||||||
|
class LoadingDocument : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
LoadingDocument (CSMDoc::Document *document);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Loader : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
std::map<CSMDoc::Document *, LoadingDocument *> mDocuments;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Loader();
|
||||||
|
|
||||||
|
virtual ~Loader();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void add (CSMDoc::Document *document, bool new_);
|
||||||
|
|
||||||
|
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||||
|
const std::string& error);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -86,6 +86,13 @@ 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)),
|
||||||
|
&mLoader, SLOT (add (CSMDoc::Document *, bool)));
|
||||||
|
|
||||||
|
connect (
|
||||||
|
&mDocumentManager, SIGNAL (loadingStopped (CSMDoc::Document *, bool, const std::string&)),
|
||||||
|
&mLoader, SLOT (loadingStopped (CSMDoc::Document *, bool, const std::string&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVDoc::ViewManager::~ViewManager()
|
CSVDoc::ViewManager::~ViewManager()
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "loader.hpp"
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Document;
|
class Document;
|
||||||
|
@ -29,6 +31,7 @@ namespace CSVDoc
|
||||||
CSVWorld::CommandDelegateFactoryCollection *mDelegateFactories;
|
CSVWorld::CommandDelegateFactoryCollection *mDelegateFactories;
|
||||||
bool mExitOnSaveStateChange;
|
bool mExitOnSaveStateChange;
|
||||||
bool mUserWarned;
|
bool mUserWarned;
|
||||||
|
Loader mLoader;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
ViewManager (const ViewManager&);
|
ViewManager (const ViewManager&);
|
||||||
|
|
Loading…
Reference in a new issue