File indexing completed on 2025-01-26 04:24:56
0001 /* Copyright 2013-2014 Robert Schroll 0002 * 0003 * This file is part of Beru and is distributed under the terms of 0004 * the GPL. See the file COPYING for full details. 0005 */ 0006 0007 #ifndef EPUBREADER_H 0008 #define EPUBREADER_H 0009 0010 #include <QObject> 0011 #include <QDomDocument> 0012 #include <QVariant> 0013 #include "quazip/quazip.h" 0014 //#include "../qhttpserver/qhttpresponse.h" 0015 0016 class EpubReader : public QObject 0017 { 0018 Q_OBJECT 0019 Q_PROPERTY(QString hash READ hash) 0020 Q_PROPERTY(QString title READ title) 0021 public: 0022 explicit EpubReader(QObject *parent = 0); 0023 QString hash(); 0024 QString title(); 0025 Q_INVOKABLE bool load(const QString &filename); 0026 // Q_INVOKABLE void serveBookData(QHttpResponse *response); 0027 // Q_INVOKABLE void serveComponent(const QString &filename, QHttpResponse *response); 0028 Q_INVOKABLE QVariantMap getCoverInfo(int thumbsize, int fullsize); 0029 0030 Q: 0031 void contentsReady(QVariantList contents); 0032 0033 private: 0034 QDomDocument *getFileAsDom(const QString &filename); 0035 bool parseOPF(); 0036 QVariantList getContents(); 0037 QVariantList parseNav(); 0038 QVariantList parseNavList(QDomElement element); 0039 QVariantList parseNCX(); 0040 QVariantList parseNCXChildren(QDomElement element); 0041 0042 QuaZip* zip; 0043 QString _hash; 0044 QString navhref; 0045 QString ncxhref; 0046 QString coverhtml; 0047 QStringList spine; 0048 QVariantMap metadata; 0049 QVariantMap sortmetadata; 0050 0051 }; 0052 0053 #endif // EPUBREADER_H