12 class Book: public QObject
18 /** Content item in the table of contents. */
26 /** Bookmark: a volume index and a relative position in volume. */
29 Bookmark(int part_, qreal pos_): part(part_), pos(pos_) {}
30 Bookmark() {part = pos = 0;}
33 bool operator<(const Bookmark&other) const {
34 return (part == other.part)? (pos < other.pos): (part < other.part);
38 /** Construct a book from an EPUB file in path. */
39 Book(const QString &path, QObject *parent = 0);
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 part, qreal position);
74 /** Get last bookmark. */
75 Bookmark lastBookmark() const;
78 void addBookmark(int part, qreal position);
80 /** Delete bookmark. */
81 void deleteBookmark(int index);
83 /** List bookmarks. */
84 QList<Bookmark> bookmarks() const;
88 * @return @see title or path name combined with author(s) name.
92 /** Get short friendly name: title or file name. */
93 QString shortName() const;
95 /** Get chapter index from part index. */
96 int chapterFromPart(int index);
98 /** Get part index from chapter index. */
99 int partFromChapter(int index);
101 /** Get progress (0..1) corresponding to part index and part position. */
102 qreal getProgress(int part, qreal position);
104 QString title; //< Book title from EPUB.
105 QStringList parts; //< EPUB part list.
106 QHash<QString, ContentItem> content; //< Content items from EPUB.
107 QImage cover; //< Cover image.
108 QStringList creators; //< Creators.
109 QString date; //< Date of creation.
110 QString publisher; //< Publisher.
111 QString datePublished; //< Date of publishing.
112 QString subject; //< Subject.
113 QString source; //< Source.
114 QString rights; //< Rights.
115 QString tocPath; //< Path to toc ncx.
116 QString coverPath; //< Path to cover html.
117 QStringList chapters; //< Main navigation items from EPUB.
118 qint64 size; //< Size of all parts.
121 /** Emitted if @see open() succeeds. */
122 void opened(const QString &bookPath);
125 /** Extract EPUB as ZIP. */
128 /** Parse extracted EPUB. */
131 /** Clear all book fields except path. */
134 /** Get location of OPS file in EPUB archive. */
137 QString mPath; //< Path to EPUB file.
138 Bookmark mLastBookmark; //< Last position read.
139 QList<Bookmark> mBookmarks; //< List of bookmarks.
140 QString mRootPath; //< Path to root item in EPUB dir.