Refactorizations in Report classes:

- Base class destructor already calls Close() - removed redundant call
- Avoid creation of temporary variable
This commit is contained in:
PKEuS 2012-10-21 10:33:11 +02:00
parent d1fad4b762
commit d7bdb90bc9
4 changed files with 13 additions and 24 deletions

View File

@ -30,17 +30,15 @@ CsvReport::CsvReport(const QString &filename, QObject * parent) :
CsvReport::~CsvReport()
{
Close();
}
bool CsvReport::Create()
{
bool success = false;
if (Report::Create()) {
mTxtWriter.setDevice(Report::GetFile());
success = true;
return true;
}
return success;
return false;
}
void CsvReport::WriteHeader()
@ -60,9 +58,8 @@ void CsvReport::WriteError(const ErrorItem &error)
gui/test.cpp,23,error,Mismatching allocation and deallocation: k
*/
QString line;
const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]);
line += QString("%1,%2,").arg(file).arg(error.lines[error.lines.size() - 1]);
QString line = QString("%1,%2,").arg(file).arg(error.lines[error.lines.size() - 1]);
line += QString("%1,%2").arg(GuiSeverity::toString(error.severity)).arg(error.summary);
mTxtWriter << line << endl;

View File

@ -26,17 +26,15 @@ TxtReport::TxtReport(const QString &filename, QObject * parent) :
TxtReport::~TxtReport()
{
Close();
}
bool TxtReport::Create()
{
bool success = false;
if (Report::Create()) {
mTxtWriter.setDevice(Report::GetFile());
success = true;
return true;
}
return success;
return false;
}
void TxtReport::WriteHeader()

View File

@ -46,27 +46,24 @@ XmlReportV1::~XmlReportV1()
{
delete mXmlReader;
delete mXmlWriter;
Close();
}
bool XmlReportV1::Create()
{
bool success = false;
if (Report::Create()) {
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
success = true;
return true;
}
return success;
return false;
}
bool XmlReportV1::Open()
{
bool success = false;
if (Report::Open()) {
mXmlReader = new QXmlStreamReader(Report::GetFile());
success = true;
return true;
}
return success;
return false;
}
void XmlReportV1::WriteHeader()

View File

@ -52,27 +52,24 @@ XmlReportV2::~XmlReportV2()
{
delete mXmlReader;
delete mXmlWriter;
Close();
}
bool XmlReportV2::Create()
{
bool success = false;
if (Report::Create()) {
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
success = true;
return true;
}
return success;
return false;
}
bool XmlReportV2::Open()
{
bool success = false;
if (Report::Open()) {
mXmlReader = new QXmlStreamReader(Report::GetFile());
success = true;
return true;
}
return success;
return false;
}
void XmlReportV2::WriteHeader()