mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 11:10:44 +00:00
Support multi-file imports for Somnopose
This commit is contained in:
parent
56cf4a452c
commit
a1e011da4d
@ -2394,16 +2394,46 @@ void MainWindow::on_actionImport_Somnopose_Data_triggered()
|
|||||||
w.setNameFilters(QStringList("Somnopause CSV File (*.csv)"));
|
w.setNameFilters(QStringList("Somnopause CSV File (*.csv)"));
|
||||||
|
|
||||||
SomnoposeLoader somno;
|
SomnoposeLoader somno;
|
||||||
|
// Display progress if we have more than 1 file to load...
|
||||||
|
ProgressDialog progress(this);
|
||||||
|
|
||||||
if (w.exec() == QFileDialog::Accepted) {
|
if (w.exec() == QFileDialog::Accepted) {
|
||||||
QString filename = w.selectedFiles()[0];
|
int i, skipped = 0;
|
||||||
|
int size = w.selectedFiles().size();
|
||||||
|
if (size > 1) {
|
||||||
|
progress.setMessage(QObject::tr("Importing Sessions..."));
|
||||||
|
progress.setProgressMax(size);
|
||||||
|
progress.setProgressValue(0);
|
||||||
|
progress.setWindowModality(Qt::ApplicationModal);
|
||||||
|
progress.open();
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
for (i=0; i < size; i++) {
|
||||||
|
QString filename = w.selectedFiles()[i];
|
||||||
|
|
||||||
if (!somno.OpenFile(filename)) {
|
int res = somno.OpenFile(filename);
|
||||||
Notify(tr("There was a problem opening Somnopose Data File: ") + filename);
|
if (!res) {
|
||||||
return;
|
if (i == 0) {
|
||||||
|
Notify(tr("There was a problem opening Somnopose Data File: ") + filename);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Notify(tr("Somnopause Data Import of %1 file(s) complete").arg(i) + "\n\n" +
|
||||||
|
tr("There was a problem opening Somnopose Data File: ") + filename,
|
||||||
|
tr("Somnopose Import Partial Success"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res < 0) {
|
||||||
|
// Should we report on skipped count?
|
||||||
|
skipped++;
|
||||||
|
}
|
||||||
|
progress.setProgressValue(i+1);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
Notify(tr("Somnopause Data Import complete"));
|
if (i == size) {
|
||||||
|
Notify(tr("Somnopause Data Import complete"));
|
||||||
|
}
|
||||||
PopulatePurgeMenu();
|
PopulatePurgeMenu();
|
||||||
if (overview) overview->ReloadGraphs();
|
if (overview) overview->ReloadGraphs();
|
||||||
if (welcome) welcome->refreshPage();
|
if (welcome) welcome->refreshPage();
|
||||||
|
Loading…
Reference in New Issue
Block a user