Fix forward navigation control on Linux.
[dorian] / bookmarkinfodialog.cpp
1 #include <QtGui>
2
3 #include "bookmarkinfodialog.h"
4 #include "book.h"
5
6 BookmarkInfoDialog::BookmarkInfoDialog(Book *b, int i, QWidget *parent):
7     Dyalog(parent, true),
8     book(b),
9     index(i)
10 {
11     setWindowTitle(tr("Bookmark details"));
12
13     Book::Bookmark bookmark = book->bookmarks()[index];
14     QString label("At ");
15     label += QString::number((int)(100 * book->
16         getProgress(bookmark.part, bookmark.pos))) + "%";
17     if (!bookmark.note.isEmpty()) {
18         label += ": " + bookmark.note;
19     }
20     label += "\n";
21     int chapterIndex = book->chapterFromPart(bookmark.part);
22     if (chapterIndex != -1) {
23         QString chapterId = book->chapters[chapterIndex];
24         label += "In\"" + book->content[chapterId].name + "\"";
25     }
26     QLabel *info = new QLabel(label, this);
27     addWidget(info);
28     addStretch();
29     addButton(tr("Go to"), this, SLOT(onRead()), QDialogButtonBox::ActionRole);
30     addButton(tr("Delete"), this, SLOT(onRemove()),
31               QDialogButtonBox::DestructiveRole);
32 }
33
34 void BookmarkInfoDialog::onRead()
35 {
36     done(GoTo);
37 }
38
39 void BookmarkInfoDialog::onRemove()
40 {
41     if (QMessageBox::Yes ==
42         QMessageBox::question(this, tr("Delete bookmark"),
43                               tr("Delete bookmark?"),
44                               QMessageBox::Yes | QMessageBox::No)) {
45         done(Delete);
46     }
47 }