From 2eb0832ac20c67524060f055449d859b9a775f3e Mon Sep 17 00:00:00 2001 From: Blubbz0r Date: Fri, 17 Apr 2015 16:46:58 +0200 Subject: [PATCH] Refactoring Adjusted documentation of PrintableReport PrintableReport no longer provides the formatted report as QTextDocument but as plain QString (so that the caller can decide how to deal with the text) --- gui/printablereport.cpp | 9 +++------ gui/printablereport.h | 17 +++++++++-------- gui/resultsview.cpp | 3 ++- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gui/printablereport.cpp b/gui/printablereport.cpp index 1cb7cba13..156d733e8 100644 --- a/gui/printablereport.cpp +++ b/gui/printablereport.cpp @@ -18,11 +18,9 @@ #include "printablereport.h" #include -#include PrintableReport::PrintableReport() : - Report(QString()), - mReportDocument(new QTextDocument(this)) + Report(QString()) { } @@ -55,9 +53,8 @@ void PrintableReport::WriteError(const ErrorItem &error) mFormattedReport += "\n"; } -QTextDocument* PrintableReport::GetReport() const +QString PrintableReport::GetFormattedReportText() const { - mReportDocument->setPlainText(mFormattedReport); - return mReportDocument; + return mFormattedReport; } diff --git a/gui/printablereport.h b/gui/printablereport.h index 6317d18b8..8cf1f60e5 100644 --- a/gui/printablereport.h +++ b/gui/printablereport.h @@ -21,17 +21,13 @@ #include "report.h" -class QTextDocument; - /// @addtogroup GUI /// @{ /** -* @brief CSV text file report. -* This report exports results as CSV (comma separated values). CSV files are -* easy to import to many other programs. -* @todo This class should be inherited from TxtReport? +* @brief Printable (in-memory) report. +* This report formats results and exposes them for printing. */ class PrintableReport : public Report { public: @@ -60,12 +56,17 @@ public: */ virtual void WriteError(const ErrorItem &error); - QTextDocument* GetReport() const; + /** + * @brief Returns the formatted report. + */ + QString GetFormattedReportText() const; private: + /** + * @brief Stores the formatted report contents. + */ QString mFormattedReport; - QTextDocument* mReportDocument; }; /// @} #endif // PRINTABLE_REPORT_H diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 8c29a1af4..8c92e3a59 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -213,7 +213,8 @@ void ResultsView::Print(QPrinter* printer) PrintableReport report; mUI.mTree->SaveResults(&report); - report.GetReport()->print(printer); + QTextDocument doc(report.GetFormattedReportText()); + doc.print(printer); } void ResultsView::UpdateSettings(bool showFullPath,