forked from teamnwah/openmw-tes3coop
display record count in loading window
This commit is contained in:
parent
7b1e1d03d8
commit
bd252d0aec
7 changed files with 47 additions and 27 deletions
|
@ -31,8 +31,8 @@ CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& con
|
|||
&mLoader, SLOT (loadDocument (CSMDoc::Document *)));
|
||||
connect (&mLoader, SIGNAL (nextStage (CSMDoc::Document *, const std::string&, int)),
|
||||
this, SIGNAL (nextStage (CSMDoc::Document *, const std::string&, int)));
|
||||
connect (&mLoader, SIGNAL (nextRecord (CSMDoc::Document *)),
|
||||
this, SIGNAL (nextRecord (CSMDoc::Document *)));
|
||||
connect (&mLoader, SIGNAL (nextRecord (CSMDoc::Document *, int)),
|
||||
this, SIGNAL (nextRecord (CSMDoc::Document *, int)));
|
||||
connect (this, SIGNAL (cancelLoading (CSMDoc::Document *)),
|
||||
&mLoader, SLOT (abortLoading (CSMDoc::Document *)));
|
||||
connect (&mLoader, SIGNAL (loadMessage (CSMDoc::Document *, const std::string&)),
|
||||
|
|
|
@ -79,9 +79,10 @@ namespace CSMDoc
|
|||
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||
const std::string& error);
|
||||
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name, int steps);
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name,
|
||||
int totalRecords);
|
||||
|
||||
void nextRecord (CSMDoc::Document *document);
|
||||
void nextRecord (CSMDoc::Document *document, int records);
|
||||
|
||||
void cancelLoading (CSMDoc::Document *document);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "document.hpp"
|
||||
#include "state.hpp"
|
||||
|
||||
CSMDoc::Loader::Stage::Stage() : mFile (0), mRecordsLeft (false) {}
|
||||
CSMDoc::Loader::Stage::Stage() : mFile (0), mRecordsLoaded (0), mRecordsLeft (false) {}
|
||||
|
||||
|
||||
CSMDoc::Loader::Loader()
|
||||
|
@ -59,17 +59,21 @@ void CSMDoc::Loader::load()
|
|||
iter->second.mRecordsLeft = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
++(iter->second.mRecordsLoaded);
|
||||
|
||||
CSMWorld::UniversalId log (CSMWorld::UniversalId::Type_LoadErrorLog, 0);
|
||||
|
||||
{ // silence a g++ warning
|
||||
for (CSMDoc::Stage::Messages::const_iterator iter (messages.begin());
|
||||
iter!=messages.end(); ++iter)
|
||||
{
|
||||
document->getReport (log)->add (iter->first, iter->second);
|
||||
emit loadMessage (document, iter->second);
|
||||
}
|
||||
}
|
||||
|
||||
emit nextRecord (document);
|
||||
emit nextRecord (document, iter->second.mRecordsLoaded);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -80,15 +84,17 @@ void CSMDoc::Loader::load()
|
|||
|
||||
int steps = document->getData().startLoading (path, iter->second.mFile!=editedIndex, false);
|
||||
iter->second.mRecordsLeft = true;
|
||||
iter->second.mRecordsLoaded = 0;
|
||||
|
||||
emit nextStage (document, path.filename().string(), steps/batchingSize);
|
||||
emit nextStage (document, path.filename().string(), steps);
|
||||
}
|
||||
else if (iter->second.mFile==size)
|
||||
{
|
||||
int steps = document->getData().startLoading (document->getProjectPath(), false, true);
|
||||
iter->second.mRecordsLeft = true;
|
||||
iter->second.mRecordsLoaded = 0;
|
||||
|
||||
emit nextStage (document, "Project File", steps/batchingSize);
|
||||
emit nextStage (document, "Project File", steps);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace CSMDoc
|
|||
struct Stage
|
||||
{
|
||||
int mFile;
|
||||
int mRecordsLoaded;
|
||||
bool mRecordsLeft;
|
||||
|
||||
Stage();
|
||||
|
@ -56,9 +57,10 @@ namespace CSMDoc
|
|||
///< 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, int steps);
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name,
|
||||
int totalRecords);
|
||||
|
||||
void nextRecord (CSMDoc::Document *document);
|
||||
void nextRecord (CSMDoc::Document *document, int records);
|
||||
///< \note This signal is only given once per group of records. The group size is
|
||||
/// approximately the total number of records divided by the steps value of the
|
||||
/// previous nextStage signal.
|
||||
|
|
|
@ -45,7 +45,7 @@ CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
|||
mFileProgress->setValue (0);
|
||||
|
||||
// record progress
|
||||
mLayout->addWidget (new QLabel ("Records", this));
|
||||
mLayout->addWidget (mRecords = new QLabel ("Records", this));
|
||||
|
||||
mRecordProgress = new QProgressBar (this);
|
||||
|
||||
|
@ -75,22 +75,30 @@ CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
|||
connect (mButtons, SIGNAL (rejected()), this, SLOT (cancel()));
|
||||
}
|
||||
|
||||
void CSVDoc::LoadingDocument::nextStage (const std::string& name, int steps)
|
||||
void CSVDoc::LoadingDocument::nextStage (const std::string& name, int totalRecords)
|
||||
{
|
||||
mFile->setText (QString::fromUtf8 (("Loading: " + name).c_str()));
|
||||
|
||||
mFileProgress->setValue (mFileProgress->value()+1);
|
||||
|
||||
mRecordProgress->setValue (0);
|
||||
mRecordProgress->setMaximum (steps>0 ? steps : 1);
|
||||
mRecordProgress->setMaximum (totalRecords>0 ? totalRecords : 1);
|
||||
|
||||
mTotalRecords = totalRecords;
|
||||
}
|
||||
|
||||
void CSVDoc::LoadingDocument::nextRecord()
|
||||
void CSVDoc::LoadingDocument::nextRecord (int records)
|
||||
{
|
||||
int value = mRecordProgress->value()+1;
|
||||
if (records<=mTotalRecords)
|
||||
{
|
||||
mRecordProgress->setValue (records);
|
||||
|
||||
if (value<=mRecordProgress->maximum())
|
||||
mRecordProgress->setValue (value);
|
||||
std::ostringstream stream;
|
||||
|
||||
stream << "Records: " << records << " of " << mTotalRecords;
|
||||
|
||||
mRecords->setText (QString::fromUtf8 (stream.str().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void CSVDoc::LoadingDocument::abort (const std::string& error)
|
||||
|
@ -168,20 +176,21 @@ void CSVDoc::Loader::loadingStopped (CSMDoc::Document *document, bool completed,
|
|||
}
|
||||
}
|
||||
|
||||
void CSVDoc::Loader::nextStage (CSMDoc::Document *document, const std::string& name, int steps)
|
||||
void CSVDoc::Loader::nextStage (CSMDoc::Document *document, const std::string& name,
|
||||
int totalRecords)
|
||||
{
|
||||
std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter = mDocuments.find (document);
|
||||
|
||||
if (iter!=mDocuments.end())
|
||||
iter->second->nextStage (name, steps);
|
||||
iter->second->nextStage (name, totalRecords);
|
||||
}
|
||||
|
||||
void CSVDoc::Loader::nextRecord (CSMDoc::Document *document)
|
||||
void CSVDoc::Loader::nextRecord (CSMDoc::Document *document, int records)
|
||||
{
|
||||
std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter = mDocuments.find (document);
|
||||
|
||||
if (iter!=mDocuments.end())
|
||||
iter->second->nextRecord();
|
||||
iter->second->nextRecord (records);
|
||||
}
|
||||
|
||||
void CSVDoc::Loader::loadMessage (CSMDoc::Document *document, const std::string& message)
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace CSVDoc
|
|||
|
||||
CSMDoc::Document *mDocument;
|
||||
QLabel *mFile;
|
||||
QLabel *mRecords;
|
||||
QProgressBar *mFileProgress;
|
||||
QProgressBar *mRecordProgress;
|
||||
bool mAborted;
|
||||
|
@ -33,6 +34,7 @@ namespace CSVDoc
|
|||
QLabel *mError;
|
||||
QListWidget *mMessages;
|
||||
QVBoxLayout *mLayout;
|
||||
int mTotalRecords;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -42,9 +44,9 @@ namespace CSVDoc
|
|||
|
||||
LoadingDocument (CSMDoc::Document *document);
|
||||
|
||||
void nextStage (const std::string& name, int steps);
|
||||
void nextStage (const std::string& name, int totalRecords);
|
||||
|
||||
void nextRecord();
|
||||
void nextRecord (int records);
|
||||
|
||||
void abort (const std::string& error);
|
||||
|
||||
|
@ -88,9 +90,9 @@ namespace CSVDoc
|
|||
void loadingStopped (CSMDoc::Document *document, bool completed,
|
||||
const std::string& error);
|
||||
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name, int steps);
|
||||
void nextStage (CSMDoc::Document *document, const std::string& name, int totalRecords);
|
||||
|
||||
void nextRecord (CSMDoc::Document *document);
|
||||
void nextRecord (CSMDoc::Document *document, int records);
|
||||
|
||||
void loadMessage (CSMDoc::Document *document, const std::string& message);
|
||||
};
|
||||
|
|
|
@ -97,8 +97,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
&mLoader, SLOT (nextStage (CSMDoc::Document *, const std::string&, int)));
|
||||
|
||||
connect (
|
||||
&mDocumentManager, SIGNAL (nextRecord (CSMDoc::Document *)),
|
||||
&mLoader, SLOT (nextRecord (CSMDoc::Document *)));
|
||||
&mDocumentManager, SIGNAL (nextRecord (CSMDoc::Document *, int)),
|
||||
&mLoader, SLOT (nextRecord (CSMDoc::Document *, int)));
|
||||
|
||||
connect (
|
||||
&mDocumentManager, SIGNAL (loadMessage (CSMDoc::Document *, const std::string&)),
|
||||
|
|
Loading…
Reference in a new issue