diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index 1b1aa9e8..da7b3044 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -2585,3 +2585,9 @@ bool gGraphView::LoadSettings(QString title) return true; } +gGraph *gGraphView::findGraph(QString name) +{ + QHash::iterator i=m_graphsbytitle.find(name); + if (i==m_graphsbytitle.end()) return NULL; + return i.value(); +} diff --git a/Graphs/gGraphView.h b/Graphs/gGraphView.h index 6b00b477..4d5f40eb 100644 --- a/Graphs/gGraphView.h +++ b/Graphs/gGraphView.h @@ -404,7 +404,7 @@ public: void SaveSettings(QString title); bool LoadSettings(QString title); - int findGraph(QString name); + gGraph *findGraph(QString name); //bool hasGraphs() { return m_graphs.size()>0; } diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index 49ceaf0d..c31234a4 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -585,6 +585,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 int pos=0; int cnt=0; short delta; + int tdata; while (pos0x12) { @@ -721,7 +722,8 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 if (!Code[17]) { if (!(Code[17]=session->AddEventList(PRS1_0E,EVL_Event))) return false; } - Code[17]->AddEvent(t,data[0]); + tdata=unsigned(data[1]) << 8 | unsigned(data[0]); + Code[17]->AddEvent(t,tdata); //qDebug() << hex << data[0] << data[1] << data[2]; //session->AddEvent(new Event(t,cpapcode, 0, data, 3)); //tt-=data[1]*1000; diff --git a/daily.cpp b/daily.cpp index 4a60e9db..53ebb031 100644 --- a/daily.cpp +++ b/daily.cpp @@ -4,9 +4,6 @@ License: GPL */ -#include "daily.h" -#include "ui_daily.h" - #include #include #include @@ -18,6 +15,9 @@ #include #include +#include "daily.h" +#include "ui_daily.h" + #include "common_gui.h" #include "SleepLib/profiles.h" #include "SleepLib/session.h" @@ -188,7 +188,6 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) PTB->AddLayer(AddCPAP(new gLineChart(CPAP_PTB,Qt::gray,square))); MP->AddLayer(AddCPAP(new gLineChart(CPAP_MaskPressure,Qt::blue,false))); - RR->AddLayer(AddCPAP(new gLineChart("RespRate2",Qt::red,square))); RR->AddLayer(AddCPAP(new gLineChart(CPAP_RespRate,Qt::darkMagenta,square))); MV->AddLayer(AddCPAP(new gLineChart(CPAP_MinuteVent,Qt::darkCyan,square))); TV->AddLayer(AddCPAP(new gLineChart(CPAP_TidalVolume,Qt::magenta,square))); @@ -912,11 +911,8 @@ void Daily::RedrawGraphs() GraphView->updateGL(); } -void Daily::on_treeWidget_itemSelectionChanged() +void Daily::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column) { - if (ui->treeWidget->selectedItems().size()==0) return; - QTreeWidgetItem *item=ui->treeWidget->selectedItems().at(0); - if (!item) return; QDateTime d; if (!item->text(1).isEmpty()) { d=d.fromString(item->text(1),"yyyy-MM-dd HH:mm:ss"); @@ -924,19 +920,28 @@ void Daily::on_treeWidget_itemSelectionChanged() double st=qint64((d.addSecs(-(winsize/2))).toTime_t())*1000L; double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L; - if (st<(*GraphView)[0]->rmin_x) { - st=(*GraphView)[0]->rmin_x; - //et=st+winsize*1000; + gGraph *g=GraphView->findGraph("Event Flags"); + if (!g) return; + if (strmin_x) { + st=g->rmin_x; + et=st+winsize*1000; } - if (et>(*GraphView)[0]->rmax_x) { - et=(*GraphView)[0]->rmax_x; - //st=et-winsize*1000; + if (et>g->rmax_x) { + et=g->rmax_x; + st=et-winsize*1000; } - GraphView->SetXBounds(st,et); } } +void Daily::on_treeWidget_itemSelectionChanged() +{ + if (ui->treeWidget->selectedItems().size()==0) return; + QTreeWidgetItem *item=ui->treeWidget->selectedItems().at(0); + if (!item) return; + on_treeWidget_itemClicked(item, 0); +} + void Daily::on_JournalNotesUnderline_clicked() { QTextCursor cursor = ui->JournalNotes->textCursor(); @@ -1004,10 +1009,10 @@ void Daily::on_evViewSlider_valueChanged(int value) { ui->evViewLCD->display(value); PROFILE["EventViewSize"]=value; - //ui->evViewSlider->value(); int winsize=PROFILE["EventViewSize"].toInt()*60; + return; if (0) { /* if (ui->treeWidget->selectedItems().size()==0) return; QTreeWidgetItem *item=ui->treeWidget->selectedItems().at(0); @@ -1020,34 +1025,38 @@ void Daily::on_evViewSlider_valueChanged(int value) double st=qint64((d.addSecs(-(winsize/2))).toTime_t())*1000L; double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L; - if (st<(*GraphView)[0]->rmin_x) { - st=(*GraphView)[0]->rmin_x; + gGraph *g=GraphView->findGraph("Event Flags"); + if (!g) return; + if (strmin_x) { + st=g->rmin_x; et=st+winsize*1000; } - if (et>(*GraphView)[0]->rmax_x) { - et=(*GraphView)[0]->rmax_x; + if (et>g->rmax_x) { + et=g->rmax_x; st=et-winsize*1000; } GraphView->SetXBounds(st,et); } */ } else { - qint64 st=(*GraphView)[0]->min_x; - qint64 et=(*GraphView)[0]->max_x; + gGraph *g=GraphView->findGraph("Event Flags"); + if (!g) return; + + qint64 st=g->min_x; + qint64 et=g->max_x; qint64 len=et-st; qint64 d=st+len/2.0; st=d-(winsize/2)*1000; et=d+(winsize/2)*1000; - if (st<(*GraphView)[0]->rmin_x) { - st=(*GraphView)[0]->rmin_x; + if (strmin_x) { + st=g->rmin_x; et=st+winsize*1000; } - if (et>(*GraphView)[0]->rmax_x) { - et=(*GraphView)[0]->rmax_x; + if (et>g->rmax_x) { + et=g->rmax_x; st=et-winsize*1000; } GraphView->SetXBounds(st,et); } } - diff --git a/daily.h b/daily.h index b750bec5..56ae659f 100644 --- a/daily.h +++ b/daily.h @@ -68,6 +68,8 @@ private slots: void on_Link_clicked(const QUrl &url); void on_evViewSlider_valueChanged(int value); + void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column); + protected: private: