mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-17 19:20:46 +00:00
Report Cleanup
This commit is contained in:
parent
a15ad7befa
commit
05efde10ea
14
overview.cpp
14
overview.cpp
@ -170,10 +170,6 @@ void Overview::on_printButton_clicked()
|
|||||||
|
|
||||||
if (!report) {
|
if (!report) {
|
||||||
report=new Report(this,profile,m_shared,this);
|
report=new Report(this,profile,m_shared,this);
|
||||||
//report->setMinimumSize(ui->graphArea->width(),ui->graphArea->height());
|
|
||||||
//report->setMaximumSize(ui->graphArea->width(),ui->graphArea->height());
|
|
||||||
//report->setMinimumSize(1280,800);
|
|
||||||
//report->setMaximumSize(1280,800);
|
|
||||||
report->hide();
|
report->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,18 +180,10 @@ void Overview::on_printButton_clicked()
|
|||||||
lk->deselect();
|
lk->deselect();
|
||||||
npb->deselect();
|
npb->deselect();
|
||||||
|
|
||||||
//GraphView->hide();
|
|
||||||
//report->show();
|
|
||||||
report->ReloadGraphs();
|
report->ReloadGraphs();
|
||||||
report->GenerateReport(ui->dateStart->date(),ui->dateEnd->date());
|
report->GenerateReport(ui->dateStart->date(),ui->dateEnd->date());
|
||||||
report->on_printButton_clicked();
|
report->Print();
|
||||||
//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::readyToPrint(bool)
|
void Overview::readyToPrint(bool)
|
||||||
|
36
report.cpp
36
report.cpp
@ -19,10 +19,10 @@ Report::Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overvie
|
|||||||
Q_ASSERT(profile!=NULL);
|
Q_ASSERT(profile!=NULL);
|
||||||
|
|
||||||
GraphView=new gGraphView(this,shared);
|
GraphView=new gGraphView(this,shared);
|
||||||
setMaximumSize(1280,800);
|
setMaximumSize(graph_print_width,800);
|
||||||
setMinimumSize(1280,800);
|
setMinimumSize(graph_print_width,800);
|
||||||
GraphView->setMaximumSize(1280,graph_height);
|
GraphView->setMaximumSize(graph_print_width,graph_print_height);
|
||||||
GraphView->setMinimumSize(1280,graph_height);
|
GraphView->setMinimumSize(graph_print_width,graph_print_height);
|
||||||
|
|
||||||
|
|
||||||
GraphView->hide();
|
GraphView->hide();
|
||||||
@ -31,19 +31,19 @@ Report::Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overvie
|
|||||||
// Reusing the layer data from overview screen,
|
// Reusing the layer data from overview screen,
|
||||||
// (Can't reuse the graphs objects without breaking things)
|
// (Can't reuse the graphs objects without breaking things)
|
||||||
|
|
||||||
UC=new gGraph(GraphView,"Usage",graph_height,0);
|
UC=new gGraph(GraphView,"Usage",graph_print_height,0);
|
||||||
UC->AddLayer(m_overview->uc);
|
UC->AddLayer(m_overview->uc);
|
||||||
|
|
||||||
AHI=new gGraph(GraphView,"AHI",graph_height,0);
|
AHI=new gGraph(GraphView,"AHI",graph_print_height,0);
|
||||||
AHI->AddLayer(m_overview->bc);
|
AHI->AddLayer(m_overview->bc);
|
||||||
|
|
||||||
PR=new gGraph(GraphView,"Pressure",graph_height,0);
|
PR=new gGraph(GraphView,"Pressure",graph_print_height,0);
|
||||||
PR->AddLayer(m_overview->pr);
|
PR->AddLayer(m_overview->pr);
|
||||||
|
|
||||||
LK=new gGraph(GraphView,"Leaks",graph_height,0);
|
LK=new gGraph(GraphView,"Leaks",graph_print_height,0);
|
||||||
LK->AddLayer(m_overview->lk);
|
LK->AddLayer(m_overview->lk);
|
||||||
|
|
||||||
NPB=new gGraph(GraphView,"% in PB",graph_height,0);
|
NPB=new gGraph(GraphView,"% in PB",graph_print_height,0);
|
||||||
NPB->AddLayer(m_overview->npb);
|
NPB->AddLayer(m_overview->npb);
|
||||||
|
|
||||||
graphs.push_back(AHI);
|
graphs.push_back(AHI);
|
||||||
@ -86,13 +86,6 @@ void Report::ReloadGraphs()
|
|||||||
m_ready=true;
|
m_ready=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
void Report::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
// QWidget::resizeEvent(event);
|
|
||||||
//GraphView->setMinimumSize(1280,graph_height);
|
|
||||||
//GraphView->setMaximumSize(1280,graph_height);
|
|
||||||
//GenerateReport(startDate,endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap Report::Snapshot(gGraph * graph)
|
QPixmap Report::Snapshot(gGraph * graph)
|
||||||
{
|
{
|
||||||
@ -106,7 +99,7 @@ QPixmap Report::Snapshot(gGraph * graph)
|
|||||||
GraphView->ResetBounds();
|
GraphView->ResetBounds();
|
||||||
GraphView->SetXBounds(first,last);
|
GraphView->SetXBounds(first,last);
|
||||||
|
|
||||||
QPixmap pixmap=GraphView->renderPixmap(1280,graph_height,false);
|
QPixmap pixmap=GraphView->renderPixmap(graph_print_width,graph_print_height,false);
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
@ -121,7 +114,7 @@ void Report::GenerateReport(QDate start, QDate end)
|
|||||||
QString html="<html><head><style type='text/css'>p,a,td,body { font-family: 'FreeSans', 'Sans Serif'; } p,a,td,body { font-size: 12px; } </style>"
|
QString html="<html><head><style type='text/css'>p,a,td,body { font-family: 'FreeSans', 'Sans Serif'; } p,a,td,body { font-size: 12px; } </style>"
|
||||||
"</head>"
|
"</head>"
|
||||||
"<body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0>"
|
"<body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0>"
|
||||||
"<div align=center><table width='1280px' cellpadding=0 cellspacing=0>"
|
"<div align=center><table width='100%' cellpadding=0 cellspacing=0>"
|
||||||
"<tr><td valign=top>";
|
"<tr><td valign=top>";
|
||||||
html+="<h2>CPAP Overview</h2>";
|
html+="<h2>CPAP Overview</h2>";
|
||||||
html+="<table border='1px'><tr><td valign=top><table border=0>";
|
html+="<table border='1px'><tr><td valign=top><table border=0>";
|
||||||
@ -164,7 +157,7 @@ void Report::GenerateReport(QDate start, QDate end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
html+="</table></td></tr></table>";
|
html+="</table></td></tr></table>";
|
||||||
html+="<td ><div align=center><img src='qrc:/docs/sheep.png' width=100 height=100'><br/>SleepyHead v"+pref["VersionString"].toString()+"</div></td></tr>"
|
html+="<td valign=center align=right><img src='qrc:/docs/sheep.png' width=100 height=100'><br/>SleepyHead v"+pref["VersionString"].toString()+"</td></tr>"
|
||||||
"<tr><td colspan=2>"
|
"<tr><td colspan=2>"
|
||||||
"Reporting from <b>"+startDate.toString()+"</b> to <b>"+endDate.toString()+"</b>"
|
"Reporting from <b>"+startDate.toString()+"</b> to <b>"+endDate.toString()+"</b>"
|
||||||
"<hr width=1270px>"
|
"<hr width=1270px>"
|
||||||
@ -180,14 +173,15 @@ void Report::GenerateReport(QDate start, QDate end)
|
|||||||
QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
|
QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
pixmap.save(&buffer, "PNG");
|
pixmap.save(&buffer, "PNG");
|
||||||
html += "<div align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\" width=\"1280px\" height=\""+QString::number(graph_height)+"px\"></div>\n"; //
|
//html += "<div align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\" width=\""+QString::number(graph_print_width)+"px\" height=\""+QString::number(graph_print_height)+"px\"></div>\n"; //
|
||||||
|
html += "<div align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\" height=\""+QString::number(graph_print_height)+"px\"></div>\n"; //
|
||||||
}
|
}
|
||||||
|
|
||||||
html+="</body></html>";
|
html+="</body></html>";
|
||||||
ui->webView->setHtml(html);
|
ui->webView->setHtml(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Report::on_printButton_clicked()
|
void Report::Print()
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
//printer.setPrinterName("Print to File (PDF)");
|
//printer.setPrinterName("Print to File (PDF)");
|
||||||
|
10
report.h
10
report.h
@ -11,7 +11,8 @@ namespace Ui {
|
|||||||
class Report;
|
class Report;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int graph_height=220;
|
const int graph_print_width=1280;
|
||||||
|
const int graph_print_height=256;
|
||||||
|
|
||||||
class Daily;
|
class Daily;
|
||||||
class Overview;
|
class Overview;
|
||||||
@ -25,11 +26,7 @@ public:
|
|||||||
void GenerateReport(QDate start, QDate end);
|
void GenerateReport(QDate start, QDate end);
|
||||||
void ReloadGraphs();
|
void ReloadGraphs();
|
||||||
QPixmap Snapshot(gGraph * graph);
|
QPixmap Snapshot(gGraph * graph);
|
||||||
public slots:
|
void Print();
|
||||||
void on_printButton_clicked();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// virtual void showEvent (QShowEvent * event);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Report *ui;
|
Ui::Report *ui;
|
||||||
@ -45,7 +42,6 @@ private:
|
|||||||
QDate endDate;
|
QDate endDate;
|
||||||
|
|
||||||
bool m_ready;
|
bool m_ready;
|
||||||
virtual void resizeEvent(QResizeEvent *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REPORT_H
|
#endif // REPORT_H
|
||||||
|
Loading…
Reference in New Issue
Block a user