mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 03:30:44 +00:00
Move Viatom filename pattern matching into loader.
This commit is contained in:
parent
c06057ef14
commit
b6f7ebac6f
@ -172,6 +172,11 @@ void ViatomLoader::EndEventList(ChannelID channel, qint64 /*t*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList ViatomLoader::getNameFilter()
|
||||||
|
{
|
||||||
|
return QStringList("20[0-5][0-9][01][0-9][0-3][0-9][012][0-9][0-5][0-9][0-5][0-9]");
|
||||||
|
}
|
||||||
|
|
||||||
static bool viatom_initialized = false;
|
static bool viatom_initialized = false;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -40,6 +40,8 @@ class ViatomLoader : public MachineLoader
|
|||||||
return MachineInfo(MT_OXIMETER, 0, viatom_class_name, QObject::tr("Viatom"), QString(), QString(), QString(), QObject::tr("Viatom Software"), QDateTime::currentDateTime(), viatom_data_version);
|
return MachineInfo(MT_OXIMETER, 0, viatom_class_name, QObject::tr("Viatom"), QString(), QString(), QString(), QObject::tr("Viatom Software"), QDateTime::currentDateTime(), viatom_data_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList getNameFilter();
|
||||||
|
|
||||||
//Machine *CreateMachine();
|
//Machine *CreateMachine();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -2399,13 +2399,13 @@ void MainWindow::on_actionImport_Somnopose_Data_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionImport_Viatom_Data_triggered()
|
void MainWindow::on_actionImport_Viatom_Data_triggered()
|
||||||
{
|
{
|
||||||
|
ViatomLoader viatom;
|
||||||
|
|
||||||
QFileDialog w;
|
QFileDialog w;
|
||||||
w.setFileMode(QFileDialog::ExistingFiles);
|
w.setFileMode(QFileDialog::AnyFile);
|
||||||
w.setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
w.setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
w.setOption(QFileDialog::ShowDirsOnly, false);
|
w.setOption(QFileDialog::ShowDirsOnly, false);
|
||||||
w.setNameFilters(QStringList("Viatom Data File (20[0-5][0-9][01][0-9][0-3][0-9][012][0-9][0-5][0-9][0-5][0-9])"));
|
w.setNameFilters(viatom.getNameFilter());
|
||||||
|
|
||||||
ViatomLoader viatom;
|
|
||||||
|
|
||||||
if (w.exec() == QFileDialog::Accepted) {
|
if (w.exec() == QFileDialog::Accepted) {
|
||||||
QString filename = w.selectedFiles()[0];
|
QString filename = w.selectedFiles()[0];
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "viatomtests.h"
|
#include "viatomtests.h"
|
||||||
#include "sessiontests.h"
|
#include "sessiontests.h"
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
#define TESTDATA_PATH "./testdata/"
|
#define TESTDATA_PATH "./testdata/"
|
||||||
|
|
||||||
@ -47,17 +46,14 @@ static void parseAndEmitSessionYaml(const QString & path)
|
|||||||
void ViatomTests::testSessionsToYaml()
|
void ViatomTests::testSessionsToYaml()
|
||||||
{
|
{
|
||||||
static const QString root = TESTDATA_PATH "viatom/input/";
|
static const QString root = TESTDATA_PATH "viatom/input/";
|
||||||
static const QRegularExpression re("(20[0-5][0-9][01][0-9][0-3][0-9][012][0-9][0-5][0-9][0-5][0-9])");
|
|
||||||
|
|
||||||
QDir dir(root);
|
QDir dir(root);
|
||||||
dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks);
|
dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks);
|
||||||
|
dir.setNameFilters(s_loader->getNameFilter());
|
||||||
dir.setSorting(QDir::Name);
|
dir.setSorting(QDir::Name);
|
||||||
|
|
||||||
for (auto & fi : dir.entryInfoList()) {
|
for (auto & fi : dir.entryInfoList()) {
|
||||||
QRegularExpressionMatch match = re.match(fi.fileName());
|
parseAndEmitSessionYaml(fi.canonicalFilePath());
|
||||||
if (match.hasMatch()) {
|
|
||||||
parseAndEmitSessionYaml(fi.canonicalFilePath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user