Make ResMed & PRS1 importer check ignoreOlderSessions, make import progress dialog modal

This commit is contained in:
Mark Watkins 2018-05-07 11:30:42 +10:00
parent adf6f1917d
commit c4ac37d4ae
6 changed files with 42 additions and 13 deletions

View File

@ -431,6 +431,7 @@ int PRS1Loader::Open(const QString & dirpath)
c += OpenMachine(newpath + "/" + *sn);
}
}
// Serial numbers that don't start with a letter.
for (sn = SerialNumbers.begin(); sn != SerialNumbers.end(); sn++) {
if (!(*sn)[0].isLetter()) {
c += OpenMachine(newpath + "/" + *sn);
@ -632,6 +633,11 @@ int PRS1Loader::OpenMachine(const QString & path)
emit updateMessage(QObject::tr("Scanning Files..."));
QCoreApplication::processEvents();
QDateTime datetime;
QDateTime ignoreBefore = p_profile->session->ignoreOlderSessionsDate();
bool ignoreOldSessions = p_profile->session->ignoreOlderSessions();
// for each p0/p1/p2/etc... folder
for (int p=0; p < size; ++p) {
dir.setPath(paths.at(p));
@ -658,6 +664,14 @@ int PRS1Loader::OpenMachine(const QString & path)
continue;
}
if (ignoreOldSessions) {
datetime = QDateTime::fromTime_t(sid);
if (datetime < ignoreBefore) {
continue;
}
}
if (m->SessionExists(sid)) {
// Skip already imported session
continue;

View File

@ -118,6 +118,9 @@ void ResmedLoader::ParseSTR(Machine *mach, QMap<QDate, STRFile> & STRmap)
return;
}
QDateTime ignoreBefore = p_profile->session->ignoreOlderSessionsDate();
bool ignoreOldSessions = p_profile->session->ignoreOlderSessions();
for (auto it=STRmap.begin(), end=STRmap.end(); it != end; ++it) {
STRFile & file = it.value();
QString & strfile = file.filename;
@ -144,6 +147,11 @@ void ResmedLoader::ParseSTR(Machine *mach, QMap<QDate, STRFile> & STRmap)
// For each data record, representing 1 day each
for (int rec = 0; rec < size; ++rec, date = date.addDays(1)) {
if (ignoreOldSessions) {
if (date < ignoreBefore.date()) {
continue;
}
}
auto rit = resdayList.find(date);
if (rit != resdayList.end()) {
@ -1441,6 +1449,8 @@ int ResmedLoader::scanFiles(Machine * mach, const QString & datalog_path)
int cnt = 0;
// Scan through all folders looking for EDF files, skip any already imported and peek inside to get durations
QDateTime ignoreBefore = p_profile->session->ignoreOlderSessionsDate();
bool ignoreOldSessions = p_profile->session->ignoreOlderSessions();
qDebug() << "Starting EDF duration scan pass";
for (int i=0; i < totalfiles; ++i) {
@ -1468,6 +1478,11 @@ int ResmedLoader::scanFiles(Machine * mach, const QString & datalog_path)
date = date.addDays(-1);
}
if (ignoreOldSessions) {
if (date < ignoreBefore.date())
continue;
}
// Chop off the .gz component if it exists, it's not needed at this stage
if (filename.endsWith(STR_ext_gz)) {
filename.chop(3);

View File

@ -234,8 +234,6 @@ bool Machine::AddSession(Session *s)
return false;
}
updateChannels(s);
if (p_profile->session->ignoreOlderSessions()) {
qint64 ignorebefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch();
if (s->last() < ignorebefore) {
@ -244,6 +242,9 @@ bool Machine::AddSession(Session *s)
}
}
updateChannels(s);
if (s->session() > highest_sessionid) {
highest_sessionid = s->session();
}

View File

@ -219,11 +219,11 @@ void MachineLoader::runTasks(bool threaded)
ImportTask * task = m_tasklist.takeFirst();
task->run();
if ((m_currenttask++ % 10)==0) {
// update progress bar
m_currenttask++;
qprogress->setValue(m_currenttask);
QApplication::processEvents();
}
}
} else {
ImportTask * task = m_tasklist[0];
@ -239,10 +239,9 @@ void MachineLoader::runTasks(bool threaded)
task = m_tasklist[0];
// update progress bar
if ((m_currenttask++ % 10) == 0) {
m_currenttask++;
qprogress->setValue(m_currenttask);
QApplication::processEvents();
}
} else {
// job list finished
break;

View File

@ -9,7 +9,7 @@
#include "progressdialog.h"
ProgressDialog::ProgressDialog(QWidget * parent):
QDialog(parent, Qt::Popup)
QDialog(parent, Qt::Tool | Qt::FramelessWindowHint)
{
waitmsg = new QLabel(QObject::tr("PLease Wait..."));
hlayout = new QHBoxLayout;

View File

@ -567,10 +567,10 @@ int MainWindow::importCPAP(ImportPath import, const QString &message)
QProgressBar *saveQprogress = qprogress;
qprogress = progdlg->progress;
progdlg->show();
progdlg->setWindowModality(Qt::ApplicationModal);
progdlg->open();
progdlg->setMessage(message);
import.loader->setParent(this);
connect(import.loader, SIGNAL(updateMessage(QString)), progdlg, SLOT(setMessage(QString)));
int c = import.loader->Open(import.path);