3 #include "infodialog.h"
8 InfoDialog::InfoDialog(Book *b, QWidget *parent, bool showButtons):
9 Dyalog(parent, showButtons), book(b)
13 setWindowTitle(tr("Book details"));
16 QLabel *title = new QLabel(book->title, this);
17 title->setWordWrap(true);
19 if (book->subject != "") {
20 QLabel *subject = new QLabel(book->subject, this);
21 subject->setWordWrap(true);
24 if (book->creators.size()) {
25 QLabel *creators = new QLabel(this);
26 creators->setWordWrap(true);
27 creators->setText(book->creators.join(", "));
30 QLabel *path = new QLabel("File: " + book->path(), this);
31 path->setWordWrap(true);
33 if (book->publisher != "") {
35 new QLabel("Published by " + book->publisher, this);
36 publisher->setWordWrap(true);
39 if (book->source != "") {
40 QLabel *source = new QLabel("Source: " + book->source, this);
41 source->setWordWrap(true);
44 if (book->rights != "") {
45 QLabel *rights = new QLabel(book->rights, this);
46 rights->setWordWrap(true);
52 addButton(tr("Read"), this, SLOT(onReadBook()),
53 QDialogButtonBox::ActionRole);
54 addButton(tr("Delete"), this, SLOT(onRemoveBook()),
55 QDialogButtonBox::DestructiveRole);
58 void InfoDialog::onReadBook()
60 done(InfoDialog::Read);
63 void InfoDialog::onRemoveBook()
65 if (QMessageBox::Yes ==
66 QMessageBox::question(this, tr("Delete book"),
67 tr("Delete book \"%1\" from library?").arg(book->shortName()),
68 QMessageBox::Yes | QMessageBox::No)) {
69 done(InfoDialog::Delete);