diff --git a/ProjectReader.cpp b/ProjectReader.cpp index 0e7375d..4976069 100644 --- a/ProjectReader.cpp +++ b/ProjectReader.cpp @@ -117,10 +117,15 @@ void ProjectReader::parsePaint(const QDomElement& paint) void ProjectReader::parseMapping(const QDomElement& mapping) { + uid id = NULL_UID; QString mappingAttrId = mapping.attribute("id", QString::number(NULL_UID)); QString mappingAttrPaintId = mapping.attribute("paint_id", QString::number(NULL_UID)); QString mappingAttrType = mapping.attribute("type", ""); + bool isLocked = (mapping.attribute("locked", QString::number(1)) == "1"); + bool isSolo = (mapping.attribute("solo", QString::number(1)) == "1"); + bool isVisible = (mapping.attribute("visible", QString::number(1)) == "1"); + // Get destination shape. QDomElement dst = mapping.firstChildElement("destination"); QVector dstPoints; @@ -135,7 +140,7 @@ void ProjectReader::parseMapping(const QDomElement& mapping) QVector srcPoints; _parseTriangle(src, srcPoints); - uid id = _window->createTriangleTextureMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), srcPoints, dstPoints); + id = _window->createTriangleTextureMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), srcPoints, dstPoints); if (id == NULL_UID) _xml.raiseError(QObject::tr("Cannot create triangle texture mapping")); @@ -152,7 +157,7 @@ void ProjectReader::parseMapping(const QDomElement& mapping) QVector srcPoints; _parseMesh(src, srcPoints, nColumns, nRows); - uid id = _window->createMeshTextureMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), nColumns, nRows, srcPoints, dstPoints); + id = _window->createMeshTextureMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), nColumns, nRows, srcPoints, dstPoints); if (id == NULL_UID) _xml.raiseError(QObject::tr("Cannot create mesh texture mapping")); @@ -168,7 +173,7 @@ void ProjectReader::parseMapping(const QDomElement& mapping) QVector srcPoints; _parseEllipse(src, srcPoints); - uid id = _window->createEllipseTextureMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), srcPoints, dstPoints); + id = _window->createEllipseTextureMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), srcPoints, dstPoints); if (id == NULL_UID) _xml.raiseError(QObject::tr("Cannot create ellipse texture mapping")); @@ -178,7 +183,7 @@ void ProjectReader::parseMapping(const QDomElement& mapping) // Parse destination triangle. _parseTriangle(dst, dstPoints); - uid id = _window->createTriangleColorMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), dstPoints); + id = _window->createTriangleColorMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), dstPoints); if (id == NULL_UID) _xml.raiseError(QObject::tr("Cannot create triangle color mapping")); @@ -188,7 +193,7 @@ void ProjectReader::parseMapping(const QDomElement& mapping) // Parse destination quad. _parseQuad(dst, dstPoints); - uid id = _window->createQuadColorMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), dstPoints); + id = _window->createQuadColorMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), dstPoints); if (id == NULL_UID) _xml.raiseError(QObject::tr("Cannot create quad color mapping")); @@ -198,13 +203,22 @@ void ProjectReader::parseMapping(const QDomElement& mapping) // Parse destination ellipse. _parseEllipse(dst, dstPoints); - uid id = _window->createEllipseColorMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), dstPoints); + id = _window->createEllipseColorMapping(mappingAttrId.toInt(), mappingAttrPaintId.toInt(), dstPoints); if (id == NULL_UID) _xml.raiseError(QObject::tr("Cannot create ellipse color mapping")); } else _xml.raiseError(QObject::tr("Unsupported mapping type: %1.").arg(mappingAttrType)); + // and then set some more attributes: + if (id != NULL_UID) + { + MappingManager& manager = _window->getMappingManager(); + Mapping::ptr mapping = manager.getMappingById(id); + mapping->setSolo(isSolo); + mapping->setVisible(isVisible); + mapping->setLocked(isLocked); + } } void ProjectReader::_parseStandardShape(const QString& type, const QDomElement& shape, QVector& points, int nVertices) diff --git a/ProjectWriter.cpp b/ProjectWriter.cpp index 51d29d9..3c5790e 100644 --- a/ProjectWriter.cpp +++ b/ProjectWriter.cpp @@ -54,7 +54,7 @@ void ProjectWriter::writeItem(Paint *item) { _xml.writeStartElement("paint"); _xml.writeAttribute("id", QString::number(item->getId())); - _xml.writeAttribute("name", item->getName()); + //_xml.writeAttribute("name", item->getName()); _xml.writeAttribute("type", item->getType()); if (item->getType() == "media") @@ -139,6 +139,11 @@ void ProjectWriter::writeItem(Mapping *item) _xml.writeAttribute("paint_id", QString::number(item->getPaint()->getId())); _xml.writeAttribute("type", item->getType()); + // boolean attributes: + _xml.writeAttribute("locked", QString::number((int) item->isLocked() ? 1 : 0)); + _xml.writeAttribute("solo", QString::number((int) item->isSolo() ? 1 : 0)); + _xml.writeAttribute("visible", QString::number((int) item->isVisible() ? 1 : 0)); + Shape *shape = item->getShape().get(); _xml.writeStartElement("destination"); _xml.writeAttribute("shape", shape->getType());