3 #include "infodialog.h"
7 InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons):
8 Dyalog(parent, showButtons), book(b)
10 setWindowTitle(tr("Book Details"));
13 QLabel *title = new QLabel(book->title, this);
15 if (book->subject != "") {
16 QLabel *subject = new QLabel(book->subject, this);
19 if (book->creators.size()) {
20 QLabel *creators = new QLabel(this);
21 QString c = "By " + book->creators[0];
22 for (int i = 1; i < book->creators.size(); i++) {
23 c += ", " + book->creators[i];
28 QLabel *path = new QLabel("File: " + book->path(), this);
30 if (book->publisher != "") {
32 new QLabel("Published by " + book->publisher, this);
35 if (book->source != "") {
36 QLabel *source = new QLabel("Source: " + book->source, this);
39 if (book->rights != "") {
40 QLabel *rights = new QLabel(book->rights, this);
46 addButton(tr("Read"), this, SLOT(onReadBook()),
47 QDialogButtonBox::ActionRole);
48 addButton(tr("Delete"), this, SLOT(onRemoveBook()),
49 QDialogButtonBox::DestructiveRole);
52 void InfoDialog::onReadBook()
54 Library::instance()->setNowReading(Library::instance()->find(book));
58 void InfoDialog::onRemoveBook()
60 if (QMessageBox::Yes ==
61 QMessageBox::question(this, tr("Delete book"),
62 tr("Delete book \"%1\" from library?").arg(book->shortName()),
63 QMessageBox::Yes | QMessageBox::No)) {
64 Library::instance()->remove(Library::instance()->find(book));