- bool endDocument() {return true;}
- bool endPrefixMapping(const QString &) {return true;}
- QString errorString() const {return "";}
- bool ignorableWhitespace(const QString &) {return true;}
- bool processingInstruction(const QString &, const QString &) {return true;}
- void setDocumentLocator(QXmlLocator *) {}
- bool skippedEntity(const QString &) {return true;}
- bool startDocument() {return true;}
- bool startPrefixMapping(const QString &, const QString &) {return true;}
+ struct TreeItem
+ {
+ TreeItem(const QString &i, TreeItem *p = 0): id(i), parent(p) {
+ if (parent) {
+ parent->children.append(this);
+ depth = parent->depth + 1;
+ } else {
+ depth = 0;
+ }
+ }
+ ~TreeItem() {
+ qDeleteAll(children);
+ }
+ void addToBook(Book &book) {
+ Book::ContentItem contentItem;
+ contentItem.href = href;
+ contentItem.name = QString(" ").repeated(depth) + name;
+ contentItem.size = 0;
+ book.content[id] = contentItem;
+ book.chapters.append(id);
+ qDebug() << "TreeItem::addToBook" << id << contentItem.href
+ << contentItem.name;
+ foreach (TreeItem *child, children) {
+ child->addToBook(book);
+ }
+ }
+ QList<TreeItem *> children;
+ QString id;
+ QString href;
+ QString name;
+ TreeItem *parent;
+ int depth;
+ };