From 39c889d43b199ee9c042014c9a44db0f40665491 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 26 Apr 2020 14:12:20 +0200 Subject: [PATCH] Piece Name and UUID taken into account in *vlt reader / writer --- src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp | 8 +++++++- src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp index 8fd1de929..be52922c3 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp @@ -247,7 +247,13 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) Q_UNUSED(piece); Q_ASSERT(isStartElement() && name() == ML::TagPiece); - // TODO read the attributes + QXmlStreamAttributes attribs = attributes(); + piece->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece"))); + QString uuidStr = ReadAttributeString(attribs, ML::AttrID, QUuid().toString());// FIXME: is that correct to have a default value here? + piece->SetUuid(QUuid(uuidStr)); + + // TODO read the further attributes + while (readNextStartElement()) { diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp index c85f725b9..f9d4ef1c7 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp @@ -163,8 +163,8 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) Q_UNUSED(piece); writeStartElement(ML::TagPiece); - SetAttribute(ML::AttrID, "uuid1"); // TODO / Fixme get the right value - SetAttribute(ML::AttrName, "Piece name"); // TODO / Fixme get the right value + SetAttribute(ML::AttrID, piece->GetUuid().toString()); + SetAttribute(ML::AttrName, piece->GetName()); SetAttribute(ML::AttrMirrored, "false"); // TODO / Fixme get the right value SetAttribute(ML::AttrTransform, "string representation of the transformation"); // TODO / Fixme get the right value