Refactoring VPuzzleLayoutFileReader

This commit is contained in:
Ronan Le Tiec 2020-05-23 14:01:03 +02:00
parent 63d5ac0158
commit d9e3a08eac
4 changed files with 27 additions and 27 deletions

View File

@ -18,9 +18,9 @@ SOURCES += \
$$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \
$$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlepiece.cpp \
$$PWD/vpuzzlesettings.cpp \ $$PWD/vpuzzlesettings.cpp \
$$PWD/xml/vplayoutfilereader.cpp \
$$PWD/xml/vplayoutliterals.cpp \ $$PWD/xml/vplayoutliterals.cpp \
$$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/xml/vpuzzlelayoutfilewriter.cpp \
$$PWD/xml/vpuzzlelayoutfilereader.cpp \
$$PWD/vpiececarrousellayer.cpp \ $$PWD/vpiececarrousellayer.cpp \
$$PWD/vpiececarrouselpiece.cpp $$PWD/vpiececarrouselpiece.cpp
@ -43,9 +43,9 @@ HEADERS += \
$$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlemimedatapiece.h \
$$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlepiece.h \
$$PWD/vpuzzlesettings.h \ $$PWD/vpuzzlesettings.h \
$$PWD/xml/vplayoutfilereader.h \
$$PWD/xml/vplayoutliterals.h \ $$PWD/xml/vplayoutliterals.h \
$$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/xml/vpuzzlelayoutfilewriter.h \
$$PWD/xml/vpuzzlelayoutfilereader.h \
$$PWD/vpiececarrousellayer.h \ $$PWD/vpiececarrousellayer.h \
$$PWD/vpiececarrouselpiece.h $$PWD/vpiececarrouselpiece.h

View File

@ -33,7 +33,7 @@
#include "ui_puzzlemainwindow.h" #include "ui_puzzlemainwindow.h"
#include "dialogs/vpdialogabout.h" #include "dialogs/vpdialogabout.h"
#include "xml/vpuzzlelayoutfilewriter.h" #include "xml/vpuzzlelayoutfilewriter.h"
#include "xml/vpuzzlelayoutfilereader.h" #include "xml/vplayoutfilereader.h"
#include "puzzleapplication.h" #include "puzzleapplication.h"
#include "../vlayout/vrawlayout.h" #include "../vlayout/vrawlayout.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
@ -106,7 +106,7 @@ bool PuzzleMainWindow::LoadFile(QString path)
QFile file(path); QFile file(path);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
QScopedPointer<VPuzzleLayoutFileReader> fileReader(new VPuzzleLayoutFileReader()); QScopedPointer<VPLayoutFileReader> fileReader(new VPLayoutFileReader());
if(m_layout == nullptr) if(m_layout == nullptr)
{ {

View File

@ -27,27 +27,27 @@
** *************************************************************************/ ** *************************************************************************/
#include <QXmlStreamAttributes> #include <QXmlStreamAttributes>
#include "vpuzzlelayoutfilereader.h" #include "vplayoutfilereader.h"
#include "vpuzzlelayoutfilewriter.h" #include "vpuzzlelayoutfilewriter.h"
#include "vplayoutliterals.h" #include "vplayoutliterals.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionconversionerror.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayoutFileReader::VPuzzleLayoutFileReader() VPLayoutFileReader::VPLayoutFileReader()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayoutFileReader::~VPuzzleLayoutFileReader() VPLayoutFileReader::~VPLayoutFileReader()
{ {
// TODO // TODO
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) bool VPLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file)
{ {
setDevice(file); setDevice(file);
@ -60,7 +60,7 @@ bool VPuzzleLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout) void VPLayoutFileReader::ReadLayout(VPuzzleLayout *layout)
{ {
SCASSERT(isStartElement() && name() == ML::TagLayout); SCASSERT(isStartElement() && name() == ML::TagLayout);
@ -82,7 +82,7 @@ void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout) void VPLayoutFileReader::ReadProperties(VPuzzleLayout *layout)
{ {
SCASSERT(isStartElement() && name() == ML::TagProperties); SCASSERT(isStartElement() && name() == ML::TagProperties);
@ -158,7 +158,7 @@ void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout) void VPLayoutFileReader::ReadTiles(VPuzzleLayout *layout)
{ {
Q_UNUSED(layout); // to be removed when used Q_UNUSED(layout); // to be removed when used
@ -193,7 +193,7 @@ void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout) void VPLayoutFileReader::ReadLayers(VPuzzleLayout *layout)
{ {
SCASSERT(isStartElement() && name() == ML::TagLayers); SCASSERT(isStartElement() && name() == ML::TagLayers);
@ -217,7 +217,7 @@ void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer) void VPLayoutFileReader::ReadLayer(VPuzzleLayer *layer)
{ {
SCASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer)); SCASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer));
@ -242,7 +242,7 @@ void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) void VPLayoutFileReader::ReadPiece(VPuzzlePiece *piece)
{ {
Q_UNUSED(piece); Q_UNUSED(piece);
SCASSERT(isStartElement() && name() == ML::TagPiece); SCASSERT(isStartElement() && name() == ML::TagPiece);
@ -278,7 +278,7 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMarginsF VPuzzleLayoutFileReader::ReadMargins() QMarginsF VPLayoutFileReader::ReadMargins()
{ {
QMarginsF margins = QMarginsF(); QMarginsF margins = QMarginsF();
@ -292,7 +292,7 @@ QMarginsF VPuzzleLayoutFileReader::ReadMargins()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSizeF VPuzzleLayoutFileReader::ReadSize() QSizeF VPLayoutFileReader::ReadSize()
{ {
QSizeF size = QSize(); QSizeF size = QSize();
@ -304,7 +304,7 @@ QSizeF VPuzzleLayoutFileReader::ReadSize()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VPuzzleLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name, QString VPLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) const QString &defValue)
{ {
const QString parameter = attribs.value(name).toString(); const QString parameter = attribs.value(name).toString();
@ -323,13 +323,13 @@ QString VPuzzleLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VPuzzleLayoutFileReader::ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name) QString VPLayoutFileReader::ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name)
{ {
return attribs.value(name).toString(); return attribs.value(name).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name, bool VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) const QString &defValue)
{ {
QString parametr; QString parametr;
@ -366,7 +366,7 @@ bool VPuzzleLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attr
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VPuzzleLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name, qreal VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) const QString &defValue)
{ {
bool ok = false; bool ok = false;

View File

@ -26,8 +26,8 @@
** **
** *************************************************************************/ ** *************************************************************************/
#ifndef VPUZZLELAYOUTFILEREADER_H #ifndef VPLAYOUTFILEREADER_H
#define VPUZZLELAYOUTFILEREADER_H #define VPLAYOUTFILEREADER_H
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include "../ifc/xml/vabstractconverter.h" #include "../ifc/xml/vabstractconverter.h"
@ -35,17 +35,17 @@
#include "vpuzzlelayer.h" #include "vpuzzlelayer.h"
#include "vpuzzlepiece.h" #include "vpuzzlepiece.h"
class VPuzzleLayoutFileReader : public QXmlStreamReader class VPLayoutFileReader : public QXmlStreamReader
{ {
Q_DECLARE_TR_FUNCTIONS(VPuzzleLayoutFileReader) Q_DECLARE_TR_FUNCTIONS(VPuzzleLayoutFileReader)
public: public:
VPuzzleLayoutFileReader(); VPLayoutFileReader();
~VPuzzleLayoutFileReader(); ~VPLayoutFileReader();
bool ReadFile(VPuzzleLayout *layout, QFile *file); bool ReadFile(VPuzzleLayout *layout, QFile *file);
private: private:
Q_DISABLE_COPY(VPuzzleLayoutFileReader) Q_DISABLE_COPY(VPLayoutFileReader)
void ReadLayout(VPuzzleLayout *layout); void ReadLayout(VPuzzleLayout *layout);
void ReadProperties(VPuzzleLayout *layout); void ReadProperties(VPuzzleLayout *layout);
@ -65,4 +65,4 @@ private:
const QString &defValue); const QString &defValue);
}; };
#endif // VPUZZLELAYOUTFILEREADER_H #endif // VPLAYOUTFILEREADER_H