Not much progress.
[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     int chapterIndex = book->chapterFromPart(bookmark.part);
18     if (chapterIndex != -1) {
19         QString chapterId = book->chapters[chapterIndex];
20         label += ", in\n\"" + book->content[chapterId].name + "\"";
21     }
22     QLabel *info = new QLabel(label, this);
23     addWidget(info);
24     addStretch();
25
26     QPushButton *read = new QPushButton(tr("Go to"), this);
27     QPushButton *remove = new QPushButton(tr("Delete"), this);
28     connect(read, SIGNAL(clicked()), this, SLOT(onRead()));
29     connect(remove, SIGNAL(clicked()), this, SLOT(onRemove()));
30     addButton(read, QDialogButtonBox::ActionRole);
31     addButton(remove, 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 }