diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index f24d6225..f1ff9242 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -320,8 +320,10 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height) GetTextExtent(a,x,y); px-=30+x; w.renderText(a,px+24,py+5); - lines->add(px,py,px+20,py,m_colors[j]); - lines->add(px,py+1,px+20,py+1,m_colors[j]); + quads->add(px,py-3,px+20,py-3,px+20,py+4,px,py+4,m_colors[j]); + //quads->add(m_colors[j]); + //lines->add(px,py,px+20,py,m_colors[j]); + //lines->add(px,py+1,px+20,py+1,m_colors[j]); } QString z=m_label; diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index d691c9d4..b8425d05 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -132,6 +132,40 @@ void GLBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & color qDebug() << "GLBuffer overflow"; } } +void GLBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4,QColor & color) // add with vertex colors +{ +if (m_cnt0) { diff --git a/Graphs/gGraphView.h b/Graphs/gGraphView.h index dc1b2ae2..e2d9dc9b 100644 --- a/Graphs/gGraphView.h +++ b/Graphs/gGraphView.h @@ -41,6 +41,7 @@ public: void add(GLshort x, GLshort y,QColor & col); // add with vertex color void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & col); // add with vertex colors + void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4,QColor & col); // add with vertex colors void scissor(GLshort x1, GLshort y1, GLshort x2, GLshort y2) { s1=x1; s2=y1; s3=x2; s4=y2; m_scissor=true; } void draw(); diff --git a/SleepLib/day.h b/SleepLib/day.h index 2f4d6bd9..ab7f9c80 100644 --- a/SleepLib/day.h +++ b/SleepLib/day.h @@ -55,7 +55,7 @@ public: qint64 total_time(); // in milliseconds - double hours() { return double(total_time())/3600000.0; } + EventDataType hours() { return EventDataType(double(total_time())/3600000.0); } Session *operator [](int i) { return sessions[i]; } diff --git a/SleepLib/loader_plugins/cms50_loader.h b/SleepLib/loader_plugins/cms50_loader.h index 70a79b11..a407d89c 100644 --- a/SleepLib/loader_plugins/cms50_loader.h +++ b/SleepLib/loader_plugins/cms50_loader.h @@ -11,7 +11,7 @@ License: GPL #include "SleepLib/machine_loader.h" const QString cms50_class_name="CMS50"; -const int cms50_data_version=2; +const int cms50_data_version=3; class CMS50Loader : public MachineLoader { @@ -23,8 +23,8 @@ class CMS50Loader : public MachineLoader virtual int Open(QString & path,Profile *profile); static void Register(); - virtual int Version() { return cms50_data_version; }; - virtual const QString & ClassName() { return cms50_class_name; }; + virtual int Version() { return cms50_data_version; } + virtual const QString & ClassName() { return cms50_class_name; } Machine *CreateMachine(Profile *profile); diff --git a/SleepLib/loader_plugins/prs1_loader.h b/SleepLib/loader_plugins/prs1_loader.h index 5b2443f9..c9b96d47 100644 --- a/SleepLib/loader_plugins/prs1_loader.h +++ b/SleepLib/loader_plugins/prs1_loader.h @@ -21,7 +21,7 @@ License: GPL //******************************************************************************************** // Please INCREMENT the following value when making changes to this loaders implementation. // -const int prs1_data_version=4; +const int prs1_data_version=5; // //******************************************************************************************** diff --git a/SleepLib/loader_plugins/resmed_loader.h b/SleepLib/loader_plugins/resmed_loader.h index 6e8f26d3..7d1d448a 100644 --- a/SleepLib/loader_plugins/resmed_loader.h +++ b/SleepLib/loader_plugins/resmed_loader.h @@ -20,7 +20,7 @@ License: GPL //******************************************************************************************** // Please INCREMENT the following value when making changes to this loaders implementation. // -const int resmed_data_version=2; +const int resmed_data_version=3; // //******************************************************************************************** diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index 36ef2120..27d16c62 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -464,7 +464,9 @@ bool Machine::Purge(int secret) QDir dir(path); - if (!dir.exists() || !dir.isReadable()) + if (!dir.exists()) // It doesn't exist anyway. + return true; + if (!dir.isReadable()) return false; diff --git a/daily.cpp b/daily.cpp index 3d92bed2..f4a32118 100644 --- a/daily.cpp +++ b/daily.cpp @@ -31,17 +31,11 @@ const int min_height=150; const int default_height=150; -Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) - :QWidget(parent),mainwin(mw), ui(new Ui::Daily) +Daily::Daily(QWidget *parent,Profile * _profile,gGraphView * shared, MainWindow *mw) + :QWidget(parent),mainwin(mw), ui(new Ui::Daily),profile(_profile) { ui->setupUi(this); - QString prof=pref["Profile"].toString(); - profile=Profiles::Get(prof); - if (!profile) { - QMessageBox::critical(this,"Profile Error",QString("Couldn't get profile '%1'.. Have to abort!").arg(pref["Profile"].toString())); - exit(-1); - } QList a; a.push_back(300); a.push_back(this->width()-300); diff --git a/daily.h b/daily.h index 48a651a4..a1c21ef8 100644 --- a/daily.h +++ b/daily.h @@ -35,7 +35,7 @@ class Daily : public QWidget Q_OBJECT public: - explicit Daily(QWidget *parent,gGraphView *shared,MainWindow *mw); + explicit Daily(QWidget *parent, Profile * _profile, gGraphView *shared,MainWindow *mw); ~Daily(); void ReloadGraphs(); void ResetGraphLayout(); diff --git a/docs/index.html b/docs/index.html index 069d9bda..c232d9b7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -17,9 +17,13 @@ p,a,td,body { font-size: 14px }
  • Contec CMS50 Oximeters
  • A few usage notes, plus some important information for Mac users.

    This is a developer preview, features are missing and bugs will be plentyful.

    -

    Project Website: http://sleepyhead.sourceforge.net
    -About Sleep Apnea: http://en.wikipedia.org/wiki/Sleep_apnea
    -CPAPTalk Forum: http://www.cpaptalk.com

    +

    SleepyHead Project Website on SourceForge
    +Jedimark's Personal Blog
    +About Sleep Apnea on Wikipedia

    +

    Friendly places to talk about Sleep Apnea
    +CPAPTalk Forum, +Apnea Board +


    This is a temporary logo
    diff --git a/mainwindow.cpp b/mainwindow.cpp index 66a27471..36eeb91e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -110,6 +110,9 @@ MainWindow::MainWindow(QWidget *parent) : if (!pref.Exists("Profile")) pref["Profile"]=getUserName(); + profile=Profiles::Get(pref["Profile"].toString()); + Q_ASSERT(profile!=NULL); + if (!pref.Exists("LinkGraphMovement")) pref["LinkGraphMovement"]=true; ui->action_Link_Graphs->setChecked(pref["LinkGraphMovement"].toBool()); @@ -142,6 +145,8 @@ MainWindow::MainWindow(QWidget *parent) : netmanager = new QNetworkAccessManager(this); connect(netmanager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); + + connect(ui->webView, SIGNAL(statusBarMessage(QString)), this, SLOT(updatestatusBarMessage(QString))); } extern MainWindow *mainwin; MainWindow::~MainWindow() @@ -158,10 +163,6 @@ MainWindow::~MainWindow() oximetry->close(); delete oximetry; } - if (report) { - report->close(); - delete report; - } DoneGraphs(); Profiles::Done(); mainwin=NULL; @@ -175,26 +176,19 @@ void MainWindow::Startup() qprogress->show(); //qstatusbar->showMessage(tr("Loading Data"),0); - profile=Profiles::Get(pref["Profile"].toString()); profile->LoadMachineData(); - daily=new Daily(ui->tabWidget,NULL,this); + daily=new Daily(ui->tabWidget,profile,NULL,this); ui->tabWidget->insertTab(1,daily,tr("Daily")); - overview=new Overview(ui->tabWidget,daily->SharedWidget()); + overview=new Overview(ui->tabWidget,profile,daily->SharedWidget()); ui->tabWidget->insertTab(2,overview,tr("Overview")); - oximetry=new Oximetry(ui->tabWidget,daily->SharedWidget()); + oximetry=new Oximetry(ui->tabWidget,profile,daily->SharedWidget()); ui->tabWidget->insertTab(3,oximetry,tr("Oximetry")); - report=new Report(ui->tabWidget,daily->SharedWidget(),daily,overview); - ui->tabWidget->insertTab(4,report,tr("Overview Report")); - - if (daily) daily->ReloadGraphs(); if (overview) overview->ReloadGraphs(); - if (report) report->ReloadGraphs(); - qprogress->hide(); qstatus->setText(""); //qstatusbar->clearMessage(); @@ -233,7 +227,6 @@ void MainWindow::on_action_Import_Data_triggered() profile->Save(); if (daily) daily->ReloadGraphs(); if (overview) overview->ReloadGraphs(); - if (report) report->ReloadGraphs(); //qDebug() << "overview->ReloadGraphs();"; } qstatus->setText(""); @@ -383,7 +376,7 @@ void MainWindow::on_action_Reset_Graph_Layout_triggered() void MainWindow::on_action_Preferences_triggered() { - PreferencesDialog pd(this); + PreferencesDialog pd(this,profile); if (pd.exec()==PreferencesDialog::Accepted) { qDebug() << "Preferences Accepted"; pd.Save(); @@ -458,3 +451,17 @@ void MainWindow::on_actionView_O_ximetry_triggered() { on_oximetryButton_clicked(); } +void MainWindow::updatestatusBarMessage (const QString & text) +{ + ui->statusbar->showMessage(text,1000); +} + +void MainWindow::on_actionPrint_Report_triggered() +{ + if (ui->tabWidget->currentWidget()==overview) { + overview->on_printButton_clicked(); + //} else if (ui->tabWidget->currentWidget()==daily) { + } else { + QMessageBox::information(this,"Not supported","Printing from this page is not supported yet",QMessageBox::Ok); + } +} diff --git a/mainwindow.h b/mainwindow.h index a8136784..d598b3c7 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -28,6 +28,7 @@ extern QStatusBar *qstatusbar; class Daily; class Report; +class Overview; class MainWindow : public QMainWindow { Q_OBJECT @@ -92,13 +93,14 @@ private slots: void DelayedScreenshot(); void on_actionView_O_ximetry_triggered(); + void updatestatusBarMessage (const QString & text); + void on_actionPrint_Report_triggered(); private: Ui::MainWindow *ui; Daily * daily; Overview * overview; Oximetry * oximetry; - Report * report; bool first_load; Profile *profile; QNetworkAccessManager *netmanager; diff --git a/mainwindow.ui b/mainwindow.ui index 6852ef78..805625f9 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -582,6 +582,8 @@ + + @@ -771,6 +773,11 @@ F7 + + + Print &Report + + diff --git a/overview.cpp b/overview.cpp index 0fa8b740..5a3c1fb6 100644 --- a/overview.cpp +++ b/overview.cpp @@ -14,19 +14,15 @@ #include "Graphs/gLineChart.h" #include "Graphs/gYAxis.h" -Overview::Overview(QWidget *parent,gGraphView * shared) : +Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : QWidget(parent), - ui(new Ui::Overview) + ui(new Ui::Overview), + profile(_profile), + m_shared(shared) { - m_shared=shared; ui->setupUi(this); + Q_ASSERT(profile!=NULL); - QString prof=pref["Profile"].toString(); - profile=Profiles::Get(prof); - if (!profile) { - qWarning("Couldn't get profile.. Have to abort!"); - exit(-1); - } // Create dummy day & session for holding eventlists. //day=new Day(mach); @@ -117,265 +113,83 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : NPB->AddLayer(gx,LayerBottom,0,gXAxis::Margin); NPB->AddLayer(new gXGrid()); - //ReloadGraphs(); + QLocale locale=QLocale::system(); + QString shortformat=locale.dateFormat(QLocale::ShortFormat); + if (!shortformat.toLower().contains("yyyy")) { + shortformat.replace("yy","yyyy"); + } + ui->dateStart->setDisplayFormat(shortformat); + ui->dateEnd->setDisplayFormat(shortformat); + + report=NULL; } Overview::~Overview() { + if (!report) { + report->close(); + delete report; + } //delete day; delete ui; } void Overview::ReloadGraphs() { - /*bc->SetDay(NULL); - uc->SetDay(NULL); - pr->SetDay(NULL); - lk->SetDay(NULL); */ + ui->dateStart->setDate(profile->FirstDay()); + ui->dateEnd->setDate(profile->LastDay()); GraphView->setDay(NULL); - // GraphView->ResetBounds(); } - /* - ui->setupUi(this); - profile=Profiles::Get(pref["Profile"].toString()); - AddData(ahidata=new HistoryData(profile)); - AddData(pressure=new HistoryCodeData(profile,CPAP_PressureAverage)); - AddData(pressure_min=new HistoryCodeData(profile,CPAP_PressureMin)); - AddData(pressure_max=new HistoryCodeData(profile,CPAP_PressureMax)); - AddData(pressure_eap=new HistoryCodeData(profile,BIPAP_EAPAverage)); - AddData(pressure_iap=new HistoryCodeData(profile,BIPAP_IAPAverage)); - AddData(leak=new HistoryCodeData(profile,CPAP_LeakMedian)); - AddData(usage=new UsageHistoryData(profile,UHD_Hours)); - AddData(waketime=new UsageHistoryData(profile,UHD_Waketime)); - AddData(bedtime=new UsageHistoryData(profile,UHD_Bedtime)); - AddData(session_times=new SessionTimes(profile)); - // pressure->ForceMinY(3); - // pressure->ForceMaxY(12); +void Overview::on_dateEnd_dateChanged(const QDate &date) +{ + qint64 d1=qint64(QDateTime(ui->dateStart->date(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; + qint64 d2=qint64(QDateTime(date,QTime(23,59,59),Qt::UTC).toTime_t())*1000L; + GraphView->SetXBounds(d1,d2); - gSplitter=new QSplitter(Qt::Vertical,ui->SummaryGraphWindow); - gSplitter->setStyleSheet("QSplitter::handle { background-color: 'dark grey'; }"); - gSplitter->setChildrenCollapsible(true); - gSplitter->setHandleWidth(3); - ui->graphLayout->addWidget(gSplitter); +} - AddGraph(AHI=new gGraphWindow(ui->SummaryGraphWindow,tr("AHI"),shared)); //(QGLContext *)NULL)); - AHI->SetTopMargin(10); - AHI->SetBottomMargin(AHI->GetBottomMargin()+gXAxis::Margin+25); - //AHI->AddLayer(new gFooBar(7)); - AHI->AddLayer(new gYAxis()); - AHI->AddLayer(new gBarChart(ahidata,QColor("red"))); - AHI->setMinimumHeight(170); +void Overview::on_dateStart_dateChanged(const QDate &date) +{ + qint64 d1=qint64(QDateTime(date,QTime(0,0,0),Qt::UTC).toTime_t())*1000L; + qint64 d2=qint64(QDateTime(ui->dateEnd->date(),QTime(23,59,59),Qt::UTC).toTime_t())*1000L; + GraphView->SetXBounds(d1,d2); - AddGraph(PRESSURE=new gGraphWindow(ui->SummaryGraphWindow,tr("Pressure"),AHI)); - //PRESSURE->SetMargins(10,15,65,80); - PRESSURE->AddLayer(new gYAxis()); - PRESSURE->AddLayer(new gXAxis()); - //PRESSURE->AddLayer(new gFooBar(7)); - PRESSURE->AddLayer(prmax=new gLineChart(pressure_max,QColor("blue"),6192,false,true,true)); - PRESSURE->AddLayer(prmin=new gLineChart(pressure_min,QColor("red"),6192,false,true,true)); - PRESSURE->AddLayer(eap=new gLineChart(pressure_eap,QColor("blue"),6192,false,true,true)); - PRESSURE->AddLayer(iap=new gLineChart(pressure_iap,QColor("red"),6192,false,true,true)); - PRESSURE->AddLayer(pr=new gLineChart(pressure,QColor("dark green"),6192,false,true,true)); - PRESSURE->SetBottomMargin(PRESSURE->GetBottomMargin()+25); - PRESSURE->setMinimumHeight(170); +} - AddGraph(LEAK=new gGraphWindow(ui->SummaryGraphWindow,tr("Leak"),AHI)); - LEAK->AddLayer(new gXAxis()); - LEAK->AddLayer(new gYAxis()); - //LEAK->AddLayer(new gFooBar(7)); - LEAK->AddLayer(new gLineChart(leak,QColor("purple"),6192,false,false,true)); - LEAK->SetBottomMargin(LEAK->GetBottomMargin()+25); - LEAK->setMinimumHeight(170); +void Overview::on_toolButton_clicked() +{ + qint64 d1=qint64(QDateTime(ui->dateStart->date(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; + qint64 d2=qint64(QDateTime(ui->dateEnd->date(),QTime(23,59,59),Qt::UTC).toTime_t())*1000L; + GraphView->SetXBounds(d1,d2); +} - AddGraph(USAGE=new gGraphWindow(ui->SummaryGraphWindow,tr("Usage (Hours)"),AHI)); - //USAGE->AddLayer(new gFooBar(7)); - USAGE->AddLayer(new gYAxis()); - USAGE->AddLayer(new gBarChart(usage,QColor("green"))); - USAGE->SetBottomMargin(USAGE->GetBottomMargin()+gXAxis::Margin+25); - //USAGE->AddLayer(new gXAxis()); - //USAGE->AddLayer(new gLineChart(usage,QColor("green"))); - USAGE->setMinimumHeight(170); +void Overview::on_printButton_clicked() +{ - AddGraph(SESSTIMES=new gGraphWindow(ui->SummaryGraphWindow,tr("Session Times"),AHI)); - //SESSTIMES->SetMargins(10,15,65,80); - //SESSTIMES->AddLayer(new gFooBar(7)); - SESSTIMES->AddLayer(new gTimeYAxis()); - SESSTIMES->AddLayer(new gSessionTime(session_times,QColor("green"))); - SESSTIMES->SetBottomMargin(SESSTIMES->GetBottomMargin()+gXAxis::Margin+25); - //SESSTIMES->AddLayer(new gXAxis()); - SESSTIMES->setMinimumHeight(270); - - NoData=new QLabel(tr("No data"),gSplitter); - NoData->setAlignment(Qt::AlignCenter); - QFont font("FreeSans",20); //NoData->font(); - //font.setBold(true); - NoData->setFont(font); - NoData->hide(); - - - gGraphWindow * graphs[]={AHI,PRESSURE,LEAK,USAGE,SESSTIMES}; - int ss=sizeof(graphs)/sizeof(gGraphWindow *); - - for (int i=0;iAddLayer(new gFooBar(7)); - for (int j=0;jLinkZoom(graphs[j]); - } - gSplitter->addWidget(graphs[i]); - graphs[i]->SetSplitter(gSplitter); + if (!report) { + report=new Report(this,profile,m_shared,this); } - dummyday=new Day(NULL); + if (report) { + report->setMinimumSize(ui->graphArea->width(),ui->graphArea->height()); + report->setMaximumSize(ui->graphArea->width(),ui->graphArea->height()); - ReloadGraphs(); -} - -void Overview::RedrawGraphs() -{ - for (QList::iterator g=Graphs.begin();g!=Graphs.end();g++) { - (*g)->updateGL(); - } - //SESSTIMES->updateGL(); -} -void Overview::ReloadGraphs() -{ - for (QList::iterator h=Data.begin();h!=Data.end();h++) { - if (HistoryData *hd=dynamic_cast(*h)){ - hd->SetProfile(profile); - hd->ResetDateRange(); - hd->Reload(NULL); - } - - } -// session_times->SetProfile(profile); - // session_times->ResetDateRange(); - // session_times->Reload(NULL); - on_rbLastWeek_clicked(); -} -void Overview::UpdateHTML() -{ - QString html="
    "; - html+=""; - html+=""; - html+=""; - html+=QString("\n") - .arg(ahidata->CalcMinY(),2,'f',2,'0') - .arg(ahidata->CalcAverage(),2,'f',2,'0') - .arg(ahidata->CalcMaxY(),2,'f',2,'0'); - html+=QString("") - .arg(leak->CalcMinY(),2,'f',2,'0') - .arg(leak->CalcAverage(),2,'f',2,'0') - .arg(leak->CalcMaxY(),2,'f',2,'0'); - html+=QString("") - .arg(pressure->CalcMinY(),2,'f',2,'0') - .arg(pressure->CalcAverage(),2,'f',2,'0') - .arg(pressure->CalcMaxY(),2,'f',2,'0'); - html+=QString("") - .arg(usage->CalcMinY(),2,'f',2,'0') - .arg(usage->CalcAverage(),2,'f',2,'0') - .arg(usage->CalcMaxY(),2,'f',2,'0'); - - html+="
    Statistics
    DetailsMinAvgMax
    AHI%1%2%3
    Leak%1%2%3
    Pressure%1%2%3
    Usage%1%2%3
    " - "
    "; - ui->webView->setHtml(html); -} -void Overview::UpdateGraphs() -{ - QDate first=ui->drStart->date(); - QDate last=ui->drEnd->date(); - for (QList::iterator h=Data.begin();h!=Data.end();h++) { - //(*h)->Update(dummyday); - (*h)->SetDateRange(first,last); - } - session_times->SetDateRange(first,last); - RedrawGraphs(); - UpdateHTML(); -} - - -void UpdateCal(QCalendarWidget *cal) -{ - QDate d1=cal->minimumDate(); - d1.setYMD(d1.year(),d1.month(),1); - QTextCharFormat fmt=cal->weekdayTextFormat(Qt::Monday); - fmt.setForeground(QBrush(Qt::gray)); - for (QDate d=d1;d < cal->minimumDate();d=d.addDays(1)) { - cal->setDateTextFormat(d,fmt); - } - d1=cal->maximumDate(); - d1.setYMD(d1.year(),d1.month(),d1.daysInMonth()); - for (QDate d=cal->maximumDate().addDays(1);d <= d1;d=d.addDays(1)) { - cal->setDateTextFormat(d,fmt); + GraphView->hide(); + report->show(); + report->ReloadGraphs(); + report->GenerateReport(ui->dateStart->date(),ui->dateEnd->date()); + report->on_printButton_clicked(); + report->hide(); + GraphView->show(); + //report->connect(report->webview(),SIGNAL(loadFinished(bool)),this,SLOT(readyToPrint(bool))); } + //report->hide(); + //ui->tabWidget->insertTab(4,report,tr("Overview Report")); + } -void Overview::on_drStart_dateChanged(const QDate &date) + +void Overview::readyToPrint(bool) { - ui->drEnd->setMinimumDate(date); - QCalendarWidget *cal=ui->drEnd->calendarWidget(); - cal->setDateRange(date,profile->LastDay()); - UpdateCal(cal); - UpdateGraphs(); } - -void Overview::on_drEnd_dateChanged(const QDate &date) -{ - ui->drStart->setMaximumDate(date); - QCalendarWidget *cal=ui->drStart->calendarWidget(); - cal->setDateRange(profile->FirstDay(),date); - UpdateCal(cal); - UpdateGraphs(); -} - -void Overview::on_rbDateRange_toggled(bool checked) -{ - ui->drStart->setEnabled(checked); - ui->drEnd->setEnabled(checked); - ui->drStartLabel->setEnabled(checked); - ui->drEndLabel->setEnabled(checked); -} - -void Overview::on_rbLastWeek_clicked() -{ - ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); - ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); - - QDate d=profile->LastDay(); - ui->drEnd->setDate(d); - d=d.addDays(-7); - if (dFirstDay()) d=profile->FirstDay(); - ui->drStart->setDate(d); - UpdateGraphs(); -} - -void Overview::on_rbLastMonth_clicked() -{ - ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); - ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); - - QDate d=profile->LastDay(); - ui->drEnd->setDate(d); - d=d.addDays(-30); - if (dFirstDay()) d=profile->FirstDay(); - ui->drStart->setDate(d); - UpdateGraphs(); -} - -void Overview::on_rbEverything_clicked() -{ - ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); - ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); - - ui->drEnd->setDate(profile->LastDay()); - ui->drStart->setDate(profile->FirstDay()); - UpdateGraphs(); -} - -void Overview::on_rbDateRange_clicked() -{ - UpdateGraphs(); -} -*/ diff --git a/overview.h b/overview.h index 1e1327eb..34fde0d6 100644 --- a/overview.h +++ b/overview.h @@ -10,21 +10,22 @@ #include #include #include - #include "SleepLib/profiles.h" #include "Graphs/gGraphView.h" #include "Graphs/gBarChart.h" +#include "report.h" namespace Ui { class Overview; } +class Report; class Overview : public QWidget { Q_OBJECT public: - explicit Overview(QWidget *parent,gGraphView *shared=NULL); + explicit Overview(QWidget *parent,Profile *profile, gGraphView *shared=NULL); ~Overview(); void ReloadGraphs(); @@ -32,6 +33,8 @@ public: gGraph *AHI,*UC,*PR,*LK,*NPB; SummaryChart *bc,*uc,*pr,*lk,*npb; +public slots: + void on_printButton_clicked(); private slots: /* void on_drStart_dateChanged(const QDate &date); @@ -42,6 +45,13 @@ private slots: void on_rbEverything_clicked(); void on_rbDateRange_clicked(); */ + void on_dateEnd_dateChanged(const QDate &date); + + void on_dateStart_dateChanged(const QDate &date); + + void on_toolButton_clicked(); + + void readyToPrint(bool); private: Ui::Overview *ui; Profile *profile; @@ -49,6 +59,7 @@ private: MyScrollBar *scrollbar; QHBoxLayout *layout; gGraphView * m_shared; + Report * report; void UpdateHTML(); diff --git a/overview.ui b/overview.ui index a28d48e6..81a07a6d 100644 --- a/overview.ui +++ b/overview.ui @@ -7,7 +7,7 @@ 0 0 668 - 355 + 393 @@ -28,8 +28,111 @@ + + + + + 16777215 + 45 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 9 + + + 0 + + + 9 + + + 0 + + + + + Start: + + + + + + + true + + + Qt::UTC + + + + + + + End: + + + + + + + true + + + Qt::UTC + + + + + + + Reset view to selected date range + + + ... + + + + :/icons/refresh.png:/icons/refresh.png + + + + + + + Qt::Horizontal + + + + 260 + 20 + + + + + + + + &Print + + + + + + - + + + diff --git a/oximetry.cpp b/oximetry.cpp index 39dfd450..020a4516 100644 --- a/oximetry.cpp +++ b/oximetry.cpp @@ -13,20 +13,18 @@ #include "Graphs/gLineChart.h" #include "Graphs/gYAxis.h" -Oximetry::Oximetry(QWidget *parent,gGraphView * shared) : +Oximetry::Oximetry(QWidget *parent,Profile * _profile,gGraphView * shared) : QWidget(parent), - ui(new Ui::Oximetry) + ui(new Ui::Oximetry), + profile(_profile) { m_shared=shared; ui->setupUi(this); + Q_ASSERT(profile!=NULL); + port=NULL; portname=""; - QString prof=pref["Profile"].toString(); - profile=Profiles::Get(prof); - if (!profile) { - qWarning("Couldn't get profile.. Have to abort!"); - exit(-1); - } + mach=profile->GetMachine(MT_OXIMETER); if (!mach) { CMS50Loader *l=dynamic_cast(GetLoader("CMS50")); diff --git a/oximetry.h b/oximetry.h index 5098e9f9..fce64a37 100644 --- a/oximetry.h +++ b/oximetry.h @@ -32,7 +32,7 @@ class Oximetry : public QWidget Q_OBJECT public: - explicit Oximetry(QWidget *parent,gGraphView * shared=NULL); + explicit Oximetry(QWidget *parent, Profile * _profile,gGraphView * shared=NULL); ~Oximetry(); void RedrawGraphs(); diff --git a/preferencesdialog.cpp b/preferencesdialog.cpp index f0c36695..999dd381 100644 --- a/preferencesdialog.cpp +++ b/preferencesdialog.cpp @@ -4,15 +4,13 @@ #include "ui_preferencesdialog.h" #include "SleepLib/machine_common.h" -PreferencesDialog::PreferencesDialog(QWidget *parent) : +PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) : QDialog(parent), - ui(new Ui::PreferencesDialog) + ui(new Ui::PreferencesDialog), + profile(_profile) { ui->setupUi(this); - - QString prof=pref["Profile"].toString(); - profile=Profiles::Get(prof); - + Q_ASSERT(profile!=NULL); ui->firstNameEdit->setText((*profile)["FirstName"].toString()); ui->lastNameEdit->setText((*profile)["LastName"].toString()); ui->addressEdit->clear(); diff --git a/preferencesdialog.h b/preferencesdialog.h index e54a5997..9bb0b940 100644 --- a/preferencesdialog.h +++ b/preferencesdialog.h @@ -20,11 +20,9 @@ class PreferencesDialog : public QDialog Q_OBJECT public: - explicit PreferencesDialog(QWidget *parent = 0); + explicit PreferencesDialog(QWidget *parent, Profile * _profile); ~PreferencesDialog(); void Save(); -protected: - Profile * profile; private slots: void on_eventTable_doubleClicked(const QModelIndex &index); void on_combineSlider_sliderMoved(int position); @@ -33,6 +31,7 @@ private slots: private: Ui::PreferencesDialog *ui; + Profile * profile; }; #endif // PREFERENCESDIALOG_H diff --git a/report.cpp b/report.cpp index ea4f26b1..69152d5c 100644 --- a/report.cpp +++ b/report.cpp @@ -8,19 +8,16 @@ #include #include -Report::Report(QWidget *parent, gGraphView * shared, Daily * daily, Overview * overview) : +Report::Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overview * overview) : QWidget(parent), ui(new Ui::Report), - m_daily(daily), + profile(_profile), m_overview(overview) { ui->setupUi(this); - QString prof=pref["Profile"].toString(); - profile=Profiles::Get(prof); - if (!profile) { - QMessageBox::critical(this,"Profile Error",QString("Couldn't get profile '%1'.. Have to abort!").arg(pref["Profile"].toString())); - exit(-1); - } + + Q_ASSERT(profile!=NULL); + GraphView=new gGraphView(this,shared); GraphView->hide(); @@ -72,20 +69,17 @@ Report::~Report() { delete ui; } -void Report::showEvent (QShowEvent * event) -{ - QTimer::singleShot(0,this,SLOT(on_refreshButton_clicked())); -} void Report::ReloadGraphs() { for (int i=0;isetDay(NULL); } - ui->startDate->setDate(profile->FirstDay()); - ui->endDate->setDate(profile->LastDay()); + startDate=profile->FirstDay(); + endDate=profile->LastDay(); for (int i=0;iResetBounds(); } + m_ready=true; } void Report::resizeEvent(QResizeEvent *event) @@ -93,14 +87,14 @@ void Report::resizeEvent(QResizeEvent *event) QWidget::resizeEvent(event); GraphView->setMinimumSize(event->size().width()-20,240); GraphView->setMaximumSize(event->size().width()-20,240); - Reload(); + //GenerateReport(startDate,endDate); } QPixmap Report::Snapshot(gGraph * graph) { - QDateTime d1(ui->startDate->date(),QTime(0,0,0),Qt::UTC); + QDateTime d1(startDate,QTime(0,0,0),Qt::UTC); qint64 first=qint64(d1.toTime_t())*1000L; - QDateTime d2(ui->endDate->date(),QTime(0,0,0),Qt::UTC); + QDateTime d2(endDate,QTime(23,59,59),Qt::UTC); qint64 last=qint64(d2.toTime_t())*1000L; GraphView->TrashGraphs(); @@ -111,13 +105,14 @@ QPixmap Report::Snapshot(gGraph * graph) int w=this->width()-20; QPixmap pixmap=GraphView->renderPixmap(w,240,false); //gwwidth,gwheight,false); - return pixmap; } -void Report::Reload() +void Report::GenerateReport(QDate start, QDate end) { if (!m_ready) return; + startDate=start; + endDate=end; //UC->ResetBounds(); QString html="" @@ -167,7 +162,7 @@ void Report::Reload() html+=""; html+="

    SleepyHead v"+pref["VersionString"].toString()+"
     
    " - "Reporting from "+ui->startDate->date().toString()+" to "+ui->endDate->date().toString()+"
    " + "Reporting from "+startDate.toString()+" to "+endDate.toString()+"
    " "
    "; @@ -186,22 +181,6 @@ void Report::Reload() ui->webView->setHtml(html); } -void Report::on_refreshButton_clicked() -{ - m_ready=true; - Reload(); -} - -void Report::on_startDate_dateChanged(const QDate &date) -{ - Reload(); -} - -void Report::on_endDate_dateChanged(const QDate &date) -{ - Reload(); -} - void Report::on_printButton_clicked() { QPrinter printer; diff --git a/report.h b/report.h index a2c23e31..72c142a0 100644 --- a/report.h +++ b/report.h @@ -2,9 +2,9 @@ #define REPORT_H #include +#include #include "SleepLib/profiles.h" #include "Graphs/gGraphView.h" -#include "daily.h" #include "overview.h" namespace Ui { @@ -12,32 +12,26 @@ namespace Ui { } class Daily; +class Overview; class Report : public QWidget { Q_OBJECT public: - explicit Report(QWidget *parent, gGraphView * shared, Daily * daily, Overview * overview); + explicit Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overview * overview); ~Report(); - void Reload(); + void GenerateReport(QDate start, QDate end); void ReloadGraphs(); QPixmap Snapshot(gGraph * graph); +public slots: + void on_printButton_clicked(); protected: - virtual void showEvent (QShowEvent * event); -private slots: - void on_refreshButton_clicked(); - - void on_startDate_dateChanged(const QDate &date); - - void on_endDate_dateChanged(const QDate &date); - - void on_printButton_clicked(); +// virtual void showEvent (QShowEvent * event); private: Ui::Report *ui; Profile * profile; - Daily * m_daily; Overview * m_overview; gGraphView * shared; gGraphView * GraphView; @@ -45,6 +39,9 @@ private: SummaryChart *bc,*uc,*pr,*lk,*npb; QVector graphs; + QDate startDate; + QDate endDate; + bool m_ready; virtual void resizeEvent(QResizeEvent *); }; diff --git a/report.ui b/report.ui index 5079680d..a1586174 100644 --- a/report.ui +++ b/report.ui @@ -29,78 +29,6 @@
    - - - - - - Start - - - - - - - d/MM/yyyy - - - true - - - - - - - End - - - - - - - d/MM/yyyy - - - true - - - - - - - &Refresh - - - - - - - Temporary Page - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - &Print - - - - -