Show progress bar works when preloading sessions

This commit is contained in:
Mark Watkins 2014-09-22 18:20:44 +10:00
parent a09308db2c
commit fc78ebfc16
3 changed files with 20 additions and 5 deletions

View File

@ -499,7 +499,10 @@ void Machine::setInfo(MachineInfo inf)
const QString Machine::getDataPath() const QString Machine::getDataPath()
{ {
return p_profile->Get("{" + STR_GEN_DataFolder + "}/" + info.loadername + "_" + (info.serial.isEmpty() ? hexid() : info.serial)) + "/"; if (m_dataPath.isEmpty()) {
m_dataPath = p_profile->Get("{" + STR_GEN_DataFolder + "}/" + info.loadername + "_" + (info.serial.isEmpty() ? hexid() : info.serial)) + "/";
}
return m_dataPath;
} }
const QString Machine::getSummariesPath() const QString Machine::getSummariesPath()
{ {
@ -535,7 +538,7 @@ bool Machine::Load()
QProgressBar * progress = popup->progress; QProgressBar * progress = popup->progress;
if (!LoadSummary()) { if (!LoadSummary(progress)) {
// No XML index file, so assume upgrading, or it simply just got screwed up or deleted... // No XML index file, so assume upgrading, or it simply just got screwed up or deleted...
QTime time; QTime time;
time.start(); time.start();
@ -844,7 +847,7 @@ bool Machine::hasModifiedSessions()
const QString summaryFileName = "Summaries.xml"; const QString summaryFileName = "Summaries.xml";
bool Machine::LoadSummary() bool Machine::LoadSummary(QProgressBar * progress)
{ {
QTime time; QTime time;
time.start(); time.start();
@ -911,7 +914,12 @@ bool Machine::LoadSummary()
int cnt = 0; int cnt = 0;
bool loadSummaries = p_profile->session->preloadSummaries(); bool loadSummaries = p_profile->session->preloadSummaries();
progress->setMaximum(sess_order.size());
for (it = sess_order.begin(); it != it_end; ++it, ++cnt) { for (it = sess_order.begin(); it != it_end; ++it, ++cnt) {
if ((cnt % 100) == 0) {
progress->setValue(cnt);
QApplication::processEvents();
}
Session * sess = it.value(); Session * sess = it.value();
if (!AddSession(sess)) { if (!AddSession(sess)) {
delete sess; delete sess;
@ -919,6 +927,8 @@ bool Machine::LoadSummary()
if (loadSummaries) sess->LoadSummary(); if (loadSummaries) sess->LoadSummary();
} }
} }
progress->setValue(sess_order.size());
QApplication::processEvents();
qDebug() << "Loaded" << info.series << info.model << "data in" << time.elapsed() << "ms"; qDebug() << "Loaded" << info.series << info.model << "data in" << time.elapsed() << "ms";

View File

@ -18,6 +18,7 @@
#include <QThread> #include <QThread>
#include <QMutex> #include <QMutex>
#include <QSemaphore> #include <QSemaphore>
#include <QProgressBar>
#include <QHash> #include <QHash>
#include <QVector> #include <QVector>
@ -87,7 +88,7 @@ class Machine
//! \brief Load all Machine summary data //! \brief Load all Machine summary data
bool Load(); bool Load();
bool LoadSummary(); bool LoadSummary(QProgressBar * progress);
//! \brief Save all Sessions where changed bit is set. //! \brief Save all Sessions where changed bit is set.
bool Save(); bool Save();
@ -246,6 +247,10 @@ class Machine
QList<ImportTask *> m_tasklist; QList<ImportTask *> m_tasklist;
QHash<ChannelID, bool> m_availableChannels; QHash<ChannelID, bool> m_availableChannels;
QString m_summaryPath;
QString m_eventsPath;
QString m_dataPath;
}; };

View File

@ -374,7 +374,7 @@ bool Session::LoadSummary()
} }
qDebug() << "Loading" << s_machine->loaderName() << "Summary" << filename << sumcnt++; // qDebug() << "Loading" << s_machine->loaderName() << "Summary" << filename << sumcnt++;
QDataStream in(&file); QDataStream in(&file);
in.setVersion(QDataStream::Qt_4_6); in.setVersion(QDataStream::Qt_4_6);