GUI: Renamed methods in Report

This commit is contained in:
Daniel Marjamäki 2017-07-28 11:12:05 +02:00
parent c4bd70210c
commit 0d8b7af2b3
15 changed files with 89 additions and 89 deletions

View File

@ -32,26 +32,26 @@ CsvReport::~CsvReport()
{ {
} }
bool CsvReport::Create() bool CsvReport::create()
{ {
if (Report::Create()) { if (Report::create()) {
mTxtWriter.setDevice(Report::GetFile()); mTxtWriter.setDevice(Report::getFile());
return true; return true;
} }
return false; return false;
} }
void CsvReport::WriteHeader() void CsvReport::writeHeader()
{ {
// No header for CSV report // No header for CSV report
} }
void CsvReport::WriteFooter() void CsvReport::writeFooter()
{ {
// No footer for CSV report // No footer for CSV report
} }
void CsvReport::WriteError(const ErrorItem &error) void CsvReport::writeError(const ErrorItem &error)
{ {
/* /*
Error as CSV line Error as CSV line

View File

@ -42,23 +42,23 @@ public:
* @brief Create the report (file). * @brief Create the report (file).
* @return true if succeeded, false if file could not be created. * @return true if succeeded, false if file could not be created.
*/ */
virtual bool Create(); virtual bool create();
/** /**
* @brief Write report header. * @brief Write report header.
*/ */
virtual void WriteHeader(); virtual void writeHeader();
/** /**
* @brief Write report footer. * @brief Write report footer.
*/ */
virtual void WriteFooter(); virtual void writeFooter();
/** /**
* @brief Write error to report. * @brief Write error to report.
* @param error Error data. * @param error Error data.
*/ */
virtual void WriteError(const ErrorItem &error); virtual void writeError(const ErrorItem &error);
private: private:

View File

@ -28,22 +28,22 @@ PrintableReport::~PrintableReport()
{ {
} }
bool PrintableReport::Create() bool PrintableReport::create()
{ {
return true; return true;
} }
void PrintableReport::WriteHeader() void PrintableReport::writeHeader()
{ {
// No header for printable report // No header for printable report
} }
void PrintableReport::WriteFooter() void PrintableReport::writeFooter()
{ {
// No footer for printable report // No footer for printable report
} }
void PrintableReport::WriteError(const ErrorItem &error) void PrintableReport::writeError(const ErrorItem &error)
{ {
const QString file = QDir::toNativeSeparators(error.errorPath.back().file); const QString file = QDir::toNativeSeparators(error.errorPath.back().file);
QString line = QString("%1,%2,").arg(file).arg(error.errorPath.back().line); QString line = QString("%1,%2,").arg(file).arg(error.errorPath.back().line);
@ -53,7 +53,7 @@ void PrintableReport::WriteError(const ErrorItem &error)
mFormattedReport += "\n"; mFormattedReport += "\n";
} }
QString PrintableReport::GetFormattedReportText() const QString PrintableReport::getFormattedReportText() const
{ {
return mFormattedReport; return mFormattedReport;
} }

View File

@ -38,28 +38,28 @@ public:
* @brief Create the report (file). * @brief Create the report (file).
* @return true if succeeded, false if file could not be created. * @return true if succeeded, false if file could not be created.
*/ */
virtual bool Create(); virtual bool create();
/** /**
* @brief Write report header. * @brief Write report header.
*/ */
virtual void WriteHeader(); virtual void writeHeader();
/** /**
* @brief Write report footer. * @brief Write report footer.
*/ */
virtual void WriteFooter(); virtual void writeFooter();
/** /**
* @brief Write error to report. * @brief Write error to report.
* @param error Error data. * @param error Error data.
*/ */
virtual void WriteError(const ErrorItem &error); virtual void writeError(const ErrorItem &error);
/** /**
* @brief Returns the formatted report. * @brief Returns the formatted report.
*/ */
QString GetFormattedReportText() const; QString getFormattedReportText() const;
private: private:

View File

@ -16,22 +16,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QObject>
#include <QString> #include <QString>
#include <QFile> #include <QFile>
#include "report.h" #include "report.h"
Report::Report(const QString &filename) : Report::Report(const QString &filename) :
QObject(),
mFilename(filename) mFilename(filename)
{ {
} }
Report::~Report() Report::~Report()
{ {
Close(); close();
} }
bool Report::Create() bool Report::create()
{ {
bool succeed = false; bool succeed = false;
if (!mFile.isOpen()) { if (!mFile.isOpen()) {
@ -41,7 +41,7 @@ bool Report::Create()
return succeed; return succeed;
} }
bool Report::Open() bool Report::open()
{ {
bool succeed = false; bool succeed = false;
if (!mFile.isOpen()) { if (!mFile.isOpen()) {
@ -51,13 +51,13 @@ bool Report::Open()
return succeed; return succeed;
} }
void Report::Close() void Report::close()
{ {
if (mFile.isOpen()) if (mFile.isOpen())
mFile.close(); mFile.close();
} }
QFile* Report::GetFile() QFile* Report::getFile()
{ {
return &mFile; return &mFile;
} }

View File

@ -47,41 +47,41 @@ public:
* @brief Create the report (file). * @brief Create the report (file).
* @return true if succeeded, false if file could not be created. * @return true if succeeded, false if file could not be created.
*/ */
virtual bool Create(); virtual bool create();
/** /**
* @brief Open the existing report (file). * @brief Open the existing report (file).
* @return true if succeeded, false if file could not be created. * @return true if succeeded, false if file could not be created.
*/ */
virtual bool Open(); virtual bool open();
/** /**
* @brief Close the report (file). * @brief Close the report (file).
*/ */
virtual void Close(); virtual void close();
/** /**
* @brief Write report header. * @brief Write report header.
*/ */
virtual void WriteHeader() = 0; virtual void writeHeader() = 0;
/** /**
* @brief Write report footer. * @brief Write report footer.
*/ */
virtual void WriteFooter() = 0; virtual void writeFooter() = 0;
/** /**
* @brief Write error to report. * @brief Write error to report.
* @param error Error data. * @param error Error data.
*/ */
virtual void WriteError(const ErrorItem &error) = 0; virtual void writeError(const ErrorItem &error) = 0;
protected: protected:
/** /**
* @brief Get the file object where the report is written to. * @brief Get the file object where the report is written to.
*/ */
QFile* GetFile(); QFile* getFile();
private: private:

View File

@ -964,7 +964,7 @@ QString ResultsTree::SeverityToIcon(Severity::SeverityType severity) const
void ResultsTree::SaveResults(Report *report) const void ResultsTree::SaveResults(Report *report) const
{ {
report->WriteHeader(); report->writeHeader();
for (int i = 0; i < mModel.rowCount(); i++) { for (int i = 0; i < mModel.rowCount(); i++) {
QStandardItem *item = mModel.item(i, 0); QStandardItem *item = mModel.item(i, 0);
@ -972,7 +972,7 @@ void ResultsTree::SaveResults(Report *report) const
SaveErrors(report, item); SaveErrors(report, item);
} }
report->WriteFooter(); report->writeFooter();
} }
void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const
@ -1027,7 +1027,7 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const
item.errorPath << e; item.errorPath << e;
} }
report->WriteError(item); report->writeError(item);
} }
} }

View File

@ -162,7 +162,7 @@ void ResultsView::Save(const QString &filename, Report::Type type) const
} }
if (report) { if (report) {
if (report->Create()) if (report->create())
mUI.mTree->SaveResults(report); mUI.mTree->SaveResults(report);
else { else {
QMessageBox msgBox; QMessageBox msgBox;
@ -211,7 +211,7 @@ void ResultsView::Print(QPrinter* printer)
PrintableReport report; PrintableReport report;
mUI.mTree->SaveResults(&report); mUI.mTree->SaveResults(&report);
QTextDocument doc(report.GetFormattedReportText()); QTextDocument doc(report.getFormattedReportText());
doc.print(printer); doc.print(printer);
} }
@ -322,8 +322,8 @@ void ResultsView::ReadErrorsXml(const QString &filename)
QList<ErrorItem> errors; QList<ErrorItem> errors;
if (report) { if (report) {
if (report->Open()) if (report->open())
errors = report->Read(); errors = report->read();
else { else {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("Failed to read the report.")); msgBox.setText(tr("Failed to read the report."));

View File

@ -28,26 +28,26 @@ TxtReport::~TxtReport()
{ {
} }
bool TxtReport::Create() bool TxtReport::create()
{ {
if (Report::Create()) { if (Report::create()) {
mTxtWriter.setDevice(Report::GetFile()); mTxtWriter.setDevice(Report::getFile());
return true; return true;
} }
return false; return false;
} }
void TxtReport::WriteHeader() void TxtReport::writeHeader()
{ {
// No header for txt report // No header for txt report
} }
void TxtReport::WriteFooter() void TxtReport::writeFooter()
{ {
// No footer for txt report // No footer for txt report
} }
void TxtReport::WriteError(const ErrorItem &error) void TxtReport::writeError(const ErrorItem &error)
{ {
/* /*
Error example from the core program in text Error example from the core program in text

View File

@ -42,23 +42,23 @@ public:
* @brief Create the report (file). * @brief Create the report (file).
* @return true if succeeded, false if file could not be created. * @return true if succeeded, false if file could not be created.
*/ */
virtual bool Create(); virtual bool create();
/** /**
* @brief Write report header. * @brief Write report header.
*/ */
virtual void WriteHeader(); virtual void writeHeader();
/** /**
* @brief Write report footer. * @brief Write report footer.
*/ */
virtual void WriteFooter(); virtual void writeFooter();
/** /**
* @brief Write error to report. * @brief Write error to report.
* @param error Error data. * @param error Error data.
*/ */
virtual void WriteError(const ErrorItem &error); virtual void writeError(const ErrorItem &error);
private: private:

View File

@ -40,7 +40,7 @@ public:
/** /**
* @brief Read contents of the report file. * @brief Read contents of the report file.
*/ */
virtual QList<ErrorItem> Read() = 0; virtual QList<ErrorItem> read() = 0;
/** /**
* @brief Quote the message. * @brief Quote the message.

View File

@ -48,38 +48,38 @@ XmlReportV1::~XmlReportV1()
delete mXmlWriter; delete mXmlWriter;
} }
bool XmlReportV1::Create() bool XmlReportV1::create()
{ {
if (Report::Create()) { if (Report::create()) {
mXmlWriter = new QXmlStreamWriter(Report::GetFile()); mXmlWriter = new QXmlStreamWriter(Report::getFile());
return true; return true;
} }
return false; return false;
} }
bool XmlReportV1::Open() bool XmlReportV1::open()
{ {
if (Report::Open()) { if (Report::open()) {
mXmlReader = new QXmlStreamReader(Report::GetFile()); mXmlReader = new QXmlStreamReader(Report::getFile());
return true; return true;
} }
return false; return false;
} }
void XmlReportV1::WriteHeader() void XmlReportV1::writeHeader()
{ {
mXmlWriter->setAutoFormatting(true); mXmlWriter->setAutoFormatting(true);
mXmlWriter->writeStartDocument(); mXmlWriter->writeStartDocument();
mXmlWriter->writeStartElement(ResultElementName); mXmlWriter->writeStartElement(ResultElementName);
} }
void XmlReportV1::WriteFooter() void XmlReportV1::writeFooter()
{ {
mXmlWriter->writeEndElement(); mXmlWriter->writeEndElement();
mXmlWriter->writeEndDocument(); mXmlWriter->writeEndDocument();
} }
void XmlReportV1::WriteError(const ErrorItem &error) void XmlReportV1::writeError(const ErrorItem &error)
{ {
/* /*
Error example from the core program in xml Error example from the core program in xml
@ -106,7 +106,7 @@ void XmlReportV1::WriteError(const ErrorItem &error)
mXmlWriter->writeEndElement(); mXmlWriter->writeEndElement();
} }
QList<ErrorItem> XmlReportV1::Read() QList<ErrorItem> XmlReportV1::read()
{ {
QList<ErrorItem> errors; QList<ErrorItem> errors;
bool insideResults = false; bool insideResults = false;
@ -122,7 +122,7 @@ QList<ErrorItem> XmlReportV1::Read()
// Read error element from inside result element // Read error element from inside result element
if (insideResults && mXmlReader->name() == ErrorElementName) { if (insideResults && mXmlReader->name() == ErrorElementName) {
ErrorItem item = ReadError(mXmlReader); ErrorItem item = readError(mXmlReader);
errors.append(item); errors.append(item);
} }
break; break;
@ -148,7 +148,7 @@ QList<ErrorItem> XmlReportV1::Read()
return errors; return errors;
} }
ErrorItem XmlReportV1::ReadError(QXmlStreamReader *reader) ErrorItem XmlReportV1::readError(QXmlStreamReader *reader)
{ {
ErrorItem item; ErrorItem item;
if (reader->name().toString() == ErrorElementName) { if (reader->name().toString() == ErrorElementName) {

View File

@ -42,40 +42,40 @@ public:
* @brief Create the report (file). * @brief Create the report (file).
* @return true if succeeded, false if file could not be created. * @return true if succeeded, false if file could not be created.
*/ */
virtual bool Create(); virtual bool create();
/** /**
* @brief Open existing report file. * @brief Open existing report file.
*/ */
bool Open(); bool open();
/** /**
* @brief Write report header. * @brief Write report header.
*/ */
virtual void WriteHeader(); virtual void writeHeader();
/** /**
* @brief Write report footer. * @brief Write report footer.
*/ */
virtual void WriteFooter(); virtual void writeFooter();
/** /**
* @brief Write error to report. * @brief Write error to report.
* @param error Error data. * @param error Error data.
*/ */
virtual void WriteError(const ErrorItem &error); virtual void writeError(const ErrorItem &error);
/** /**
* @brief Read contents of the report file. * @brief Read contents of the report file.
*/ */
virtual QList<ErrorItem> Read(); virtual QList<ErrorItem> read();
protected: protected:
/** /**
* @brief Read and parse error item from XML stream. * @brief Read and parse error item from XML stream.
* @param reader XML stream reader to use. * @param reader XML stream reader to use.
*/ */
ErrorItem ReadError(QXmlStreamReader *reader); ErrorItem readError(QXmlStreamReader *reader);
private: private:
/** /**

View File

@ -59,25 +59,25 @@ XmlReportV2::~XmlReportV2()
delete mXmlWriter; delete mXmlWriter;
} }
bool XmlReportV2::Create() bool XmlReportV2::create()
{ {
if (Report::Create()) { if (Report::create()) {
mXmlWriter = new QXmlStreamWriter(Report::GetFile()); mXmlWriter = new QXmlStreamWriter(Report::getFile());
return true; return true;
} }
return false; return false;
} }
bool XmlReportV2::Open() bool XmlReportV2::open()
{ {
if (Report::Open()) { if (Report::open()) {
mXmlReader = new QXmlStreamReader(Report::GetFile()); mXmlReader = new QXmlStreamReader(Report::getFile());
return true; return true;
} }
return false; return false;
} }
void XmlReportV2::WriteHeader() void XmlReportV2::writeHeader()
{ {
mXmlWriter->setAutoFormatting(true); mXmlWriter->setAutoFormatting(true);
mXmlWriter->writeStartDocument(); mXmlWriter->writeStartDocument();
@ -89,14 +89,14 @@ void XmlReportV2::WriteHeader()
mXmlWriter->writeStartElement(ErrorsElementName); mXmlWriter->writeStartElement(ErrorsElementName);
} }
void XmlReportV2::WriteFooter() void XmlReportV2::writeFooter()
{ {
mXmlWriter->writeEndElement(); // errors mXmlWriter->writeEndElement(); // errors
mXmlWriter->writeEndElement(); // results mXmlWriter->writeEndElement(); // results
mXmlWriter->writeEndDocument(); mXmlWriter->writeEndDocument();
} }
void XmlReportV2::WriteError(const ErrorItem &error) void XmlReportV2::writeError(const ErrorItem &error)
{ {
/* /*
Error example from the core program in xml Error example from the core program in xml
@ -141,7 +141,7 @@ void XmlReportV2::WriteError(const ErrorItem &error)
mXmlWriter->writeEndElement(); mXmlWriter->writeEndElement();
} }
QList<ErrorItem> XmlReportV2::Read() QList<ErrorItem> XmlReportV2::read()
{ {
QList<ErrorItem> errors; QList<ErrorItem> errors;
bool insideResults = false; bool insideResults = false;
@ -157,7 +157,7 @@ QList<ErrorItem> XmlReportV2::Read()
// Read error element from inside result element // Read error element from inside result element
if (insideResults && mXmlReader->name() == ErrorElementName) { if (insideResults && mXmlReader->name() == ErrorElementName) {
ErrorItem item = ReadError(mXmlReader); ErrorItem item = readError(mXmlReader);
errors.append(item); errors.append(item);
} }
break; break;
@ -183,7 +183,7 @@ QList<ErrorItem> XmlReportV2::Read()
return errors; return errors;
} }
ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader) ErrorItem XmlReportV2::readError(QXmlStreamReader *reader)
{ {
/* /*
Error example from the core program in xml Error example from the core program in xml

View File

@ -43,40 +43,40 @@ public:
* @brief Create the report (file). * @brief Create the report (file).
* @return true if succeeded, false if file could not be created. * @return true if succeeded, false if file could not be created.
*/ */
virtual bool Create(); virtual bool create();
/** /**
* @brief Open existing report file. * @brief Open existing report file.
*/ */
bool Open(); bool open();
/** /**
* @brief Write report header. * @brief Write report header.
*/ */
virtual void WriteHeader(); virtual void writeHeader();
/** /**
* @brief Write report footer. * @brief Write report footer.
*/ */
virtual void WriteFooter(); virtual void writeFooter();
/** /**
* @brief Write error to report. * @brief Write error to report.
* @param error Error data. * @param error Error data.
*/ */
virtual void WriteError(const ErrorItem &error); virtual void writeError(const ErrorItem &error);
/** /**
* @brief Read contents of the report file. * @brief Read contents of the report file.
*/ */
virtual QList<ErrorItem> Read(); virtual QList<ErrorItem> read();
protected: protected:
/** /**
* @brief Read and parse error item from XML stream. * @brief Read and parse error item from XML stream.
* @param reader XML stream reader to use. * @param reader XML stream reader to use.
*/ */
ErrorItem ReadError(QXmlStreamReader *reader); ErrorItem readError(QXmlStreamReader *reader);
private: private:
/** /**