Added Purge CPAP Day option in Data->Advanced. (Be careful, does not yet ask for confirmation)

This commit is contained in:
Mark Watkins 2011-12-08 14:10:35 +10:00
parent 4756c734f5
commit 8d7e6f785a
17 changed files with 98 additions and 49 deletions

View File

@ -1196,7 +1196,7 @@ void gGraph::mouseMoveEvent(QMouseEvent * event)
if (a2>w) a2=w;
m_selecting_area=true;
m_selection=QRect(a1-m_marginleft-1,0,a2-a1,m_lastbounds.height());
double w2=m_lastbounds.width();-(right+m_marginright)-(m_marginleft+left);
double w2=m_lastbounds.width(); //-(right+m_marginright)-(m_marginleft+left);
if (m_blockzoom) {
xmult=(rmax_x-rmin_x)/w2;
} else xmult=(max_x-min_x)/w2;

View File

@ -62,7 +62,7 @@ void SummaryChart::SetDay(Day * nullday)
m_empty=true;
int suboffset;
SummaryType type;
for (QMap<QDate,QVector<Day *> >::iterator d=PROFILE.daylist.begin();d!=PROFILE.daylist.end();d++) {
for (QMap<QDate,QList<Day *> >::iterator d=PROFILE.daylist.begin();d!=PROFILE.daylist.end();d++) {
tt=QDateTime(d.key(),QTime(0,0,0),Qt::UTC).toTime_t();
dn=tt/86400;
tt*=1000L;
@ -75,7 +75,7 @@ void SummaryChart::SetDay(Day * nullday)
for (int i=0;i<m_codes.size();i++)
m_goodcodes[i]=true;
for (int i=0;i<d.value().size();i++) { // for each day
day=d.value()[i];
day=d.value().at(i);
if (!day) continue;
if (day->machine_type()!=m_machinetype) continue;
int ft=qint64(day->first())/1000L;
@ -181,11 +181,11 @@ void SummaryChart::SetDay(Day * nullday)
ChannelID code=m_codes[j];
if (type==ST_HOURS || type==ST_SESSIONS || m_zeros[j]) continue;
for (QMap<QDate,QVector<Day *> >::iterator d=PROFILE.daylist.begin();d!=PROFILE.daylist.end();d++) {
for (QMap<QDate,QList<Day *> >::iterator d=PROFILE.daylist.begin();d!=PROFILE.daylist.end();d++) {
tt=QDateTime(d.key(),QTime(0,0,0),Qt::UTC).toTime_t();
dn=tt/86400;
for (int i=0;i<d.value().size();i++) { // for each machine object for this day
day=d.value()[i];
day=d.value().at(i);
if (day->machine_type()!=m_machinetype) continue;
if (!m_values[dn].contains(j+1)) {
m_days[dn]=day;

View File

@ -88,7 +88,7 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub
QVector<int> breaths;
QVector<EventDataType> TV;
QVector<qint64> breaths_start;
int lasti=0;
//int lasti=0;
for (i=0;i<size;i++) {
c=stage1[i];
@ -152,7 +152,7 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub
QVector<EventDataType> TV2;
QVector<qint64> TV2_start;
int fir=0,fir2=0;
int fir=0;//,fir2=0;
EventDataType T,L;
bool done=false;
do {
@ -208,7 +208,7 @@ int filterFlow(EventList *in, EventList *out, EventList *tv, EventList *mv, doub
t1+=window/2.0;
t2+=window/2.0;
} while (t2<in->last());
} while (t2<in->last() && !done);
for (int i=2;i<breaths2.size()-2;i++) {
t=breaths2_start[i];
@ -333,9 +333,7 @@ int calcLeaks(Session *session)
const qint64 winsize=3600000; // 5 minute window
qint64 first=session->first(),
last=session->last(),
f;
//qint64 first=session->first(), last=session->last(), f;
EventList *leak=new EventList(EVL_Event);
session->eventlist[CPAP_Leak].push_back(leak);

View File

@ -309,9 +309,9 @@ Machine *CMS50Loader::CreateMachine(Profile *profile)
// NOTE: This only allows for one CMS50 machine per profile..
// Upgrading their oximeter will use this same record..
QVector<Machine *> ml=profile->GetMachines(MT_OXIMETER);
QList<Machine *> ml=profile->GetMachines(MT_OXIMETER);
for (QVector<Machine *>::iterator i=ml.begin(); i!=ml.end(); i++) {
for (QList<Machine *>::iterator i=ml.begin(); i!=ml.end(); i++) {
if ((*i)->GetClass()==cms50_class_name) {
return (*i);
break;

View File

@ -351,9 +351,9 @@ Machine *IntellipapLoader::CreateMachine(QString serial,Profile *profile)
return NULL;
qDebug() << "Create Machine " << serial;
QVector<Machine *> ml=profile->GetMachines(MT_CPAP);
QList<Machine *> ml=profile->GetMachines(MT_CPAP);
bool found=false;
QVector<Machine *>::iterator i;
QList<Machine *>::iterator i;
for (i=ml.begin(); i!=ml.end(); i++) {
if (((*i)->GetClass()==intellipap_class_name) && ((*i)->properties["Serial"]==serial)) {
MachList[serial]=*i; //static_cast<CPAP *>(*i);

View File

@ -120,9 +120,9 @@ Machine *PRS1Loader::CreateMachine(QString serial,Profile *profile)
return NULL;
qDebug() << "Create Machine " << serial;
QVector<Machine *> ml=profile->GetMachines(MT_CPAP);
QList<Machine *> ml=profile->GetMachines(MT_CPAP);
bool found=false;
QVector<Machine *>::iterator i;
QList<Machine *>::iterator i;
for (i=ml.begin(); i!=ml.end(); i++) {
if (((*i)->GetClass()=="PRS1") && ((*i)->properties["Serial"]==serial)) {
PRS1List[serial]=*i; //static_cast<CPAP *>(*i);

View File

@ -215,9 +215,9 @@ ResmedLoader::~ResmedLoader()
Machine *ResmedLoader::CreateMachine(QString serial,Profile *profile)
{
if (!profile) return NULL;
QVector<Machine *> ml=profile->GetMachines(MT_CPAP);
QList<Machine *> ml=profile->GetMachines(MT_CPAP);
bool found=false;
QVector<Machine *>::iterator i;
QList<Machine *>::iterator i;
for (i=ml.begin(); i!=ml.end(); i++) {
if (((*i)->GetClass()==resmed_class_name) && ((*i)->properties["Serial"]==serial)) {
ResmedList[serial]=*i; //static_cast<CPAP *>(*i);

View File

@ -60,9 +60,9 @@ Machine *ZEOLoader::CreateMachine(Profile *profile)
// NOTE: This only allows for one ZEO machine per profile..
// Upgrading their ZEO will use this same record..
QVector<Machine *> ml=profile->GetMachines(MT_SLEEPSTAGE);
QList<Machine *> ml=profile->GetMachines(MT_SLEEPSTAGE);
for (QVector<Machine *>::iterator i=ml.begin(); i!=ml.end(); i++) {
for (QList<Machine *>::iterator i=ml.begin(); i!=ml.end(); i++) {
if ((*i)->GetClass()==zeo_class_name) {
return (*i);
break;

View File

@ -173,8 +173,8 @@ Day *Machine::AddSession(Session *s,Profile *p)
for (QVector<Session *>::iterator i=nextday.value()->begin();i!=nextday.value()->end();i++) {
dd->AddSession(*i);
}
QMap<QDate,QVector<Day *> >::iterator nd=p->daylist.find(date.addDays(1));
for (QVector<Day *>::iterator i=nd->begin();i!=nd->end();i++) {
QMap<QDate,QList<Day *> >::iterator nd=p->daylist.find(date.addDays(1));
for (QList<Day *>::iterator i=nd->begin();i!=nd->end();i++) {
if (*i==nextday.value()) {
nd.value().erase(i);
}

View File

@ -10,9 +10,9 @@
#include "machine_loader.h"
// This crap moves to Profile
QVector<MachineLoader *> m_loaders;
QList<MachineLoader *> m_loaders;
QVector<MachineLoader *> GetLoaders()
QList<MachineLoader *> GetLoaders()
{
return m_loaders;
}
@ -23,7 +23,7 @@ void RegisterLoader(MachineLoader *loader)
}
void DestroyLoaders()
{
for (QVector<MachineLoader *>::iterator i=m_loaders.begin(); i!=m_loaders.end(); i++) {
for (QList<MachineLoader *>::iterator i=m_loaders.begin(); i!=m_loaders.end(); i++) {
delete (*i);
}
m_loaders.clear();
@ -40,7 +40,7 @@ MachineLoader::MachineLoader()
}*/
MachineLoader::~MachineLoader()
{
for (QVector<Machine *>::iterator m=m_machlist.begin();m!=m_machlist.end();m++) {
for (QList<Machine *>::iterator m=m_machlist.begin();m!=m_machlist.end();m++) {
delete *m;
}
}

View File

@ -47,7 +47,7 @@ public:
virtual bool SaveWaveform(Machine * m, QString & filename);*/
protected:
QVector<Machine *> m_machlist;
QList<Machine *> m_machlist;
QString m_class;
MachineType m_type;
Profile * m_profile;
@ -55,6 +55,6 @@ protected:
void RegisterLoader(MachineLoader *loader);
void DestroyLoaders();
QVector<MachineLoader *> GetLoaders();
QList<MachineLoader *> GetLoaders();
#endif //MACHINE_LOADER_H

View File

@ -204,8 +204,8 @@ void Profile::AddDay(QDate date,Day *day,MachineType mt) {
if (m_last<date) m_last=date;
// Check for any other machines of same type.. Throw an exception if one already exists.
QVector<Day *> & dl=daylist[date];
for (QVector<Day *>::iterator a=dl.begin();a!=dl.end();a++) {
QList<Day *> & dl=daylist[date];
for (QList<Day *>::iterator a=dl.begin();a!=dl.end();a++) {
if ((*a)->machine->GetType()==mt) {
throw OneTypePerDay();
}
@ -218,7 +218,7 @@ Day * Profile::GetDay(QDate date,MachineType type)
Day *day=NULL;
// profile-> why did I d that??
if (daylist.find(date)!=daylist.end()) {
for (QVector<Day *>::iterator di=daylist[date].begin();di!=daylist[date].end();di++) {
for (QList<Day *>::iterator di=daylist[date].begin();di!=daylist[date].end();di++) {
if (type==MT_UNKNOWN) { // Who cares.. We just want to know there is data available.
day=(*di);
break;
@ -244,8 +244,8 @@ int Profile::Import(QString path)
path=path.replace("\\","/");
if (path.endsWith("/")) path.chop(1);
QVector<MachineLoader *>loaders=GetLoaders();
for (QVector<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) {
QList<MachineLoader *>loaders=GetLoaders();
for (QList<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) {
if (c+=(*i)->Open(path,this)) break;
}
//qDebug() << "Import Done";
@ -255,8 +255,8 @@ int Profile::Import(QString path)
MachineLoader * GetLoader(QString name)
{
MachineLoader *l=NULL;
QVector<MachineLoader *>loaders=GetLoaders();
for (QVector<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) {
QList<MachineLoader *>loaders=GetLoaders();
for (QList<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) {
if ((*i)->ClassName()==name) {
l=*i;
break;
@ -266,10 +266,10 @@ MachineLoader * GetLoader(QString name)
}
QVector<Machine *> Profile::GetMachines(MachineType t)
QList<Machine *> Profile::GetMachines(MachineType t)
// Returns a QVector containing all machine objects regisered of type t
{
QVector<Machine *> vec;
QList<Machine *> vec;
QHash<MachineID,Machine *>::iterator i;
for (i=machlist.begin(); i!=machlist.end(); i++) {
@ -286,7 +286,7 @@ QVector<Machine *> Profile::GetMachines(MachineType t)
Machine * Profile::GetMachine(MachineType t)
{
QVector<Machine *>vec=GetMachines(t);
QList<Machine *>vec=GetMachines(t);
if (vec.size()==0) return NULL;
return vec[0];
@ -294,7 +294,7 @@ Machine * Profile::GetMachine(MachineType t)
void Profile::RemoveSession(Session * sess)
{
QMap<QDate,QVector<Day *> >::iterator di;
QMap<QDate,QList<Day *> >::iterator di;
for (di=daylist.begin();di!=daylist.end();di++) {
for (int d=0;d<di.value().size();d++) {

View File

@ -11,7 +11,6 @@ License: GPL
#define PROFILES_H
#include <QString>
#include <map>
#include "machine.h"
#include "machine_loader.h"
#include "preferences.h"
@ -43,14 +42,14 @@ public:
void AddDay(QDate date,Day *day,MachineType mt);
Day * GetDay(QDate date,MachineType type=MT_UNKNOWN);
QVector<Machine *> GetMachines(MachineType t);
QList<Machine *> GetMachines(MachineType t);
Machine * GetMachine(MachineType t,QDate date);
Machine * GetMachine(MachineType t);
virtual void ExtraLoad(QDomElement & root);
virtual QDomElement ExtraSave(QDomDocument & doc);
QMap<QDate,QVector<Day *> > daylist;
QMap<QDate,QList<Day *> > daylist;
const QDate & FirstDay() { return m_first; }
const QDate & LastDay() { return m_last; }

View File

@ -45,7 +45,6 @@ public:
void RedrawGraphs();
void LoadDate(QDate date);
QDate getDate() { return previous_date; }
void PrintReport();
void UnitsChanged();

View File

@ -860,9 +860,6 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
first=false;
}
gGraph *g=(*gv)[i];
if (g->title()=="Minute Vent.") {
int i=0;
}
if (g->isEmpty()) continue;
if (!g->visible()) continue;
g->deselect();
@ -907,14 +904,14 @@ void MainWindow::on_action_Rebuild_Oximetry_Index_triggered()
QVector<QString> invalid;
QVector<Machine *> machines=PROFILE.GetMachines(MT_OXIMETER);
QList<Machine *> machines=PROFILE.GetMachines(MT_OXIMETER);
bool ok;
int discard_threshold=PROFILE["OxiDiscardThreshold"].toInt(&ok);
if (!ok) discard_threshold=10;
Machine *m;
for (int z=0;z<machines.size();z++) {
m=machines[z];
m=machines.at(z);
//m->sessionlist.erase(m->sessionlist.find(0));
for (QHash<SessionID,Session *>::iterator s=m->sessionlist.begin();s!=m->sessionlist.end();s++) {
Session *sess=s.value();
@ -1009,3 +1006,37 @@ void MainWindow::on_actionChange_User_triggered()
#endif
}
void MainWindow::on_actionPurge_Current_Day_triggered()
{
QDate date=getDaily()->getDate();
Day *day=PROFILE.GetDay(date,MT_CPAP);
Machine *m;
if (day) {
m=day->machine;
QString path=PROFILE.Get("DataFolder")+QDir::separator()+m->hexid()+QDir::separator();
QVector<Session *>::iterator s,km=day->end();
for (s=day->begin();s!=day->end();s++) {
SessionID id=(*s)->session();
QString filename0=path+QString().sprintf("%08lx.000",id);
QString filename1=path+QString().sprintf("%08lx.001",id);
qDebug() << "Removing" << filename0;
qDebug() << "Removing" << filename1;
QFile::remove(filename0);
QFile::remove(filename1);
m->sessionlist.erase(m->sessionlist.find(id)); // remove from machines session list
}
QList<Day *> & dl=PROFILE.daylist[date];
QList<Day *>::iterator it;//=dl.begin();
for (it=dl.begin();it!=dl.end();it++) {
if ((*it)==day) break;
}
if (it!=dl.end()) {
PROFILE.daylist[date].erase(it);
delete day;
}
}
getDaily()->ReloadGraphs();
}

View File

@ -118,6 +118,8 @@ private slots:
void on_actionChange_User_triggered();
void on_actionPurge_Current_Day_triggered();
private:
Ui::MainWindow *ui;

View File

@ -615,7 +615,22 @@
<property name="title">
<string>&amp;Data</string>
</property>
<widget class="QMenu" name="menu_Advanced">
<property name="title">
<string>&amp;Advanced</string>
</property>
<widget class="QMenu" name="menu_Purge_CPAP_Data">
<property name="title">
<string>&amp;Purge CPAP Data</string>
</property>
<addaction name="actionPurge_Current_Day"/>
</widget>
<addaction name="menu_Purge_CPAP_Data"/>
</widget>
<addaction name="action_Rebuild_Oximetry_Index"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="menu_Advanced"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_View"/>
@ -779,6 +794,11 @@
<string>Change &amp;User</string>
</property>
</action>
<action name="actionPurge_Current_Day">
<property name="text">
<string>&amp;Current Selected Day</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>