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 *)));
|
&mLoader, SLOT (loadDocument (CSMDoc::Document *)));
|
||||||
connect (&mLoader, SIGNAL (nextStage (CSMDoc::Document *, const std::string&, int)),
|
connect (&mLoader, SIGNAL (nextStage (CSMDoc::Document *, const std::string&, int)),
|
||||||
this, SIGNAL (nextStage (CSMDoc::Document *, const std::string&, int)));
|
this, SIGNAL (nextStage (CSMDoc::Document *, const std::string&, int)));
|
||||||
connect (&mLoader, SIGNAL (nextRecord (CSMDoc::Document *)),
|
connect (&mLoader, SIGNAL (nextRecord (CSMDoc::Document *, int)),
|
||||||
this, SIGNAL (nextRecord (CSMDoc::Document *)));
|
this, SIGNAL (nextRecord (CSMDoc::Document *, int)));
|
||||||
connect (this, SIGNAL (cancelLoading (CSMDoc::Document *)),
|
connect (this, SIGNAL (cancelLoading (CSMDoc::Document *)),
|
||||||
&mLoader, SLOT (abortLoading (CSMDoc::Document *)));
|
&mLoader, SLOT (abortLoading (CSMDoc::Document *)));
|
||||||
connect (&mLoader, SIGNAL (loadMessage (CSMDoc::Document *, const std::string&)),
|
connect (&mLoader, SIGNAL (loadMessage (CSMDoc::Document *, const std::string&)),
|
||||||
|
|
|
@ -79,9 +79,10 @@ 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, 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);
|
void cancelLoading (CSMDoc::Document *document);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
#include "state.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()
|
CSMDoc::Loader::Loader()
|
||||||
|
@ -59,17 +59,21 @@ void CSMDoc::Loader::load()
|
||||||
iter->second.mRecordsLeft = false;
|
iter->second.mRecordsLeft = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
++(iter->second.mRecordsLoaded);
|
||||||
|
|
||||||
CSMWorld::UniversalId log (CSMWorld::UniversalId::Type_LoadErrorLog, 0);
|
CSMWorld::UniversalId log (CSMWorld::UniversalId::Type_LoadErrorLog, 0);
|
||||||
|
|
||||||
|
{ // silence a g++ warning
|
||||||
for (CSMDoc::Stage::Messages::const_iterator iter (messages.begin());
|
for (CSMDoc::Stage::Messages::const_iterator iter (messages.begin());
|
||||||
iter!=messages.end(); ++iter)
|
iter!=messages.end(); ++iter)
|
||||||
{
|
{
|
||||||
document->getReport (log)->add (iter->first, iter->second);
|
document->getReport (log)->add (iter->first, iter->second);
|
||||||
emit loadMessage (document, iter->second);
|
emit loadMessage (document, iter->second);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emit nextRecord (document);
|
emit nextRecord (document, iter->second.mRecordsLoaded);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -80,15 +84,17 @@ void CSMDoc::Loader::load()
|
||||||
|
|
||||||
int steps = document->getData().startLoading (path, iter->second.mFile!=editedIndex, false);
|
int steps = document->getData().startLoading (path, iter->second.mFile!=editedIndex, false);
|
||||||
iter->second.mRecordsLeft = true;
|
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)
|
else if (iter->second.mFile==size)
|
||||||
{
|
{
|
||||||
int steps = document->getData().startLoading (document->getProjectPath(), false, true);
|
int steps = document->getData().startLoading (document->getProjectPath(), false, true);
|
||||||
iter->second.mRecordsLeft = true;
|
iter->second.mRecordsLeft = true;
|
||||||
|
iter->second.mRecordsLoaded = 0;
|
||||||
|
|
||||||
emit nextStage (document, "Project File", steps/batchingSize);
|
emit nextStage (document, "Project File", steps);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace CSMDoc
|
||||||
struct Stage
|
struct Stage
|
||||||
{
|
{
|
||||||
int mFile;
|
int mFile;
|
||||||
|
int mRecordsLoaded;
|
||||||
bool mRecordsLeft;
|
bool mRecordsLeft;
|
||||||
|
|
||||||
Stage();
|
Stage();
|
||||||
|
@ -56,9 +57,10 @@ namespace CSMDoc
|
||||||
///< 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, 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
|
///< \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
|
/// approximately the total number of records divided by the steps value of the
|
||||||
/// previous nextStage signal.
|
/// previous nextStage signal.
|
||||||
|
|
|
@ -45,7 +45,7 @@ CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
||||||
mFileProgress->setValue (0);
|
mFileProgress->setValue (0);
|
||||||
|
|
||||||
// record progress
|
// record progress
|
||||||
mLayout->addWidget (new QLabel ("Records", this));
|
mLayout->addWidget (mRecords = new QLabel ("Records", this));
|
||||||
|
|
||||||
mRecordProgress = new QProgressBar (this);
|
mRecordProgress = new QProgressBar (this);
|
||||||
|
|
||||||
|
@ -75,22 +75,30 @@ CSVDoc::LoadingDocument::LoadingDocument (CSMDoc::Document *document)
|
||||||
connect (mButtons, SIGNAL (rejected()), this, SLOT (cancel()));
|
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()));
|
mFile->setText (QString::fromUtf8 (("Loading: " + name).c_str()));
|
||||||
|
|
||||||
mFileProgress->setValue (mFileProgress->value()+1);
|
mFileProgress->setValue (mFileProgress->value()+1);
|
||||||
|
|
||||||
mRecordProgress->setValue (0);
|
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())
|
std::ostringstream stream;
|
||||||
mRecordProgress->setValue (value);
|
|
||||||
|
stream << "Records: " << records << " of " << mTotalRecords;
|
||||||
|
|
||||||
|
mRecords->setText (QString::fromUtf8 (stream.str().c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::LoadingDocument::abort (const std::string& error)
|
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);
|
std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter = mDocuments.find (document);
|
||||||
|
|
||||||
if (iter!=mDocuments.end())
|
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);
|
std::map<CSMDoc::Document *, LoadingDocument *>::iterator iter = mDocuments.find (document);
|
||||||
|
|
||||||
if (iter!=mDocuments.end())
|
if (iter!=mDocuments.end())
|
||||||
iter->second->nextRecord();
|
iter->second->nextRecord (records);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::Loader::loadMessage (CSMDoc::Document *document, const std::string& message)
|
void CSVDoc::Loader::loadMessage (CSMDoc::Document *document, const std::string& message)
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace CSVDoc
|
||||||
|
|
||||||
CSMDoc::Document *mDocument;
|
CSMDoc::Document *mDocument;
|
||||||
QLabel *mFile;
|
QLabel *mFile;
|
||||||
|
QLabel *mRecords;
|
||||||
QProgressBar *mFileProgress;
|
QProgressBar *mFileProgress;
|
||||||
QProgressBar *mRecordProgress;
|
QProgressBar *mRecordProgress;
|
||||||
bool mAborted;
|
bool mAborted;
|
||||||
|
@ -33,6 +34,7 @@ namespace CSVDoc
|
||||||
QLabel *mError;
|
QLabel *mError;
|
||||||
QListWidget *mMessages;
|
QListWidget *mMessages;
|
||||||
QVBoxLayout *mLayout;
|
QVBoxLayout *mLayout;
|
||||||
|
int mTotalRecords;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -42,9 +44,9 @@ namespace CSVDoc
|
||||||
|
|
||||||
LoadingDocument (CSMDoc::Document *document);
|
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);
|
void abort (const std::string& error);
|
||||||
|
|
||||||
|
@ -88,9 +90,9 @@ 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, 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);
|
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)));
|
&mLoader, SLOT (nextStage (CSMDoc::Document *, const std::string&, int)));
|
||||||
|
|
||||||
connect (
|
connect (
|
||||||
&mDocumentManager, SIGNAL (nextRecord (CSMDoc::Document *)),
|
&mDocumentManager, SIGNAL (nextRecord (CSMDoc::Document *, int)),
|
||||||
&mLoader, SLOT (nextRecord (CSMDoc::Document *)));
|
&mLoader, SLOT (nextRecord (CSMDoc::Document *, int)));
|
||||||
|
|
||||||
connect (
|
connect (
|
||||||
&mDocumentManager, SIGNAL (loadMessage (CSMDoc::Document *, const std::string&)),
|
&mDocumentManager, SIGNAL (loadMessage (CSMDoc::Document *, const std::string&)),
|
||||||
|
|
Loading…
Reference in a new issue