diff --git a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp index 883b1074..c8299607 100644 --- a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp @@ -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; diff --git a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp index 14b04334..26d9c73c 100644 --- a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp @@ -118,6 +118,9 @@ void ResmedLoader::ParseSTR(Machine *mach, QMap & 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 & 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); diff --git a/sleepyhead/SleepLib/machine.cpp b/sleepyhead/SleepLib/machine.cpp index c27b9dd3..eca8fbff 100644 --- a/sleepyhead/SleepLib/machine.cpp +++ b/sleepyhead/SleepLib/machine.cpp @@ -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(); } diff --git a/sleepyhead/SleepLib/machine_loader.cpp b/sleepyhead/SleepLib/machine_loader.cpp index b0a52d5e..f303a8ae 100644 --- a/sleepyhead/SleepLib/machine_loader.cpp +++ b/sleepyhead/SleepLib/machine_loader.cpp @@ -219,10 +219,10 @@ void MachineLoader::runTasks(bool threaded) ImportTask * task = m_tasklist.takeFirst(); task->run(); - if ((m_currenttask++ % 10)==0) { - qprogress->setValue(m_currenttask); - QApplication::processEvents(); - } + // 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) { - qprogress->setValue(m_currenttask); - QApplication::processEvents(); - } + m_currenttask++; + qprogress->setValue(m_currenttask); + QApplication::processEvents(); } else { // job list finished break; diff --git a/sleepyhead/SleepLib/progressdialog.cpp b/sleepyhead/SleepLib/progressdialog.cpp index be624a1f..99e19972 100644 --- a/sleepyhead/SleepLib/progressdialog.cpp +++ b/sleepyhead/SleepLib/progressdialog.cpp @@ -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; diff --git a/sleepyhead/mainwindow.cpp b/sleepyhead/mainwindow.cpp index 72fe8b8c..12ace414 100644 --- a/sleepyhead/mainwindow.cpp +++ b/sleepyhead/mainwindow.cpp @@ -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);