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 part_, qreal pos_): part(part_), pos(pos_) {}
29 Bookmark() {part = pos = 0;}
32 bool operator<(const Bookmark&other) const {
33 return (part == other.part)? (pos < other.pos): (part < other.part);
37 /** Construct a book from an EPUB file in path. */
38 Book(const QString &path, QObject *parent = 0);
40 /** Default constructor. */
43 /** Load book from persistent storage. */
46 /** Save book to persistent storage. */
49 /** Extract and parse EPUB contents, fill in all members except mPath. */
52 /** Clear toc and content members, remove extracted content files. */
55 /** Return path to EPUB. */
59 * Return path to root directory of extracted EPUB.
60 * Only valid after parsing Book::opsPath().
62 QString rootPath() const;
64 /** Return temporary directory path for extracting EPUB file. */
65 QString tmpDir() const;
67 /** Clear directory. */
68 bool clearDir(const QString &directory);
70 /** Set last bookmark. */
71 void setLastBookmark(int part, qreal position);
73 /** Get last bookmark. */
74 Bookmark lastBookmark() const;
77 void addBookmark(int part, qreal position);
79 /** Delete bookmark. */
80 void deleteBookmark(int index);
82 /** List bookmarks. */
83 QList<Bookmark> bookmarks() const;
87 * @return @see title or path name combined with author(s) name.
91 /** Get short friendly name: title or file name. */
92 QString shortName() const;
94 /** Get chapter index from toc index. */
95 int chapterFromToc(int index);
97 /** Get toc index from chapter index. */
98 int tocFromChapter(int index);
100 QString title; //< Book title from EPUB.
101 QStringList toc; //< Table of contents from EPUB.
102 QHash<QString, ContentItem> content; //< Content items from EPUB.
103 QImage cover; //< Cover image.
104 QStringList creators; //< Creators.
105 QString date; //< Date of creation.
106 QString publisher; //< Publisher.
107 QString datePublished; //< Date of publishing.
108 QString subject; //< Subject.
109 QString source; //< Source.
110 QString rights; //< Rights.
111 QString tocPath; //< Path to toc ncx.
112 QString coverPath; //< Path to cover html.
113 QStringList chapters; //< Main navigation items from EPUB.
116 /** Emitted if @see open() succeeds. */
117 void opened(const QString &bookPath);
120 /** Extract EPUB as ZIP. */
123 /** Parse exteacted EPUB. */
126 /** Clear all book fields except path. */
129 /** Get location of OPS file in EPUB archive. */
132 QString mPath; //< Path to EPUB file.
133 Bookmark mLastBookmark; //< Last position read.
134 QList<Bookmark> mBookmarks; //< List of bookmarks.
135 QString mRootPath; //< Path to root item in EPUB dir.