From 05efde10eab01364d1ff42a8c7836ac8969304ef Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Mon, 12 Sep 2011 12:49:56 +1000 Subject: [PATCH] Report Cleanup --- overview.cpp | 14 +------------- report.cpp | 36 +++++++++++++++--------------------- report.h | 10 +++------- 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/overview.cpp b/overview.cpp index d1c89111..b42135a2 100644 --- a/overview.cpp +++ b/overview.cpp @@ -170,10 +170,6 @@ void Overview::on_printButton_clicked() if (!report) { 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(); } @@ -184,18 +180,10 @@ void Overview::on_printButton_clicked() lk->deselect(); npb->deselect(); - //GraphView->hide(); - //report->show(); report->ReloadGraphs(); report->GenerateReport(ui->dateStart->date(),ui->dateEnd->date()); - report->on_printButton_clicked(); - //GraphView->show(); - //report->connect(report->webview(),SIGNAL(loadFinished(bool)),this,SLOT(readyToPrint(bool))); + report->Print(); } - - //report->hide(); - //ui->tabWidget->insertTab(4,report,tr("Overview Report")); - } void Overview::readyToPrint(bool) diff --git a/report.cpp b/report.cpp index 5fe69385..a62bcea8 100644 --- a/report.cpp +++ b/report.cpp @@ -19,10 +19,10 @@ Report::Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overvie Q_ASSERT(profile!=NULL); GraphView=new gGraphView(this,shared); - setMaximumSize(1280,800); - setMinimumSize(1280,800); - GraphView->setMaximumSize(1280,graph_height); - GraphView->setMinimumSize(1280,graph_height); + setMaximumSize(graph_print_width,800); + setMinimumSize(graph_print_width,800); + GraphView->setMaximumSize(graph_print_width,graph_print_height); + GraphView->setMinimumSize(graph_print_width,graph_print_height); GraphView->hide(); @@ -31,19 +31,19 @@ Report::Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overvie // Reusing the layer data from overview screen, // (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); - AHI=new gGraph(GraphView,"AHI",graph_height,0); + AHI=new gGraph(GraphView,"AHI",graph_print_height,0); 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); - LK=new gGraph(GraphView,"Leaks",graph_height,0); + LK=new gGraph(GraphView,"Leaks",graph_print_height,0); 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); graphs.push_back(AHI); @@ -86,13 +86,6 @@ void Report::ReloadGraphs() 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) { @@ -106,7 +99,7 @@ QPixmap Report::Snapshot(gGraph * graph) GraphView->ResetBounds(); 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; } @@ -121,7 +114,7 @@ void Report::GenerateReport(QDate start, QDate end) QString html="" "" "" - "
" + "
" "" + html+="" "
"; html+="

CPAP Overview

"; html+="
"; @@ -164,7 +157,7 @@ void Report::GenerateReport(QDate start, QDate end) } html+="
"; - html+="

SleepyHead v"+pref["VersionString"].toString()+"

SleepyHead v"+pref["VersionString"].toString()+"
" "Reporting from "+startDate.toString()+" to "+endDate.toString()+"" "
" @@ -180,14 +173,15 @@ void Report::GenerateReport(QDate start, QDate end) QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray buffer.open(QIODevice::WriteOnly); pixmap.save(&buffer, "PNG"); - html += "
\n"; // + //html += "
\n"; // + html += "
\n"; // } html+=""; ui->webView->setHtml(html); } -void Report::on_printButton_clicked() +void Report::Print() { QPrinter printer; //printer.setPrinterName("Print to File (PDF)"); diff --git a/report.h b/report.h index d2e6366d..061fe100 100644 --- a/report.h +++ b/report.h @@ -11,7 +11,8 @@ namespace Ui { class Report; } -const int graph_height=220; +const int graph_print_width=1280; +const int graph_print_height=256; class Daily; class Overview; @@ -25,11 +26,7 @@ public: void GenerateReport(QDate start, QDate end); void ReloadGraphs(); QPixmap Snapshot(gGraph * graph); -public slots: - void on_printButton_clicked(); - -protected: -// virtual void showEvent (QShowEvent * event); + void Print(); private: Ui::Report *ui; @@ -45,7 +42,6 @@ private: QDate endDate; bool m_ready; - virtual void resizeEvent(QResizeEvent *); }; #endif // REPORT_H