From 13c060f2fc17c21c4a29f19ee521a91914110412 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:02:39 +0200 Subject: [PATCH] Refactoring VPuzzleLayoutFileWriter --- src/app/puzzle/puzzle.pri | 4 +-- src/app/puzzle/puzzlemainwindow.cpp | 4 +-- src/app/puzzle/xml/vplayoutfilereader.cpp | 2 +- ...tfilewriter.cpp => vplayoutfilewriter.cpp} | 26 +++++++++---------- ...ayoutfilewriter.h => vplayoutfilewriter.h} | 22 ++++++++-------- 5 files changed, 29 insertions(+), 29 deletions(-) rename src/app/puzzle/xml/{vpuzzlelayoutfilewriter.cpp => vplayoutfilewriter.cpp} (89%) rename src/app/puzzle/xml/{vpuzzlelayoutfilewriter.h => vplayoutfilewriter.h} (81%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 0ebac1854..410a04e1b 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -19,8 +19,8 @@ SOURCES += \ $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ + $$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutliterals.cpp \ - $$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/vpiececarrousellayer.cpp \ $$PWD/vpiececarrouselpiece.cpp @@ -44,8 +44,8 @@ HEADERS += \ $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ $$PWD/xml/vplayoutfilereader.h \ + $$PWD/xml/vplayoutfilewriter.h \ $$PWD/xml/vplayoutliterals.h \ - $$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/vpiececarrousellayer.h \ $$PWD/vpiececarrouselpiece.h diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 851c1eb12..78414ef41 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -32,7 +32,7 @@ #include "ui_puzzlemainwindow.h" #include "dialogs/vpdialogabout.h" -#include "xml/vpuzzlelayoutfilewriter.h" +#include "xml/vplayoutfilewriter.h" #include "xml/vplayoutfilereader.h" #include "puzzleapplication.h" #include "../vlayout/vrawlayout.h" @@ -126,7 +126,7 @@ bool PuzzleMainWindow::SaveFile(const QString &path) QFile file(path); file.open(QIODevice::WriteOnly); - VPuzzleLayoutFileWriter *fileWriter = new VPuzzleLayoutFileWriter(); + VPLayoutFileWriter *fileWriter = new VPLayoutFileWriter(); fileWriter->WriteFile(m_layout, &file); // TODO / FIXME : better return value and error handling diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 046805035..1fac4bb55 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -28,7 +28,7 @@ #include #include "vplayoutfilereader.h" -#include "vpuzzlelayoutfilewriter.h" +#include "vplayoutfilewriter.h" #include "vplayoutliterals.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionconversionerror.h" diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp similarity index 89% rename from src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp rename to src/app/puzzle/xml/vplayoutfilewriter.cpp index 88baa5784..92650b61b 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vpuzzlelayoutfilewriter.h" +#include "vplayoutfilewriter.h" #include "vpuzzlelayout.h" #include "vpuzzlelayer.h" #include "vpuzzlepiece.h" @@ -34,19 +34,19 @@ #include "../ifc/xml/vlayoutconverter.h" //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayoutFileWriter::VPuzzleLayoutFileWriter() +VPLayoutFileWriter::VPLayoutFileWriter() { } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayoutFileWriter::~VPuzzleLayoutFileWriter() +VPLayoutFileWriter::~VPLayoutFileWriter() { } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) +void VPLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) { setDevice(file); setAutoFormatting(true); @@ -59,7 +59,7 @@ void VPuzzleLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) { writeStartElement(ML::TagLayout); SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); @@ -71,7 +71,7 @@ void VPuzzleLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) { writeStartElement(ML::TagProperties); @@ -97,7 +97,7 @@ void VPuzzleLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) { Q_UNUSED(layout); // to be removed @@ -116,7 +116,7 @@ void VPuzzleLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) { writeStartElement(ML::TagLayers); @@ -133,13 +133,13 @@ void VPuzzleLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer) +void VPLayoutFileWriter::WriteLayer(VPuzzleLayer *layer) { WriteLayer(layer, ML::TagLayer); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tagName) +void VPLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tagName) { writeStartElement(tagName); // layer SetAttribute(ML::AttrName, layer->GetName()); @@ -158,7 +158,7 @@ void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tag } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) +void VPLayoutFileWriter::WritePiece(VPuzzlePiece *piece) { Q_UNUSED(piece); @@ -182,7 +182,7 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteMargins(const QMarginsF &margins) +void VPLayoutFileWriter::WriteMargins(const QMarginsF &margins) { writeStartElement(ML::TagMargin); SetAttribute(ML::AttrLeft, margins.left()); @@ -193,7 +193,7 @@ void VPuzzleLayoutFileWriter::WriteMargins(const QMarginsF &margins) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteSize(QSizeF size) +void VPLayoutFileWriter::WriteSize(QSizeF size) { // maybe not necessary to test this, the writer should "stupidly write", the application should take care of these tests qreal width = size.width(); diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h similarity index 81% rename from src/app/puzzle/xml/vpuzzlelayoutfilewriter.h rename to src/app/puzzle/xml/vplayoutfilewriter.h index abbc7377f..e3c23373b 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -26,8 +26,8 @@ ** ** *************************************************************************/ -#ifndef VPUZZLELAYOUTFILEWRITER_H -#define VPUZZLELAYOUTFILEWRITER_H +#ifndef VPLAYOUTFILEWRITER_H +#define VPLAYOUTFILEWRITER_H #include #include @@ -40,11 +40,11 @@ class VPuzzlePiece; class QFile; class QMarginsF; -class VPuzzleLayoutFileWriter : public QXmlStreamWriter +class VPLayoutFileWriter : public QXmlStreamWriter { public: - VPuzzleLayoutFileWriter(); - ~VPuzzleLayoutFileWriter(); + VPLayoutFileWriter(); + ~VPLayoutFileWriter(); void WriteFile(VPuzzleLayout *layout, QFile *file); @@ -71,7 +71,7 @@ private: //--------------------------------------------------------------------------------------------------------------------- template -void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const T &value) +void VPLayoutFileWriter::SetAttribute(const QString &name, const T &value) { // See specification for xs:decimal const QLocale locale = QLocale::c(); @@ -80,30 +80,30 @@ void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const T &value) //--------------------------------------------------------------------------------------------------------------------- template <> -inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const QString &value) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const QString &value) { writeAttribute(name, value); } //--------------------------------------------------------------------------------------------------------------------- template <> -inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const QChar &value) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const QChar &value) { writeAttribute(name, value); } //--------------------------------------------------------------------------------------------------------------------- template <> -inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const bool &value) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const bool &value) { writeAttribute(name, value ? trueStr : falseStr); } //--------------------------------------------------------------------------------------------------------------------- template -inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) { writeAttribute(name, QString(value)); } -#endif // VPUZZLELAYOUTFILEWRITER_H +#endif // VPLAYOUTFILEWRITER_H