1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-31 23:36:41 +00:00

content file loading progress bar

This commit is contained in:
Marc Zinnschlag 2014-05-03 13:01:29 +02:00
parent e09218f164
commit e0e2ad8316
8 changed files with 78 additions and 3 deletions

View file

@ -3,9 +3,11 @@
#include <exception> #include <exception>
#include <iostream> #include <iostream>
#include <string>
#include <QApplication> #include <QApplication>
#include <QIcon> #include <QIcon>
#include <QMetaType>
#include <extern/shiny/Main/Factory.hpp> #include <extern/shiny/Main/Factory.hpp>
@ -15,6 +17,8 @@
#include <QDir> #include <QDir>
#endif #endif
Q_DECLARE_METATYPE (std::string)
class Application : public QApplication class Application : public QApplication
{ {
private: private:
@ -42,6 +46,8 @@ int main(int argc, char *argv[])
{ {
Q_INIT_RESOURCE (resources); Q_INIT_RESOURCE (resources);
qRegisterMetaType<std::string> ("std::string");
OgreInit::OgreInit ogreInit; OgreInit::OgreInit ogreInit;
std::auto_ptr<sh::Factory> shinyFactory; std::auto_ptr<sh::Factory> shinyFactory;

View file

@ -29,6 +29,8 @@ CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& con
this, SLOT (documentNotLoaded (Document *, const std::string&))); this, SLOT (documentNotLoaded (Document *, const std::string&)));
connect (this, SIGNAL (loadRequest (CSMDoc::Document *)), connect (this, SIGNAL (loadRequest (CSMDoc::Document *)),
&mLoader, SLOT (loadDocument (CSMDoc::Document *))); &mLoader, SLOT (loadDocument (CSMDoc::Document *)));
connect (&mLoader, SIGNAL (nextStage (CSMDoc::Document *, const std::string&)),
this, SIGNAL (nextStage (CSMDoc::Document *, const std::string&)));
} }
CSMDoc::DocumentManager::~DocumentManager() CSMDoc::DocumentManager::~DocumentManager()

View file

@ -71,6 +71,8 @@ namespace CSMDoc
void loadingStopped (CSMDoc::Document *document, bool completed, void loadingStopped (CSMDoc::Document *document, bool completed,
const std::string& error); const std::string& error);
void nextStage (CSMDoc::Document *document, const std::string& name);
}; };
} }

View file

@ -46,11 +46,16 @@ void CSMDoc::Loader::load()
{ {
if (iter->second.mFile<size) if (iter->second.mFile<size)
{ {
document->getData().loadFile (document->getContentFiles()[iter->second.mFile], boost::filesystem::path path = document->getContentFiles()[iter->second.mFile];
iter->second.mFile<size-1, false);
emit nextStage (document, path.filename().string());
document->getData().loadFile (path, iter->second.mFile<size-1, false);
} }
else if (iter->second.mFile==size) else if (iter->second.mFile==size)
{ {
emit nextStage (document, "Project File");
document->getData().loadFile (document->getProjectPath(), false, true); document->getData().loadFile (document->getProjectPath(), false, true);
} }
else else

View file

@ -54,6 +54,8 @@ namespace CSMDoc
void documentNotLoaded (Document *document, const std::string& error); void documentNotLoaded (Document *document, const std::string& error);
///< Document load has been interrupted either because of a call to abortLoading ///< Document load has been interrupted either because of a call to abortLoading
/// or a problem during loading). In the former case error will be an empty string. /// or a problem during loading). In the former case error will be an empty string.
void nextStage (CSMDoc::Document *document, const std::string& name);
}; };
} }

View file

@ -1,14 +1,50 @@
#include "loader.hpp" #include "loader.hpp"
#include <QVBoxLayout>
#include <QLabel>
#include <QProgressBar>
#include <QCursor>
#include "../../model/doc/document.hpp" #include "../../model/doc/document.hpp"
CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document) CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
{ {
setWindowTitle (("Loading " + document->getSavePath().filename().string()).c_str()); setWindowTitle (("Opening " + document->getSavePath().filename().string()).c_str());
QVBoxLayout *layout = new QVBoxLayout (this);
mFileProgress = new QProgressBar (this);
layout->addWidget (mFileProgress);
int size = static_cast<int> (document->getContentFiles().size())+1;
if (document->isNew())
--size;
mFileProgress->setMinimum (0);
mFileProgress->setMaximum (size);
mFileProgress->setTextVisible (true);
mFileProgress->setValue (0);
mFile = new QLabel (this);
layout->addWidget (mFile);
setLayout (layout);
move (QCursor::pos());
show(); show();
} }
void CSVDoc::LoadingDocument::nextStage (const std::string& name)
{
mFile->setText (QString::fromUtf8 (("Loading: " + name).c_str()));
mFileProgress->setValue (mFileProgress->value()+1);
}
CSVDoc::Loader::Loader() CSVDoc::Loader::Loader()
{ {
@ -42,3 +78,11 @@ void CSVDoc::Loader::loadingStopped (CSMDoc::Document *document, bool completed,
} }
} }
} }
void CSVDoc::Loader::nextStage (CSMDoc::Document *document, const std::string& name)
{
std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter = mDocuments.find (document);
if (iter!=mDocuments.end())
iter->second->nextStage (name);
}

View file

@ -6,6 +6,9 @@
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
class QLabel;
class QProgressBar;
namespace CSMDoc namespace CSMDoc
{ {
class Document; class Document;
@ -17,9 +20,14 @@ namespace CSVDoc
{ {
Q_OBJECT Q_OBJECT
QLabel *mFile;
QProgressBar *mFileProgress;
public: public:
LoadingDocument (CSMDoc::Document *document); LoadingDocument (CSMDoc::Document *document);
void nextStage (const std::string& name);
}; };
class Loader : public QObject class Loader : public QObject
@ -40,6 +48,8 @@ namespace CSVDoc
void loadingStopped (CSMDoc::Document *document, bool completed, void loadingStopped (CSMDoc::Document *document, bool completed,
const std::string& error); const std::string& error);
void nextStage (CSMDoc::Document *document, const std::string& name);
}; };
} }

View file

@ -93,6 +93,10 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
connect ( connect (
&mDocumentManager, SIGNAL (loadingStopped (CSMDoc::Document *, bool, const std::string&)), &mDocumentManager, SIGNAL (loadingStopped (CSMDoc::Document *, bool, const std::string&)),
&mLoader, SLOT (loadingStopped (CSMDoc::Document *, bool, const std::string&))); &mLoader, SLOT (loadingStopped (CSMDoc::Document *, bool, const std::string&)));
connect (
&mDocumentManager, SIGNAL (nextStage (CSMDoc::Document *, const std::string&)),
&mLoader, SLOT (nextStage (CSMDoc::Document *, const std::string&)));
} }
CSVDoc::ViewManager::~ViewManager() CSVDoc::ViewManager::~ViewManager()