5#include <QTextDocument>
11 "scribe-document",
"scribe",
"qt.nokia.com/scribe");
18 "xml",
"version=\"1.0\" encoding=\"utf-8\"");
27 while (currentBlock.
isValid()) {
32 readFragment(currentBlock, blockElement, document);
35 processBlock(currentBlock);
39 currentBlock = currentBlock.
next();
46void XmlWriter::readFragment(
const QTextBlock ¤tBlock,
52 for (
it = currentBlock.
begin(); !(
it.atEnd()); ++
it) {
56 processFragment(currentFragment);
59 if (currentFragment.
isValid()) {
60 QDomElement fragmentElement = document->createElement(
"fragment");
64 QDomText fragmentText = document->createTextNode(currentFragment.
text());
73void XmlWriter::processBlock(
const QTextBlock ¤tBlock)
77 localBlock = currentBlock;
81void XmlWriter::processFragment(
const QTextFragment ¤tFragment)
85 localFragment = currentFragment;
QDomProcessingInstruction createProcessingInstruction(const QString &target, const QString &data)
Creates a new processing instruction that can be inserted into the document, e.g.
QDomElement createElement(const QString &tagName)
Creates a new element called tagName that can be inserted into the DOM tree, e.g.
void setAttribute(const QString &name, const QString &value)
Adds an attribute called name with value value.
QDomDocumentType createDocumentType(const QString &qName, const QString &publicId, const QString &systemId)
Creates a document type node for the name qName.
QDomNode appendChild(const QDomNode &newChild)
Appends newChild as the node's last child.
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
QTextBlock begin() const
Returns the document's first text block.
QString text() const
Returns the text fragment's as plain text.
bool isValid() const
Returns true if this is a valid text fragment (i.e.
int length() const
Returns the number of characters in the text fragment.
QSet< QString >::iterator it