diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index eded36394..1febb1678 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -3,9 +3,11 @@ #include #include +#include #include #include +#include #include @@ -15,6 +17,8 @@ #include #endif +Q_DECLARE_METATYPE (std::string) + class Application : public QApplication { private: @@ -42,6 +46,8 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE (resources); + qRegisterMetaType ("std::string"); + OgreInit::OgreInit ogreInit; std::auto_ptr shinyFactory; diff --git a/apps/opencs/model/doc/documentmanager.cpp b/apps/opencs/model/doc/documentmanager.cpp index ae6f1103f..f102dac70 100644 --- a/apps/opencs/model/doc/documentmanager.cpp +++ b/apps/opencs/model/doc/documentmanager.cpp @@ -29,6 +29,8 @@ CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& con this, SLOT (documentNotLoaded (Document *, const std::string&))); connect (this, SIGNAL (loadRequest (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() diff --git a/apps/opencs/model/doc/documentmanager.hpp b/apps/opencs/model/doc/documentmanager.hpp index 4adc9726c..be9528659 100644 --- a/apps/opencs/model/doc/documentmanager.hpp +++ b/apps/opencs/model/doc/documentmanager.hpp @@ -71,6 +71,8 @@ namespace CSMDoc void loadingStopped (CSMDoc::Document *document, bool completed, const std::string& error); + + void nextStage (CSMDoc::Document *document, const std::string& name); }; } diff --git a/apps/opencs/model/doc/loader.cpp b/apps/opencs/model/doc/loader.cpp index 5277b08d2..47cac1713 100644 --- a/apps/opencs/model/doc/loader.cpp +++ b/apps/opencs/model/doc/loader.cpp @@ -46,11 +46,16 @@ void CSMDoc::Loader::load() { if (iter->second.mFilegetData().loadFile (document->getContentFiles()[iter->second.mFile], - iter->second.mFilegetContentFiles()[iter->second.mFile]; + + emit nextStage (document, path.filename().string()); + + document->getData().loadFile (path, iter->second.mFilesecond.mFile==size) { + emit nextStage (document, "Project File"); + document->getData().loadFile (document->getProjectPath(), false, true); } else diff --git a/apps/opencs/model/doc/loader.hpp b/apps/opencs/model/doc/loader.hpp index dee7d06cb..270aeeb00 100644 --- a/apps/opencs/model/doc/loader.hpp +++ b/apps/opencs/model/doc/loader.hpp @@ -54,6 +54,8 @@ namespace CSMDoc void documentNotLoaded (Document *document, const std::string& error); ///< 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. + + void nextStage (CSMDoc::Document *document, const std::string& name); }; } diff --git a/apps/opencs/view/doc/loader.cpp b/apps/opencs/view/doc/loader.cpp index 15296d616..50c29eedb 100644 --- a/apps/opencs/view/doc/loader.cpp +++ b/apps/opencs/view/doc/loader.cpp @@ -1,14 +1,50 @@ #include "loader.hpp" +#include +#include +#include +#include + #include "../../model/doc/document.hpp" 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 (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(); } +void CSVDoc::LoadingDocument::nextStage (const std::string& name) +{ + mFile->setText (QString::fromUtf8 (("Loading: " + name).c_str())); + + mFileProgress->setValue (mFileProgress->value()+1); +} + CSVDoc::Loader::Loader() { @@ -41,4 +77,12 @@ void CSVDoc::Loader::loadingStopped (CSMDoc::Document *document, bool completed, break; } } +} + +void CSVDoc::Loader::nextStage (CSMDoc::Document *document, const std::string& name) +{ + std::map::iterator iter = mDocuments.find (document); + + if (iter!=mDocuments.end()) + iter->second->nextStage (name); } \ No newline at end of file diff --git a/apps/opencs/view/doc/loader.hpp b/apps/opencs/view/doc/loader.hpp index cb154b13e..ad1e3ffb8 100644 --- a/apps/opencs/view/doc/loader.hpp +++ b/apps/opencs/view/doc/loader.hpp @@ -6,6 +6,9 @@ #include #include +class QLabel; +class QProgressBar; + namespace CSMDoc { class Document; @@ -17,9 +20,14 @@ namespace CSVDoc { Q_OBJECT + QLabel *mFile; + QProgressBar *mFileProgress; + public: LoadingDocument (CSMDoc::Document *document); + + void nextStage (const std::string& name); }; class Loader : public QObject @@ -40,6 +48,8 @@ namespace CSVDoc void loadingStopped (CSMDoc::Document *document, bool completed, const std::string& error); + + void nextStage (CSMDoc::Document *document, const std::string& name); }; } diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index c18cca809..877bc1dea 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -93,6 +93,10 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) connect ( &mDocumentManager, SIGNAL (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()