14 /** Content item in the table of contents. */
21 /** Bookmark: a volume index and a relative position in volume. */
24 Bookmark(int chapter_, qreal pos_): chapter(chapter_), pos(pos_) {}
25 Bookmark() {chapter = pos = 0;}
28 bool operator<(const Bookmark&other) const {
29 if (chapter != other.chapter) {
30 return chapter < other.chapter;
32 return pos < other.pos;
37 /** Construct a book from an EPUB file in path. */
38 explicit Book(const QString &path);
40 /** Load book from persistent storage. */
43 /** Save book to persistent storage. */
46 /** Extract and parse EPUB contents, fill in all members except mPath. */
49 /** Clear toc and content members, remove extracted content files. */
52 /** Return path to EPUB. */
56 * Return path to root directory of extracted EPUB.
57 * Only valid after parsing Book::opsPath().
59 QString rootPath() const;
61 /** Return temporary directory path for extracting EPUB file. */
62 QString tmpDir() const;
64 /** Clear directory. */
65 bool clearDir(const QString &directory);
67 /** Set last bookmark. */
68 void setLastBookmark(int chapter, qreal position);
70 /** Get last bookmark. */
71 Bookmark lastBookmark() const;
74 void addBookmark(int chapter, qreal position);
76 /** List bookmarks. */
77 QList<Bookmark> bookmarks() const;
79 QString title; //< Book title from EPUB.
80 QStringList toc; //< Table of contents from EPUB.
81 QHash<QString, ContentItem> content; //< Content items from EPUB.
82 QIcon cover; //< Cover image.
83 QStringList creators; //< Creators.
84 QString date; //< Date of creation.
85 QString publisher; //< Publisher.
86 QString datePublished; //< Date of publishing.
87 QString subject; //< Subject.
88 QString source; //< Source.
89 QString rights; //< Rights.
92 /** Indicate failure by creating a single "error" content item. */
93 void fail(const QString &details,
94 const QString &error = QString("Could not open book"));
96 /** Extract EPUB as ZIP. */
99 /** Parse exteacted EPUB. */
102 /** Clear all book fields except path. */
105 /** Get location of OPS file in EPUB archive. */
108 QString mPath; //< Path to EPUB file.
109 Bookmark mLastBookmark; //< Last position read.
110 QList<Bookmark> mBookmarks; //< List of bookmarks.
111 QString mRootPath; //< Path to root item in EPUB dir.