Make ResMed imports progress bar move a bit more during stages

This commit is contained in:
Mark Watkins 2018-04-23 06:04:39 +10:00
parent 777c3aa98a
commit 887273849f
2 changed files with 40 additions and 4 deletions

View File

@ -1683,6 +1683,28 @@ int ResmedLoader::scanFiles(Machine * mach, QString datalog_path)
QHash<EDFType, QList<EDFduration *> > filesbytype; QHash<EDFType, QList<EDFduration *> > filesbytype;
QTime time;
time.start();
// Calculate number of files for progress bar for this stage
int dsiz = dirs.size();
int numfiles = 0;
for (int d=0; d < dsiz; ++d) {
dir.setPath(dirs.at(d));
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Name);
flist = dir.entryInfoList();
// get number of files in current directory being processed
int size = flist.size();
numfiles += size;
}
qprogress->setMaximum(numfiles);
int cnt = 0;
// Scan through all folders looking for EDF files, skip any already imported and peek inside to get durations // Scan through all folders looking for EDF files, skip any already imported and peek inside to get durations
for (int d=0; d < dirs.size(); ++d) { for (int d=0; d < dirs.size(); ++d) {
dir.setPath(dirs.at(d)); dir.setPath(dirs.at(d));
@ -1698,6 +1720,11 @@ int ResmedLoader::scanFiles(Machine * mach, QString datalog_path)
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
QFileInfo fi = flist.at(i); QFileInfo fi = flist.at(i);
filename = fi.fileName(); filename = fi.fileName();
cnt++;
if (cnt % 50) {
qprogress->setValue(cnt);
QApplication::processEvents();
}
// Forget about it if it can't be read. // Forget about it if it can't be read.
if (!fi.isReadable()) { if (!fi.isReadable()) {
@ -1736,11 +1763,12 @@ int ResmedLoader::scanFiles(Machine * mach, QString datalog_path)
dur.filename = filename; dur.filename = filename;
if (dur.start != dur.end) { // make sure empty EVE's are skipped if (dur.start != dur.end) { // make sure empty EVE's are skipped
QMap<QString, EDFduration>::iterator it = newfiles.insert(filename, getEDFDuration(fullname)); QMap<QString, EDFduration>::iterator it = newfiles.insert(filename, dur); //getEDFDuration(fullname));
filesbytype[dur.type].append(&it.value()); filesbytype[dur.type].append(&it.value());
} }
} }
} }
qDebug() << "ResmedLoader::scanFiles() took" << time.elapsed() << "ms";
QList<EDFType> EDForder; QList<EDFType> EDForder;
EDForder.push_back(EDF_PLD); EDForder.push_back(EDF_PLD);
@ -1748,6 +1776,9 @@ int ResmedLoader::scanFiles(Machine * mach, QString datalog_path)
EDForder.push_back(EDF_SAD); EDForder.push_back(EDF_SAD);
QHash<EDFType, QStringList>::iterator gi; QHash<EDFType, QStringList>::iterator gi;
qprogress->setMaximum(filesbytype[EDF_PLD].size() + filesbytype[EDF_BRP].size() + filesbytype[EDF_SAD].size());
cnt = 0;
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
EDFType basetype = EDForder.takeFirst(); EDFType basetype = EDForder.takeFirst();
@ -1755,6 +1786,11 @@ int ResmedLoader::scanFiles(Machine * mach, QString datalog_path)
QList<EDFduration *> & LIST = filesbytype[basetype]; QList<EDFduration *> & LIST = filesbytype[basetype];
int base_size = LIST.size(); int base_size = LIST.size();
for (int f=0; f < base_size; ++f) { for (int f=0; f < base_size; ++f) {
if ((cnt % 50) == 0) {
qprogress->setValue(cnt);
QApplication::processEvents();
}
cnt++;
const EDFduration * dur = LIST.at(f); const EDFduration * dur = LIST.at(f);
quint32 start = dur->start; quint32 start = dur->start;

View File

@ -187,12 +187,12 @@ void MachineLoader::runTasks(bool threaded)
} }
} else { } else {
QThreadPool * threadpool = QThreadPool::globalInstance(); QThreadPool * threadpool = QThreadPool::globalInstance();
qprogress->setMaximum(m_totaltasks);
while (!m_tasklist.isEmpty()) { while (!m_tasklist.isEmpty()) {
if (threadpool->tryStart(m_tasklist.at(0))) { if (threadpool->tryStart(m_tasklist.at(0))) {
m_tasklist.pop_front(); m_tasklist.pop_front();
float f = float(m_currenttask) / float(m_totaltasks) * 100.0; //float f = float(m_currenttask) / float(m_totaltasks) * 100.0;
qprogress->setValue(f); qprogress->setValue(m_currenttask);
m_currenttask++; m_currenttask++;
} }
if ((m_currenttask % 50)==0) { if ((m_currenttask % 50)==0) {