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 QString c = "By " + book->creators[0];
28 for (int i = 1; i < book->creators.size(); i++) {
29 c += ", " + book->creators[i];
34 QLabel *path = new QLabel("File: " + book->path(), this);
35 path->setWordWrap(true);
37 if (book->publisher != "") {
39 new QLabel("Published by " + book->publisher, this);
40 publisher->setWordWrap(true);
43 if (book->source != "") {
44 QLabel *source = new QLabel("Source: " + book->source, this);
45 source->setWordWrap(true);
48 if (book->rights != "") {
49 QLabel *rights = new QLabel(book->rights, this);
50 rights->setWordWrap(true);
56 addButton(tr("Read"), this, SLOT(onReadBook()),
57 QDialogButtonBox::ActionRole);
58 addButton(tr("Delete"), this, SLOT(onRemoveBook()),
59 QDialogButtonBox::DestructiveRole);
62 void InfoDialog::onReadBook()
64 done(InfoDialog::Read);
67 void InfoDialog::onRemoveBook()
69 if (QMessageBox::Yes ==
70 QMessageBox::question(this, tr("Delete book"),
71 tr("Delete book \"%1\" from library?").arg(book->shortName()),
72 QMessageBox::Yes | QMessageBox::No)) {
73 done(InfoDialog::Delete);