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()) {
mTxtWriter.setDevice(Report::GetFile());
if (Report::create()) {
mTxtWriter.setDevice(Report::getFile());
return true;
}
return false;
}
void CsvReport::WriteHeader()
void CsvReport::writeHeader()
{
// No header for CSV report
}
void CsvReport::WriteFooter()
void CsvReport::writeFooter()
{
// No footer for CSV report
}
void CsvReport::WriteError(const ErrorItem &error)
void CsvReport::writeError(const ErrorItem &error)
{
/*
Error as CSV line

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -964,7 +964,7 @@ QString ResultsTree::SeverityToIcon(Severity::SeverityType severity) const
void ResultsTree::SaveResults(Report *report) const
{
report->WriteHeader();
report->writeHeader();
for (int i = 0; i < mModel.rowCount(); i++) {
QStandardItem *item = mModel.item(i, 0);
@ -972,7 +972,7 @@ void ResultsTree::SaveResults(Report *report) const
SaveErrors(report, item);
}
report->WriteFooter();
report->writeFooter();
}
void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const
@ -1027,7 +1027,7 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const
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->Create())
if (report->create())
mUI.mTree->SaveResults(report);
else {
QMessageBox msgBox;
@ -211,7 +211,7 @@ void ResultsView::Print(QPrinter* printer)
PrintableReport report;
mUI.mTree->SaveResults(&report);
QTextDocument doc(report.GetFormattedReportText());
QTextDocument doc(report.getFormattedReportText());
doc.print(printer);
}
@ -322,8 +322,8 @@ void ResultsView::ReadErrorsXml(const QString &filename)
QList<ErrorItem> errors;
if (report) {
if (report->Open())
errors = report->Read();
if (report->open())
errors = report->read();
else {
QMessageBox msgBox;
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()) {
mTxtWriter.setDevice(Report::GetFile());
if (Report::create()) {
mTxtWriter.setDevice(Report::getFile());
return true;
}
return false;
}
void TxtReport::WriteHeader()
void TxtReport::writeHeader()
{
// No header for txt report
}
void TxtReport::WriteFooter()
void TxtReport::writeFooter()
{
// 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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