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 combined with author(s) name.
95 /** Get short friendly name: title or file name. */
96 QString shortName() const;
98 QString title; //< Book title from EPUB.
99 QStringList toc; //< Table of contents from EPUB.
100 QHash<QString, ContentItem> content; //< Content items from EPUB.
101 QImage cover; //< Cover image.
102 QStringList creators; //< Creators.
103 QString date; //< Date of creation.
104 QString publisher; //< Publisher.
105 QString datePublished; //< Date of publishing.
106 QString subject; //< Subject.
107 QString source; //< Source.
108 QString rights; //< Rights.
109 QString tocPath; //< Path to toc ncx.
110 QString coverPath; //< Path to cover html.
111 QStringList chapters; //< Main navigation items from EPUB.
114 /** Emitted if @see open() succeeds. */
115 void opened(const QString &bookPath);
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.