void Document::loadImage(QXmlStreamReader &reader) { LOG4CPP_INFO_S ((*mainCat)) << "Document::loadImage"; loadNextFromReader(reader); // Read to CDATA if (reader.isCDATA ()) { // Get base64 array QByteArray array64 = reader.text().toString().toUtf8(); // Decoded array QByteArray array; array = QByteArray::fromBase64(array64); // Read decoded array into image QDataStream str (&array, QIODevice::ReadOnly); QImage img = m_pixmap.toImage (); str >> img; m_pixmap = QPixmap::fromImage (img); // Read until end of this subtree while ((reader.tokenType() != QXmlStreamReader::EndElement) || (reader.name() != DOCUMENT_SERIALIZE_IMAGE)){ loadNextFromReader(reader); } } else {
QDebug operator<<(QDebug dbg, const QXmlStreamReader& reader) { dbg.nospace() << "QXmlStreamReader("; if (reader.isStartElement()) { dbg.nospace() << "<"; dbg.nospace() << reader.qualifiedName().toString().toLocal8Bit().constData(); QString attrsString; const QXmlStreamAttributes& attrs = reader.attributes(); for (int i = 0; i < attrs.count(); i++) { dbg.nospace() << " " << attrs[i].qualifiedName().toString().toLocal8Bit().constData(); dbg.nospace() << "="; dbg.nospace() << attrs[i].value().toString(); } if (reader.isEndElement()) { dbg.nospace() << "/>)"; } else { dbg.nospace() << ">)"; } } else if (reader.isEndElement()) { dbg.nospace() << "</" << reader.qualifiedName().toString().toLocal8Bit().constData() << ">)"; } else if (reader.isCharacters()) { dbg.nospace() << "characters:" << reader.text() << ")"; } else if (reader.isComment()) { dbg.nospace() << "<!-- " << reader.text().toString().toLocal8Bit().constData() << " -->)"; } else if (reader.isCDATA()) { dbg.nospace() << "CDATA:" << reader.text() << ")"; } else if (reader.isWhitespace()) { dbg.nospace() << "whitespace:" << reader.text() << ")"; } else { dbg.nospace() << reader.tokenString() << reader.text(); } return dbg.space(); }