diff --git a/oscar/SleepLib/loader_plugins/resmed_loader.cpp b/oscar/SleepLib/loader_plugins/resmed_loader.cpp index 3cc929d1..1962a18a 100644 --- a/oscar/SleepLib/loader_plugins/resmed_loader.cpp +++ b/oscar/SleepLib/loader_plugins/resmed_loader.cpp @@ -360,6 +360,7 @@ int ResmedLoader::Open(const QString & dirpath) firstImportDay = lastDate.addDays(-1); } else { // Starting from new beginnings - new or purged qDebug() << "New machine or just purged"; + p_profile->forceResmedPrefs(); QDateTime ignoreBefore = p_profile->session->ignoreOlderSessionsDate(); bool ignoreOldSessions = p_profile->session->ignoreOlderSessions(); mach = p_profile->CreateMachine( info ); @@ -949,7 +950,7 @@ void ResmedLoader::ProcessSTRfiles(Machine *mach, QMap & STRmap, // if (ignoreOldSessions) { if (date < firstImport) { #ifdef SESSION_DEBUG - qDebug() << "Skipping" << date.toString() << "Before" << ignoreBefore.date().toString(); + qDebug() << "Skipping" << date.toString() << "Before" << firstImport.toString(); #endif continue; } diff --git a/oscar/SleepLib/profiles.cpp b/oscar/SleepLib/profiles.cpp index 98e421dc..edf94273 100644 --- a/oscar/SleepLib/profiles.cpp +++ b/oscar/SleepLib/profiles.cpp @@ -353,7 +353,17 @@ qint64 Profile::diskSpace() return (diskSpaceSummaries()+diskSpaceEvents()+diskSpaceBackups()); } - +void Profile::forceResmedPrefs() +{ + session->setBackupCardData(true); + session->setDaySplitTime(QTime(12,0,0)); + session->setIgnoreShortSessions(0); + session->setCombineCloseSessions(0); + session->setLockSummarySessions(true); + general->setPrefCalcPercentile(95.0); // 95% + general->setPrefCalcMiddle(0); // Median (50%) + general->setPrefCalcMax(1); // 99.9th percentile max +} #if defined(Q_OS_WIN) class Environment diff --git a/oscar/SleepLib/profiles.h b/oscar/SleepLib/profiles.h index 8ba9ed74..4c218082 100644 --- a/oscar/SleepLib/profiles.h +++ b/oscar/SleepLib/profiles.h @@ -57,6 +57,9 @@ class Profile : public Preferences qint64 diskSpaceBackups(); qint64 diskSpace(); + //! \brief Force some preferences for ResMed machines + virtual void forceResmedPrefs(); + //! \brief Returns hostname that locked profile, or empty string if unlocked QString checkLock(); diff --git a/oscar/preferencesdialog.cpp b/oscar/preferencesdialog.cpp index ff284be6..d6dcd8d9 100644 --- a/oscar/preferencesdialog.cpp +++ b/oscar/preferencesdialog.cpp @@ -52,12 +52,20 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) : channeltype[schema::UNKNOWN] = tr("Always Minor"); bool haveResMed = false; QList machines = profile->GetMachines(MT_CPAP); - for (QList::iterator it = machines.begin(); it != machines.end(); ++it) { - const QString & mclass=(*it)->loaderName(); - if (mclass == STR_MACH_ResMed) { - haveResMed = true; - break; +// qDebug() << "Machile list size is" << machines.size(); + if ( machines.size() > 0 ) { + for (QList::iterator it = machines.begin(); it != machines.end(); ++it) { + const QString & mclass=(*it)->loaderName(); + if (mclass == STR_MACH_ResMed) { + haveResMed = true; + break; + } } + } else { + if (QMessageBox::question(this, tr("No CPAP machines detected"), + tr("Will you be using a ResMed brand machine?"), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes ) + haveResMed = true; } #ifdef LOCK_RESMED_SESSIONS @@ -66,21 +74,21 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) : ui->ResMedWarning->setVisible(haveResMed); if (haveResMed) { + profile->forceResmedPrefs(); +// profile->session->setDaySplitTime(QTime(12,0,0)); +// profile->session->setIgnoreShortSessions(0); +// profile->session->setCombineCloseSessions(0); +// profile->session->setLockSummarySessions(true); +// p_profile->general->setPrefCalcPercentile(95.0); // 95% +// p_profile->general->setPrefCalcMiddle(0); // Median (50%) +// p_profile->general->setPrefCalcMax(1); // 99.9th percentile max +// p_profile->session->setBackupCardData(true); ui->sessionSplitWidget->setVisible(!haveResMed); - profile->session->setDaySplitTime(QTime(12,0,0)); - profile->session->setIgnoreShortSessions(0); - profile->session->setCombineCloseSessions(0); - profile->session->setLockSummarySessions(true); - p_profile->general->setPrefCalcPercentile(95.0); // 95% - p_profile->general->setPrefCalcMiddle(0); // Median (50%) - p_profile->general->setPrefCalcMax(1); // 99.9th percentile max ui->prefCalcMax->setEnabled(false); ui->prefCalcMiddle->setEnabled(false); ui->prefCalcPercentile->setEnabled(false); ui->showUnknownFlags->setEnabled(false); ui->calculateUnintentionalLeaks->setEnabled(false); - - p_profile->session->setBackupCardData(true); ui->createSDBackups->setChecked(true); ui->createSDBackups->setEnabled(false);