4 #include <QXmlContentHandler>
8 /** XML content handler for OPS format. */
9 class OpsHandler: public QXmlContentHandler
12 OpsHandler(Book &b): book(b), partCount(0) {}
13 bool endDocument() {return true;}
14 bool endPrefixMapping(const QString &) {return true;}
15 QString errorString() const {return "";}
16 bool ignorableWhitespace(const QString &) {return true;}
17 bool processingInstruction(const QString &, const QString &) {
20 void setDocumentLocator(QXmlLocator *) {}
21 bool skippedEntity(const QString &) {return true;}
22 bool startDocument() {return true;}
23 bool startPrefixMapping(const QString &, const QString &) {return true;}
25 bool characters(const QString &ch)
31 bool endElement(const QString &namespaceUri, const QString &name,
36 if (currentText != "") {
37 if (name == "title") {
38 book.title = currentText;
40 else if (name == "creator") {
41 book.creators.append(currentText);
43 else if (name == "publisher") {
44 book.publisher = currentText;
46 else if (name == "subject") {
47 book.subject = currentText;
49 else if (name == "source") {
50 book.source = currentText;
52 else if (name == "rights") {
53 book.rights = currentText;
59 bool startElement(const QString &namespaceUri, const QString &name,
60 const QString &qName, const QXmlAttributes &attrs)
67 Book::ContentItem item;
68 item.href = book.rootPath() + "/" + attrs.value("href");
69 item.name = QString("Part %1").arg(partCount + 1);
70 QString key = attrs.value("id");
71 book.content[key] = item;
74 else if (name == "itemref") {
75 book.toc.append(attrs.value("idref"));
86 #endif // OPSHANDLER_H