15 /** Content item in the table of contents. */
22 /** Bookmark: a volume index and a relative position in volume. */
25 Bookmark(int chapter_, qreal pos_): chapter(chapter_), pos(pos_) {}
26 Bookmark() {chapter = pos = 0;}
29 bool operator<(const Bookmark&other) const {
30 if (chapter != other.chapter) {
31 return chapter < other.chapter;
33 return pos < other.pos;
38 /** Construct a book from an EPUB file in path. */
39 Book(const QString &path);
41 /** Default constructor. */
44 /** Load book from persistent storage. */
47 /** Save book to persistent storage. */
50 /** Extract and parse EPUB contents, fill in all members except mPath. */
53 /** Clear toc and content members, remove extracted content files. */
56 /** Return path to EPUB. */
60 * Return path to root directory of extracted EPUB.
61 * Only valid after parsing Book::opsPath().
63 QString rootPath() const;
65 /** Return temporary directory path for extracting EPUB file. */
66 QString tmpDir() const;
68 /** Clear directory. */
69 bool clearDir(const QString &directory);
71 /** Set last bookmark. */
72 void setLastBookmark(int chapter, qreal position);
74 /** Get last bookmark. */
75 Bookmark lastBookmark() const;
78 void addBookmark(int chapter, qreal position);
80 /** List bookmarks. */
81 QList<Bookmark> bookmarks() const;
83 QString title; //< Book title from EPUB.
84 QStringList toc; //< Table of contents from EPUB.
85 QHash<QString, ContentItem> content; //< Content items from EPUB.
86 QIcon cover; //< Cover image.
87 QStringList creators; //< Creators.
88 QString date; //< Date of creation.
89 QString publisher; //< Publisher.
90 QString datePublished; //< Date of publishing.
91 QString subject; //< Subject.
92 QString source; //< Source.
93 QString rights; //< Rights.
96 /** Indicate failure by creating a single "error" content item. */
97 void fail(const QString &details,
98 const QString &error = QString("Could not open book"));
100 /** Extract EPUB as ZIP. */
103 /** Parse exteacted EPUB. */
106 /** Clear all book fields except path. */
109 /** Get location of OPS file in EPUB archive. */
112 QString mPath; //< Path to EPUB file.
113 Bookmark mLastBookmark; //< Last position read.
114 QList<Bookmark> mBookmarks; //< List of bookmarks.
115 QString mRootPath; //< Path to root item in EPUB dir.
118 Q_DECLARE_METATYPE(Book)