From ad15655ffb29a8de89f4d5a2c9762e699fe797a4 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Wed, 6 May 2020 11:42:03 -0400 Subject: [PATCH] Improve Viatom file selection on Windows. Also remove a warning about unexpected data. --- oscar/SleepLib/loader_plugins/viatom_loader.cpp | 7 ++----- oscar/mainwindow.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/oscar/SleepLib/loader_plugins/viatom_loader.cpp b/oscar/SleepLib/loader_plugins/viatom_loader.cpp index c784a779..1f61a8c3 100644 --- a/oscar/SleepLib/loader_plugins/viatom_loader.cpp +++ b/oscar/SleepLib/loader_plugins/viatom_loader.cpp @@ -303,11 +303,8 @@ bool ViatomFile::ParseHeader() //int spo2_avg = header[17]; //int spo2_min = header[18]; //int spo2_3pct = header[19]; // number of events - int spo2_4pct = header[20]; // number of events - if (header[21] > spo2_4pct) { - //CHECK_VALUE(header[21], 0); // sometimes nonzero; maybe spo2_5pct or something like that? - UNEXPECTED_VALUE(header[21], "< drops over 4%"); - } + //int spo2_4pct = header[20]; // number of events + //CHECK_VALUE(header[21], 0); // ??? sometimes nonzero; maybe pulse spike, not a threshold of SpO2 or pulse, not always smaller than spo2_4pct //int time_under_90pct = header[22] | (header[23] << 8); // in seconds //int events_under_90pct = header[24]; // number of distinct events //float o2_score = header[25] * 0.1; diff --git a/oscar/mainwindow.cpp b/oscar/mainwindow.cpp index 369e2199..d0ec5e89 100644 --- a/oscar/mainwindow.cpp +++ b/oscar/mainwindow.cpp @@ -2504,10 +2504,17 @@ void MainWindow::on_actionImport_Viatom_Data_triggered() #if defined(Q_OS_WIN) // Windows can't handle this name filter. w.setOption(QFileDialog::DontUseNativeDialog, true); + // And since the non-native dialog can't select both directories and files, + // it needs the following to enable selecting multiple files. + w.setFileMode(QFileDialog::ExistingFiles); #endif if (w.exec() == QFileDialog::Accepted) { QString filename = w.selectedFiles()[0]; + if (w.selectedFiles().size() > 1) { + // The user selected multiple files in a directory, so use the parent directory as the filename. + filename = QFileInfo(filename).absoluteDir().canonicalPath(); + } int c = viatom.Open(filename); if (c > 0) {