12 class Book: public QObject
18 /** Content item in the table of contents. */
25 /** Bookmark: a volume index and a relative position in volume. */
28 Bookmark(int chapter_, qreal pos_): chapter(chapter_), pos(pos_) {}
29 Bookmark() {chapter = pos = 0;}
32 bool operator<(const Bookmark&other) const {
33 if (chapter != other.chapter) {
34 return chapter < other.chapter;
36 return pos < other.pos;
41 /** Construct a book from an EPUB file in path. */
42 Book(const QString &path, QObject *parent = 0);
44 /** Default constructor. */
47 /** Load book from persistent storage. */
50 /** Save book to persistent storage. */
53 /** Extract and parse EPUB contents, fill in all members except mPath. */
56 /** Clear toc and content members, remove extracted content files. */
59 /** Return path to EPUB. */
63 * Return path to root directory of extracted EPUB.
64 * Only valid after parsing Book::opsPath().
66 QString rootPath() const;
68 /** Return temporary directory path for extracting EPUB file. */
69 QString tmpDir() const;
71 /** Clear directory. */
72 bool clearDir(const QString &directory);
74 /** Set last bookmark. */
75 void setLastBookmark(int chapter, qreal position);
77 /** Get last bookmark. */
78 Bookmark lastBookmark() const;
81 void addBookmark(int chapter, qreal position);
83 /** Delete bookmark. */
84 void deleteBookmark(int index);
86 /** List bookmarks. */
87 QList<Bookmark> bookmarks() const;
91 * @return @see title or path name if title is not available yet.
95 QString title; //< Book title from EPUB.
96 QStringList toc; //< Table of contents from EPUB.
97 QHash<QString, ContentItem> content; //< Content items from EPUB.
98 QImage cover; //< Cover image.
99 QStringList creators; //< Creators.
100 QString date; //< Date of creation.
101 QString publisher; //< Publisher.
102 QString datePublished; //< Date of publishing.
103 QString subject; //< Subject.
104 QString source; //< Source.
105 QString rights; //< Rights.
106 QString tocPath; //< Path to toc ncx.
107 QString coverPath; //< Path to cover html.
110 /** Emitted if @see open() succeeds. */
111 void opened(const QString &bookPath);
114 /** Indicate failure by creating a single "error" content item. */
115 void fail(const QString &details,
116 const QString &error = QString("Could not open book"));
118 /** Extract EPUB as ZIP. */
121 /** Parse exteacted EPUB. */
124 /** Clear all book fields except path. */
127 /** Get location of OPS file in EPUB archive. */
130 QString mPath; //< Path to EPUB file.
131 Bookmark mLastBookmark; //< Last position read.
132 QList<Bookmark> mBookmarks; //< List of bookmarks.
133 QString mRootPath; //< Path to root item in EPUB dir.