diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index f80fe389..c48459d1 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -240,7 +240,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile) SessionID session; long ext; typedef QVector StringList; - QHash sessfiles; + QMap sessfiles; int size=paths.size(); int cnt=0; bool ok; @@ -281,7 +281,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile) return 0; cnt=0; - for (QHash::iterator s=sessfiles.begin(); s!=sessfiles.end(); s++) { + for (QMap::iterator s=sessfiles.begin(); s!=sessfiles.end(); s++) { session=s.key(); cnt++; if (qprogress) qprogress->setValue(33.0+(float(cnt)/float(size)*33.0)); diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index 14f9c2bb..4e3f6908 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -266,7 +266,7 @@ int ResmedLoader::Open(QString & path,Profile *profile) dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setSorting(QDir::Name); QFileInfoList flist=dir.entryInfoList(); - QHash > sessfiles; + QMap > sessfiles; QString ext,rest,datestr,s,codestr; SessionID sessionid; @@ -285,8 +285,10 @@ int ResmedLoader::Open(QString & path,Profile *profile) sessionid=date.toTime_t(); // Resmed bugs up on the session filenames.. 1 second either way if (sessfiles.find(sessionid)==sessfiles.end()) { - if (sessfiles.find(sessionid+1)!=sessfiles.end()) sessionid++; - if (sessfiles.find(sessionid-1)!=sessfiles.end()) sessionid--; + if (sessfiles.find(sessionid+2)!=sessfiles.end()) sessionid+=2; + else if (sessfiles.find(sessionid+1)!=sessfiles.end()) sessionid++; + else if (sessfiles.find(sessionid-1)!=sessfiles.end()) sessionid--; + else if (sessfiles.find(sessionid-2)!=sessfiles.end()) sessionid-=2; } sessfiles[sessionid].push_back(fi.canonicalFilePath()); @@ -301,7 +303,7 @@ int ResmedLoader::Open(QString & path,Profile *profile) Session *sess; int cnt=0; size=sessfiles.size(); - for (QHash >::iterator si=sessfiles.begin();si!=sessfiles.end();si++) { + for (QMap >::iterator si=sessfiles.begin();si!=sessfiles.end();si++) { sessionid=si.key(); //qDebug() << "Parsing Session " << sessionid; bool done=false; diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index adbdb979..9741f7f1 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -346,12 +346,18 @@ Day *Machine::AddSession(Session *s,Profile *p) if (s->session()>highest_sessionid) highest_sessionid=s->session(); + QDateTime d1,d2=QDateTime::fromMSecsSinceEpoch(s->first()); QDate date=d2.date(); - //QTime time=d2.time(); + QTime time=d2.time(); - if (pref.Exists("NoonDataSplit") && pref["NoonDateSplit"].toBool()) { + if (s->session()==1311991200) { + int q=03; + } + QMap::iterator dit; + + if (pref.Exists("NoonDateSplit") && pref["NoonDateSplit"].toBool()) { int hour=d2.time().hour(); if (hour<12) date=date.addDays(-1); @@ -364,11 +370,12 @@ Day *Machine::AddSession(Session *s,Profile *p) bool previous=false; // Find what day session belongs to. - if (day.find(date)!=day.end()) { + dit=day.find(date); + if (dit!=day.end()) { // Previous day record exists... // Calculate time since end of previous days last session - span=(s->first() - day[date]->last())/3600000.0; + span=(s->first() - (*dit)->last())/3600000.0; // less than n hours since last session yesterday? if (span < hours_since_last_session) { @@ -405,18 +412,24 @@ Day *Machine::AddSession(Session *s,Profile *p) firstsession=false; } - if (day.find(date)==day.end()) { + + Day *dd=NULL; + dit=day.find(date); + if (dit==day.end()) { //QString dstr=date.toString("yyyyMMdd"); //qDebug("Adding Profile Day %s",dstr.toAscii().data()); - day[date]=new Day(this); + dd=new Day(this); + day[date]=dd; // Add this Day record to profile //QDateTime d=QDateTime::fromMSecsSinceEpoch(date); //qDebug() << "New day: " << d.toString("yyyy-MM-dd HH:mm:ss"); - p->AddDay(date,day[date],m_type); + p->AddDay(date,dd,m_type); + } else { + dd=*dit; } - day[date]->AddSession(s); + dd->AddSession(s); - return day[date]; + return dd; } // This functions purpose is murder and mayhem... It deletes all of a machines data. @@ -481,8 +494,8 @@ bool Machine::Load() QFileInfoList list=dir.entryInfoList(); typedef QVector StringList; - QHash sessfiles; - QHash::iterator s; + QMap sessfiles; + QMap::iterator s; QString fullpath,ext_s,sesstr; int ext;