2011-06-28 15:25:20 +00:00
/*
2011-06-26 08:30:44 +00:00
Daily Panel
Copyright ( c ) 2011 Mark Watkins < jedimark @ users . sourceforge . net >
License : GPL
2011-06-28 15:25:20 +00:00
*/
2011-06-26 08:30:44 +00:00
# include <QTextCharFormat>
2011-08-20 07:38:50 +00:00
# include <QPalette>
2011-06-26 08:30:44 +00:00
# include <QTextBlock>
# include <QColorDialog>
2011-07-28 11:09:53 +00:00
# include <QSpacerItem>
2011-06-26 08:30:44 +00:00
# include <QBuffer>
# include <QPixmap>
2011-07-27 09:21:53 +00:00
# include <QMessageBox>
2011-07-28 11:09:53 +00:00
# include <QResizeEvent>
2011-08-20 08:20:22 +00:00
# include <QScrollBar>
2011-12-01 06:06:13 +00:00
# include <QSpacerItem>
2011-12-02 13:48:05 +00:00
# include <cmath>
2011-12-01 15:40:32 +00:00
//#include <QPrinter>
//#include <QProgressBar>
2011-06-26 08:30:44 +00:00
2011-11-27 22:36:38 +00:00
# include "daily.h"
# include "ui_daily.h"
2011-11-15 21:22:08 +00:00
# include "common_gui.h"
2011-10-05 07:41:56 +00:00
# include "SleepLib/profiles.h"
2011-06-26 08:30:44 +00:00
# include "SleepLib/session.h"
# include "Graphs/graphdata_custom.h"
# include "Graphs/gLineOverlay.h"
# include "Graphs/gFlagsLine.h"
# include "Graphs/gFooBar.h"
# include "Graphs/gXAxis.h"
# include "Graphs/gYAxis.h"
2011-07-28 17:15:15 +00:00
# include "Graphs/gSegmentChart.h"
2011-08-30 08:46:24 +00:00
# include "Graphs/gStatsLine.h"
2011-06-26 08:30:44 +00:00
2011-12-01 15:40:32 +00:00
//extern QProgressBar *qprogress;
2011-12-18 10:53:51 +00:00
extern MainWindow * mainwin ;
2011-12-01 15:40:32 +00:00
2011-08-02 10:28:29 +00:00
const int min_height = 150 ;
2011-07-22 13:46:17 +00:00
2011-12-18 10:53:51 +00:00
Daily : : Daily ( QWidget * parent , gGraphView * shared )
: QWidget ( parent ) , ui ( new Ui : : Daily )
2011-06-26 08:30:44 +00:00
{
ui - > setupUi ( this ) ;
2011-10-05 12:43:34 +00:00
// Remove Incomplete Extras Tab
2011-12-02 11:40:47 +00:00
//ui->tabWidget->removeTab(3);
2011-10-05 12:43:34 +00:00
2011-12-03 09:26:59 +00:00
ZombieMeterMoved = false ;
BookmarksChanged = false ;
2011-08-26 13:22:16 +00:00
QList < int > a ;
a . push_back ( 300 ) ;
a . push_back ( this - > width ( ) - 300 ) ;
2011-10-05 03:05:35 +00:00
ui - > splitter_2 - > setStretchFactor ( 1 , 1 ) ;
2011-08-26 13:22:16 +00:00
ui - > splitter_2 - > setSizes ( a ) ;
ui - > splitter_2 - > setStretchFactor ( 1 , 1 ) ;
2011-06-26 08:30:44 +00:00
2011-08-25 06:11:44 +00:00
layout = new QHBoxLayout ( ui - > graphMainArea ) ;
layout - > setSpacing ( 0 ) ;
layout - > setMargin ( 0 ) ;
layout - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
ui - > graphMainArea - > setLayout ( layout ) ;
//ui->graphMainArea->setLayout(layout);
ui - > graphMainArea - > setAutoFillBackground ( false ) ;
2011-08-30 17:22:54 +00:00
GraphView = new gGraphView ( ui - > graphMainArea , shared ) ;
2011-08-25 06:11:44 +00:00
GraphView - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Expanding ) ;
2011-12-08 14:47:10 +00:00
snapGV = new gGraphView ( ui - > graphMainArea ) ;
2011-09-21 14:10:10 +00:00
snapGV - > setMinimumSize ( 172 , 172 ) ;
snapGV - > hideSplitter ( ) ;
snapGV - > hide ( ) ;
2011-12-08 14:47:10 +00:00
2011-08-25 06:11:44 +00:00
scrollbar = new MyScrollBar ( ui - > graphMainArea ) ;
scrollbar - > setOrientation ( Qt : : Vertical ) ;
scrollbar - > setSizePolicy ( QSizePolicy : : Maximum , QSizePolicy : : Expanding ) ;
scrollbar - > setMaximumWidth ( 20 ) ;
2011-12-02 11:40:47 +00:00
ui - > bookmarkTable - > setColumnCount ( 2 ) ;
ui - > bookmarkTable - > setColumnWidth ( 0 , 70 ) ;
//ui->bookmarkTable->setEditTriggers(QAbstractItemView::SelectedClicked);
//ui->bookmarkTable->setColumnHidden(2,true);
//ui->bookmarkTable->setColumnHidden(3,true);
2011-08-25 06:11:44 +00:00
GraphView - > setScrollBar ( scrollbar ) ;
layout - > addWidget ( GraphView , 1 ) ;
layout - > addWidget ( scrollbar , 0 ) ;
2011-07-29 14:58:44 +00:00
2011-12-21 12:47:47 +00:00
int default_height = PROFILE . appearance - > graphHeight ( ) ;
2011-12-21 14:24:09 +00:00
SF = new gGraph ( GraphView , STR_TR_EventFlags , STR_TR_EventFlags , default_height ) ;
2011-12-21 11:09:50 +00:00
FRW = new gGraph ( GraphView , tr ( " Flow Rate " ) , schema : : channel [ CPAP_FlowRate ] . description ( ) + " \n ( " + schema : : channel [ CPAP_FlowRate ] . units ( ) + " ) " , default_height ) ;
2011-12-24 05:55:44 +00:00
if ( PROFILE . general - > calculateRDI ( ) ) {
AHI = new gGraph ( GraphView , tr ( " RDI " ) , schema : : channel [ CPAP_RDI ] . description ( ) + " \n ( " + schema : : channel [ CPAP_RDI ] . units ( ) + " ) " , default_height ) ;
} else AHI = new gGraph ( GraphView , tr ( " AHI " ) , schema : : channel [ CPAP_AHI ] . description ( ) + " \n ( " + schema : : channel [ CPAP_AHI ] . units ( ) + " ) " , default_height ) ;
2011-12-21 11:09:50 +00:00
MP = new gGraph ( GraphView , tr ( " Mask Pressure " ) , schema : : channel [ CPAP_MaskPressure ] . description ( ) + " \n ( " + schema : : channel [ CPAP_MaskPressure ] . units ( ) + " ) " , default_height ) ;
PRD = new gGraph ( GraphView , tr ( " Pressure " ) , schema : : channel [ CPAP_Pressure ] . description ( ) + " \n ( " + schema : : channel [ CPAP_Pressure ] . units ( ) + " ) " , default_height ) ;
LEAK = new gGraph ( GraphView , tr ( " Leak " ) , schema : : channel [ CPAP_Leak ] . description ( ) + " \n ( " + schema : : channel [ CPAP_Leak ] . units ( ) + " ) " , default_height ) ;
SNORE = new gGraph ( GraphView , tr ( " Snore " ) , schema : : channel [ CPAP_Snore ] . description ( ) + " \n ( " + schema : : channel [ CPAP_Snore ] . units ( ) + " ) " , default_height ) ;
RR = new gGraph ( GraphView , tr ( " Resp. Rate " ) , schema : : channel [ CPAP_RespRate ] . description ( ) + " \n ( " + schema : : channel [ CPAP_RespRate ] . units ( ) + " ) " , default_height ) ;
TV = new gGraph ( GraphView , tr ( " Tidal Volume " ) , schema : : channel [ CPAP_TidalVolume ] . description ( ) + " \n ( " + schema : : channel [ CPAP_TidalVolume ] . units ( ) + " ) " , default_height ) ;
MV = new gGraph ( GraphView , tr ( " Minute Vent. " ) , schema : : channel [ CPAP_MinuteVent ] . description ( ) + " \n ( " + schema : : channel [ CPAP_MinuteVent ] . units ( ) + " ) " , default_height ) ;
FLG = new gGraph ( GraphView , tr ( " Flow Limitation " ) , schema : : channel [ CPAP_FLG ] . description ( ) + " \n ( " + schema : : channel [ CPAP_FLG ] . units ( ) + " ) " , default_height ) ;
PTB = new gGraph ( GraphView , tr ( " Pat. Trig. Breath " ) , schema : : channel [ CPAP_PTB ] . description ( ) + " \n ( " + schema : : channel [ CPAP_PTB ] . units ( ) + " ) " , default_height ) ;
RE = new gGraph ( GraphView , tr ( " Resp. Event " ) , schema : : channel [ CPAP_RespEvent ] . description ( ) + " \n ( " + schema : : channel [ CPAP_RespEvent ] . units ( ) + " ) " , default_height ) ;
IE = new gGraph ( GraphView , tr ( " IE " ) , schema : : channel [ CPAP_IE ] . description ( ) + " \n ( " + schema : : channel [ CPAP_IE ] . units ( ) + " ) " , default_height ) ;
TE = new gGraph ( GraphView , tr ( " Te " ) , schema : : channel [ CPAP_Te ] . description ( ) + " \n ( " + schema : : channel [ CPAP_Te ] . units ( ) + " ) " , default_height ) ;
TI = new gGraph ( GraphView , tr ( " Ti " ) , schema : : channel [ CPAP_Ti ] . description ( ) + " \n ( " + schema : : channel [ CPAP_Ti ] . units ( ) + " ) " , default_height ) ;
TgMV = new gGraph ( GraphView , tr ( " Tgt. Min. Vent " ) , schema : : channel [ CPAP_TgMV ] . description ( ) + " \n ( " + schema : : channel [ CPAP_TgMV ] . units ( ) + " ) " , default_height ) ;
2011-11-30 06:01:38 +00:00
int oxigrp = PROFILE . ExistsAndTrue ( " SyncOximetry " ) ? 0 : 1 ;
2011-12-25 05:05:12 +00:00
PULSE = new gGraph ( GraphView , STR_TR_PulseRate , schema : : channel [ OXI_Pulse ] . description ( ) + " \n ( " + schema : : channel [ OXI_Pulse ] . units ( ) + " ) " , default_height , oxigrp ) ;
SPO2 = new gGraph ( GraphView , STR_TR_SpO2 , schema : : channel [ OXI_SPO2 ] . description ( ) + " \n ( " + schema : : channel [ OXI_SPO2 ] . units ( ) + " ) " , default_height , oxigrp ) ;
PLETHY = new gGraph ( GraphView , STR_TR_Plethy , schema : : channel [ OXI_Plethy ] . description ( ) + " \n ( " + schema : : channel [ OXI_Plethy ] . units ( ) + " ) " , default_height , oxigrp ) ;
2011-08-26 03:26:53 +00:00
2011-09-21 14:10:10 +00:00
// Event Pie Chart (for snapshot purposes)
// TODO: Convert snapGV to generic for snapshotting multiple graphs (like reports does)
2011-12-21 14:24:09 +00:00
// TAP=new gGraph(GraphView,"Time@Pressure",STR_UNIT_CMH2O,100);
2011-12-14 04:54:17 +00:00
// TAP->showTitle(false);
// gTAPGraph * tap=new gTAPGraph(CPAP_Pressure,GST_Line);
// TAP->AddLayer(AddCPAP(tap));
//TAP->setMargins(0,0,0,0);
2011-12-21 11:09:50 +00:00
GAHI = new gGraph ( snapGV , tr ( " Breakdown " ) , tr ( " events " ) , 172 ) ;
2011-09-21 14:10:10 +00:00
gSegmentChart * evseg = new gSegmentChart ( GST_Pie ) ;
2011-12-21 11:09:50 +00:00
evseg - > AddSlice ( CPAP_Hypopnea , QColor ( 0x40 , 0x40 , 0xff , 0xff ) , tr ( " H " ) ) ;
evseg - > AddSlice ( CPAP_Apnea , QColor ( 0x20 , 0x80 , 0x20 , 0xff ) , tr ( " A " ) ) ;
evseg - > AddSlice ( CPAP_Obstructive , QColor ( 0x40 , 0xaf , 0xbf , 0xff ) , tr ( " OA " ) ) ;
evseg - > AddSlice ( CPAP_ClearAirway , QColor ( 0xb2 , 0x54 , 0xcd , 0xff ) , tr ( " CA " ) ) ;
evseg - > AddSlice ( CPAP_RERA , QColor ( 0xff , 0xff , 0x80 , 0xff ) , tr ( " RE " ) ) ;
evseg - > AddSlice ( CPAP_FlowLimit , QColor ( 0x40 , 0x40 , 0x40 , 0xff ) , tr ( " FL " ) ) ;
2011-09-21 14:10:10 +00:00
GAHI - > AddLayer ( AddCPAP ( evseg ) ) ;
GAHI - > setMargins ( 0 , 0 , 0 , 0 ) ;
//SF->AddLayer(AddCPAP(evseg),LayerRight,100);
2011-08-25 06:11:44 +00:00
gFlagsGroup * fg = new gFlagsGroup ( ) ;
2011-11-28 04:05:09 +00:00
SF - > AddLayer ( AddCPAP ( fg ) ) ;
2011-12-21 11:09:50 +00:00
fg - > AddLayer ( ( new gFlagsLine ( CPAP_CSR , QColor ( " light green " ) , tr ( " PB " ) , false , FT_Span ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_ClearAirway , QColor ( " purple " ) , tr ( " CA " ) , false ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_Obstructive , QColor ( " #40c0ff " ) , tr ( " OA " ) , true ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_Apnea , QColor ( " dark green " ) , tr ( " A " ) ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_Hypopnea , QColor ( " blue " ) , tr ( " H " ) , true ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_ExP , QColor ( " dark cyan " ) , tr ( " E " ) , false ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_LeakFlag , QColor ( " dark blue " ) , tr ( " L " ) , false ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_NRI , QColor ( " dark magenta " ) , tr ( " NRI " ) , false ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_FlowLimit , QColor ( " black " ) , tr ( " FL " ) ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_RERA , QColor ( " gold " ) , tr ( " RE " ) ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_VSnore , QColor ( " red " ) , tr ( " VS " ) ) ) ) ;
2011-12-21 12:47:47 +00:00
fg - > AddLayer ( ( new gFlagsLine ( CPAP_UserFlag1 , QColor ( " yellow " ) , tr ( " UF1 " ) ) ) ) ;
fg - > AddLayer ( ( new gFlagsLine ( CPAP_UserFlag2 , QColor ( " green " ) , tr ( " UF2 " ) ) ) ) ;
2011-12-21 11:09:50 +00:00
//fg->AddLayer((new gFlagsLine(PRS1_0B,QColor("dark green"),tr("U0B"))));
2011-12-24 05:55:44 +00:00
fg - > AddLayer ( ( new gFlagsLine ( CPAP_VSnore2 , QColor ( " red " ) , tr ( " VS2 " ) ) ) ) ;
2011-08-25 08:02:04 +00:00
SF - > setBlockZoom ( true ) ;
2011-08-25 09:00:19 +00:00
SF - > AddLayer ( new gShadowArea ( ) ) ;
2011-08-25 06:11:44 +00:00
SF - > AddLayer ( new gYSpacer ( ) , LayerLeft , gYAxis : : Margin ) ;
2011-08-27 05:06:08 +00:00
//SF->AddLayer(new gFooBar(),LayerBottom,0,1);
2011-12-12 07:10:45 +00:00
SF - > AddLayer ( new gXAxis ( Qt : : black , false ) , LayerBottom , 0 , 20 ) ; //gXAxis::Margin);
2011-08-25 06:11:44 +00:00
gLineChart * l ;
l = new gLineChart ( CPAP_FlowRate , Qt : : black , false , false ) ;
2011-12-21 11:09:50 +00:00
gLineOverlaySummary * los = new gLineOverlaySummary ( tr ( " Selection AHI " ) , 5 , - 4 ) ;
2011-08-25 06:11:44 +00:00
AddCPAP ( l ) ;
2011-08-25 10:38:42 +00:00
FRW - > AddLayer ( new gXGrid ( ) ) ;
2011-12-21 11:09:50 +00:00
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( CPAP_CSR , QColor ( " light green " ) , tr ( " CSR " ) , FT_Span ) ) ) ;
2011-08-25 06:11:44 +00:00
FRW - > AddLayer ( l ) ;
FRW - > AddLayer ( new gYAxis ( ) , LayerLeft , gYAxis : : Margin ) ;
FRW - > AddLayer ( new gXAxis ( ) , LayerBottom , 0 , 20 ) ;
2011-12-21 11:09:50 +00:00
FRW - > AddLayer ( AddCPAP ( los - > add ( new gLineOverlayBar ( CPAP_Hypopnea , QColor ( " blue " ) , tr ( " H " ) ) ) ) ) ;
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( CPAP_PressurePulse , QColor ( " red " ) , tr ( " PR " ) , FT_Dot ) ) ) ;
//FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Pressure,QColor("white"),tr("P"),FT_Dot)));
2011-09-17 12:39:00 +00:00
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( PRS1_0B , QColor ( " blue " ) , " 0B " , FT_Dot ) ) ) ;
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( PRS1_10 , QColor ( " orange " ) , " 10 " , FT_Dot ) ) ) ;
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( PRS1_0E , QColor ( " dark red " ) , " 0E " , FT_Dot ) ) ) ;
2011-12-24 05:55:44 +00:00
if ( PROFILE . general - > calculateRDI ( ) )
FRW - > AddLayer ( AddCPAP ( los - > add ( new gLineOverlayBar ( CPAP_RERA , QColor ( " gold " ) , tr ( " RE " ) ) ) ) ) ;
else
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( CPAP_RERA , QColor ( " gold " ) , tr ( " RE " ) ) ) ) ;
2011-12-21 11:09:50 +00:00
FRW - > AddLayer ( AddCPAP ( los - > add ( new gLineOverlayBar ( CPAP_Apnea , QColor ( " dark green " ) , tr ( " A " ) ) ) ) ) ;
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( CPAP_VSnore , QColor ( " red " ) , tr ( " VS " ) ) ) ) ;
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( CPAP_FlowLimit , QColor ( " black " ) , tr ( " FL " ) ) ) ) ;
FRW - > AddLayer ( AddCPAP ( los - > add ( new gLineOverlayBar ( CPAP_Obstructive , QColor ( " #40c0ff " ) , tr ( " OA " ) ) ) ) ) ;
FRW - > AddLayer ( AddCPAP ( los - > add ( new gLineOverlayBar ( CPAP_ClearAirway , QColor ( " purple " ) , tr ( " CA " ) ) ) ) ) ;
2011-12-21 12:47:47 +00:00
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( CPAP_UserFlag1 , QColor ( " yellow " ) , tr ( " U1 " ) , FT_Bar ) ) ) ;
FRW - > AddLayer ( AddCPAP ( new gLineOverlayBar ( CPAP_UserFlag2 , QColor ( " orange " ) , tr ( " U2 " ) , FT_Bar ) ) ) ;
2011-12-21 11:09:50 +00:00
FRW - > AddLayer ( AddOXI ( new gLineOverlayBar ( OXI_SPO2Drop , QColor ( " red " ) , tr ( " O2 " ) ) ) ) ;
FRW - > AddLayer ( AddOXI ( new gLineOverlayBar ( OXI_PulseChange , QColor ( " blue " ) , tr ( " PC " ) , FT_Dot ) ) ) ;
2011-11-28 13:16:50 +00:00
2011-11-12 13:58:58 +00:00
FRW - > AddLayer ( AddCPAP ( los ) ) ;
2011-08-25 06:11:44 +00:00
2011-12-05 08:32:46 +00:00
gGraph * graphs [ ] = { PRD , LEAK , AHI , SNORE , PTB , MP , RR , MV , TV , FLG , IE , TI , TE , TgMV , SPO2 , PLETHY , PULSE } ;
2011-08-29 11:42:40 +00:00
int ng = sizeof ( graphs ) / sizeof ( gGraph * ) ;
for ( int i = 0 ; i < ng ; i + + ) {
graphs [ i ] - > AddLayer ( new gXGrid ( ) ) ;
}
2011-08-31 05:24:48 +00:00
/*PRD->AddLayer(AddCPAP(new gStatsLine(CPAP_Pressure,"Pressure")),LayerBottom,0,20,1);
2011-08-30 08:46:24 +00:00
PRD - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_EPAP , " EPAP " ) ) , LayerBottom , 0 , 20 , 1 ) ;
PRD - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_IPAP , " IPAP " ) ) , LayerBottom , 0 , 20 , 1 ) ;
LEAK - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_Leak ) ) , LayerBottom , 0 , 20 , 1 ) ;
SNORE - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_Snore ) ) , LayerBottom , 0 , 20 , 1 ) ;
PTB - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_PatientTriggeredBreaths ) ) , LayerBottom , 0 , 20 , 1 ) ;
RR - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_RespiratoryRate ) ) , LayerBottom , 0 , 20 , 1 ) ;
MV - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_MinuteVentilation ) ) , LayerBottom , 0 , 20 , 1 ) ;
TV - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_TidalVolume ) ) , LayerBottom , 0 , 20 , 1 ) ;
FLG - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_FlowLimitGraph ) ) , LayerBottom , 0 , 20 , 1 ) ;
IE - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_IE ) ) , LayerBottom , 0 , 20 , 1 ) ;
TE - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_Te ) ) , LayerBottom , 0 , 20 , 1 ) ;
2011-08-31 05:24:48 +00:00
TI - > AddLayer ( AddCPAP ( new gStatsLine ( CPAP_Ti ) ) , LayerBottom , 0 , 20 , 1 ) ; */
2011-08-30 08:46:24 +00:00
2011-11-07 08:14:58 +00:00
2011-12-21 12:47:47 +00:00
bool square = PROFILE . appearance - > squareWavePlots ( ) ;
2011-12-27 13:21:10 +00:00
gLineChart * pc = new gLineChart ( CPAP_Pressure , QColor ( " dark green " ) , square ) ;
PRD - > AddLayer ( AddCPAP ( pc ) ) ;
pc - > addPlot ( CPAP_EPAP , Qt : : blue , square ) ;
pc - > addPlot ( CPAP_IPAPLo , Qt : : darkRed , square ) ;
pc - > addPlot ( CPAP_IPAP , Qt : : red , square ) ;
pc - > addPlot ( CPAP_IPAPHi , Qt : : darkRed , square ) ;
2011-11-07 04:10:48 +00:00
2011-12-24 05:55:44 +00:00
if ( PROFILE . general - > calculateRDI ( ) ) {
AHI - > AddLayer ( AddCPAP ( new AHIChart ( QColor ( " #37a24b " ) ) ) ) ;
} else {
AHI - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_AHI , QColor ( " light green " ) , square ) ) ) ;
}
2011-11-30 06:56:20 +00:00
2011-12-27 13:21:10 +00:00
gLineChart * lc = new gLineChart ( CPAP_LeakTotal , Qt : : darkYellow , square ) ;
lc - > addPlot ( CPAP_Leak , Qt : : darkMagenta , square ) ;
lc - > addPlot ( CPAP_MaxLeak , Qt : : darkRed , square ) ;
LEAK - > AddLayer ( AddCPAP ( lc ) ) ;
//LEAK->AddLayer(AddCPAP(new gLineChart(CPAP_Leak,Qt::darkMagenta,square)));
//LEAK->AddLayer(AddCPAP(new gLineChart(CPAP_MaxLeak,Qt::darkRed,square)));
2011-11-07 08:14:58 +00:00
SNORE - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_Snore , Qt : : darkGray , true ) ) ) ;
2011-11-07 04:10:48 +00:00
PTB - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_PTB , Qt : : gray , square ) ) ) ;
2011-11-07 05:25:29 +00:00
MP - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_MaskPressure , Qt : : blue , false ) ) ) ;
2011-11-07 04:10:48 +00:00
RR - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_RespRate , Qt : : darkMagenta , square ) ) ) ;
MV - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_MinuteVent , Qt : : darkCyan , square ) ) ) ;
2011-12-01 03:40:23 +00:00
TV - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_TidalVolume , Qt : : magenta , square ) ) ) ;
//TV->AddLayer(AddCPAP(new gLineChart("TidalVolume2",Qt::magenta,square)));
2011-11-07 08:14:58 +00:00
FLG - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_FLG , Qt : : darkBlue , true ) ) ) ;
2011-08-29 11:42:40 +00:00
//RE->AddLayer(AddCPAP(new gLineChart(CPAP_RespiratoryEvent,Qt::magenta,true)));
2011-11-07 04:10:48 +00:00
IE - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_IE , Qt : : darkRed , square ) ) ) ;
TE - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_Te , Qt : : darkGreen , square ) ) ) ;
TI - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_Ti , Qt : : darkBlue , square ) ) ) ;
2011-11-14 09:26:58 +00:00
TgMV - > AddLayer ( AddCPAP ( new gLineChart ( CPAP_TgMV , Qt : : darkCyan , square ) ) ) ;
2011-12-05 08:32:46 +00:00
//INTPULSE->AddLayer(AddCPAP(new gLineChart(OXI_Pulse,Qt::red,square)));
//INTSPO2->AddLayer(AddCPAP(new gLineChart(OXI_SPO2,Qt::blue,square)));
2011-11-28 22:49:43 +00:00
2011-12-23 10:52:31 +00:00
gLineOverlaySummary * los1 = new gLineOverlaySummary ( tr ( " Events/hour " ) , 5 , - 4 ) ;
gLineOverlaySummary * los2 = new gLineOverlaySummary ( tr ( " Events/hour " ) , 5 , - 4 ) ;
PULSE - > AddLayer ( AddOXI ( los1 - > add ( new gLineOverlayBar ( OXI_PulseChange , QColor ( " light gray " ) , tr ( " PD " ) , FT_Span ) ) ) ) ;
PULSE - > AddLayer ( AddOXI ( los1 ) ) ;
SPO2 - > AddLayer ( AddOXI ( los2 - > add ( new gLineOverlayBar ( OXI_SPO2Drop , QColor ( " light blue " ) , tr ( " O2 " ) , FT_Span ) ) ) ) ;
SPO2 - > AddLayer ( AddOXI ( los2 ) ) ;
2011-11-28 22:49:43 +00:00
2011-11-07 04:10:48 +00:00
PULSE - > AddLayer ( AddOXI ( new gLineChart ( OXI_Pulse , Qt : : red , square ) ) ) ;
2011-11-28 22:49:43 +00:00
SPO2 - > AddLayer ( AddOXI ( new gLineChart ( OXI_SPO2 , Qt : : blue , true ) ) ) ;
2011-09-17 12:39:00 +00:00
PLETHY - > AddLayer ( AddOXI ( new gLineChart ( OXI_Plethy , Qt : : darkBlue , false ) ) ) ;
2011-08-26 03:26:53 +00:00
2011-11-28 01:39:28 +00:00
PTB - > setForceMaxY ( 100 ) ;
SPO2 - > setForceMaxY ( 100 ) ;
2011-11-27 06:25:27 +00:00
2011-08-29 11:42:40 +00:00
for ( int i = 0 ; i < ng ; i + + ) {
graphs [ i ] - > AddLayer ( new gYAxis ( ) , LayerLeft , gYAxis : : Margin ) ;
graphs [ i ] - > AddLayer ( new gXAxis ( ) , LayerBottom , 0 , 20 ) ;
}
2011-08-25 06:11:44 +00:00
layout - > layout ( ) ;
2011-08-26 03:26:53 +00:00
QTextCharFormat format = ui - > calendar - > weekdayTextFormat ( Qt : : Saturday ) ;
format . setForeground ( QBrush ( Qt : : black , Qt : : SolidPattern ) ) ;
ui - > calendar - > setWeekdayTextFormat ( Qt : : Saturday , format ) ;
ui - > calendar - > setWeekdayTextFormat ( Qt : : Sunday , format ) ;
2011-11-15 21:22:08 +00:00
Qt : : DayOfWeek dow = firstDayOfWeekFromLocale ( ) ;
ui - > calendar - > setFirstDayOfWeek ( dow ) ;
2011-08-26 03:26:53 +00:00
ui - > tabWidget - > setCurrentWidget ( ui - > details ) ;
2011-10-05 10:44:41 +00:00
ui - > webView - > settings ( ) - > setFontSize ( QWebSettings : : DefaultFontSize , QApplication : : font ( ) . pointSize ( ) ) ;
2011-11-24 23:03:33 +00:00
ui - > webView - > page ( ) - > setLinkDelegationPolicy ( QWebPage : : DelegateAllLinks ) ;
2011-12-03 08:52:24 +00:00
connect ( ui - > webView , SIGNAL ( linkClicked ( QUrl ) ) , this , SLOT ( Link_clicked ( QUrl ) ) ) ;
2011-11-27 07:41:00 +00:00
2011-12-21 12:47:47 +00:00
int ews = PROFILE . general - > eventWindowSize ( ) ;
2011-11-27 07:41:00 +00:00
ui - > evViewSlider - > setValue ( ews ) ;
ui - > evViewLCD - > display ( ews ) ;
2011-11-27 16:07:28 +00:00
GraphView - > LoadSettings ( " Daily " ) ;
2011-12-23 14:12:04 +00:00
emptyToggleArea = new QLabel ( this ) ;
emptyToggleArea - > setText ( " This may take a while... " ) ;
2011-12-22 10:29:12 +00:00
ui - > graphToggleArea - > addWidget ( emptyToggleArea , 1 , Qt : : AlignCenter ) ;
emptyToggleArea - > setVisible ( false ) ;
2011-12-01 06:06:13 +00:00
for ( int i = 0 ; i < GraphView - > size ( ) ; i + + ) {
QString title = ( * GraphView ) [ i ] - > title ( ) ;
QPushButton * btn = new QPushButton ( title , this ) ;
btn - > setCheckable ( true ) ;
2011-12-01 06:10:06 +00:00
btn - > setChecked ( ( * GraphView ) [ i ] - > visible ( ) ) ;
2011-12-21 11:09:50 +00:00
btn - > setToolTip ( tr ( " Show/Hide %1 " ) . arg ( title ) ) ;
2011-12-23 14:12:04 +00:00
btn - > setVisible ( false ) ;
2011-12-01 06:06:13 +00:00
GraphToggles [ title ] = btn ;
btn - > setSizePolicy ( QSizePolicy : : Fixed , QSizePolicy : : Minimum ) ;
ui - > graphToggleArea - > addWidget ( btn ) ;
2011-12-03 08:52:24 +00:00
connect ( btn , SIGNAL ( toggled ( bool ) ) , this , SLOT ( graphtogglebutton_toggled ( bool ) ) ) ;
2011-12-01 06:06:13 +00:00
}
ui - > graphToggleArea - > addSpacerItem ( new QSpacerItem ( 0 , 0 , QSizePolicy : : Expanding ) ) ;
2011-12-23 14:12:04 +00:00
ui - > graphVisibilityToggleArea - > setVisible ( false ) ;
ui - > splitter - > setVisible ( false ) ;
2011-12-01 06:06:13 +00:00
2011-10-30 03:09:43 +00:00
// TODO: Add preference to hide do this for Widget Haters..
//ui->calNavWidget->hide();
2011-12-21 11:09:50 +00:00
2011-12-21 12:47:47 +00:00
if ( PROFILE . general - > unitSystem ( ) = = US_Archiac ) {
ui - > weightSpinBox - > setSuffix ( STR_UNIT_POUND ) ;
2011-12-02 13:48:05 +00:00
ui - > weightSpinBox - > setDecimals ( 0 ) ;
ui - > ouncesSpinBox - > setVisible ( true ) ;
2011-12-21 12:47:47 +00:00
ui - > ouncesSpinBox - > setSuffix ( STR_UNIT_OUNCE ) ;
2011-12-21 11:09:50 +00:00
} else {
ui - > ouncesSpinBox - > setVisible ( false ) ;
ui - > weightSpinBox - > setDecimals ( 3 ) ;
2011-12-21 12:47:47 +00:00
ui - > weightSpinBox - > setSuffix ( STR_UNIT_KG ) ;
2011-12-02 13:48:05 +00:00
}
2011-12-23 14:12:04 +00:00
GraphView - > setCubeImage ( images [ " sheep " ] ) ;
2011-12-25 16:56:22 +00:00
GraphView - > setEmptyText ( tr ( " No Data " ) ) ;
2011-10-30 03:09:43 +00:00
}
2011-06-26 08:30:44 +00:00
Daily : : ~ Daily ( )
{
2011-11-27 16:07:28 +00:00
GraphView - > SaveSettings ( " Daily " ) ;
2011-12-03 08:52:24 +00:00
disconnect ( ui - > webView , SIGNAL ( linkClicked ( QUrl ) ) , this , SLOT ( Link_clicked ( QUrl ) ) ) ;
2011-06-26 08:30:44 +00:00
// Save any last minute changes..
if ( previous_date . isValid ( ) )
Unload ( previous_date ) ;
2011-08-02 10:28:29 +00:00
// delete splitter;
2011-06-26 08:30:44 +00:00
delete ui ;
}
2011-12-03 08:52:24 +00:00
void Daily : : Link_clicked ( const QUrl & url )
2011-11-24 23:03:33 +00:00
{
QString code = url . toString ( ) . section ( " = " , 0 , 0 ) . toLower ( ) ;
QString data = url . toString ( ) . section ( " = " , 1 ) ;
int sid = data . toInt ( ) ;
Day * day = NULL ;
2011-12-27 13:21:10 +00:00
if ( code = = " togglecpapsession " ) {
day = PROFILE . GetDay ( previous_date , MT_CPAP ) ;
Session * sess = day - > find ( sid ) ;
if ( ! sess )
return ;
bool b ;
if ( sess - > settings . contains ( SESSION_ENABLED ) ) b = false ;
else b = ! sess - > settings [ SESSION_ENABLED ] . toBool ( ) ;
sess - > settings [ SESSION_ENABLED ] = b ;
sess - > SetChanged ( true ) ;
day - > machine - > Save ( ) ;
GraphView - > ResetBounds ( ) ;
// reload day
return ;
} else if ( code = = " cpap " ) {
2011-11-24 23:03:33 +00:00
day = PROFILE . GetDay ( previous_date , MT_CPAP ) ;
} else if ( code = = " oxi " ) {
day = PROFILE . GetDay ( previous_date , MT_OXIMETER ) ;
2011-12-06 14:39:14 +00:00
Session * sess = day - > machine - > sessionlist [ sid ] ;
if ( mainwin - > getOximetry ( ) ) {
mainwin - > getOximetry ( ) - > openSession ( sess ) ;
mainwin - > selectOximetryTab ( ) ;
}
return ;
2011-11-24 23:03:33 +00:00
} else if ( code = = " event " ) {
2011-12-24 05:55:44 +00:00
QList < QTreeWidgetItem * > list = ui - > treeWidget - > findItems ( schema : : channel [ sid ] . description ( ) , Qt : : MatchContains ) ;
2011-11-24 23:03:33 +00:00
if ( list . size ( ) > 0 ) {
2011-11-24 23:14:17 +00:00
ui - > treeWidget - > collapseAll ( ) ;
ui - > treeWidget - > expandItem ( list . at ( 0 ) ) ;
QTreeWidgetItem * wi = list . at ( 0 ) - > child ( 0 ) ;
ui - > treeWidget - > setCurrentItem ( wi ) ;
2011-11-24 23:03:33 +00:00
ui - > tabWidget - > setCurrentIndex ( 1 ) ;
2011-12-03 08:52:24 +00:00
} else {
2011-12-24 05:55:44 +00:00
mainwin - > Notify ( tr ( " No %1 events are recorded this day " ) . arg ( schema : : channel [ sid ] . description ( ) ) , " " , 1500 ) ;
2011-11-24 23:03:33 +00:00
}
2011-12-03 03:43:23 +00:00
} else if ( code = = " graph " ) {
qDebug ( ) < < " Select graph " < < data ;
2011-11-24 23:03:33 +00:00
} else {
qDebug ( ) < < " Clicked on " < < code < < data ;
}
if ( day ) {
Session * sess = day - > machine - > sessionlist [ sid ] ;
if ( sess ) {
GraphView - > SetXBounds ( sess - > first ( ) , sess - > last ( ) ) ;
}
}
}
2011-07-04 11:37:26 +00:00
2011-06-26 08:30:44 +00:00
void Daily : : ReloadGraphs ( )
{
2011-12-23 14:12:04 +00:00
ui - > splitter - > setVisible ( true ) ;
2011-12-06 14:39:14 +00:00
QDate d ;
if ( previous_date . isValid ( ) ) {
d = previous_date ;
Unload ( d ) ;
2011-12-10 12:14:48 +00:00
} //else
d = PROFILE . LastDay ( ) ;
2011-06-26 08:30:44 +00:00
if ( ! d . isValid ( ) ) {
d = ui - > calendar - > selectedDate ( ) ;
}
on_calendar_currentPageChanged ( d . year ( ) , d . month ( ) ) ;
ui - > calendar - > setSelectedDate ( d ) ;
2011-12-21 17:00:19 +00:00
//Load(d);
2011-06-26 08:30:44 +00:00
}
void Daily : : on_calendar_currentPageChanged ( int year , int month )
{
QDate d ( year , month , 1 ) ;
int dom = d . daysInMonth ( ) ;
for ( int i = 1 ; i < = dom ; i + + ) {
d = QDate ( year , month , i ) ;
this - > UpdateCalendarDay ( d ) ;
}
}
void Daily : : UpdateEventsTree ( QTreeWidget * tree , Day * day )
{
tree - > clear ( ) ;
2011-06-27 10:55:55 +00:00
if ( ! day ) return ;
2011-06-26 08:30:44 +00:00
tree - > setColumnCount ( 1 ) ; // 1 visible common.. (1 hidden)
2011-12-25 05:05:12 +00:00
QTreeWidgetItem * root = NULL ;
2011-07-31 20:24:43 +00:00
QHash < ChannelID , QTreeWidgetItem * > mcroot ;
QHash < ChannelID , int > mccnt ;
2011-07-05 05:33:06 +00:00
int total_events = 0 ;
2011-07-31 20:24:43 +00:00
for ( QVector < Session * > : : iterator s = day - > begin ( ) ; s ! = day - > end ( ) ; s + + ) {
2011-06-26 08:30:44 +00:00
2011-07-31 20:24:43 +00:00
QHash < ChannelID , QVector < EventList * > > : : iterator m ;
2011-06-26 08:30:44 +00:00
2011-07-27 09:21:53 +00:00
for ( m = ( * s ) - > eventlist . begin ( ) ; m ! = ( * s ) - > eventlist . end ( ) ; m + + ) {
2011-07-31 20:24:43 +00:00
ChannelID code = m . key ( ) ;
2011-07-27 09:53:29 +00:00
if ( ( code ! = CPAP_Obstructive )
& & ( code ! = CPAP_Hypopnea )
& & ( code ! = CPAP_Apnea )
2011-09-17 12:39:00 +00:00
& & ( code ! = PRS1_0B )
2011-07-27 09:53:29 +00:00
& & ( code ! = CPAP_ClearAirway )
& & ( code ! = CPAP_CSR )
& & ( code ! = CPAP_RERA )
2011-12-21 11:09:50 +00:00
& & ( code ! = CPAP_UserFlag1 )
& & ( code ! = CPAP_UserFlag2 )
2011-11-24 23:03:33 +00:00
& & ( code ! = CPAP_NRI )
& & ( code ! = CPAP_LeakFlag )
& & ( code ! = CPAP_ExP )
2011-07-27 09:53:29 +00:00
& & ( code ! = CPAP_FlowLimit )
2011-07-31 20:24:43 +00:00
& & ( code ! = CPAP_PressurePulse )
2011-12-24 05:55:44 +00:00
& & ( code ! = CPAP_VSnore2 )
2011-07-27 09:53:29 +00:00
& & ( code ! = CPAP_VSnore ) ) continue ;
2011-06-26 08:30:44 +00:00
QTreeWidgetItem * mcr ;
if ( mcroot . find ( code ) = = mcroot . end ( ) ) {
2011-07-05 05:33:06 +00:00
int cnt = day - > count ( code ) ;
total_events + = cnt ;
2011-12-03 10:08:40 +00:00
QString st = schema : : channel [ code ] . description ( ) ;
2011-06-26 08:30:44 +00:00
if ( st . isEmpty ( ) ) {
2011-12-21 11:09:50 +00:00
st = " Fixme %1 " + code ;
2011-06-26 08:30:44 +00:00
}
2011-12-21 11:09:50 +00:00
st + = " " ;
if ( cnt = = 1 ) st + = tr ( " %1 event " ) . arg ( cnt ) ;
else st + = tr ( " %1 events " ) . arg ( cnt ) ;
2011-06-26 08:30:44 +00:00
QStringList l ( st ) ;
l . append ( " " ) ;
mcroot [ code ] = mcr = new QTreeWidgetItem ( root , l ) ;
mccnt [ code ] = 0 ;
} else {
mcr = mcroot [ code ] ;
}
2011-07-31 20:24:43 +00:00
for ( int z = 0 ; z < m . value ( ) . size ( ) ; z + + ) {
2011-11-24 12:47:25 +00:00
for ( quint32 o = 0 ; o < m . value ( ) [ z ] - > count ( ) ; o + + ) {
2011-07-31 20:24:43 +00:00
qint64 t = m . value ( ) [ z ] - > time ( o ) ;
2011-07-30 03:52:29 +00:00
2011-12-25 05:05:12 +00:00
if ( code = = CPAP_CSR ) { // center it in the middle of span
2011-07-31 20:24:43 +00:00
t - = float ( m . value ( ) [ z ] - > raw ( o ) / 2.0 ) * 1000.0 ;
2011-07-27 09:21:53 +00:00
}
QStringList a ;
2011-09-01 13:07:26 +00:00
QDateTime d = QDateTime : : fromTime_t ( t / 1000 ) ;
2011-12-25 05:05:12 +00:00
QString s = QString ( " #%1: %2 (%3) " ) . arg ( ( int ) ( + + mccnt [ code ] ) , ( int ) 3 , ( int ) 10 , QChar ( ' 0 ' ) ) . arg ( d . toString ( " HH:mm:ss " ) ) . arg ( m . value ( ) [ z ] - > raw ( o ) ) ;
2011-07-27 09:21:53 +00:00
a . append ( s ) ;
2011-12-25 05:05:12 +00:00
QTreeWidgetItem * item = new QTreeWidgetItem ( a ) ;
item - > setData ( 0 , Qt : : UserRole , t ) ;
//a.append(d.toString("yyyy-MM-dd HH:mm:ss"));
mcr - > addChild ( item ) ;
2011-06-26 08:30:44 +00:00
}
2011-07-30 03:52:29 +00:00
}
}
2011-06-26 08:30:44 +00:00
}
int cnt = 0 ;
2011-07-31 20:24:43 +00:00
for ( QHash < ChannelID , QTreeWidgetItem * > : : iterator m = mcroot . begin ( ) ; m ! = mcroot . end ( ) ; m + + ) {
tree - > insertTopLevelItem ( cnt + + , m . value ( ) ) ;
2011-06-26 08:30:44 +00:00
}
2011-07-05 05:33:06 +00:00
//tree->insertTopLevelItem(cnt++,new QTreeWidgetItem(QStringList("[Total Events ("+QString::number(total_events)+")]")));
2011-06-26 08:30:44 +00:00
tree - > sortByColumn ( 0 , Qt : : AscendingOrder ) ;
//tree->expandAll();
}
2011-12-01 06:06:13 +00:00
2011-06-26 08:30:44 +00:00
void Daily : : UpdateCalendarDay ( QDate date )
{
2011-12-11 09:45:28 +00:00
QTextCharFormat nodata ;
QTextCharFormat cpaponly ;
QTextCharFormat cpapjour ;
2011-07-03 12:08:30 +00:00
QTextCharFormat oxiday ;
2011-12-11 09:45:28 +00:00
QTextCharFormat oxicpap ;
2011-12-02 14:18:47 +00:00
QTextCharFormat jourday ;
2011-12-11 09:45:28 +00:00
cpaponly . setForeground ( QBrush ( Qt : : blue , Qt : : SolidPattern ) ) ;
cpaponly . setFontWeight ( QFont : : Normal ) ;
cpapjour . setForeground ( QBrush ( Qt : : blue , Qt : : SolidPattern ) ) ;
cpapjour . setFontWeight ( QFont : : Bold ) ;
2011-07-03 12:08:30 +00:00
oxiday . setForeground ( QBrush ( Qt : : red , Qt : : SolidPattern ) ) ;
2011-12-11 09:45:28 +00:00
oxiday . setFontWeight ( QFont : : Normal ) ;
oxicpap . setForeground ( QBrush ( Qt : : red , Qt : : SolidPattern ) ) ;
oxicpap . setFontWeight ( QFont : : Bold ) ;
2011-12-02 14:18:47 +00:00
jourday . setForeground ( QBrush ( QColor ( " black " ) , Qt : : SolidPattern ) ) ;
jourday . setFontWeight ( QFont : : Bold ) ;
2011-12-11 09:45:28 +00:00
nodata . setForeground ( QBrush ( QColor ( " black " ) , Qt : : SolidPattern ) ) ;
nodata . setFontWeight ( QFont : : Normal ) ;
2011-12-02 14:18:47 +00:00
2011-10-05 07:41:56 +00:00
bool hascpap = PROFILE . GetDay ( date , MT_CPAP ) ! = NULL ;
bool hasoxi = PROFILE . GetDay ( date , MT_OXIMETER ) ! = NULL ;
2011-12-02 14:18:47 +00:00
bool hasjournal = PROFILE . GetDay ( date , MT_JOURNAL ) ! = NULL ;
2011-07-03 12:08:30 +00:00
if ( hascpap ) {
if ( hasoxi ) {
2011-12-11 09:45:28 +00:00
ui - > calendar - > setDateTextFormat ( date , oxicpap ) ;
2011-12-02 14:18:47 +00:00
} else if ( hasjournal ) {
2011-12-11 09:45:28 +00:00
ui - > calendar - > setDateTextFormat ( date , cpapjour ) ;
2011-07-03 12:08:30 +00:00
} else {
2011-12-11 09:45:28 +00:00
ui - > calendar - > setDateTextFormat ( date , cpaponly ) ;
2011-07-03 12:08:30 +00:00
}
2011-12-11 09:45:28 +00:00
} else if ( hasoxi ) {
ui - > calendar - > setDateTextFormat ( date , oxiday ) ;
} else if ( hasjournal ) {
ui - > calendar - > setDateTextFormat ( date , jourday ) ;
2011-06-26 08:30:44 +00:00
} else {
2011-12-11 09:45:28 +00:00
ui - > calendar - > setDateTextFormat ( date , nodata ) ;
2011-06-26 08:30:44 +00:00
}
ui - > calendar - > setHorizontalHeaderFormat ( QCalendarWidget : : ShortDayNames ) ;
}
2011-10-28 03:45:31 +00:00
void Daily : : LoadDate ( QDate date )
{
2011-12-26 04:58:02 +00:00
ui - > calendar - > blockSignals ( true ) ;
2011-12-26 18:26:06 +00:00
if ( date . month ( ) ! = previous_date . month ( ) ) {
on_calendar_currentPageChanged ( date . year ( ) , date . month ( ) ) ;
}
2011-10-28 03:45:31 +00:00
ui - > calendar - > setSelectedDate ( date ) ;
2011-12-26 04:58:02 +00:00
ui - > calendar - > blockSignals ( false ) ;
on_calendar_selectionChanged ( ) ;
2011-10-28 03:45:31 +00:00
}
2011-06-26 08:30:44 +00:00
void Daily : : on_calendar_selectionChanged ( )
{
2011-12-25 16:38:37 +00:00
this - > setCursor ( Qt : : BusyCursor ) ;
2011-06-26 08:30:44 +00:00
2011-12-20 11:12:52 +00:00
if ( previous_date . isValid ( ) ) {
2011-12-25 16:38:37 +00:00
// GraphView->fadeOut();
2011-12-20 11:12:52 +00:00
Unload ( previous_date ) ;
}
bool fadedir = previous_date < ui - > calendar - > selectedDate ( ) ;
2011-12-02 11:40:47 +00:00
ZombieMeterMoved = false ;
2011-06-26 08:30:44 +00:00
Load ( ui - > calendar - > selectedDate ( ) ) ;
2011-12-25 16:38:37 +00:00
//GraphView->fadeIn(fadedir);
2011-12-25 16:58:22 +00:00
GraphView - > redraw ( ) ;
2011-10-30 03:44:00 +00:00
ui - > calButton - > setText ( ui - > calendar - > selectedDate ( ) . toString ( Qt : : TextDate ) ) ;
2011-10-30 04:35:55 +00:00
ui - > calendar - > setFocus ( Qt : : ActiveWindowFocusReason ) ;
2011-12-02 13:48:05 +00:00
2011-12-21 12:47:47 +00:00
if ( PROFILE . general - > unitSystem ( ) = = US_Archiac ) {
ui - > weightSpinBox - > setSuffix ( STR_UNIT_POUND ) ;
2011-12-02 13:48:05 +00:00
ui - > weightSpinBox - > setDecimals ( 0 ) ;
ui - > ouncesSpinBox - > setVisible ( true ) ;
2011-12-21 12:47:47 +00:00
ui - > ouncesSpinBox - > setSuffix ( STR_UNIT_OUNCE ) ;
2011-12-21 11:09:50 +00:00
} else {
ui - > ouncesSpinBox - > setVisible ( false ) ;
ui - > weightSpinBox - > setDecimals ( 3 ) ;
2011-12-21 12:47:47 +00:00
ui - > weightSpinBox - > setSuffix ( STR_UNIT_KG ) ;
2011-12-02 13:48:05 +00:00
}
2011-12-25 16:38:37 +00:00
this - > setCursor ( Qt : : ArrowCursor ) ;
2011-06-26 08:30:44 +00:00
}
2011-07-28 14:20:59 +00:00
void Daily : : ResetGraphLayout ( )
{
2011-09-12 17:47:37 +00:00
GraphView - > resetLayout ( ) ;
2011-07-28 14:20:59 +00:00
}
2011-12-03 08:52:24 +00:00
void Daily : : graphtogglebutton_toggled ( bool b )
2011-12-01 06:06:13 +00:00
{
2011-12-03 08:52:24 +00:00
Q_UNUSED ( b )
2011-12-01 06:06:13 +00:00
for ( int i = 0 ; i < GraphView - > size ( ) ; i + + ) {
QString title = ( * GraphView ) [ i ] - > title ( ) ;
( * GraphView ) [ i ] - > setVisible ( GraphToggles [ title ] - > isChecked ( ) ) ;
}
GraphView - > updateScale ( ) ;
2011-12-20 11:12:52 +00:00
GraphView - > redraw ( ) ;
2011-12-01 06:06:13 +00:00
}
2011-06-26 08:30:44 +00:00
void Daily : : Load ( QDate date )
{
2011-07-27 10:47:50 +00:00
static Day * lastcpapday = NULL ;
2011-06-26 08:30:44 +00:00
previous_date = date ;
2011-10-05 07:41:56 +00:00
Day * cpap = PROFILE . GetDay ( date , MT_CPAP ) ;
Day * oxi = PROFILE . GetDay ( date , MT_OXIMETER ) ;
2011-07-01 10:10:44 +00:00
// Day *sleepstage=profile->GetDay(date,MT_SLEEPSTAGE);
2011-06-26 08:30:44 +00:00
2011-12-21 12:47:47 +00:00
if ( ! PROFILE . session - > cacheSessions ( ) ) {
2011-07-28 07:32:02 +00:00
if ( lastcpapday & & ( lastcpapday ! = cpap ) ) {
2011-07-31 20:24:43 +00:00
for ( QVector < Session * > : : iterator s = lastcpapday - > begin ( ) ; s ! = lastcpapday - > end ( ) ; s + + ) {
2011-07-28 07:32:02 +00:00
( * s ) - > TrashEvents ( ) ;
}
2011-07-27 10:47:50 +00:00
}
}
2011-12-03 08:52:24 +00:00
if ( cpap & & oxi ) {
2011-12-25 05:05:12 +00:00
int gr ;
if ( qAbs ( cpap - > first ( ) - oxi - > first ( ) ) > 30000 ) {
2011-12-18 16:39:36 +00:00
mainwin - > Notify ( tr ( " Oximetry data exists for this day, however it's timestamps are too different, so the Graphs will not be linked. " ) , " " , 3000 ) ;
2011-12-25 05:05:12 +00:00
gr = 1 ;
} else
gr = 0 ;
GraphView - > findGraph ( STR_TR_PulseRate ) - > setGroup ( gr ) ;
GraphView - > findGraph ( STR_TR_SpO2 ) - > setGroup ( gr ) ;
GraphView - > findGraph ( STR_TR_Plethy ) - > setGroup ( gr ) ;
2011-12-03 08:52:24 +00:00
}
2011-07-27 10:47:50 +00:00
lastcpapday = cpap ;
2011-12-10 15:50:40 +00:00
2011-11-24 23:03:33 +00:00
QString html = " <html><head><style type='text/css'> "
2011-12-10 15:50:40 +00:00
" p,a,td,body { font-family: ' " + QApplication : : font ( ) . family ( ) + " '; } "
" p,a,td,body { font-size: " + QString : : number ( QApplication : : font ( ) . pointSize ( ) + 2 ) + " px; } "
2011-11-24 23:14:17 +00:00
" a:link,a:visited { color: inherit; text-decoration: none; font-weight: normal;} "
" a:hover { background-color: inherit; color: inherit; text-decoration:none; font-weight: bold; } "
2011-11-24 23:03:33 +00:00
" </style> "
2011-12-07 12:23:19 +00:00
" <script language='javascript'><!-- "
" func dosession(sessid) { "
" "
" } "
" --></script> "
2011-07-05 05:33:06 +00:00
" </head> "
" <body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0> "
2011-11-27 04:50:22 +00:00
" <table cellspacing=0 cellpadding=1 border=0 width='100%'> \n " ;
2011-06-26 08:30:44 +00:00
QString tmp ;
2011-08-30 17:22:54 +00:00
//const int gwwidth=240;
//const int gwheight=100;
2011-07-28 12:13:28 +00:00
UpdateOXIGraphs ( oxi ) ;
2011-07-22 13:46:17 +00:00
UpdateCPAPGraphs ( cpap ) ;
2011-07-28 12:13:28 +00:00
UpdateEventsTree ( ui - > treeWidget , cpap ) ;
2011-12-22 10:29:12 +00:00
2011-09-21 14:10:10 +00:00
snapGV - > setDay ( cpap ) ;
2011-12-20 11:12:52 +00:00
GraphView - > ResetBounds ( false ) ;
2011-09-21 14:10:10 +00:00
//snapGV->ResetBounds();
2011-08-26 05:56:43 +00:00
//GraphView->ResetBounds(1);
2011-08-25 06:11:44 +00:00
2011-08-29 07:13:58 +00:00
//GraphView->setEmptyText(tr("No Data")); //tr("No data for ")+date.toString(Qt::SystemLocaleLongDate));
2011-07-28 12:13:28 +00:00
if ( ! cpap & & ! oxi ) {
2011-08-02 10:28:29 +00:00
//splitter->setMinimumHeight(0);
2011-08-25 06:11:44 +00:00
scrollbar - > hide ( ) ;
2011-08-29 07:13:58 +00:00
// GraphView->hide();
2011-07-27 09:21:53 +00:00
} else {
2011-08-29 07:13:58 +00:00
//NoData->hide();
// GraphView->show();
2011-08-25 06:11:44 +00:00
scrollbar - > show ( ) ;
2011-07-27 09:21:53 +00:00
}
2011-12-20 11:12:52 +00:00
//GraphView->redraw();
//snapGV->redraw();
2011-12-22 10:29:12 +00:00
int graphsAvailable = 0 ;
2011-12-01 06:06:13 +00:00
for ( int i = 0 ; i < GraphView - > size ( ) ; i + + ) {
QString title = ( * GraphView ) [ i ] - > title ( ) ;
2011-12-22 10:29:12 +00:00
bool empty = ( * GraphView ) [ i ] - > isEmpty ( ) ;
if ( ! empty ) graphsAvailable + + ;
GraphToggles [ title ] - > setVisible ( ! empty ) ;
2011-12-01 06:06:13 +00:00
}
2011-12-22 10:29:12 +00:00
emptyToggleArea - > setVisible ( graphsAvailable = = 0 ) ;
//ui->graphVisibilityToggleArea->setVisible(graphsAvailable>0);
//RedrawGraphs();
2011-12-01 06:06:13 +00:00
2011-07-28 12:13:28 +00:00
QString epr , modestr ;
2011-08-30 17:22:54 +00:00
//float iap90,eap90;
2011-06-26 08:30:44 +00:00
CPAPMode mode = MODE_UNKNOWN ;
QString a ;
2011-12-10 12:14:48 +00:00
bool isBrick = false ;
2011-12-23 10:52:31 +00:00
2011-12-23 14:12:04 +00:00
ui - > graphVisibilityToggleArea - > setVisible ( true ) ;
2011-12-23 10:52:31 +00:00
if ( graphsAvailable > 0 ) {
GraphView - > setCubeImage ( images [ " sheep " ] ) ;
GraphView - > setEmptyText ( tr ( " Graphs Switched Off " ) ) ;
} else {
GraphView - > setCubeImage ( images [ " nodata " ] ) ;
2011-12-22 15:33:47 +00:00
GraphView - > setEmptyText ( tr ( " No Data " ) ) ;
2011-12-23 14:12:04 +00:00
emptyToggleArea - > setText ( " No data available for this day " ) ;
2011-12-22 15:33:47 +00:00
}
2011-12-23 10:52:31 +00:00
2011-06-26 08:30:44 +00:00
if ( cpap ) {
2011-12-10 12:14:48 +00:00
if ( GraphView - > isEmpty ( ) ) {
2011-12-20 17:22:02 +00:00
GraphView - > setCubeImage ( images [ " brick " ] ) ;
2011-12-18 16:39:36 +00:00
GraphView - > setEmptyText ( tr ( " Brick Machine :( " ) ) ;
2011-12-22 10:29:12 +00:00
2011-12-10 12:14:48 +00:00
isBrick = true ;
}
2011-12-22 10:29:12 +00:00
2011-12-17 14:50:59 +00:00
mode = ( CPAPMode ) ( int ) cpap - > settings_max ( CPAP_Mode ) ;
2011-12-14 05:15:13 +00:00
2011-09-17 12:39:00 +00:00
modestr = schema : : channel [ CPAP_Mode ] . m_options [ mode ] ;
2011-07-31 20:24:43 +00:00
2011-12-24 05:55:44 +00:00
float ahi = ( cpap - > count ( CPAP_Obstructive ) + cpap - > count ( CPAP_Hypopnea ) + cpap - > count ( CPAP_ClearAirway ) + cpap - > count ( CPAP_Apnea ) ) ;
if ( PROFILE . general - > calculateRDI ( ) ) ahi + = cpap - > count ( CPAP_RERA ) ;
ahi / = cpap - > hours ( ) ;
2011-06-26 08:30:44 +00:00
float csr = ( 100.0 / cpap - > hours ( ) ) * ( cpap - > sum ( CPAP_CSR ) / 3600.0 ) ;
2011-07-30 08:10:02 +00:00
float uai = cpap - > count ( CPAP_Apnea ) / cpap - > hours ( ) ;
2011-06-26 08:30:44 +00:00
float oai = cpap - > count ( CPAP_Obstructive ) / cpap - > hours ( ) ;
2011-11-24 12:47:25 +00:00
float hi = ( cpap - > count ( CPAP_ExP ) + cpap - > count ( CPAP_Hypopnea ) ) / cpap - > hours ( ) ;
2011-06-26 08:30:44 +00:00
float cai = cpap - > count ( CPAP_ClearAirway ) / cpap - > hours ( ) ;
float rei = cpap - > count ( CPAP_RERA ) / cpap - > hours ( ) ;
float fli = cpap - > count ( CPAP_FlowLimit ) / cpap - > hours ( ) ;
2011-11-24 23:03:33 +00:00
float nri = cpap - > count ( CPAP_NRI ) / cpap - > hours ( ) ;
float lki = cpap - > count ( CPAP_LeakFlag ) / cpap - > hours ( ) ;
float exp = cpap - > count ( CPAP_ExP ) / cpap - > hours ( ) ;
2011-07-22 13:46:17 +00:00
2011-08-07 20:51:11 +00:00
//float p90=cpap->p90(CPAP_Pressure);
//eap90=cpap->p90(CPAP_EPAP);
//iap90=cpap->p90(CPAP_IPAP);
2011-12-12 09:16:26 +00:00
QString submodel ; //=tr("Unknown Model");
2011-06-26 08:30:44 +00:00
2011-06-30 10:56:22 +00:00
//html+="<tr><td colspan=4 align=center><i>"+tr("Machine Information")+"</i></td></tr>\n";
2011-12-21 14:24:09 +00:00
if ( cpap - > machine - > properties . find ( STR_PROP_SubModel ) ! = cpap - > machine - > properties . end ( ) )
submodel = " <br/> " + cpap - > machine - > properties [ STR_PROP_SubModel ] ;
html + = " <tr><td colspan=4 align=center><b> " + cpap - > machine - > properties [ STR_PROP_Brand ] + " </b> <br> " + cpap - > machine - > properties [ STR_PROP_Model ] + " " + cpap - > machine - > properties [ STR_PROP_ModelNumber ] + submodel + " </td></tr> \n " ;
2011-12-21 12:47:47 +00:00
if ( PROFILE . session - > showSerialNumbers ( ) ) {
2011-12-21 14:24:09 +00:00
html + = " <tr><td colspan=4 align=center> " + cpap - > machine - > properties [ STR_PROP_Serial ] + " </td></tr> \n " ;
2011-06-26 08:30:44 +00:00
}
2011-12-17 14:50:59 +00:00
CPAPMode mode = ( CPAPMode ) ( int ) cpap - > settings_max ( CPAP_Mode ) ;
2011-12-12 09:16:26 +00:00
html + = " <tr><td colspan=4 align=center>Mode: " ;
EventDataType min = cpap - > settings_min ( CPAP_PressureMin ) ;
EventDataType max = cpap - > settings_max ( CPAP_PressureMax ) ;
2011-12-21 14:24:09 +00:00
if ( mode = = MODE_CPAP ) html + = tr ( " CPAP " ) + " " + QString : : number ( min ) + STR_UNIT_CMH2O ;
else if ( mode = = MODE_APAP ) html + = tr ( " APAP " ) + " " + QString : : number ( min ) + " - " + QString : : number ( max ) + STR_UNIT_CMH2O ;
2011-12-18 16:39:36 +00:00
else if ( mode = = MODE_BIPAP ) html + = tr ( " Bi-Level " ) ;
else if ( mode = = MODE_ASV ) html + = tr ( " ASV " ) ;
else html + = tr ( " Unknown " ) ;
2011-12-12 09:16:26 +00:00
html + = " </td></tr> \n " ;
2011-06-26 08:30:44 +00:00
2011-12-21 14:24:09 +00:00
html + = " <tr><td align='center'><b> " + tr ( " Date " ) + " </b></td><td align='center'><b> " + tr ( " Sleep " ) + " </b></td><td align='center'><b> " + tr ( " Wake " ) + " </b></td><td align='center'><b> " + STR_UNIT_Hours + " </b></td></tr> " ;
2011-09-12 02:24:58 +00:00
int tt = qint64 ( cpap - > total_time ( ) ) / 1000L ;
QDateTime date = QDateTime : : fromTime_t ( cpap - > first ( ) / 1000L ) ;
QDateTime date2 = QDateTime : : fromTime_t ( cpap - > last ( ) / 1000L ) ;
2011-07-02 14:35:50 +00:00
2011-09-12 02:24:58 +00:00
int h = tt / 3600 ;
2011-07-31 21:07:40 +00:00
int m = ( tt / 60 ) % 60 ;
int s = tt % 60 ;
2011-07-05 05:33:06 +00:00
html + = QString ( " <tr><td align='center'>%1</td><td align='center'>%2</td><td align='center'>%3</td><td align='center'>%4</td></tr> \n "
" <tr><td colspan=4 align=center><hr></td></tr> \n " )
. arg ( date . date ( ) . toString ( Qt : : SystemLocaleShortDate ) )
. arg ( date . toString ( " HH:mm " ) )
. arg ( date2 . toString ( " HH:mm " ) )
2011-07-31 21:07:40 +00:00
. arg ( QString ( ) . sprintf ( " %02i:%02i:%02i " , h , m , s ) ) ;
2011-06-26 08:30:44 +00:00
2011-06-30 09:37:24 +00:00
QString cs ;
2011-12-10 12:14:48 +00:00
if ( ! isBrick ) {
2011-12-21 14:24:09 +00:00
if ( cpap - > machine - > GetClass ( ) = = STR_MACH_ResMed ) {
2011-12-10 12:14:48 +00:00
cs = " 4 width='100%' align=center> " ;
} else cs = " 2 width='50%'> " ;
2011-12-24 05:55:44 +00:00
html + = " <tr><td colspan= " + cs + " <table cellspacing=0 cellpadding=1 border=0 width='100%'> " ;
if ( PROFILE . general - > calculateRDI ( ) ) {
html + = " <tr><td align='right' bgcolor='#F88017'><b><font color='black'><a href='nothing' title=' " + schema : : channel [ CPAP_RDI ] . description ( ) + " '> " + tr ( " RDI " ) + " </a></font></b></td><td width=20% bgcolor='#F88017'><b><font color='black'> " + QString ( ) . sprintf ( " %.2f " , ahi ) + " </font></b></td></tr> \n " ;
} else {
html + = " <tr><td align='right' bgcolor='#F88017'><b><font color='black'><a href='nothing' title=' " + schema : : channel [ CPAP_AHI ] . description ( ) + " '> " + tr ( " AHI " ) + " </a></font></b></td><td width=20% bgcolor='#F88017'><b><font color='black'> " + QString ( ) . sprintf ( " %.2f " , ahi ) + " </font></b></td></tr> \n " ;
}
html + = " <tr><td align='right' bgcolor='#4040ff'><b><font color='white'> <a href='event= " + QString : : number ( CPAP_Hypopnea ) + " ' title=' " + schema : : channel [ CPAP_Hypopnea ] . description ( ) + " '> " + tr ( " Hypopnea " ) + " </a></font></b></td><td bgcolor='#4040ff'><font color='white'> " + QString ( ) . sprintf ( " %.2f " , hi ) + " </font></td></tr> \n " ;
2011-12-21 14:24:09 +00:00
if ( cpap - > machine - > GetClass ( ) = = STR_MACH_ResMed ) {
2011-12-21 17:00:19 +00:00
html + = " <tr><td align='right' bgcolor='#208020'><b> <a href='event= " + QString : : number ( CPAP_Apnea ) + " ' title=' " + schema : : channel [ CPAP_Apnea ] . description ( ) + " '> " + tr ( " Unspecified Apnea " ) + " </a></b></td><td bgcolor='#208020'> " + QString ( ) . sprintf ( " %.2f " , uai ) + " </td></tr> \n " ;
2011-12-10 12:14:48 +00:00
}
2011-12-21 17:00:19 +00:00
html + = " <tr><td align='right' bgcolor='#40afbf'><b> <a href='event= " + QString : : number ( CPAP_Obstructive ) + " ' title=' " + schema : : channel [ CPAP_Obstructive ] . description ( ) + " '> " + tr ( " Obstructive " ) + " </a></b></td><td bgcolor='#40afbf'> " + QString ( ) . sprintf ( " %.2f " , oai ) + " </td></tr> \n "
" <tr><td align='right' bgcolor='#b254cd'><b> <a href='event= " + QString : : number ( CPAP_ClearAirway ) + " ' title=' " + schema : : channel [ CPAP_ClearAirway ] . description ( ) + " '> " + tr ( " Clear Airway " ) + " </a></b></td><td bgcolor='#b254cd'> " + QString ( ) . sprintf ( " %.2f " , cai ) + " </td></tr> \n "
2011-11-24 23:03:33 +00:00
" </table></td> " ;
2011-12-21 14:24:09 +00:00
if ( cpap - > machine - > GetClass ( ) = = STR_MACH_PRS1 ) {
2011-12-10 12:14:48 +00:00
html + = " <td colspan=2><table cellspacing=0 cellpadding=1 border=0 width='100%'> "
2011-12-24 05:55:44 +00:00
" <tr><td align='right' bgcolor='#ffff80'><b> <a href='event= " + QString : : number ( CPAP_RERA ) + " ' title=' " + schema : : channel [ CPAP_RERA ] . description ( ) + " '> " + tr ( " RERA " ) + " </a></b></td><td width=20% bgcolor='#ffff80'> " + QString ( ) . sprintf ( " %.2f " , rei ) + " </td></tr> \n " ;
if ( mode > MODE_CPAP ) {
html + = " <tr><td align='right' bgcolor='#404040'><b> <font color='white'><a href='event= " + QString : : number ( CPAP_FlowLimit ) + " ' title=' " + schema : : channel [ CPAP_FlowLimit ] . description ( ) + " '> " + tr ( " Flow Limit " ) + " </a></font></b></td><td bgcolor='#404040'><font color='white'> " + a . sprintf ( " %.2f " , fli ) + " </font></td></tr> \n " ;
html + = " <tr><td align='right' bgcolor='#ff4040'><b> <a href='event= " + QString : : number ( CPAP_VSnore ) + " 'title=' " + schema : : channel [ CPAP_VSnore ] . description ( ) + " '> " + tr ( " Vsnore " ) + " </a></b></td><td bgcolor='#ff4040'> " + QString ( ) . sprintf ( " %.2f " , cpap - > count ( CPAP_VSnore ) / cpap - > hours ( ) ) + " </td></tr> \n " ;
} else {
html + = " <tr bgcolor='#404040'><td colspan=2> </td></tr> " ;
html + = " <tr><td align='right' bgcolor='#ff4040'><b> <a href='event= " + QString : : number ( CPAP_VSnore2 ) + " 'title=' " + schema : : channel [ CPAP_VSnore2 ] . description ( ) + " '> " + tr ( " Vsnore " ) + " </a></b></td><td bgcolor='#ff4040'> " + QString ( ) . sprintf ( " %.2f " , cpap - > count ( CPAP_VSnore2 ) / cpap - > hours ( ) ) + " </td></tr> \n " ;
}
html + = " <tr><td align='right' bgcolor='#80ff80'><b> <a href='event= " + QString : : number ( CPAP_CSR ) + " ' title=' " + schema : : channel [ CPAP_CSR ] . description ( ) + " '> " + tr ( " PB/CSR " ) + " </a></b></td><td bgcolor='#80ff80'> " + QString ( ) . sprintf ( " %.2f " , csr ) + " %</td></tr> \n "
2011-12-10 12:14:48 +00:00
" </table></td> " ;
2011-12-21 14:24:09 +00:00
} else if ( cpap - > machine - > GetClass ( ) = = STR_MACH_Intellipap ) {
2011-12-10 12:14:48 +00:00
html + = " <td colspan=2><table cellspacing=0 cellpadding=2 border=0 width='100%'> "
2011-12-21 17:00:19 +00:00
" <tr><td align='right' bgcolor='#ffff80'><b> <a href='event= " + QString : : number ( CPAP_NRI ) + " '> " + tr ( " NRI " ) + " </a></b></td><td width=20% bgcolor='#ffff80'> " + QString ( ) . sprintf ( " %.2f " , nri ) + " </td></tr> \n "
" <tr><td align='right' bgcolor='#404040'><b> <font color='white'><a href='event= " + QString : : number ( CPAP_Leak ) + " '> " + tr ( " Leak Idx " ) + " </a></font></b></td><td bgcolor='#404040'><font color='white'> " + a . sprintf ( " %.2f " , lki ) + " </font></td></tr> \n "
2011-12-24 05:55:44 +00:00
" <tr><td align='right' bgcolor='#ff4040'><b> <a href='event= " + QString : : number ( CPAP_VSnore ) + " '> " + tr ( " V.Snore " ) + " </a></b></td><td bgcolor='#ff4040'> " + QString ( ) . sprintf ( " %.2f " , cpap - > count ( CPAP_VSnore ) / cpap - > hours ( ) ) + " </td></tr> \n "
2011-12-21 17:00:19 +00:00
" <tr><td align='right' bgcolor='#80ff80'><b> <a href='event= " + QString : : number ( CPAP_ExP ) + " '> " + tr ( " Exh. Puff " ) + " </a></b></td><td bgcolor='#80ff80'> " + QString ( ) . sprintf ( " %.2f " , exp ) + " </td></tr> \n "
2011-12-10 12:14:48 +00:00
" </table></td> " ;
2011-07-30 08:10:02 +00:00
2011-12-10 12:14:48 +00:00
}
2011-12-25 05:05:12 +00:00
html + = " </tr> " ;
2011-08-05 15:01:17 +00:00
2011-12-10 12:14:48 +00:00
// Note, this may not be a problem since Qt bug 13622 was discovered
// as it only relates to text drawing, which the Pie chart does not do
// ^^ Scratch that.. pie now includes text..
2011-12-21 12:47:47 +00:00
if ( PROFILE . appearance - > graphSnapshots ( ) ) { // AHI Pie Chart
2011-12-25 05:05:12 +00:00
if ( oai + hi + cai + uai + rei + fli > 0 ) {
html + = " <tr><td colspan=5 align=center> </td></tr> " ;
html + = QString ( " <tr><td colspan=4 align=center><b>%1</b></td></tr> " ) . arg ( tr ( " Event Breakdown " ) ) ;
html + = " <tr><td colspan=5 align=center><hr/></td></tr> " ;
2011-12-10 12:14:48 +00:00
//G_AHI->setFixedSize(gwwidth,120);
//mainwin->snapshotGraph()->setPrintScaleX(1);
//mainwin->snapshotGraph()->setPrintScaleY(1);
2011-12-25 05:05:12 +00:00
GAHI - > setShowTitle ( false ) ;
//snapGV->setFixedSize(150,150);
QPixmap pixmap = GAHI - > renderPixmap ( 150 , 150 , false ) ;
2011-12-10 12:14:48 +00:00
QByteArray byteArray ;
QBuffer buffer ( & byteArray ) ; // use buffer to store pixmap into byteArray
buffer . open ( QIODevice : : WriteOnly ) ;
pixmap . save ( & buffer , " PNG " ) ;
html + = " <tr><td colspan=4 align=center><img src= \" data:image/png;base64, " + byteArray . toBase64 ( ) + " \" ></td></tr> \n " ;
} else {
html + = " <tr><td colspan=4 align=center><img src= \" qrc:/docs/0.0.gif \" ></td></tr> \n " ;
}
2011-08-07 11:37:56 +00:00
}
2011-12-10 12:14:48 +00:00
2011-12-23 10:52:31 +00:00
} else { // machine is a brick
html + = " <tr><td colspan='5' align='center'><b><h2> " + tr ( " BRICK :( " ) + " </h2></b></td></tr> " ;
html + = " <tr><td colspan='5' align='center'><i> " + tr ( " Sorry, your machine does not record data. " ) + " </i></td></tr> \n " ;
html + = " <tr><td colspan='5' align='center'><i> " + tr ( " Complain to your Equipment Provider! " ) + " </i></td></tr> \n " ;
html + = " <tr><td colspan='5'> </td></tr> \n " ;
}
html + = " </table> " ;
} // if (!CPAP)
2011-12-25 05:05:12 +00:00
html + = " <table cellspacing=0 cellpadding=0 border=0 width='100%'> \n " ;
2011-12-23 10:52:31 +00:00
if ( ( cpap & & ! isBrick ) | | oxi ) {
2011-12-25 05:05:12 +00:00
html + = " <tr height='2'><td colspan=5> </td></tr> \n " ;
html + = QString ( " <tr><td colspan=5 align=center><b>%1</b></td></tr> \n " ) . arg ( tr ( " Statistics " ) ) ;
html + = " <tr height='2'><td colspan=5><hr></td></tr> \n " ;
html + = QString ( " <tr><td><b>%1</b></td><td><b>%2</b></td><td><b>%3</b></td><td><b>%4</b></td><td><b>%5</b></td></tr> " )
. arg ( tr ( " Channel " ) )
. arg ( tr ( " Min " ) )
. arg ( tr ( " Avg " ) )
. arg ( tr ( " 90% " ) )
. arg ( tr ( " Max " ) ) ;
ChannelID chans [ ] = {
CPAP_Pressure , CPAP_EPAP , CPAP_IPAP , CPAP_PS , CPAP_PTB ,
CPAP_MinuteVent , CPAP_AHI , CPAP_RespRate , CPAP_RespEvent , CPAP_FLG ,
CPAP_Leak , CPAP_LeakTotal , CPAP_Snore , CPAP_IE , CPAP_Ti , CPAP_Te , CPAP_TgMV ,
CPAP_TidalVolume , OXI_Pulse , OXI_SPO2
} ;
int numchans = sizeof ( chans ) / sizeof ( ChannelID ) ;
int suboffset = 0 ;
for ( int i = 0 ; i < numchans ; i + + ) {
ChannelID code = chans [ i ] ;
if ( cpap & & cpap - > channelHasData ( code ) ) {
//if (code==CPAP_LeakTotal) suboffset=PROFILEIntentionalLeak"].toDouble(); else suboffset=0;
QString tooltip = schema : : channel [ code ] . description ( ) ;
if ( ! schema : : channel [ code ] . units ( ) . isEmpty ( ) ) tooltip + = " ( " + schema : : channel [ code ] . units ( ) + " ) " ;
html + = QString ( " <tr><td align=left>%1</td><td>%2</td><td>%3</td><td>%4</td><td>%5</td></tr> " )
. arg ( QString ( " <a href='graph=%1' title='%2'>%3</a> " )
. arg ( QString : : number ( code ) ) . arg ( tooltip ) . arg ( schema : : channel [ code ] . label ( ) ) )
. arg ( cpap - > Min ( code ) , 0 , ' f ' , 2 )
. arg ( cpap - > wavg ( code ) , 0 , ' f ' , 2 )
. arg ( cpap - > p90 ( code ) , 0 , ' f ' , 2 )
. arg ( cpap - > Max ( code ) , 0 , ' f ' , 2 ) ;
}
if ( oxi & & oxi - > channelHasData ( code ) ) {
QString tooltip = schema : : channel [ code ] . description ( ) ;
if ( ! schema : : channel [ code ] . units ( ) . isEmpty ( ) ) tooltip + = " ( " + schema : : channel [ code ] . units ( ) + " ) " ;
html + = " <tr><td align=left><a href='graph= " + QString : : number ( code ) + " ' title=' " + tooltip + " '> " + schema : : channel [ code ] . label ( ) + " </a> " ;
html + = " </td><td> " + a . sprintf ( " %.2f " , oxi - > Min ( code ) ) ;
html + = " </td><td> " + a . sprintf ( " %.2f " , oxi - > wavg ( code ) ) ;
html + = " </td><td> " + a . sprintf ( " %.2f " , oxi - > p90 ( code ) ) ;
html + = " </td><td> " + a . sprintf ( " %.2f " , oxi - > Max ( code ) ) ;
html + = " </td><tr> " ;
}
2011-06-26 08:30:44 +00:00
}
} else {
2011-08-07 15:37:01 +00:00
html + = " <tr><td colspan=5 align=center><i> " + tr ( " No data available " ) + " </i></td></tr> " ;
2011-08-07 11:37:56 +00:00
html + = " <tr><td colspan=5> </td></tr> \n " ;
2011-06-26 08:30:44 +00:00
}
2011-12-25 05:12:00 +00:00
if ( oxi ) {
html + = " <tr><td colspan=5 align=center> </td></tr> " ;
html + = QString ( " <tr><td colspan=5 align=center><b>%1</b></td></tr> \n " ) . arg ( tr ( " Oximeter Information " ) ) ;
html + = " <tr><td colspan=5 align=center><hr/></td></tr> " ;
html + = " <tr><td colspan=5 align=center> " + oxi - > machine - > properties [ STR_PROP_Brand ] + " " + oxi - > machine - > properties [ STR_PROP_Model ] + " </td></tr> \n " ;
html + = " <tr><td colspan=5 align=center> </td></tr> " ;
2011-12-26 03:06:39 +00:00
html + = QString ( " <tr><td colspan=5 align=center>%1: %2 (%3) \ %</td></tr> " ) . arg ( tr ( " SpO2 Desaturations " ) ) . arg ( oxi - > count ( OXI_SPO2Drop ) ) . arg ( ( 100.0 / oxi - > hours ( ) ) * ( oxi - > sum ( OXI_SPO2Drop ) / 3600.0 ) , 0 , ' f ' , 2 ) ;
html + = QString ( " <tr><td colspan=5 align=center>%1: %2 (%3) \ %</td></tr> " ) . arg ( tr ( " Pulse Change events " ) ) . arg ( oxi - > count ( OXI_PulseChange ) ) . arg ( ( 100.0 / oxi - > hours ( ) ) * ( oxi - > sum ( OXI_PulseChange ) / 3600.0 ) , 0 , ' f ' , 2 ) ;
html + = QString ( " <tr><td colspan=5 align=center>%1: %2 \ %</td></tr> " ) . arg ( tr ( " SpO2 Baseline Used " ) ) . arg ( oxi - > settings_wavg ( OXI_SPO2Drop ) , 0 , ' f ' , 2 ) ;
2011-12-25 05:12:00 +00:00
}
2011-06-26 08:30:44 +00:00
if ( cpap ) {
2011-12-25 05:05:12 +00:00
html + = " <tr><td colspan=5> </td></tr> " ;
// html+="<table cellpadding=0 cellspacing=0 border=0 width=100%>";
html + = QString ( " <tr><td colspan=5 align=center><b>%1</b></td></tr> " ) . arg ( tr ( " Machine Settings " ) ) ;
html + = " <tr><td colspan=5><hr height=2></td></tr> " ;
2011-12-21 14:24:09 +00:00
if ( cpap - > machine - > GetClass ( ) = = STR_MACH_PRS1 ) {
2011-12-14 04:54:17 +00:00
int i = cpap - > settings_max ( PRS1_FlexMode ) ;
int j = cpap - > settings_max ( PRS1_FlexSet ) ;
2011-12-14 05:15:13 +00:00
QString flexstr = ( i > 1 ) ? schema : : channel [ PRS1_FlexMode ] . option ( i ) + " " + schema : : channel [ PRS1_FlexSet ] . option ( j ) : " None " ;
2011-12-14 04:54:17 +00:00
2011-12-25 05:05:12 +00:00
html + = QString ( " <tr><td>%1</td><td colspan=4>%2</td></tr> " ) . arg ( tr ( " Flex " ) )
. arg ( flexstr ) ;
2011-12-26 18:41:48 +00:00
int humid = round ( cpap - > settings_wavg ( PRS1_HumidSetting ) ) ;
2011-12-25 05:05:12 +00:00
html + = QString ( " <tr><td>%1</td><td colspan=4>%2</td></tr> " ) . arg ( tr ( " Humidifier " ) )
2011-12-26 18:26:06 +00:00
. arg ( humid = = 0 ? STR_GEN_Off : " x " + QString : : number ( humid ) ) ;
2011-12-21 14:24:09 +00:00
} else if ( cpap - > machine - > GetClass ( ) = = STR_MACH_ResMed ) {
int epr = cpap - > settings_max ( RMS9_EPR ) ;
int epr2 = cpap - > settings_max ( RMS9_EPRSet ) ;
2011-12-27 13:28:39 +00:00
html + = QString ( " <tr><td>%1</td><td colspan=4>%2 / %3</td></tr> " )
2011-12-25 05:05:12 +00:00
. arg ( tr ( " EPR " ) ) . arg ( epr ) . arg ( epr2 ) ;
2011-12-14 05:15:13 +00:00
2011-12-14 04:54:17 +00:00
}
2011-12-23 10:52:31 +00:00
}
2011-12-25 05:05:12 +00:00
html + = " </table> " ;
2011-08-25 06:11:44 +00:00
2011-12-25 05:05:12 +00:00
if ( cpap | | oxi ) {
2011-12-10 12:14:48 +00:00
html + = " <table cellpadding=0 cellspacing=0 border=0 width=100%> " ;
2011-12-25 05:05:12 +00:00
html + = " <tr><td colspan=4 align=center> </td></tr> " ;
html + = QString ( " <tr><td colspan=4 align=center><b>%1</b></td></tr> " ) . arg ( tr ( " Session Information " ) ) ;
html + = " <tr><td colspan=4 align=center><hr height=2/></td></tr> " ;
2011-07-02 14:35:50 +00:00
QDateTime fd , ld ;
2011-07-21 03:03:20 +00:00
bool corrupted_waveform = false ;
2011-12-03 08:52:24 +00:00
QString tooltip ;
2011-12-27 13:21:10 +00:00
html + = QString ( " <tr><td align=left><b>%1</b></td><td><b>%2</b></td><td align=center><b>%3</b></td><td align=center><b>%4</b></td><td align=center><b>%5</b></td></tr> " )
2011-12-25 05:05:12 +00:00
. arg ( tr ( " SessionID " ) )
2011-12-27 13:21:10 +00:00
. arg ( tr ( " Show " ) )
2011-12-25 05:05:12 +00:00
. arg ( tr ( " Date " ) )
. arg ( tr ( " Start " ) )
. arg ( tr ( " End " ) ) ;
2011-10-07 07:10:36 +00:00
if ( cpap ) {
2011-12-23 10:52:31 +00:00
html + = QString ( " <tr><td align=left colspan=4><i>%1</i></td></tr> " ) . arg ( tr ( " CPAP Sessions " ) ) ;
2011-10-07 07:10:36 +00:00
for ( QVector < Session * > : : iterator s = cpap - > begin ( ) ; s ! = cpap - > end ( ) ; s + + ) {
fd = QDateTime : : fromTime_t ( ( * s ) - > first ( ) / 1000L ) ;
ld = QDateTime : : fromTime_t ( ( * s ) - > last ( ) / 1000L ) ;
2011-12-03 08:52:24 +00:00
int len = ( * s ) - > length ( ) / 1000L ;
int h = len / 3600 ;
int m = ( len / 60 ) % 60 ;
int s1 = len % 60 ;
2011-12-21 17:00:19 +00:00
QHash < ChannelID , QVariant > : : iterator i = ( * s ) - > settings . find ( CPAP_BrokenWaveform ) ;
2011-12-18 16:39:36 +00:00
tooltip = cpap - > machine - > GetClass ( ) + " " + tr ( " CPAP " ) + " " + QString ( ) . sprintf ( " %2ih %2im %2is " , h , m , s1 ) ;
// tooltip needs to lookup language.. :-/
2011-10-07 07:10:36 +00:00
if ( ( i ! = ( * s ) - > settings . end ( ) ) & & i . value ( ) . toBool ( ) ) corrupted_waveform = true ;
2011-12-27 13:21:10 +00:00
Session * sess = * s ;
if ( ! sess - > settings . contains ( SESSION_ENABLED ) ) {
sess - > settings [ SESSION_ENABLED ] = true ;
}
bool b = sess - > settings [ SESSION_ENABLED ] . toBool ( ) ;
html + = QString ( " <tr><td align=left><a href='cpap=%1' title='%2'>%3</a></td><td><a href='togglecpapsession=%1'><img src='qrc:/icons/toggle-%4-us.svg' width=24px></a></td><td align=center>%5</td><td align=center>%6</td><td align=center>%7</td></tr> " )
. arg ( ( * s ) - > session ( ) )
. arg ( tooltip )
. arg ( ( * s ) - > session ( ) , 8 , 10 , QChar ( ' 0 ' ) )
. arg ( ( b ? " on " : " off " ) )
. arg ( fd . date ( ) . toString ( Qt : : SystemLocaleShortDate ) )
. arg ( fd . toString ( " HH:mm " ) )
. arg ( ld . toString ( " HH:mm " ) ) ;
2011-10-07 07:10:36 +00:00
}
2011-10-07 05:28:35 +00:00
}
2011-10-07 07:10:36 +00:00
if ( oxi ) {
2011-12-23 10:52:31 +00:00
html + = QString ( " <tr><td align=left colspan=4><i>%1</i></td></tr> " ) . arg ( tr ( " Oximetry Sessions " ) ) ;
2011-10-07 07:10:36 +00:00
for ( QVector < Session * > : : iterator s = oxi - > begin ( ) ; s ! = oxi - > end ( ) ; s + + ) {
fd = QDateTime : : fromTime_t ( ( * s ) - > first ( ) / 1000L ) ;
ld = QDateTime : : fromTime_t ( ( * s ) - > last ( ) / 1000L ) ;
2011-12-03 08:52:24 +00:00
int len = ( * s ) - > length ( ) / 1000L ;
int h = len / 3600 ;
int m = ( len / 60 ) % 60 ;
int s1 = len % 60 ;
2011-12-21 17:00:19 +00:00
QHash < ChannelID , QVariant > : : iterator i = ( * s ) - > settings . find ( CPAP_BrokenWaveform ) ;
2011-12-18 16:39:36 +00:00
tooltip = oxi - > machine - > GetClass ( ) + " " + tr ( " Oximeter " ) + " " + QString ( ) . sprintf ( " %2ih, %2im, %2is " , h , m , s1 ) ;
2011-12-27 13:21:10 +00:00
Session * sess = * s ;
if ( ! sess - > settings . contains ( SESSION_ENABLED ) ) {
sess - > settings [ SESSION_ENABLED ] = true ;
}
bool b = sess - > settings [ SESSION_ENABLED ] . toBool ( ) ;
2011-12-18 16:39:36 +00:00
2011-10-07 07:10:36 +00:00
if ( ( i ! = ( * s ) - > settings . end ( ) ) & & i . value ( ) . toBool ( ) ) corrupted_waveform = true ;
2011-12-27 13:21:10 +00:00
html + = QString ( " <tr><td align=left><a href='oxi=%1' title='%2'>%3</a></td><td><a href='toggleoxisession=%1'><img src='qrc:/icons/toggle-%4-us.svg' width=24px></a></td><td align=center>%5</td><td align=center>%6</td><td align=center>%7</td></tr> " )
. arg ( ( * s ) - > session ( ) )
. arg ( tooltip )
. arg ( ( * s ) - > session ( ) , 8 , 10 , QChar ( ' 0 ' ) )
. arg ( ( b ? " on " : " off " ) )
. arg ( fd . date ( ) . toString ( Qt : : SystemLocaleShortDate ) )
. arg ( fd . toString ( " HH:mm " ) )
. arg ( ld . toString ( " HH:mm " ) ) ;
//tmp.sprintf(("<tr><td align=left><a href='oxi=%i' title='"+tooltip+"'>%08i</a></td><td align=center>"+fd.date().toString(Qt::SystemLocaleShortDate)+"</td><td align=center>"+fd.toString("HH:mm ")+"</td><td align=center>"+ld.toString("HH:mm")+"</td></tr>").toLatin1(),(*s)->session(),(*s)->session());
//html+=tmp;
2011-10-07 07:10:36 +00:00
}
2011-06-26 08:30:44 +00:00
}
2011-07-21 03:03:20 +00:00
if ( corrupted_waveform ) {
2011-12-25 05:05:12 +00:00
html + = QString ( " <tr><td colspan=4 align=center><i>%1</i></td></tr> " ) . arg ( tr ( " One or more waveform record for this session had faulty source data. Some waveform overlay points may not match up correctly. " ) ) ;
2011-07-21 03:03:20 +00:00
}
2011-12-25 05:05:12 +00:00
html + = " </table> " ;
2011-06-26 08:30:44 +00:00
}
2011-08-25 06:11:44 +00:00
html + = " </body></html> " ;
2011-06-26 08:30:44 +00:00
ui - > webView - > setHtml ( html ) ;
2011-09-17 15:41:31 +00:00
ui - > JournalNotes - > clear ( ) ;
2011-12-02 11:40:47 +00:00
2011-12-18 16:39:36 +00:00
ui - > bookmarkTable - > clearContents ( ) ;
2011-12-02 11:40:47 +00:00
ui - > bookmarkTable - > setRowCount ( 0 ) ;
QStringList sl ;
2011-12-18 16:39:36 +00:00
//sl.append(tr("Starts"));
//sl.append(tr("Notes"));
2011-12-02 11:40:47 +00:00
ui - > bookmarkTable - > setHorizontalHeaderLabels ( sl ) ;
2011-12-10 15:24:45 +00:00
ui - > ZombieMeter - > blockSignals ( true ) ;
ui - > weightSpinBox - > blockSignals ( true ) ;
ui - > ouncesSpinBox - > blockSignals ( true ) ;
2011-12-02 11:40:47 +00:00
ui - > weightSpinBox - > setValue ( 0 ) ;
2011-12-02 13:48:05 +00:00
ui - > ouncesSpinBox - > setValue ( 0 ) ;
2011-12-10 12:14:48 +00:00
ui - > ZombieMeter - > setValue ( 5 ) ;
2011-12-10 15:24:45 +00:00
ui - > ouncesSpinBox - > blockSignals ( false ) ;
ui - > weightSpinBox - > blockSignals ( false ) ;
ui - > ZombieMeter - > blockSignals ( false ) ;
2011-12-03 01:05:17 +00:00
ui - > BMI - > display ( 0 ) ;
ui - > BMI - > setVisible ( false ) ;
ui - > BMIlabel - > setVisible ( false ) ;
2011-12-02 14:18:47 +00:00
BookmarksChanged = false ;
2011-06-26 08:30:44 +00:00
Session * journal = GetJournalSession ( date ) ;
if ( journal ) {
2011-12-02 11:40:47 +00:00
bool ok ;
if ( journal - > settings . contains ( Journal_Notes ) )
ui - > JournalNotes - > setHtml ( journal - > settings [ Journal_Notes ] . toString ( ) ) ;
2011-12-21 05:47:33 +00:00
if ( journal - > settings . contains ( Journal_Weight ) ) {
double kg = journal - > settings [ Journal_Weight ] . toDouble ( & ok ) ;
2011-12-21 11:09:50 +00:00
2011-12-21 12:47:47 +00:00
if ( PROFILE . general - > unitSystem ( ) = = US_Metric ) {
2011-12-02 13:48:05 +00:00
ui - > weightSpinBox - > setDecimals ( 3 ) ;
2011-12-10 15:24:45 +00:00
ui - > weightSpinBox - > blockSignals ( true ) ;
2011-12-02 13:48:05 +00:00
ui - > weightSpinBox - > setValue ( kg ) ;
2011-12-10 15:24:45 +00:00
ui - > weightSpinBox - > blockSignals ( false ) ;
2011-12-02 13:48:05 +00:00
ui - > ouncesSpinBox - > setVisible ( false ) ;
2011-12-21 12:47:47 +00:00
ui - > weightSpinBox - > setSuffix ( STR_UNIT_KG ) ;
2011-12-02 13:48:05 +00:00
} else {
float ounces = ( kg * 1000.0 ) / ounce_convert ;
int pounds = ounces / 16.0 ;
double oz ;
double frac = modf ( ounces , & oz ) ;
ounces = ( int ( ounces ) % 16 ) + frac ;
2011-12-10 15:24:45 +00:00
ui - > weightSpinBox - > blockSignals ( true ) ;
ui - > ouncesSpinBox - > blockSignals ( true ) ;
2011-12-02 13:48:05 +00:00
ui - > weightSpinBox - > setValue ( pounds ) ;
ui - > ouncesSpinBox - > setValue ( ounces ) ;
2011-12-10 15:24:45 +00:00
ui - > ouncesSpinBox - > blockSignals ( false ) ;
ui - > weightSpinBox - > blockSignals ( false ) ;
2011-12-02 13:48:05 +00:00
2011-12-21 12:47:47 +00:00
ui - > weightSpinBox - > setSuffix ( STR_UNIT_POUND ) ;
2011-12-02 13:48:05 +00:00
ui - > weightSpinBox - > setDecimals ( 0 ) ;
ui - > ouncesSpinBox - > setVisible ( true ) ;
2011-12-21 12:47:47 +00:00
ui - > ouncesSpinBox - > setSuffix ( STR_UNIT_OUNCE ) ;
2011-12-02 13:48:05 +00:00
}
2011-12-21 12:47:47 +00:00
double height = PROFILE . user - > height ( ) / 100.0 ;
2011-12-03 01:05:17 +00:00
if ( height > 0 & & kg > 0 ) {
2011-12-14 04:54:17 +00:00
double bmi = kg / ( height * height ) ;
2011-12-03 01:05:17 +00:00
ui - > BMI - > setVisible ( true ) ;
ui - > BMIlabel - > setVisible ( true ) ;
2011-12-14 04:54:17 +00:00
ui - > BMI - > display ( bmi ) ;
2011-12-03 01:05:17 +00:00
}
2011-12-02 13:48:05 +00:00
}
2011-12-02 11:40:47 +00:00
2011-12-21 05:47:33 +00:00
if ( journal - > settings . contains ( Journal_ZombieMeter ) ) {
2011-12-10 15:24:45 +00:00
ui - > ZombieMeter - > blockSignals ( true ) ;
2011-12-21 05:47:33 +00:00
ui - > ZombieMeter - > setValue ( journal - > settings [ Journal_ZombieMeter ] . toDouble ( & ok ) ) ;
2011-12-10 15:24:45 +00:00
ui - > ZombieMeter - > blockSignals ( false ) ;
}
2011-12-02 11:40:47 +00:00
2011-12-21 05:47:33 +00:00
if ( journal - > settings . contains ( Bookmark_Start ) ) {
QVariantList start = journal - > settings [ Bookmark_Start ] . toList ( ) ;
QVariantList end = journal - > settings [ Bookmark_End ] . toList ( ) ;
QStringList notes = journal - > settings [ Bookmark_Notes ] . toStringList ( ) ;
2011-12-02 11:40:47 +00:00
2011-12-11 13:57:07 +00:00
ui - > bookmarkTable - > blockSignals ( true ) ;
2011-12-02 11:40:47 +00:00
bool ok ;
for ( int i = 0 ; i < start . size ( ) ; i + + ) {
qint64 st = start . at ( i ) . toLongLong ( & ok ) ;
qint64 et = end . at ( i ) . toLongLong ( & ok ) ;
QDateTime d = QDateTime : : fromTime_t ( st / 1000L ) ;
//int row=ui->bookmarkTable->rowCount();
ui - > bookmarkTable - > insertRow ( i ) ;
QTableWidgetItem * tw = new QTableWidgetItem ( notes . at ( i ) ) ;
QTableWidgetItem * dw = new QTableWidgetItem ( d . time ( ) . toString ( " HH:mm:ss " ) ) ;
dw - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
ui - > bookmarkTable - > setItem ( i , 0 , dw ) ;
ui - > bookmarkTable - > setItem ( i , 1 , tw ) ;
tw - > setData ( Qt : : UserRole , st ) ;
tw - > setData ( Qt : : UserRole + 1 , et ) ;
2011-12-23 10:52:31 +00:00
} // for (int i
2011-12-11 13:57:07 +00:00
ui - > bookmarkTable - > blockSignals ( false ) ;
2011-12-23 10:52:31 +00:00
} // if (journal->settings.contains(Bookmark_Start))
} // if (journal)
2011-06-26 08:30:44 +00:00
}
2011-12-02 13:48:05 +00:00
void Daily : : UnitsChanged ( )
{
double kg ;
2011-12-21 12:47:47 +00:00
if ( PROFILE . general - > unitSystem ( ) = = US_Metric ) {
2011-12-02 13:48:05 +00:00
kg = ui - > weightSpinBox - > value ( ) ;
float ounces = ( kg * 1000.0 ) / ounce_convert ;
int pounds = ounces / 16 ;
float oz = fmodf ( ounces , 16 ) ;
ui - > weightSpinBox - > setValue ( pounds ) ;
ui - > ouncesSpinBox - > setValue ( oz ) ;
ui - > weightSpinBox - > setDecimals ( 0 ) ;
2011-12-21 12:47:47 +00:00
ui - > weightSpinBox - > setSuffix ( STR_UNIT_POUND ) ;
2011-12-02 13:48:05 +00:00
ui - > ouncesSpinBox - > setVisible ( true ) ;
2011-12-21 12:47:47 +00:00
ui - > ouncesSpinBox - > setSuffix ( STR_UNIT_OUNCE ) ;
2011-12-02 13:48:05 +00:00
} else {
kg = ( ui - > weightSpinBox - > value ( ) * ( ounce_convert * 16.0 ) ) + ( ui - > ouncesSpinBox - > value ( ) * ounce_convert ) ;
kg / = 1000.0 ;
ui - > weightSpinBox - > setDecimals ( 3 ) ;
ui - > weightSpinBox - > setValue ( kg ) ;
ui - > ouncesSpinBox - > setVisible ( false ) ;
2011-12-21 12:47:47 +00:00
ui - > weightSpinBox - > setSuffix ( STR_UNIT_KG ) ;
2011-12-02 13:48:05 +00:00
}
}
2011-06-26 08:30:44 +00:00
void Daily : : Unload ( QDate date )
{
2011-09-17 15:41:31 +00:00
Session * journal = GetJournalSession ( date ) ;
2011-06-26 08:30:44 +00:00
2011-12-02 11:40:47 +00:00
bool nonotes = ui - > JournalNotes - > toPlainText ( ) . isEmpty ( ) ;
if ( journal ) {
QString jhtml = ui - > JournalNotes - > toHtml ( ) ;
2011-12-02 11:48:02 +00:00
if ( ( ! journal - > settings . contains ( Journal_Notes ) & & ! nonotes ) | | ( journal - > settings [ Journal_Notes ] ! = jhtml ) ) {
2011-09-17 15:41:31 +00:00
journal - > settings [ Journal_Notes ] = jhtml ;
2011-06-26 08:30:44 +00:00
journal - > SetChanged ( true ) ;
}
2011-12-02 11:40:47 +00:00
} else {
2011-12-11 13:57:07 +00:00
if ( ! nonotes ) {
2011-12-02 11:40:47 +00:00
journal = CreateJournalSession ( date ) ;
if ( ! nonotes ) {
journal - > settings [ Journal_Notes ] = ui - > JournalNotes - > toHtml ( ) ;
journal - > SetChanged ( true ) ;
}
}
2011-06-26 08:30:44 +00:00
}
2011-12-02 11:40:47 +00:00
2011-06-26 08:30:44 +00:00
if ( journal ) {
2011-12-02 11:48:02 +00:00
if ( nonotes ) {
QHash < ChannelID , QVariant > : : iterator it = journal - > settings . find ( Journal_Notes ) ;
if ( it ! = journal - > settings . end ( ) ) {
journal - > settings . erase ( it ) ;
}
}
2011-12-02 13:48:05 +00:00
if ( journal - > IsChanged ( ) ) {
2011-12-25 13:27:47 +00:00
mainwin - > getOverview ( ) - > ResetGraphs ( ) ;
2011-12-02 13:48:05 +00:00
}
2011-10-05 07:41:56 +00:00
Machine * jm = PROFILE . GetMachine ( MT_JOURNAL ) ;
2011-06-26 08:30:44 +00:00
if ( jm ) jm - > SaveSession ( journal ) ;
2011-09-17 15:41:31 +00:00
}
2011-06-26 08:30:44 +00:00
UpdateCalendarDay ( date ) ;
}
void Daily : : on_JournalNotesItalic_clicked ( )
{
QTextCursor cursor = ui - > JournalNotes - > textCursor ( ) ;
if ( ! cursor . hasSelection ( ) )
cursor . select ( QTextCursor : : WordUnderCursor ) ;
QTextCharFormat format = cursor . charFormat ( ) ;
format . setFontItalic ( ! format . fontItalic ( ) ) ;
cursor . mergeCharFormat ( format ) ;
//ui->JournalNotes->mergeCurrentCharFormat(format);
}
void Daily : : on_JournalNotesBold_clicked ( )
{
QTextCursor cursor = ui - > JournalNotes - > textCursor ( ) ;
if ( ! cursor . hasSelection ( ) )
cursor . select ( QTextCursor : : WordUnderCursor ) ;
QTextCharFormat format = cursor . charFormat ( ) ;
int fw = format . fontWeight ( ) ;
if ( fw ! = QFont : : Bold )
format . setFontWeight ( QFont : : Bold ) ;
else
format . setFontWeight ( QFont : : Normal ) ;
cursor . mergeCharFormat ( format ) ;
//ui->JournalNotes->mergeCurrentCharFormat(format);
}
void Daily : : on_JournalNotesFontsize_activated ( int index )
{
QTextCursor cursor = ui - > JournalNotes - > textCursor ( ) ;
if ( ! cursor . hasSelection ( ) )
cursor . select ( QTextCursor : : WordUnderCursor ) ;
QTextCharFormat format = cursor . charFormat ( ) ;
QFont font = format . font ( ) ;
int fontsize = 10 ;
if ( index = = 1 ) fontsize = 15 ;
else if ( index = = 2 ) fontsize = 25 ;
font . setPointSize ( fontsize ) ;
format . setFont ( font ) ;
cursor . mergeCharFormat ( format ) ;
}
void Daily : : on_JournalNotesColour_clicked ( )
{
2011-06-27 15:00:00 +00:00
QColor col = QColorDialog : : getColor ( Qt : : black , this , tr ( " Pick a Colour " ) ) ; //,QColorDialog::NoButtons);
2011-06-26 08:30:44 +00:00
if ( ! col . isValid ( ) ) return ;
QTextCursor cursor = ui - > JournalNotes - > textCursor ( ) ;
if ( ! cursor . hasSelection ( ) )
cursor . select ( QTextCursor : : WordUnderCursor ) ;
QBrush b ( col ) ;
QPalette newPalette = palette ( ) ;
newPalette . setColor ( QPalette : : ButtonText , col ) ;
ui - > JournalNotesColour - > setPalette ( newPalette ) ;
QTextCharFormat format = cursor . charFormat ( ) ;
format . setForeground ( b ) ;
cursor . setCharFormat ( format ) ;
}
Session * Daily : : CreateJournalSession ( QDate date )
{
2011-10-05 07:41:56 +00:00
Machine * m = PROFILE . GetMachine ( MT_JOURNAL ) ;
2011-06-26 08:30:44 +00:00
if ( ! m ) {
2011-10-05 07:41:56 +00:00
m = new Machine ( p_profile , 0 ) ;
2011-06-26 08:30:44 +00:00
m - > SetClass ( " Journal " ) ;
2011-12-21 14:24:09 +00:00
m - > properties [ STR_PROP_Brand ] = " Virtual " ;
2011-06-26 08:30:44 +00:00
m - > SetType ( MT_JOURNAL ) ;
2011-10-05 07:41:56 +00:00
PROFILE . AddMachine ( m ) ;
2011-06-26 08:30:44 +00:00
}
Session * sess = new Session ( m , 0 ) ;
2011-12-25 05:05:12 +00:00
qint64 st , et ;
Day * cday = PROFILE . GetDay ( date , MT_CPAP ) ;
if ( cday ) {
st = cday - > first ( ) ;
et = cday - > last ( ) ;
} else {
QDateTime dt ( date , QTime ( 20 , 0 ) ) ;
st = qint64 ( dt . toTime_t ( ) ) * 1000L ;
et = st + 3600000 ;
}
sess - > set_first ( st ) ;
sess - > set_last ( et ) ;
2011-06-26 08:30:44 +00:00
sess - > SetChanged ( true ) ;
2011-10-05 07:41:56 +00:00
m - > AddSession ( sess , p_profile ) ;
2011-06-26 08:30:44 +00:00
return sess ;
}
Session * Daily : : GetJournalSession ( QDate date ) // Get the first journal session
{
2011-10-05 07:41:56 +00:00
Day * journal = PROFILE . GetDay ( date , MT_JOURNAL ) ;
2011-06-26 08:30:44 +00:00
if ( ! journal )
return NULL ; //CreateJournalSession(date);
2011-07-31 20:24:43 +00:00
QVector < Session * > : : iterator s ;
2011-06-26 08:30:44 +00:00
s = journal - > begin ( ) ;
if ( s ! = journal - > end ( ) )
return * s ;
return NULL ;
}
void Daily : : UpdateCPAPGraphs ( Day * day )
{
//if (!day) return;
if ( day ) {
day - > OpenEvents ( ) ;
}
2011-08-25 06:11:44 +00:00
for ( QList < Layer * > : : iterator g = CPAPData . begin ( ) ; g ! = CPAPData . end ( ) ; g + + ) {
2011-07-27 09:21:53 +00:00
( * g ) - > SetDay ( day ) ;
2011-06-26 08:30:44 +00:00
}
2011-09-21 14:10:10 +00:00
}
2011-06-26 08:30:44 +00:00
void Daily : : UpdateOXIGraphs ( Day * day )
{
//if (!day) return;
2011-07-27 10:47:50 +00:00
2011-06-26 08:30:44 +00:00
if ( day ) {
day - > OpenEvents ( ) ;
}
2011-08-25 06:11:44 +00:00
for ( QList < Layer * > : : iterator g = OXIData . begin ( ) ; g ! = OXIData . end ( ) ; g + + ) {
2011-07-27 09:21:53 +00:00
( * g ) - > SetDay ( day ) ;
2011-06-26 08:30:44 +00:00
}
2011-06-27 07:45:59 +00:00
}
void Daily : : RedrawGraphs ( )
{
2011-12-20 11:12:52 +00:00
GraphView - > redraw ( ) ;
2011-06-27 07:45:59 +00:00
}
2011-06-26 08:30:44 +00:00
2011-11-27 22:36:38 +00:00
void Daily : : on_treeWidget_itemClicked ( QTreeWidgetItem * item , int column )
2011-06-26 08:30:44 +00:00
{
2011-12-02 14:36:40 +00:00
Q_UNUSED ( column ) ;
2011-06-26 08:30:44 +00:00
QDateTime d ;
2011-12-25 05:05:12 +00:00
if ( ! item - > data ( 0 , Qt : : UserRole ) . isNull ( ) ) {
qint64 winsize = qint64 ( PROFILE . general - > eventWindowSize ( ) ) * 60000L ;
qint64 t = item - > data ( 0 , Qt : : UserRole ) . toLongLong ( ) ;
double st = t - ( winsize / 2 ) ;
double et = t + ( winsize / 2 ) ;
2011-11-18 08:33:31 +00:00
2011-12-21 14:24:09 +00:00
gGraph * g = GraphView - > findGraph ( STR_TR_EventFlags ) ;
2011-11-27 22:36:38 +00:00
if ( ! g ) return ;
if ( st < g - > rmin_x ) {
st = g - > rmin_x ;
2011-12-25 05:05:12 +00:00
et = st + winsize ;
2011-11-27 08:31:05 +00:00
}
2011-11-27 22:36:38 +00:00
if ( et > g - > rmax_x ) {
et = g - > rmax_x ;
2011-12-25 05:05:12 +00:00
st = et - winsize ;
2011-11-27 08:31:05 +00:00
}
2011-08-25 06:11:44 +00:00
GraphView - > SetXBounds ( st , et ) ;
2011-06-26 08:30:44 +00:00
}
}
2011-06-28 01:51:21 +00:00
2011-11-27 22:36:38 +00:00
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 ) ;
}
2011-06-28 01:51:21 +00:00
void Daily : : on_JournalNotesUnderline_clicked ( )
{
QTextCursor cursor = ui - > JournalNotes - > textCursor ( ) ;
if ( ! cursor . hasSelection ( ) )
cursor . select ( QTextCursor : : WordUnderCursor ) ;
QTextCharFormat format = cursor . charFormat ( ) ;
format . setFontUnderline ( ! format . fontUnderline ( ) ) ;
cursor . mergeCharFormat ( format ) ;
//ui->JournalNotes->mergeCurrentCharFormat(format);
}
2011-10-30 02:46:17 +00:00
void Daily : : on_prevDayButton_clicked ( )
{
2011-10-30 09:29:04 +00:00
if ( ! PROFILE . ExistsAndTrue ( " SkipEmptyDays " ) ) {
2011-10-30 04:51:57 +00:00
LoadDate ( previous_date . addDays ( - 1 ) ) ;
} else {
QDate d = previous_date ;
for ( int i = 0 ; i < 90 ; i + + ) {
d = d . addDays ( - 1 ) ;
if ( PROFILE . GetDay ( d ) ) {
LoadDate ( d ) ;
break ;
}
2011-10-30 04:43:15 +00:00
}
}
2011-10-30 02:46:17 +00:00
}
void Daily : : on_nextDayButton_clicked ( )
{
2011-10-30 09:29:04 +00:00
if ( ! PROFILE . ExistsAndTrue ( " SkipEmptyDays " ) ) {
2011-10-30 04:51:57 +00:00
LoadDate ( previous_date . addDays ( 1 ) ) ;
} else {
QDate d = previous_date ;
for ( int i = 0 ; i < 90 ; i + + ) {
d = d . addDays ( 1 ) ;
if ( PROFILE . GetDay ( d ) ) {
LoadDate ( d ) ;
break ;
}
2011-10-30 04:43:15 +00:00
}
}
2011-10-30 02:46:17 +00:00
}
void Daily : : on_calButton_toggled ( bool checked )
{
2011-10-30 14:23:59 +00:00
//bool b=!ui->calendar->isVisible();
bool b = checked ;
2011-10-30 04:35:55 +00:00
ui - > calendar - > setVisible ( b ) ;
if ( ! b ) ui - > calButton - > setArrowType ( Qt : : DownArrow ) ;
2011-10-30 04:21:35 +00:00
else ui - > calButton - > setArrowType ( Qt : : UpArrow ) ;
2011-10-30 02:46:17 +00:00
}
2011-10-30 03:18:20 +00:00
void Daily : : on_todayButton_clicked ( )
{
QDate d = QDate : : currentDate ( ) ;
if ( d > PROFILE . LastDay ( ) ) d = PROFILE . LastDay ( ) ;
LoadDate ( d ) ;
}
2011-11-24 12:47:25 +00:00
2011-11-27 07:41:00 +00:00
void Daily : : on_evViewSlider_valueChanged ( int value )
{
ui - > evViewLCD - > display ( value ) ;
2011-12-21 12:47:47 +00:00
PROFILE . general - > setEventWindowSize ( value ) ;
2011-11-27 08:00:20 +00:00
2011-12-21 12:47:47 +00:00
int winsize = value * 60 ;
2011-11-27 08:31:05 +00:00
2011-12-21 14:24:09 +00:00
gGraph * g = GraphView - > findGraph ( STR_TR_EventFlags ) ;
2011-12-11 13:57:07 +00:00
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 < g - > rmin_x ) {
st = g - > rmin_x ;
et = st + winsize * 1000 ;
}
if ( et > g - > rmax_x ) {
et = g - > rmax_x ;
st = et - winsize * 1000 ;
2011-11-27 08:00:20 +00:00
}
2011-12-11 13:57:07 +00:00
GraphView - > SetXBounds ( st , et ) ;
2011-11-27 07:41:00 +00:00
}
2011-12-01 15:40:32 +00:00
2011-12-02 11:40:47 +00:00
void Daily : : on_bookmarkTable_itemClicked ( QTableWidgetItem * item )
{
int row = item - > row ( ) ;
qint64 st , et ;
QTableWidgetItem * it = ui - > bookmarkTable - > item ( row , 1 ) ;
bool ok ;
st = it - > data ( Qt : : UserRole ) . toLongLong ( & ok ) ;
et = it - > data ( Qt : : UserRole + 1 ) . toLongLong ( & ok ) ;
GraphView - > SetXBounds ( st , et ) ;
2011-12-20 11:12:52 +00:00
GraphView - > redraw ( ) ;
2011-12-02 11:40:47 +00:00
}
void Daily : : on_addBookmarkButton_clicked ( )
{
qint64 st , et ;
2011-12-11 14:05:07 +00:00
ui - > bookmarkTable - > blockSignals ( true ) ;
2011-12-02 11:40:47 +00:00
GraphView - > GetXBounds ( st , et ) ;
QDateTime d = QDateTime : : fromTime_t ( st / 1000L ) ;
int row = ui - > bookmarkTable - > rowCount ( ) ;
ui - > bookmarkTable - > insertRow ( row ) ;
QTableWidgetItem * tw = new QTableWidgetItem ( " Bookmark at " + d . time ( ) . toString ( " HH:mm:ss " ) ) ;
QTableWidgetItem * dw = new QTableWidgetItem ( d . time ( ) . toString ( " HH:mm:ss " ) ) ;
dw - > setFlags ( Qt : : ItemIsSelectable | Qt : : ItemIsEnabled ) ;
ui - > bookmarkTable - > setItem ( row , 0 , dw ) ;
ui - > bookmarkTable - > setItem ( row , 1 , tw ) ;
tw - > setData ( Qt : : UserRole , st ) ;
tw - > setData ( Qt : : UserRole + 1 , et ) ;
2011-12-11 14:05:07 +00:00
ui - > bookmarkTable - > blockSignals ( false ) ;
2011-12-11 13:57:07 +00:00
update_Bookmarks ( ) ;
2011-12-26 04:41:28 +00:00
mainwin - > updateFavourites ( ) ;
2011-12-11 13:57:07 +00:00
2011-12-02 11:40:47 +00:00
//ui->bookmarkTable->setItem(row,2,new QTableWidgetItem(QString::number(st)));
//ui->bookmarkTable->setItem(row,3,new QTableWidgetItem(QString::number(et)));
}
2011-12-11 13:57:07 +00:00
void Daily : : update_Bookmarks ( )
{
QVariantList start ;
QVariantList end ;
QStringList notes ;
QTableWidgetItem * item ;
for ( int row = 0 ; row < ui - > bookmarkTable - > rowCount ( ) ; row + + ) {
item = ui - > bookmarkTable - > item ( row , 1 ) ;
2011-12-11 14:05:07 +00:00
2011-12-11 13:57:07 +00:00
start . push_back ( item - > data ( Qt : : UserRole ) ) ;
end . push_back ( item - > data ( Qt : : UserRole + 1 ) ) ;
notes . push_back ( item - > text ( ) ) ;
}
Session * journal = GetJournalSession ( previous_date ) ;
if ( ! journal ) {
journal = CreateJournalSession ( previous_date ) ;
}
2011-12-21 05:47:33 +00:00
journal - > settings [ Bookmark_Start ] = start ;
journal - > settings [ Bookmark_End ] = end ;
journal - > settings [ Bookmark_Notes ] = notes ;
2011-12-11 13:57:07 +00:00
journal - > SetChanged ( true ) ;
BookmarksChanged = true ;
2011-12-26 04:41:28 +00:00
mainwin - > updateFavourites ( ) ;
2011-12-11 13:57:07 +00:00
}
2011-12-02 11:40:47 +00:00
void Daily : : on_removeBookmarkButton_clicked ( )
{
int row = ui - > bookmarkTable - > currentRow ( ) ;
if ( row > = 0 ) {
2011-12-11 14:05:07 +00:00
ui - > bookmarkTable - > blockSignals ( true ) ;
2011-12-02 11:40:47 +00:00
ui - > bookmarkTable - > removeRow ( row ) ;
2011-12-11 14:05:07 +00:00
ui - > bookmarkTable - > blockSignals ( false ) ;
2011-12-11 13:57:07 +00:00
update_Bookmarks ( ) ;
2011-12-02 11:40:47 +00:00
}
2011-12-26 04:41:28 +00:00
mainwin - > updateFavourites ( ) ;
2011-12-02 11:40:47 +00:00
}
2011-12-10 15:24:45 +00:00
void Daily : : on_ZombieMeter_valueChanged ( int action )
2011-12-02 11:40:47 +00:00
{
2011-12-02 14:36:40 +00:00
Q_UNUSED ( action ) ;
2011-12-02 11:40:47 +00:00
ZombieMeterMoved = true ;
2011-12-10 15:24:45 +00:00
Session * journal = GetJournalSession ( previous_date ) ;
if ( ! journal ) {
journal = CreateJournalSession ( previous_date ) ;
}
2011-12-21 05:47:33 +00:00
journal - > settings [ Journal_ZombieMeter ] = ui - > ZombieMeter - > value ( ) ;
2011-12-10 15:24:45 +00:00
journal - > SetChanged ( true ) ;
gGraph * g ;
if ( mainwin - > getOverview ( ) ) {
g = mainwin - > getOverview ( ) - > graphView ( ) - > findGraph ( " Zombie " ) ;
if ( g ) g - > setDay ( NULL ) ;
//mainwin->getOverview()->RedrawGraphs();
}
2011-12-02 11:40:47 +00:00
}
2011-12-02 14:18:47 +00:00
void Daily : : on_bookmarkTable_itemChanged ( QTableWidgetItem * item )
{
Q_UNUSED ( item ) ;
2011-12-11 13:57:07 +00:00
update_Bookmarks ( ) ;
2011-12-02 14:18:47 +00:00
}
2011-12-03 01:05:17 +00:00
void Daily : : on_weightSpinBox_valueChanged ( double arg1 )
{
2011-12-21 12:47:47 +00:00
double height = PROFILE . user - > height ( ) / 100.0 ;
2011-12-10 15:24:45 +00:00
Session * journal = GetJournalSession ( previous_date ) ;
if ( ! journal ) {
journal = CreateJournalSession ( previous_date ) ;
}
2011-12-03 01:05:17 +00:00
double kg ;
2011-12-21 12:47:47 +00:00
if ( PROFILE . general - > unitSystem ( ) = = US_Archiac ) {
2011-12-21 11:09:50 +00:00
kg = ( arg1 * pound_convert ) + ( ui - > ouncesSpinBox - > value ( ) * ounce_convert ) ;
} else {
kg = arg1 ;
2011-12-03 01:05:17 +00:00
}
2011-12-21 05:47:33 +00:00
journal - > settings [ Journal_Weight ] = kg ;
2011-12-10 15:24:45 +00:00
gGraphView * gv = mainwin - > getOverview ( ) - > graphView ( ) ;
gGraph * g ;
if ( gv ) {
2011-12-21 14:24:09 +00:00
g = gv - > findGraph ( STR_TR_Weight ) ;
2011-12-10 15:24:45 +00:00
if ( g ) g - > setDay ( NULL ) ;
}
2011-12-03 01:05:17 +00:00
if ( ( height > 0 ) & & ( kg > 0 ) ) {
double bmi = kg / ( height * height ) ;
ui - > BMI - > display ( bmi ) ;
2011-12-03 05:10:23 +00:00
ui - > BMI - > setVisible ( true ) ;
2011-12-21 05:47:33 +00:00
journal - > settings [ Journal_BMI ] = bmi ;
2011-12-10 15:24:45 +00:00
if ( gv ) {
2011-12-21 14:24:09 +00:00
g = gv - > findGraph ( STR_TR_BMI ) ;
2011-12-10 15:24:45 +00:00
if ( g ) g - > setDay ( NULL ) ;
}
2011-12-03 01:05:17 +00:00
}
2011-12-10 15:24:45 +00:00
journal - > SetChanged ( true ) ;
2011-12-03 01:05:17 +00:00
}
void Daily : : on_ouncesSpinBox_valueChanged ( int arg1 )
{
2011-12-10 15:24:45 +00:00
Session * journal = GetJournalSession ( previous_date ) ;
if ( ! journal ) {
journal = CreateJournalSession ( previous_date ) ;
}
2011-12-21 12:47:47 +00:00
double height = PROFILE . user - > height ( ) / 100.0 ;
2011-12-03 01:05:17 +00:00
double kg = ( ui - > weightSpinBox - > value ( ) * pound_convert ) + ( arg1 * ounce_convert ) ;
2011-12-21 05:47:33 +00:00
journal - > settings [ Journal_Weight ] = kg ;
2011-12-10 15:24:45 +00:00
gGraph * g ;
if ( mainwin - > getOverview ( ) ) {
2011-12-21 14:24:09 +00:00
g = mainwin - > getOverview ( ) - > graphView ( ) - > findGraph ( STR_TR_Weight ) ;
2011-12-10 15:24:45 +00:00
if ( g ) g - > setDay ( NULL ) ;
}
2011-12-03 01:05:17 +00:00
if ( ( height > 0 ) & & ( kg > 0 ) ) {
double bmi = kg / ( height * height ) ;
ui - > BMI - > display ( bmi ) ;
2011-12-03 05:10:23 +00:00
ui - > BMI - > setVisible ( true ) ;
2011-12-10 15:24:45 +00:00
2011-12-21 05:47:33 +00:00
journal - > settings [ Journal_BMI ] = bmi ;
2011-12-10 15:24:45 +00:00
if ( mainwin - > getOverview ( ) ) {
2011-12-21 14:24:09 +00:00
g = mainwin - > getOverview ( ) - > graphView ( ) - > findGraph ( STR_TR_BMI ) ;
2011-12-10 15:24:45 +00:00
if ( g ) g - > setDay ( NULL ) ;
}
2011-12-03 01:05:17 +00:00
}
2011-12-10 15:24:45 +00:00
journal - > SetChanged ( true ) ;
2011-12-03 01:05:17 +00:00
}
2011-12-12 03:39:00 +00:00
QString Daily : : GetDetailsText ( )
{
ui - > webView - > triggerPageAction ( QWebPage : : SelectAll ) ;
QString text = ui - > webView - > page ( ) - > selectedText ( ) ;
ui - > webView - > triggerPageAction ( QWebPage : : MoveToEndOfDocument ) ;
ui - > webView - > triggerPageAction ( QWebPage : : SelectEndOfDocument ) ;
return text ;
}