mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 02:30:44 +00:00
Display MessageBox on Import Failure
This commit is contained in:
parent
30e9cd94a5
commit
3aac219aad
@ -37,7 +37,7 @@ CMS50Loader::~CMS50Loader()
|
||||
{
|
||||
//dtor
|
||||
}
|
||||
bool CMS50Loader::Open(QString & path,Profile *profile)
|
||||
int CMS50Loader::Open(QString & path,Profile *profile)
|
||||
{
|
||||
// CMS50 folder structure detection stuff here.
|
||||
|
||||
@ -62,16 +62,16 @@ bool CMS50Loader::Open(QString & path,Profile *profile)
|
||||
// My Logger
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
bool CMS50Loader::OpenCMS50(QString & path, Profile *profile)
|
||||
int CMS50Loader::OpenCMS50(QString & path, Profile *profile)
|
||||
{
|
||||
QString filename,pathname;
|
||||
list<QString> files;
|
||||
QDir dir(path);
|
||||
|
||||
if (!dir.exists())
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
if(qprogress) qprogress->setValue(0);
|
||||
|
||||
@ -89,7 +89,7 @@ bool CMS50Loader::OpenCMS50(QString & path, Profile *profile)
|
||||
|
||||
}
|
||||
int size=files.size();
|
||||
if (size==0) return false;
|
||||
if (size==0) return 0;
|
||||
|
||||
Machine *mach=CreateMachine(profile);
|
||||
int cnt=0;
|
||||
@ -99,7 +99,7 @@ bool CMS50Loader::OpenCMS50(QString & path, Profile *profile)
|
||||
}
|
||||
mach->Save();
|
||||
if (qprogress) qprogress->setValue(100);
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
bool CMS50Loader::OpenSPORFile(QString path,Machine *mach,Profile *profile)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ class CMS50Loader : public MachineLoader
|
||||
|
||||
CMS50Loader();
|
||||
virtual ~CMS50Loader();
|
||||
virtual bool Open(QString & path,Profile *profile);
|
||||
virtual int Open(QString & path,Profile *profile);
|
||||
static void Register();
|
||||
|
||||
virtual int Version() { return cms50_data_version; };
|
||||
@ -30,7 +30,7 @@ class CMS50Loader : public MachineLoader
|
||||
|
||||
|
||||
protected:
|
||||
bool OpenCMS50(QString & path, Profile *profile);
|
||||
int OpenCMS50(QString & path, Profile *profile);
|
||||
bool OpenSPORFile(QString path, Machine * machine,Profile *profile);
|
||||
|
||||
private:
|
||||
|
@ -93,7 +93,7 @@ bool isdigit(QChar c)
|
||||
if ((c>='0') && (c<='9')) return true;
|
||||
return false;
|
||||
}
|
||||
bool PRS1Loader::Open(QString & path,Profile *profile)
|
||||
int PRS1Loader::Open(QString & path,Profile *profile)
|
||||
{
|
||||
|
||||
QString newpath;
|
||||
@ -157,11 +157,9 @@ bool PRS1Loader::Open(QString & path,Profile *profile)
|
||||
delete m;
|
||||
}
|
||||
}
|
||||
|
||||
return PRS1List.size();
|
||||
|
||||
// return c;
|
||||
}
|
||||
|
||||
bool PRS1Loader::ParseProperties(Machine *m,QString filename)
|
||||
{
|
||||
QFile f(filename);
|
||||
|
@ -43,9 +43,9 @@ class PRS1Loader : public MachineLoader
|
||||
public:
|
||||
PRS1Loader();
|
||||
virtual ~PRS1Loader();
|
||||
virtual bool Open(QString & path,Profile *profile);
|
||||
virtual int Version() { return prs1_data_version; };
|
||||
virtual const QString & ClassName() { return prs1_class_name; };
|
||||
virtual int Open(QString & path,Profile *profile);
|
||||
virtual int Version() { return prs1_data_version; }
|
||||
virtual const QString & ClassName() { return prs1_class_name; }
|
||||
Machine *CreateMachine(QString serial,Profile *profile);
|
||||
|
||||
static void Register();
|
||||
|
@ -213,14 +213,14 @@ Machine *ResmedLoader::CreateMachine(QString serial,Profile *profile)
|
||||
|
||||
long event_cnt=0;
|
||||
|
||||
bool ResmedLoader::Open(QString & path,Profile *profile)
|
||||
int ResmedLoader::Open(QString & path,Profile *profile)
|
||||
{
|
||||
|
||||
QString newpath;
|
||||
|
||||
QString dirtag="DATALOG";
|
||||
if (path.endsWith("/"+dirtag)) {
|
||||
return false; // id10t user..
|
||||
return 0; // id10t user..
|
||||
//newpath=path;
|
||||
} else {
|
||||
newpath=path+"/"+dirtag;
|
||||
@ -230,7 +230,7 @@ bool ResmedLoader::Open(QString & path,Profile *profile)
|
||||
map<QString,QString> idmap;
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
if (!f.isReadable())
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
while (!f.atEnd()) {
|
||||
QString line=f.readLine().trimmed();
|
||||
@ -373,7 +373,7 @@ bool ResmedLoader::Open(QString & path,Profile *profile)
|
||||
m->Save();
|
||||
if (qprogress) qprogress->setValue(100);
|
||||
qDebug() << "Total Events " << event_cnt;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf)
|
||||
|
@ -99,7 +99,7 @@ class ResmedLoader : public MachineLoader
|
||||
public:
|
||||
ResmedLoader();
|
||||
virtual ~ResmedLoader();
|
||||
virtual bool Open(QString & path,Profile *profile);
|
||||
virtual int Open(QString & path,Profile *profile);
|
||||
|
||||
virtual int Version() { return resmed_data_version; };
|
||||
virtual const QString & ClassName() { return resmed_class_name; };
|
||||
|
@ -26,11 +26,11 @@ ZEOLoader::~ZEOLoader()
|
||||
{
|
||||
//dtor
|
||||
}
|
||||
bool ZEOLoader::Open(QString & path,Profile *profile)
|
||||
int ZEOLoader::Open(QString & path,Profile *profile)
|
||||
{
|
||||
// ZEO folder structure detection stuff here.
|
||||
|
||||
return false;
|
||||
return 0; // number of machines affected
|
||||
}
|
||||
Machine *ZEOLoader::CreateMachine(Profile *profile)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ class ZEOLoader : public MachineLoader
|
||||
public:
|
||||
ZEOLoader();
|
||||
virtual ~ZEOLoader();
|
||||
virtual bool Open(QString & path,Profile *profile);
|
||||
virtual int Open(QString & path,Profile *profile);
|
||||
static void Register();
|
||||
|
||||
virtual int Version() { return zeo_data_version; };
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
|
||||
//virtual Machine * CreateMachine() {};
|
||||
|
||||
virtual bool Open(QString &,Profile *)=0; // Scans for new content
|
||||
virtual int Open(QString &,Profile *)=0; // Scans for new content
|
||||
virtual int Version()=0;
|
||||
virtual const QString & ClassName()=0;
|
||||
|
||||
|
@ -203,7 +203,7 @@ Day * Profile::GetDay(QDate date,MachineType type)
|
||||
* @brief Import Machine Data
|
||||
* @param path
|
||||
*/
|
||||
void Profile::Import(QString path)
|
||||
int Profile::Import(QString path)
|
||||
{
|
||||
int c=0;
|
||||
qDebug() << "Importing " << path;
|
||||
@ -211,6 +211,7 @@ void Profile::Import(QString path)
|
||||
for (list<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) {
|
||||
if (c+=(*i)->Open(path,this)) break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
MachineLoader * GetLoader(QString name)
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void AddMachine(Machine *m);
|
||||
void DelMachine(Machine *m);
|
||||
void LoadMachineData();
|
||||
void Import(QString path);
|
||||
int Import(QString path);
|
||||
|
||||
void AddDay(QDate date,Day *day,MachineType mt);
|
||||
Day * GetDay(QDate date,MachineType type=MT_UNKNOWN);
|
||||
@ -49,8 +49,8 @@ public:
|
||||
virtual void ExtraLoad(TiXmlHandle *root);
|
||||
virtual TiXmlElement * ExtraSave();
|
||||
map<QDate,vector<Day *> > daylist;
|
||||
const QDate & FirstDay() { return m_first; };
|
||||
const QDate & LastDay() { return m_last; };
|
||||
const QDate & FirstDay() { return m_first; }
|
||||
const QDate & LastDay() { return m_last; }
|
||||
|
||||
protected:
|
||||
QDate m_first,m_last;
|
||||
|
@ -119,14 +119,21 @@ void MainWindow::on_action_Import_Data_triggered()
|
||||
qprogress->show();
|
||||
qstatus->setText(tr("Importing Data"));
|
||||
dirNames=qfd.selectedFiles();
|
||||
int c=0,d;
|
||||
for (int i=0;i<dirNames.size();i++) {
|
||||
profile->Import(dirNames[i]);
|
||||
d=profile->Import(dirNames[i]);
|
||||
if (!d) {
|
||||
QMessageBox::warning(this,"Import Problem","Couldn't Find any Machine Data at this location:\n"+dirNames[i],QMessageBox::Ok);
|
||||
}
|
||||
c+=d;
|
||||
}
|
||||
profile->Save();
|
||||
if (daily) daily->ReloadGraphs();
|
||||
if (overview) {
|
||||
overview->ReloadGraphs();
|
||||
overview->UpdateGraphs();
|
||||
if (c) {
|
||||
profile->Save();
|
||||
if (daily) daily->ReloadGraphs();
|
||||
if (overview) {
|
||||
overview->ReloadGraphs();
|
||||
overview->UpdateGraphs();
|
||||
}
|
||||
}
|
||||
qstatus->setText(tr("Ready"));
|
||||
qprogress->hide();
|
||||
|
Loading…
Reference in New Issue
Block a user