bool QLandmarkFileHandlerLmx::readLandmark(QLandmark &landmark) { /* <xsd:complexType name="landmarkType"> <xsd:sequence> <xsd:element name="name" type="xsd:string" minOccurs="0" /> <xsd:element name="description" type="xsd:string" minOccurs="0" /> <xsd:element name="coordinates" type="coordinatesType" minOccurs="0" /> <xsd:element name="coverageRadius" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:float"> <xsd:minInclusive value="0"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="addressInfo" type="addressInfoType" minOccurs="0" /> <xsd:element name="mediaLink" type="mediaLinkType" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="category" type="categoryType" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> */ if(m_cancel && (*m_cancel) == true) { m_errorCode = QLandmarkManager::CancelError; m_error = "Import of lmx file was canceled"; return false; } Q_ASSERT(m_reader->isStartElement() && (m_reader->name() == "landmark")); m_landmarkCategoryNames.append(QStringList()); if (!m_reader->readNextStartElement()) return true; if (m_reader->name() == "name") { landmark.setName(m_reader->readElementText()); if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "description") { landmark.setDescription(m_reader->readElementText()); if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "coordinates") { if (!readCoordinates(landmark)) return false; if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "coverageRadius") { bool ok = false; QString s = m_reader->readElementText(); if ((s == "INF") || (s == "-INF") || (s == "NaN")) { m_reader->raiseError(QString("The element \"coverageRadius\" expected a value convertable to type real (value was \"%1\").").arg(s)); return false; } qreal rad = (qreal)(s.toDouble(&ok)); if (!ok) { m_reader->raiseError(QString("The element \"coverageRadius\" expected a value convertable to type real (value was \"%1\").").arg(s)); return false; } if (rad < 0.0) { m_reader->raiseError(QString("The element \"coverageRadius\" is expected to have a non-negative value (value was \"%1\").").arg(s)); return false; } landmark.setRadius(rad); if (!m_reader->readNextStartElement()) return true; } if (m_reader->name() == "addressInfo") { if (!readAddressInfo(landmark)) return false; if (!m_reader->readNextStartElement()) return true; } // TODO need to document the fact that only the first link is read // and the others are ignored bool mediaLinkRead = false; while (m_reader->name() == "mediaLink") { if (!mediaLinkRead) { mediaLinkRead = true; if (!readMediaLink(landmark)) return false; } if (!m_reader->readNextStartElement()) return true; } QStringList categoryNames; while (m_reader->name() == "category") { QString name; if (!readCategory(name)) return false; categoryNames << name; if (!m_reader->readNextStartElement()) { m_landmarkCategoryNames.last() = categoryNames; return true; } } m_reader->raiseError(QString("The element \"landmark\" did not expect a child element named \"%1\" at this point (unknown child element or child element out of order).").arg(m_reader->name().toString())); return false; }