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;
85 * @return @see title or path name if title is not available yet.
89 QString title; //< Book title from EPUB.
90 QStringList toc; //< Table of contents from EPUB.
91 QHash<QString, ContentItem> content; //< Content items from EPUB.
92 QIcon cover; //< Cover image.
93 QStringList creators; //< Creators.
94 QString date; //< Date of creation.
95 QString publisher; //< Publisher.
96 QString datePublished; //< Date of publishing.
97 QString subject; //< Subject.
98 QString source; //< Source.
99 QString rights; //< Rights.
100 QString tocPath; //< Path to toc ncx.
101 QString coverPath; //< Path to cover html.
102 QString coverImagePath; //< Path to cover image.
105 /** Indicate failure by creating a single "error" content item. */
106 void fail(const QString &details,
107 const QString &error = QString("Could not open book"));
109 /** Extract EPUB as ZIP. */
112 /** Parse exteacted EPUB. */
115 /** Clear all book fields except path. */
118 /** Get location of OPS file in EPUB archive. */
121 QString mPath; //< Path to EPUB file.
122 Bookmark mLastBookmark; //< Last position read.
123 QList<Bookmark> mBookmarks; //< List of bookmarks.
124 QString mRootPath; //< Path to root item in EPUB dir.
127 Q_DECLARE_METATYPE(Book)