list = new QListWidget(this);
list->setSelectionMode(QAbstractItemView::SingleSelection);
foreach (Book::Bookmark bookmark, book_->bookmarks()) {
- QString contentId = book_->parts[bookmark.part];
- QString contentTitle = book_->content[contentId].name;
- (void)new QListWidgetItem(QIcon(":icons/bookmark.png"), contentTitle +
- "\nAt " + QString::number((int)(bookmark.pos*100)) + "%", list);
+ QString label("At ");
+ label += QString::number((int)(100 * book_->
+ getProgress(bookmark.part, bookmark.pos))) + "%";
+ int chapterIndex = book_->chapterFromPart(bookmark.part);
+ if (chapterIndex != -1) {
+ QString chapterId = book_->chapters[chapterIndex];
+ label += "\nIn \"" + book_->content[chapterId].name + "\"";
+ }
+ (void)new QListWidgetItem(QIcon(":icons/bookmark.png"), label, list);
}
horizontalLayout->addWidget(list);
QFileInfo info(content[part].href);
content[part].size = info.size();
size += content[part].size;
- t.trace(QString("Size of part %1: %2").arg(part).arg(content[part].size));
}
return ret;
int Book::chapterFromPart(int index)
{
- // FIXME
- Q_UNUSED(index);
int ret = -1;
+
+ QString partId = parts[index];
+ QString partHref = content[partId].href;
+
+ for (int i = 0; i < chapters.size(); i++) {
+ QString id = chapters[i];
+ QString href = content[id].href;
+ QString baseRef(href);
+ QUrl url(QString("file://") + href);
+ if (url.hasFragment()) {
+ QString fragment = url.fragment();
+ baseRef.chop(fragment.length() + 1);
+ }
+ if (baseRef == partHref) {
+ ret = i;
+ // Don't break, keep looking
+ }
+ }
+
return ret;
}
public:
- /** Content item in the table of contents. */
+ /** Content item: An individual, named part of the book. */
struct ContentItem
{
QString href;
QString subject; //< Subject.
QString source; //< Source.
QString rights; //< Rights.
- QString tocPath; //< Path to toc ncx.
- QString coverPath; //< Path to cover html.
+ QString tocPath; //< Path to toc NCX file.
+ QString coverPath; //< Path to cover HTML file.
QStringList chapters; //< Main navigation items from EPUB.
qint64 size; //< Size of all parts.
(void)namespaceUri;
(void)qName;
if (name == "text") {
- t.trace(currentText);
contentTitle = currentText;
} else if (name == "navPoint") {
t.trace(QString("url: ") + contentUrl);
+dorian (0.1.4-1) unstable; urgency=low
+
+ * Show better bookmark descriptions
+
+ -- Akos Polster <akos@pipacs.com> Sun, 22 Aug 2010 02:00:00 +0200
+
dorian (0.1.3-1) unstable; urgency=low
* Retrieve book metadata when adding it to library