Event selection bugfixes

This commit is contained in:
Mark Watkins 2011-11-28 08:36:38 +10:00
parent d31e0d9620
commit 9a020b1164
5 changed files with 48 additions and 29 deletions

View File

@ -2585,3 +2585,9 @@ bool gGraphView::LoadSettings(QString title)
return true; return true;
} }
gGraph *gGraphView::findGraph(QString name)
{
QHash<QString,gGraph*>::iterator i=m_graphsbytitle.find(name);
if (i==m_graphsbytitle.end()) return NULL;
return i.value();
}

View File

@ -404,7 +404,7 @@ public:
void SaveSettings(QString title); void SaveSettings(QString title);
bool LoadSettings(QString title); bool LoadSettings(QString title);
int findGraph(QString name); gGraph *findGraph(QString name);
//bool hasGraphs() { return m_graphs.size()>0; } //bool hasGraphs() { return m_graphs.size()>0; }

View File

@ -585,6 +585,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
int pos=0; int pos=0;
int cnt=0; int cnt=0;
short delta; short delta;
int tdata;
while (pos<size) { while (pos<size) {
unsigned char code=buffer[pos++]; unsigned char code=buffer[pos++];
if (code>0x12) { if (code>0x12) {
@ -721,7 +722,8 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64
if (!Code[17]) { if (!Code[17]) {
if (!(Code[17]=session->AddEventList(PRS1_0E,EVL_Event))) return false; 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]; //qDebug() << hex << data[0] << data[1] << data[2];
//session->AddEvent(new Event(t,cpapcode, 0, data, 3)); //session->AddEvent(new Event(t,cpapcode, 0, data, 3));
//tt-=data[1]*1000; //tt-=data[1]*1000;

View File

@ -4,9 +4,6 @@
License: GPL License: GPL
*/ */
#include "daily.h"
#include "ui_daily.h"
#include <QTextCharFormat> #include <QTextCharFormat>
#include <QPalette> #include <QPalette>
#include <QTextBlock> #include <QTextBlock>
@ -18,6 +15,9 @@
#include <QResizeEvent> #include <QResizeEvent>
#include <QScrollBar> #include <QScrollBar>
#include "daily.h"
#include "ui_daily.h"
#include "common_gui.h" #include "common_gui.h"
#include "SleepLib/profiles.h" #include "SleepLib/profiles.h"
#include "SleepLib/session.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))); PTB->AddLayer(AddCPAP(new gLineChart(CPAP_PTB,Qt::gray,square)));
MP->AddLayer(AddCPAP(new gLineChart(CPAP_MaskPressure,Qt::blue,false))); 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))); RR->AddLayer(AddCPAP(new gLineChart(CPAP_RespRate,Qt::darkMagenta,square)));
MV->AddLayer(AddCPAP(new gLineChart(CPAP_MinuteVent,Qt::darkCyan,square))); MV->AddLayer(AddCPAP(new gLineChart(CPAP_MinuteVent,Qt::darkCyan,square)));
TV->AddLayer(AddCPAP(new gLineChart(CPAP_TidalVolume,Qt::magenta,square))); TV->AddLayer(AddCPAP(new gLineChart(CPAP_TidalVolume,Qt::magenta,square)));
@ -912,11 +911,8 @@ void Daily::RedrawGraphs()
GraphView->updateGL(); 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; QDateTime d;
if (!item->text(1).isEmpty()) { if (!item->text(1).isEmpty()) {
d=d.fromString(item->text(1),"yyyy-MM-dd HH:mm:ss"); 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 st=qint64((d.addSecs(-(winsize/2))).toTime_t())*1000L;
double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L; double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L;
if (st<(*GraphView)[0]->rmin_x) { gGraph *g=GraphView->findGraph("Event Flags");
st=(*GraphView)[0]->rmin_x; if (!g) return;
//et=st+winsize*1000; if (st<g->rmin_x) {
st=g->rmin_x;
et=st+winsize*1000;
} }
if (et>(*GraphView)[0]->rmax_x) { if (et>g->rmax_x) {
et=(*GraphView)[0]->rmax_x; et=g->rmax_x;
//st=et-winsize*1000; st=et-winsize*1000;
} }
GraphView->SetXBounds(st,et); 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() void Daily::on_JournalNotesUnderline_clicked()
{ {
QTextCursor cursor = ui->JournalNotes->textCursor(); QTextCursor cursor = ui->JournalNotes->textCursor();
@ -1004,10 +1009,10 @@ void Daily::on_evViewSlider_valueChanged(int value)
{ {
ui->evViewLCD->display(value); ui->evViewLCD->display(value);
PROFILE["EventViewSize"]=value; PROFILE["EventViewSize"]=value;
//ui->evViewSlider->value();
int winsize=PROFILE["EventViewSize"].toInt()*60; int winsize=PROFILE["EventViewSize"].toInt()*60;
return;
if (0) { if (0) {
/* if (ui->treeWidget->selectedItems().size()==0) return; /* if (ui->treeWidget->selectedItems().size()==0) return;
QTreeWidgetItem *item=ui->treeWidget->selectedItems().at(0); 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 st=qint64((d.addSecs(-(winsize/2))).toTime_t())*1000L;
double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L; double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L;
if (st<(*GraphView)[0]->rmin_x) { gGraph *g=GraphView->findGraph("Event Flags");
st=(*GraphView)[0]->rmin_x; if (!g) return;
if (st<g->rmin_x) {
st=g->rmin_x;
et=st+winsize*1000; et=st+winsize*1000;
} }
if (et>(*GraphView)[0]->rmax_x) { if (et>g->rmax_x) {
et=(*GraphView)[0]->rmax_x; et=g->rmax_x;
st=et-winsize*1000; st=et-winsize*1000;
} }
GraphView->SetXBounds(st,et); GraphView->SetXBounds(st,et);
} }
*/ */
} else { } else {
qint64 st=(*GraphView)[0]->min_x; gGraph *g=GraphView->findGraph("Event Flags");
qint64 et=(*GraphView)[0]->max_x; if (!g) return;
qint64 st=g->min_x;
qint64 et=g->max_x;
qint64 len=et-st; qint64 len=et-st;
qint64 d=st+len/2.0; qint64 d=st+len/2.0;
st=d-(winsize/2)*1000; st=d-(winsize/2)*1000;
et=d+(winsize/2)*1000; et=d+(winsize/2)*1000;
if (st<(*GraphView)[0]->rmin_x) { if (st<g->rmin_x) {
st=(*GraphView)[0]->rmin_x; st=g->rmin_x;
et=st+winsize*1000; et=st+winsize*1000;
} }
if (et>(*GraphView)[0]->rmax_x) { if (et>g->rmax_x) {
et=(*GraphView)[0]->rmax_x; et=g->rmax_x;
st=et-winsize*1000; st=et-winsize*1000;
} }
GraphView->SetXBounds(st,et); GraphView->SetXBounds(st,et);
} }
} }

View File

@ -68,6 +68,8 @@ private slots:
void on_Link_clicked(const QUrl &url); void on_Link_clicked(const QUrl &url);
void on_evViewSlider_valueChanged(int value); void on_evViewSlider_valueChanged(int value);
void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column);
protected: protected:
private: private: